Example #1
0
        public int handleCombatChooseMove(AnimationCallback callback)
        {
            // locate the nearest human
            List <Human> humans = MyBoard.getHumans();

            if (humans.Count() > 0)
            {
                Human    human    = humans[0];
                HexBoard hexBoard = MyBoard.MyHexBoard;

                return(MyBoard.movePlayer(this, human.Location, MyAttributes.actionPoints, callback));
            }

            return(0);
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            if (this.actionHasFinished)
            {
                return;
            }

            MouseState mouseStateCurrent = Mouse.GetState();

            if (actionIsTriggered)
            {
                if (!CurrentPlayer.IsMoving)
                {
                    // Player has stopped moving, so this action is complete.
                    combatActionHandler.handleActionComplete(actionType);
                    this.actionHasFinished = true;
                }
                else
                {
                    // Player is moving, so there isn't anything we need to do
                    return;
                }
            }
            else
            {
                if (!allowUserInteraction())
                {
                    // Current player is under computer control.
                    if (CurrentPlayer.MyType == Player.Type.Zombie)
                    {
                        Zombie zombie        = (Zombie)CurrentPlayer;
                        int    numHexesMoved = zombie.handleCombatChooseMove(this);
                        zombie.subtractActionPointsBy(numHexesMoved);
                        actionIsTriggered = true;
                    }
                }
                else
                {
                    // Current player is under user control.  Wait for a mouse click
                    // Show the path the user may want to take
                    // CombatLocation location = currentPlayer.Location;
                    //List<Hex> hexPath = this.board.highlightPath(location.i, location.j, mousePoint);

                    if (mouseStateCurrent.LeftButton == ButtonState.Pressed && mouseStatePrevious.LeftButton == ButtonState.Released)
                    {
                        Point mousePoint = new Point(mouseStateCurrent.X, mouseStateCurrent.Y);
                        Hex   targetHex  = getTargetHex(mousePoint);
                        if (targetHex != null)
                        {
                            GameEntity gameEntity = targetHex.MyGameEntity;
                            if (gameEntity != null)
                            {
                                actionIsTriggered = true;
                            }
                            else
                            {
                                actionIsTriggered = true;
                            }

                            if (actionIsTriggered)
                            {
                                int numHexesMoved = MyBoard.movePlayer(CurrentPlayer, mousePoint, this);

                                // Subtract the number spaces moved from the player's action points
                                CurrentPlayer.subtractActionPointsBy(numHexesMoved);
                            }
                        }
                    }
                }
            }

            mouseStatePrevious = mouseStateCurrent;
        }