public IDecision Play(ITurnState state)
        {
            UpdatePlayerState(state);

            IDecision decision = new Decision();

            if (state.Lighthouses.Where(x => x.Position == state.Position).Any())
            {
                if (this.Keys.Where(x => x == state.Position).Any())
                {
                    if (state.Lighthouses.Where(x => x.Position == state.Position).FirstOrDefault().IdOwner != this.Id)
                    {
                        decision.Action = PlayerActions.Attack;
                        decision.Energy = (int)Math.Floor(this.Energy / 0.8);

                        return(decision);
                    }
                }
            }

            decision.Action = PlayerActions.Move;
            decision.Target = RandomMovement();

            return(decision);
        }
 private void UpdatePlayerState(ITurnState state)
 {
     this.Position    = state.Position;
     this.Lighthouses = state.Lighthouses.Select(x => new Lighthouse()
     {
         Position = x.Position, Energy = x.Energy, IdOwner = x.IdOwner
     }).ToList();
 }
Пример #3
0
 void Update()
 {
     newState = currentState.DoState(this);
     if (newState != currentState)
     {
         currentState = newState;
         currentState.InitState(this);
     }
 }
Пример #4
0
 void Start()
 {
     currentState = playerTurnState;
     isPlayerTurn = true;
     currentState.InitState(this);
     FindObjectOfType <UI_AnimController>().skipTurnDelegate += () => isPlayerTurn = false;
     FindObjectOfType <BossStateManager>().endBossTurn       += () => isPlayerTurn = true;
     //go create the enemyAISTATE MACHINE.
     //FindObjectOfType<EnemyAIStateMachine>().attackOverDelegate += () => isPlayerTurn = true;
 }
Пример #5
0
        public void TakeTurn(IPlayerStatus status, IEnemy enemy)    //TODO: ret?
        {
            //TODO: change this. Not sure what role I wnat to have vs the simulator
            //This completes a turn. Simulator aggregates per turn data? not sure
            Assert.IsNotNull(status);
            Assert.IsNotNull(enemy);

            TurnStateEnum nextState;

            do
            {
                nextState    = currentState.Execute(status, enemy);
                currentState = stateMachine[nextState];
            }while (!currentState.TurnComplete);
        }
Пример #6
0
        public void Do()
        {
            int[]  coord  = unitShooting.Shoot();
            Status status = unitDefending.CheckHit(coord[0], coord[1]);

            unitShooting.ShootReport(status, coord[0], coord[1]);
            if (status == Status.miss)
            {
                state = new MissState();
            }
            else
            {
                state = new HitState();
            }
            if (status == Status.destroyed)
            {
                unitDefending.ShipBlow(unitDefending.myMap.GetShip(coord[0], coord[1]));
            }
            this.EndTurn();
        }
        public IDecision Play(ITurnState state)
        {
            UpdatePlayerState(state);

            IDecision decision = new Decision();

            if (AttackLighthouse(decision))
            {
                return(decision);
            }

            if (destination == null || state.Position == destination)
            {
                this.route = BestRoute(state.Position, out destination);
            }

            decision.Action = PlayerActions.Move;

            Vector2 targetStep = NextStep(state.Position, route, this.energyOptimization);

            decision.Target = targetStep;

            return(decision);
        }
Пример #8
0
 public TurnStateMachine(ITurnStateFactory factory)
 {
     Assert.IsNotNull(factory);
     stateMachine = InitStateMachine(factory);
     currentState = stateMachine[TurnStateEnum.Start];
 }
Пример #9
0
 public IDecision Play(ITurnState state)
 {
     return(this.PlayerDCI.Play(state));
 }