123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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);
- }
- }
- }
|