コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            if (selected != -1 && Armies.army[selected].IsDead)
            {
                selected = -1;
            }
            if (!IsTurn)
            {
                buttons[0].enabled = false;
            }
            else
            {
                buttons[0].enabled = true;
            }
            // UPDATE ANIMTION
            if (moveArrows != null)
            {
                for (int i = 0; i < moveArrows.Count; i++)
                {
                    moveArrows[i].Update(gameTime);
                }
            }
            if (attackIcons != null)
            {
                for (int i = 0; i < attackIcons.Count; i++)
                {
                    attackIcons[i].Update(gameTime);
                }
            }
            if (selected >= 0 && canAttackThis != null && canAttack[selected])
            {
                for (int i = 0; i < canAttackThis.Count; i++)
                {
                    Character c = Armies.opponentArmy[canAttackThis[i]];

                    c.UpdateSpriteSheetAnimation(gameTime);

                    if (c.sprite.CurrentFrame == 1)
                    {
                        c.sprite.CurrentFrame = 2;
                    }
                }
            }
            // END UPDATE ANIMATION

            // UNFINISHED WIN/LOSE DEFINITION/EFFECT
            if (Armies.army[0].IsDead || Armies.opponentArmy[0].IsDead)
            {
                StateManager.ChangeState(Settings.STATES.Result);
            }
            // END UNFINISHED WIN/LOSE DEFINITION/EFFECT

            // CONNECTION LOST
            if (Globals.multiplayerConnection.ConnectionLost)
            {
                StateManager.ChangeState(Settings.STATES.Result);
            }
            // END CONNECTION LOST

            if (IsTurn && !Globals.multiplayerConnection.IsWaitingForResponse)
            {
                CheckIfCanAttack();

                if (selected != -1)
                {
                    if (Globals.mouseState.LeftButtonPressed && Main.WindowRectangle.Contains(Globals.mouseState.Position))
                    {
                        bool contains = false;
                        contains = TestForMove(gameTime);
                        if (!contains)
                        {
                            contains = TestForAttack(gameTime);
                        }

                        if (!contains)
                        {
                            canMoveTo = null;
                        }
                        moveArrows  = null;
                        attackIcons = null;
                    }
                }

                if (Globals.mouseState.LeftButtonPressed && Main.WindowRectangle.Contains(Globals.mouseState.Position))
                {
                    SelectUnit(gameTime);
                }
            }

            if (StateManager.GetState(1) is GameState)
            {
                ((GameState)StateManager.GetState(1)).Update(gameTime);
            }
            Globals.multiplayerConnection.Update(gameTime);

            statsUI.UpdateAnimation(gameTime);

            if (selected > -1 && !canAttack[selected])
            {
                canAttackThis = null;
            }
        }
コード例 #2
0
 public void ReceivedFight(int charIndexAttacker, int charIndexDefender)
 {
     statsUI.RemoveCharacter();
     ((GameState)StateManager.GetState(1)).AttackUnit(Armies.opponentArmy[charIndexAttacker], Armies.opponentArmy[charIndexAttacker].special != Character.Special.Healer ? Armies.army[charIndexDefender] : Armies.opponentArmy[charIndexDefender]);
 }
コード例 #3
0
 private void ReceivedMove(int charIndex, Point gridLocation)
 {
     ((GameState)StateManager.GetState(1)).MoveUnit(Armies.opponentArmy[charIndex], gridLocation);
 }
コード例 #4
0
 public List <Character> GetEnemyArmy()
 {
     return(((GameState)StateManager.GetState(1)).GetEnemyArmy());
 }
コード例 #5
0
 private List <Character> GetArmy()
 {
     return(((GameState)StateManager.GetState(1)).GetArmy());
 }
コード例 #6
0
 private void StartGame()
 {
     StateManager.ChangeState(Settings.STATES.Game);
 }