Пример #1
0
        public virtual UserMessage Show(CastleItem item)
        {
            UserMessage returnMessage = new UserMessage();

            returnMessage.AddLine(String.Format("The {0}", Name));
            returnMessage.AddLine("looks at you");
            returnMessage.AddLine("Funny!");

            return(returnMessage);
        }
Пример #2
0
        public override UserMessage Hit(CastleItem sword)
        {
            UserMessage returnMessage = new UserMessage();

            returnMessage.AddLine(String.Format("The {0}", Name));
            returnMessage.AddLine("is blocking");
            returnMessage.AddLine("your way. He");
            returnMessage.AddLine("can't be hurt.");

            return(returnMessage);
        }
Пример #3
0
        public override UserMessage Show(CastleItem item)
        {
            UserMessage returnMessage = new UserMessage();

            if (showItem == null)
            {
                returnMessage.AddLine(String.Format("The {0}", Name));
                returnMessage.AddLine("looks at you");
                returnMessage.AddLine("Funny!");
            }
            else
            {
                if (String.Compare(item.InventoryName, showItem, StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    this.IsVisible = false;
                    returnMessage.AddLine(showDescription);
                }
                else
                {
                    returnMessage.AddLine(String.Format("The {0}", Name));
                    returnMessage.AddLine("looks at you");
                    returnMessage.AddLine("Funny!");
                }
            }
            return(returnMessage);
        }
Пример #4
0
        public virtual UserMessage Hit(CastleItem sword)
        {
            UserMessage returnMessage = new UserMessage();

            if (sword == null)
            {
                returnMessage.AddLine("You have no");
                returnMessage.AddLine("Weapon!");
            }
            else if (this.Health > 0)
            {
                Health--;
                if (this.Health == 0)
                {
                    IsAlive = false;
                    returnMessage.AddLine("You Killed");
                    returnMessage.AddLine(String.Format("the {0}", Name));
                }
                else
                {
                    returnMessage.AddLine("You Struck");
                    returnMessage.AddLine(String.Format("the {0}", Name));
                }
            }
            return(returnMessage);
        }
Пример #5
0
        private bool ProcessTrap()
        {
            if (ItemManager.FindItemInInventory("Necklace") != null)
            {
                return(false);
            }

            GameResult = GameResult.Failed;

            // Draw Walls
            foreach (Point wallPoint in currentRoom.Trap.WallPoints)
            {
                SetGlyph(wallPoint.X, wallPoint.Y, 178, Color.White);
            }

            waterXStart = currentRoom.Trap.WaterFlowXStart;
            waterXEnd   = currentRoom.Trap.WaterFlowXEnd - 1;
            waterYStart = currentRoom.Trap.WaterFlowYStart;
            waterYEnd   = currentRoom.Trap.WaterFlowYEnd;

            // Animate the water
            animation = new InstructionSet();
            animation.Instructions.AddLast(new Wait()
            {
                Duration = 0.2f
            });

            var waterFillInstruction = new CodeInstruction();

            waterFillInstruction.CodeCallback = (inst) =>
            {
                waterXStart += 1;

                if (waterXStart > waterXEnd)
                {
                    inst.IsFinished = true;
                    gameOver        = true;
                }
                SetGlyph(waterXStart, waterYStart, 176, Color.White);
                SetGlyph(waterXStart, waterYEnd, 176, Color.White);
            };
            animation.Instructions.AddLast(waterFillInstruction);

            UserMessage userMessage = new UserMessage();

            userMessage.AddLine("You have");
            userMessage.AddLine("sprung a Trap!");
            userMessage.AddLine("The room has");
            userMessage.AddLine("filled with");
            userMessage.AddLine("water and you");
            userMessage.AddLine("drowned!");

            // Kill Character
            this.player.Kill();
            PrintUserMessage(userMessage);
            EndGame();

            return(true);
        }
Пример #6
0
        public override UserMessage Play(CastleItem item)
        {
            UserMessage returnMessage = null;

            if (playItem != null)
            {
                if (String.Compare(item.InventoryName, playItem, StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    returnMessage  = new UserMessage();
                    this.IsVisible = false;
                    returnMessage.AddLine(showDescription);
                }
            }
            return(returnMessage);
        }
Пример #7
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(CultureInfo.CurrentCulture, "The {0}", monster.Name));
                    message.AddLine("killed you!");
                    PrintUserMessage(message);
                    GameResult = GameResult.Failed;
                    EndGame();
                    gameOver = true;
                }
                else
                {
                    message.AddLine(String.Format(CultureInfo.CurrentCulture, "The {0}", monster.Name));
                    message.AddLine("struck you!");
                    if (hasHelmet)
                    {
                        message.AddLine(" ");
                    }
                    message.AddLine("The Helmet");
                    message.AddLine("helped.");
                    PrintUserMessage(message);
                }
            }
            else
            {
                switch (CollisionDetection(previewMove))
                {
                case ObjectType.None:
                    monster.Move(previewMove);
                    break;
                }
            }
        }
