Inheritance: SadConsole.Game.GameObject
コード例 #1
0
ファイル: CastleConsole.cs プロジェクト: drock07/SadConsole
        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;
                }
            }
        }