PreviewMove() public method

public PreviewMove ( Point playerLocation ) : Point
playerLocation Point
return Point
Exemplo n.º 1
0
        private void MoveMonster(Monster monster)
        {
            Point previewMove = monster.PreviewMove(player.Position);

            if (previewMove.X == player.Position.X && previewMove.Y == player.Position.Y)
            {
                UserMessage message   = new UserMessage();
                bool        hasHelmet = false;
                CastleItem  helmet    = ItemManager.FindItemInInventory("helmet");
                if (helmet != null)
                {
                    hasHelmet = true;
                }

                if (player.Hit(hasHelmet))
                {
                    message.AddLine(String.Format("The {0}", monster.Name));
                    message.AddLine("killed you!");
                    PrintUserMessage(message);
                    GameResult = GameResult.Failed;
                    EndGame();
                    gameOver = true;
                }
                else
                {
                    message.AddLine(String.Format("The {0}", monster.Name));
                    message.AddLine("struck you!");
                    if (hasHelmet)
                    {
                        message.AddLine("The Helmet");
                        message.AddLine("helped.");
                    }

                    PrintUserMessage(message);
                }
            }
            else
            {
                switch (CollisionDetection(previewMove))
                {
                case ObjectType.None:
                    monster.Move(previewMove);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void MoveMonster(Monster monster)
        {

            Point previewMove = monster.PreviewMove(player.Position);

            if (previewMove.X == player.Position.X && previewMove.Y == player.Position.Y)
            {
                UserMessage message = new UserMessage();
                bool hasHelmet = false;
                CastleItem helmet = ItemManager.FindItemInInventory("helmet");
                if(helmet != null)
                {
                    hasHelmet = true;
                }

                if (player.Hit(hasHelmet))
                {
                    message.AddLine(String.Format("The {0}", monster.Name));
                    message.AddLine("killed you!");
                    PrintUserMessage(message);
                    GameResult = GameResult.Failed;
                    EndGame();
                    gameOver = true;
                }
                else
                {
                    message.AddLine(String.Format("The {0}", monster.Name));
                    message.AddLine("struck you!");
                    if (hasHelmet)
                    {
                        message.AddLine("The Helmet");
                        message.AddLine("helped.");
                    }
                    
                    PrintUserMessage(message);
                }
            }
            else
            {
                switch (CollisionDetection(previewMove))
                {
                    case ObjectType.None:
                        monster.Move(previewMove);
                        break;
                }
            }
        }