Пример #8
0
        private void MovePlayer()
        {
            UserMessage message;

            int   testRoomIndex;
            Point previewMove = player.PreviewMove(player.CurrentDirection);

            switch (CollisionDetection(previewMove))
            {
            case ObjectType.None:
                player.Move(previewMove);
                break;

            case ObjectType.Door:
                if (currentRoom.RoomWarp == null)
                {
                    testRoomIndex = currentRoom.GetNextRoom(player.CurrentDirection);
                    if (testRoomIndex == -1)
                    {
                        this.GameResult = Castle.GameResult.Win;
                        EndGame();
                        if (StopGamePlay != null)
                        {
                            StopGamePlay(this, new EventArgs());
                        }
                        return;
                    }
                    if (mapReader.FindRoom(testRoomIndex).Dark)
                    {
                        if (ItemManager.FindItemInInventory("Lamp") != null)
                        {
                            currentRoomIndex = testRoomIndex;
                            MovePlayerRoom(previewMove);
                            DrawRoom();
                        }
                        else
                        {
                            message = new UserMessage();
                            message.AddLine("It's too dark");
                            message.AddLine("to go that way");
                            PrintUserMessage(message);
                        }
                    }
                    else
                    {
                        currentRoomIndex = testRoomIndex;
                        MovePlayerRoom(previewMove);
                        DrawRoom();
                    }
                }
                else
                {
                    currentRoomIndex = currentRoom.RoomWarp.DestinationRoomId;
                    previewMove.X    = currentRoom.RoomWarp.X;
                    previewMove.Y    = currentRoom.RoomWarp.Y;
                    message          = currentRoom.RoomWarp.UserMessage;
                    player.Move(previewMove);
                    DrawRoom();
                    PrintUserMessage(message);
                }
                break;

            case ObjectType.UpStairs:
                currentRoomIndex = currentRoom.GetNextRoom(Direction.UpStairs);
                DrawRoom();
                break;

            case ObjectType.DownStairs:
                testRoomIndex = currentRoom.GetNextRoom(Direction.DownStairs);
                if (mapReader.FindRoom(testRoomIndex).Dark)
                {
                    if (ItemManager.FindItemInInventory("Lamp") != null)
                    {
                        currentRoomIndex = currentRoom.GetNextRoom(Direction.DownStairs);
                        DrawRoom();
                    }
                    else
                    {
                        message = new UserMessage();
                        message.AddLine("It's too dark");
                        message.AddLine("to go that way");
                        PrintUserMessage(message);
                    }
                }
                else
                {
                    currentRoomIndex = currentRoom.GetNextRoom(Direction.DownStairs);
                    DrawRoom();
                }
                break;

            case ObjectType.LockedDoor:
                message = new UserMessage();
                message.AddLine("The Door is");
                message.AddLine("locked");
                PrintUserMessage(message);
                break;

            case ObjectType.Trap:
                if (ProcessTrap() == false)
                {
                    player.Move(previewMove);
                }
                break;

            case ObjectType.Item:
                PickupItem(previewMove);
                break;

            case ObjectType.Monster:
                AttackMonster(previewMove);
                break;
            }
        }
Пример #9
0
        private void CreateWarpRooms()
        {
            // Sorcerers room
            UserMessage userMessage = new UserMessage();

            userMessage.AddLine("There is a ");
            userMessage.AddLine("puff of smoke");
            userMessage.AddLine("& you appear");
            userMessage.AddLine("in the");
            userMessage.AddLine("Sorcerers room");
            FindRoom(66).AddWarp(new RoomWarp(67, 16, 9, userMessage));

            // Kings hidden room
            FindRoom(83).AddWarp(new RoomWarp(77, 11, 16, new UserMessage()));

            // Add Doors in Room 68
            Collection <Point> room68Door = new Collection <Point>();

            room68Door.Add(new Point(8, 14));
            room68Door.Add(new Point(9, 14));
            Collection <Point> room68UnlockPoints = new Collection <Point>();

            room68UnlockPoints.Add(new Point(8, 13));
            room68UnlockPoints.Add(new Point(9, 13));
            room68UnlockPoints.Add(new Point(8, 15));
            room68UnlockPoints.Add(new Point(9, 15));
            FindRoom(68).AddDoor(new Door(room68Door, room68UnlockPoints));


            // Add Doors in Room 82
            Collection <Point> room82Door = new Collection <Point>();

            room82Door.Add(new Point(13, 8));
            room82Door.Add(new Point(13, 9));
            Collection <Point> room82UnlockPoints = new Collection <Point>();

            room82UnlockPoints.Add(new Point(12, 8));
            room82UnlockPoints.Add(new Point(12, 9));
            room82UnlockPoints.Add(new Point(14, 8));
            room82UnlockPoints.Add(new Point(14, 9));
            FindRoom(82).AddDoor(new Door(room82Door, room82UnlockPoints));

            // Add Trap room 76
            Collection <Point> room76Trigger = new Collection <Point>();

            room76Trigger.Add(new Point(13, 12));
            room76Trigger.Add(new Point(13, 13));
            Collection <Point> room76TrapWall = new Collection <Point>();

            room76TrapWall.Add(new Point(10, 12));
            room76TrapWall.Add(new Point(10, 13));
            room76TrapWall.Add(new Point(16, 12));
            room76TrapWall.Add(new Point(16, 13));
            FindRoom(76).AddTrap(new Trap(room76Trigger, room76TrapWall, 10, 15, 12, 13));

            // Add Trap room 78
            Collection <Point> room78Trigger = new Collection <Point>();

            room78Trigger.Add(new Point(17, 8));
            room78Trigger.Add(new Point(17, 9));
            Collection <Point> room78TrapWall = new Collection <Point>();

            room78TrapWall.Add(new Point(11, 8));
            room78TrapWall.Add(new Point(11, 9));
            room78TrapWall.Add(new Point(23, 8));
            room78TrapWall.Add(new Point(23, 9));
            FindRoom(78).AddTrap(new Trap(room78Trigger, room78TrapWall, 11, 22, 8, 9));
        }