1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using NTERA.Core.Interop;
- namespace NTERA.Core
- {
- public class GameInstance
- {
- public IConsole Console { get; protected set; }
- public IScriptEngine ScriptEngine { get; set; }
- public void Run(IConsole console, IScriptEngine scriptEngine)
- {
- Console = console;
- ScriptEngine = scriptEngine;
-
- if (!ScriptEngine.Initialize(Console))
- return;
- ScriptEngine.Start();
- }
- public void GiveInput(string input)
- {
- //InputRequest currentRequest = Console.CurrentRequest;
- //if (Console.CurrentRequest != null)
- //{
- // switch (currentRequest.InputType)
- // {
- // case InputType.IntValue:
- // long inputValue;
- // if (string.IsNullOrEmpty(input) && currentRequest.HasDefValue)// && !IsRunningTimer)
- // {
- // inputValue = currentRequest.DefIntValue;
- // input = inputValue.ToString();
- // }
- // else if (!long.TryParse(input, out inputValue))
- // {
- // break;
- // }
- // if (currentRequest.IsSystemInput)
- // ScriptEngine.InputSystemInteger(inputValue);
- // else
- // ScriptEngine.InputInteger(inputValue);
- // break;
- // case InputType.StrValue:
- // if (string.IsNullOrEmpty(input) && currentRequest.HasDefValue)// && !IsRunningTimer)
- // input = currentRequest.DefStrValue;
- // ScriptEngine.InputString(input ?? "");
- // break;
- // }
- //}
- Console.GiveInput(input);
- if (long.TryParse(input, out long number))
- ScriptEngine.InputInteger(number);
- else
- ScriptEngine.InputString(input);
- }
- }
- }
|