Beispiel #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.DoorTriggerRight)
                    {
                        doorTrigger.IsDestructable = true;
                    }
                }

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

                IBlock 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);
                IDoorTrigger newTrigger = new BlockRightOverDoor();
                newTrigger.Position = new Vector2(Constant.RightOverDoorPositionNative.X * Game1.Instance.graphics.PreferredBackBufferWidth / Constant.OriginalNesWidth, (Constant.RightOverDoorPositionNative.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 + 1;
                Enumerations.Direction doorDirection = Enumerations.Direction.Left;
                Enumerations.DoorType  doorType      = Enumerations.DoorType.Locked;
                ToolsXML toolsXml = new ToolsXML();
                toolsXml.ReplaceOppositeDoorNodeXML(oppositeRoom, doorType, doorDirection);
            }
        }
Beispiel #2
0
        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();
                    }
                }
            }
        }