GameInstance.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using NTERA.Core.Interop;
  2. namespace NTERA.Core
  3. {
  4. public class GameInstance
  5. {
  6. public IConsole Console { get; protected set; }
  7. public IScriptEngine ScriptEngine { get; set; }
  8. public void Run(IConsole console, IScriptEngine scriptEngine)
  9. {
  10. Console = console;
  11. ScriptEngine = scriptEngine;
  12. if (!ScriptEngine.Initialize(Console))
  13. return;
  14. ScriptEngine.Start();
  15. }
  16. public void GiveInput(string input)
  17. {
  18. //InputRequest currentRequest = Console.CurrentRequest;
  19. //if (Console.CurrentRequest != null)
  20. //{
  21. // switch (currentRequest.InputType)
  22. // {
  23. // case InputType.IntValue:
  24. // long inputValue;
  25. // if (string.IsNullOrEmpty(input) && currentRequest.HasDefValue)// && !IsRunningTimer)
  26. // {
  27. // inputValue = currentRequest.DefIntValue;
  28. // input = inputValue.ToString();
  29. // }
  30. // else if (!long.TryParse(input, out inputValue))
  31. // {
  32. // break;
  33. // }
  34. // if (currentRequest.IsSystemInput)
  35. // ScriptEngine.InputSystemInteger(inputValue);
  36. // else
  37. // ScriptEngine.InputInteger(inputValue);
  38. // break;
  39. // case InputType.StrValue:
  40. // if (string.IsNullOrEmpty(input) && currentRequest.HasDefValue)// && !IsRunningTimer)
  41. // input = currentRequest.DefStrValue;
  42. // ScriptEngine.InputString(input ?? "");
  43. // break;
  44. // }
  45. //}
  46. Console.GiveInput(input);
  47. if (long.TryParse(input, out long number))
  48. ScriptEngine.InputInteger(number);
  49. else
  50. ScriptEngine.InputString(input);
  51. }
  52. }
  53. }