public void HandleEvent(GameRoundEvent gameRoundEvent) { var magic2 = new Tuple <GameRoundState, GameRoundEventType>(RoundState, gameRoundEvent.Type); if (_stateMachineTransitionMap.ContainsKey(magic2)) { var oldState = RoundState; RoundState = _stateMachineTransitionMap[magic2](gameRoundEvent); if (oldState != RoundState) { Debug.Log("State changed to " + RoundState); } foreach (var observerTuple in _stateChangeObservers) { if (observerTuple.Item1 == RoundState) { observerTuple.Item2(gameRoundEvent); } } } }
private GameRoundState SelectSoldier(GameRoundEvent gameRoundEvent) { var position = (Vector2)gameRoundEvent.Payload; var go = Battlefield[(int)position.x, (int)position.y]; if (!go) { return(GameRoundState.Idle); } var soldier = go.GetComponent <Soldier>(); if (!soldier || !OwnSoldiers.Contains(go)) { return(GameRoundState.Idle); } _soldierMover.SelectSoldier(soldier); _soldierShooter.SelectSoldier(soldier); _soldierSelector.SelectSoldier(soldier); return(GameRoundState.SoldierSelected); }
private GameRoundState DeselectSoldier(GameRoundEvent gameRoundEvent) { return(GameRoundState.Idle); }
private GameRoundState FinishRound(GameRoundEvent gameRoundEvent) { return(GameRoundState.Finished); }