Exemplo n.º 1
0
        protected void ConnectionOnStateChanged(StateChange stateChange)
        {
            Log.InfoFormat("State Changed: {0}->{1}", stateChange.OldState, stateChange.NewState);
            switch (stateChange.NewState)
            {
            case ConnectionState.Connecting:
                break;

            case ConnectionState.Connected:
                // Created a task because if reconnecting, it seems that this message doesn't go through if it doesn't have a delay
                var t = new Task(() =>
                {
                    Thread.Sleep(1000);
                    if (GameStateEngine.GetContext().State.Status == EnumHostedGameStatus.Booting)
                    {
                        GameStateEngine.GetContext().SetStatus(EnumHostedGameStatus.Booted);
                    }
                    else
                    {
                        GameStateEngine.GetContext().SetStatus(GameStateEngine.GetContext().Game.Status);
                    }
                });
                t.Start();
                break;

            case ConnectionState.Reconnecting:
                break;

            case ConnectionState.Disconnected:
                break;
            }
            ConnectionState = stateChange.NewState;
        }
        public MainWindow()
        {
            DataContext = this;
            engine      = new GameStateEngine();

            InitializeComponent();
        }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            var gameStateEngine = new GameStateEngine(new ConsoleDisplay());
            var gameState       = gameStateEngine.Start();

            while (!gameState.Quit)
            {
                var command = gameStateEngine.RequestCommand();
                gameStateEngine.Instruct(gameState, command);
            }
            Console.WriteLine("Goodbye!");
            Thread.Sleep(3000);
        }
Exemplo n.º 4
0
 public new void Stop()
 {
     Log.Info("Stopping");
     Stopped = true;
     try
     {
         GameStateEngine.GetContext().SetStatus(EnumHostedGameStatus.GameShuttingDown);
     }
     catch (Exception e)
     {
         Log.Info(e.Message);
     }
     base.Stop();
     Log.Info("Stopped");
 }
Exemplo n.º 5
0
        private void PrepareComponents()
        {
            //core components, endabled by default
            InstalledComponents.Add(new Inventory {
                Client = this, Enabled = true
            });
            InstalledComponents.Add(new PlayerAttributes {
                Client = this, Enabled = true
            });
            InstalledComponents.Add(new Magic {
                Client = this, Enabled = true
            });
            InstalledComponents.Add(new GameEquipment {
                Client = this, Enabled = true
            });
            InstalledComponents.Add(new Activebar {
                Client = this, Enabled = true
            });
            InstalledComponents.Add(new TargetFinder {
                Client = this, Enabled = true
            });

            //disabled by default components
            InstalledComponents.Add(new StressTest {
                Client = this, Enabled = false
            });

            //mandatory components
            FieldMap         = new Map();
            FieldMap.Enabled = true;
            FieldMap.Client  = this;
            FieldMap.Init(0, 0, 0);
            InstalledComponents.Add(FieldMap);

            //init state machine.
            StateMachine         = new GameStateEngine(this);
            StateMachine.Client  = this;
            StateMachine.Enabled = true;

            InstalledComponents.Add(StateMachine);

            LoadStates("BotCore.dll");

            callback = value => { };
        }
Exemplo n.º 6
0
 public GameTests()
 {
     _gameStateEngine = new GameStateEngine(new MockDisplay());
 }