コード例 #1
0
        public static void HandleCollision(ILink link, IBlock block, Enumerations.CollisionSide collision)
        {
            Contract.Requires(link != null);
            Contract.Requires(block != null);

            if (InventoryAgrees(link))
            {
                block.IsDestructable = true;
                foreach (IDoorTrigger doorTrigger in Room.CurrentRoomDoorTriggers)
                {
                    if (doorTrigger.GameObjectType == Enumerations.GameObjectType.DoorTriggerDown)
                    {
                        doorTrigger.IsDestructable = true;
                    }
                }

                foreach (IBlock blockDoor in Room.CurrentRoomBlocks)
                {
                    if (block.GameObjectType == Enumerations.GameObjectType.DoorDown)
                    {
                        blockDoor.IsDestructable = true;
                    }
                }

                IBlock newDoor = new BlockDownOpenDoor();
                newDoor.Position = new Vector2(Constant.DownDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth, (Constant.DownDoorPositionNative.Y + HUDConstants.HUDHeight) * Game1.Instance.graphics.PreferredBackBufferHeight / Constant.OriginalNesHeight);
                IDoorTrigger newTrigger = new BlockDownOverDoor();
                newTrigger.Position = new Vector2(Constant.DownOverDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth, (Constant.DownOverDoorPositionNative.Y + HUDConstants.HUDHeight) * Game1.Instance.graphics.PreferredBackBufferHeight / Constant.OriginalNesHeight);
                Room.CurrentRoomBlocks.Add(newDoor);
                Room.CurrentRoomDoorTriggers.Add(newTrigger);
                SoundManager.Instance.PlayDoorStateChange();

                int oppositeRoom = GameObjects.Instance.LevelListPosition + Constant.DungeonGridWidth;
                Enumerations.Direction doorDirection = Enumerations.Direction.Up;
                Enumerations.DoorType  doorType      = Enumerations.DoorType.Locked;
                ToolsXML toolsXml = new ToolsXML();
                toolsXml.ReplaceOppositeDoorNodeXML(oppositeRoom, doorType, doorDirection);
            }
        }
コード例 #2
0
ファイル: ToolsXML.cs プロジェクト: L0gan012/Zelda_V2
        public void OpenAllSealedDoors(List <IBlock> currentRoomBlocks)
        {
            IBlock newDoor;

            if (currentRoomBlocks.Count != 0)
            {
                for (int blockCount = 0; blockCount < currentRoomBlocks.Count; blockCount++)
                {
                    if (currentRoomBlocks[blockCount].GameObjectType == Enumerations.GameObjectType.DownSealStop)
                    {
                        currentRoomBlocks[blockCount].IsDestructable = true;
                        newDoor          = new BlockDownOpenDoor();
                        newDoor.Position = new Vector2(Constant.DownDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth,
                                                       (Constant.DownDoorPositionNative.Y + HUDConstants.HUDHeight) * Game1.Instance.graphics.PreferredBackBufferHeight / Constant.OriginalNesHeight);
                        foreach (IBlock blockDoor in Room.CurrentRoomBlocks)
                        {
                            if (blockDoor.GameObjectType == Enumerations.GameObjectType.DoorDown)
                            {
                                blockDoor.IsDestructable = true;
                            }
                        }
                        Room.CurrentRoomBlocks.Add(newDoor);
                        SoundManager.Instance.PlayDoorStateChange();
                    }
                    else if (currentRoomBlocks[blockCount].GameObjectType == Enumerations.GameObjectType.LeftSealStop)
                    {
                        currentRoomBlocks[blockCount].IsDestructable = true;
                        newDoor          = new BlockLeftOpenDoor();
                        newDoor.Position = new Vector2(Constant.LeftDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth,
                                                       (Constant.LeftDoorPositionNative.Y + HUDConstants.HUDHeight) * Game1.Instance.graphics.PreferredBackBufferHeight / Constant.OriginalNesHeight);
                        foreach (IBlock blockDoor in Room.CurrentRoomBlocks)
                        {
                            if (blockDoor.GameObjectType == Enumerations.GameObjectType.DoorLeft)
                            {
                                blockDoor.IsDestructable = true;
                            }
                        }
                        Room.CurrentRoomBlocks.Add(newDoor);
                        SoundManager.Instance.PlayDoorStateChange();
                    }
                    else if (currentRoomBlocks[blockCount].GameObjectType == Enumerations.GameObjectType.RightSealStop)
                    {
                        currentRoomBlocks[blockCount].IsDestructable = true;
                        newDoor          = new BlockRightOpenDoor();
                        newDoor.Position = new Vector2(Constant.RightDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth,
                                                       (Constant.RightDoorPositionNative.Y + HUDConstants.HUDHeight) * Game1.Instance.graphics.PreferredBackBufferHeight / Constant.OriginalNesHeight);
                        foreach (IBlock blockDoor in Room.CurrentRoomBlocks)
                        {
                            if (blockDoor.GameObjectType == Enumerations.GameObjectType.DoorRight)
                            {
                                blockDoor.IsDestructable = true;
                            }
                        }
                        Room.CurrentRoomBlocks.Add(newDoor);
                        SoundManager.Instance.PlayDoorStateChange();
                    }
                    else if (currentRoomBlocks[blockCount].GameObjectType == Enumerations.GameObjectType.UpSealStop)
                    {
                        currentRoomBlocks[blockCount].IsDestructable = true;
                        newDoor          = new BlockUpOpenDoor();
                        newDoor.Position = new Vector2(Constant.UpDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth,
                                                       (Constant.UpDoorPositionNative.Y + HUDConstants.HUDHeight) * Game1.Instance.graphics.PreferredBackBufferHeight / Constant.OriginalNesHeight);
                        foreach (IBlock blockDoor in Room.CurrentRoomBlocks)
                        {
                            if (blockDoor.GameObjectType == Enumerations.GameObjectType.DoorUp)
                            {
                                blockDoor.IsDestructable = true;
                            }
                        }
                        Room.CurrentRoomBlocks.Add(newDoor);
                        SoundManager.Instance.PlayDoorStateChange();
                    }
                }
            }
        }