Represents the state machine for the input handling By: Neil DG
Inheritance: AStateMachine
Esempio n. 1
0
        private void Start()
        {
            _gem = _locator.GetService <IEntityManager>();
            _map = _locator.GetService <IHexMap>();

            _inputMachine = new InputStateMachine();
            _inputMachine.SetState(null);

            var input = _locator.GetService <IGameInputManager>();

            input.RegisterProcessor(_inputMachine);

            _jconverter = _locator.GetService <IJsonConverter>();
            _jobManager = _locator.GetService <IJobManager>();
            _networker  = _locator.GetService <INetworker>();

            var networkDataHandler = new Dictionary <EventCode, Action <string> >();

            _networker.DataReceived += (code, data) =>
            {
                if (networkDataHandler.ContainsKey(code))
                {
                    networkDataHandler[code].Invoke(data);
                }
                else
                {
                    Debug.Log($"[GameManager] unhandeled event code received: {code}\n{data}");
                }
            };

            networkDataHandler.Add(EventCode.GameStart, MakeHandlerBridge <GameConfiguration>(StartGame));
            networkDataHandler.Add(EventCode.GameAbort, MakeHandlerBridge <GameAbortData>(GameAborted));
            networkDataHandler.Add(EventCode.StartTurn, MakeHandlerBridge <StartTurnData>(StartNextTurn));
            networkDataHandler.Add(EventCode.DoJob, MakeHandlerBridge <IJob>(OnDoJob));
        }
Esempio n. 2
0
        protected override void Init()
        {
            _map = _locator.GetService <IHexMap>();
            _im  = _locator.GetService <IGameInputManager>();
            _gem = _locator.GetService <IEntityManager>();

            _config = JsonConvert.DeserializeObject <GameConfiguration>(configFile.text);
            _seed   = 0;

            _input = new InputStateMachine();
            _input.SetState(new SpectateInputState(_input));

            _im.RegisterProcessor(_input);

            //ChanceTest();

            Generate();
        }
Esempio n. 3
0
    void Awake()
    {
        // state machine setup
        CollisionNotifier collisionNotifier = transform.Find("Sphere").GetComponent <CollisionNotifier>();

        stateMachine = new InputStateMachine();

        NormalState normalState = new NormalState(this, wanderStrength, collisionNotifier);

        stateMachine.AddState(normalState);

        AggressiveState aggressiveState = new AggressiveState(this, wanderStrength, guidePointDistance, aggressiveTime, collisionNotifier);

        stateMachine.AddState(aggressiveState);

        stateMachine.ChangeToState <NormalState>();

        // decision tree setup
        treeRoot = new DecisionQuery <AIInput, Path>
        {
            Test = (ai) => ai.currentPath.CheckIfOnCriticalSection(ai.car.position),

            Positive = new DecisionResult <AIInput, Path>(null),
            Negative = new DecisionQuery <AIInput, Path>
            {
                Test = (ai) => ai.behaviour.boostCount < ai.minBoost,

                Positive = new DecisionResult <AIInput, Path>(coinPath),
                Negative = new DecisionQuery <AIInput, Path>
                {
                    Test = (ai) => ai.otherCar.boostCount > ai.behaviour.boostCount,

                    Positive = new DecisionResult <AIInput, Path>(coinPath),
                    Negative = new DecisionResult <AIInput, Path>(fastPath)
                }
            }
        };
    }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     this.inputStateMachine = new InputStateMachine(this.gameCamera);
     this.inputStateMachine.InitializeStateTransitions();
 }
Esempio n. 5
0
 public void OnAddToStateMachine(InputStateMachine sm)
 {
     StateMachine = sm;
 }
 // Use this for initialization
 void Start()
 {
     this.inputStateMachine = new InputStateMachine(this.gameCamera);
     this.inputStateMachine.InitializeStateTransitions();
 }