Exemplo n.º 1
0
    void HitWall(MapRoomController room, string direction)
    {
        if (buttonCooldown <= 0)
        {
            buttonCooldown = 0.5f;
            GameManager.Instance.CameraShake(0.3f);
            if (room == null)
            {
                GameManager.Instance.HitWall(false);
            }
            else
            {
                switch (direction)
                {
                case "Left":
                    activeRoom.SetWallType("Left", MapRoomController.Wall.Passage);
                    room.SetWallType("Right", MapRoomController.Wall.Passage);
                    break;

                case "Up":
                    activeRoom.SetWallType("Up", MapRoomController.Wall.Passage);
                    room.SetWallType("Down", MapRoomController.Wall.Passage);
                    break;

                case "Right":
                    activeRoom.SetWallType("Right", MapRoomController.Wall.Passage);
                    room.SetWallType("Left", MapRoomController.Wall.Passage);
                    break;

                case "Down":
                    activeRoom.SetWallType("Down", MapRoomController.Wall.Passage);
                    room.SetWallType("Up", MapRoomController.Wall.Passage);
                    break;
                }
                GameManager.Instance.HitWall(true);
                activeRoom.UpdateNeighbours();
                SetButtonsTypes();
            }
        }
    }
Exemplo n.º 2
0
    void OpenDoor(MapRoomController room, string direction)
    {
        if (buttonCooldown <= 0)
        {
            buttonCooldown = 0.5f;
            if (GameManager.Instance.inventoryController.keys > 0)
            {
                switch (direction)
                {
                case "Left":
                    activeRoom.SetWallType("Left", MapRoomController.Wall.Passage);
                    room.SetWallType("Right", MapRoomController.Wall.Passage);
                    break;

                case "Up":
                    activeRoom.SetWallType("Up", MapRoomController.Wall.Passage);
                    room.SetWallType("Down", MapRoomController.Wall.Passage);
                    break;

                case "Right":
                    activeRoom.SetWallType("Right", MapRoomController.Wall.Passage);
                    room.SetWallType("Left", MapRoomController.Wall.Passage);
                    break;

                case "Down":
                    activeRoom.SetWallType("Down", MapRoomController.Wall.Passage);
                    room.SetWallType("Up", MapRoomController.Wall.Passage);
                    break;
                }
                GameManager.Instance.inventoryController.KeyLose();
                GameManager.Instance.PrintActionFeedback(null, "You used the key and opened the door.", null, false, true);
            }
            else
            {
                GameManager.Instance.PrintActionFeedback(null, "You have no keys!", null, false, true);
            }
            SetButtonsTypes();
        }
    }
    void GeneratePass(List <GameObject> roomsTempList, RaycastHit2D hit, MapRoomController roomController, string roomWall_1, string roomWall_2)
    {
        if (hit.collider != null && hit.collider.gameObject.tag == "MapRoom")
        {
            foreach (GameObject rm in roomsTempList)
            {
                if (rm == hit.collider.gameObject)
                {
                    MapRoomController neighbourRoomController = hit.collider.gameObject.GetComponent <MapRoomController>();

                    // TYPES //////////////////////////
                    if (roomController.roomType == MapRoomController.Type.Start)                                                                                  // START ROOM
                    {
                        if (neighbourRoomController.roomType == MapRoomController.Type.Default || neighbourRoomController.roomType == MapRoomController.Type.Npc) // DEFAULT OR NPC
                        {
                            if (neighbourRoomController.coreRoom)                                                                                                 // CORE ROOM
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.Passage);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Passage);
                            }
                            else // NOT CORE ROOM
                            {
                                float random = Random.value;
                                if (random > 0.3f) //  passage
                                {
                                    roomController.SetWallType(roomWall_1, MapRoomController.Wall.Passage);
                                    neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Passage);
                                }
                                else if (random > 0.6f) //  locker
                                {
                                    roomController.SetWallType(roomWall_1, MapRoomController.Wall.DoorLocked);
                                    neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.DoorLocked);
                                }
                                else //  SOLID WALL
                                {
                                    roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                                    neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                                }
                            }
                        }
                        else if (neighbourRoomController.roomType == MapRoomController.Type.Secret || neighbourRoomController.roomType == MapRoomController.Type.Boss) // SECRET OR BOSS
                        {
                            roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                            neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                        }
                        else if (neighbourRoomController.roomType == MapRoomController.Type.Treasure) // TREASURE
                        {
                            roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                            neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                        }
                    }
                    else if (roomController.roomType == MapRoomController.Type.Boss)                    // BOSS ROOM
                    {
                        if (neighbourRoomController.roomIndex == 2 && neighbourRoomController.coreRoom) // BOSS ENTRANCE PASSAGE
                        {
                            roomController.SetWallType(roomWall_1, MapRoomController.Wall.Passage);
                            neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Passage);
                        }
                        else // OTHER - SOLID WALL
                        {
                            roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                            neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                        }
                    }
                    else if (roomController.roomType == MapRoomController.Type.Default || roomController.roomType == MapRoomController.Type.Npc) // DEFAULT OR NPC
                    {
                        if (neighbourRoomController.coreRoom)                                                                                    // CORE PASSAGE
                        {
                            int roomIndexesOdds = Mathf.Abs(neighbourRoomController.roomIndex - roomController.roomIndex);

                            if (roomIndexesOdds == 1 || neighbourRoomController.roomType == MapRoomController.Type.Start)
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.Passage);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Passage);
                            }
                            else if (neighbourRoomController.roomType == MapRoomController.Type.Boss || roomIndexesOdds != 1)
                            {
                                if (neighbourRoomController.roomType != MapRoomController.Type.Start)
                                {
                                    roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                                    neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                                }
                            }
                        }
                        else // OTHER
                        {
                            float random = Random.value;
                            if (random > 0.3f) //  passage
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.Passage);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Passage);
                            }
                            else if (random > 0.6f) //  locker
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.DoorLocked);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.DoorLocked);
                            }
                            else //  SOLID WALL
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                            }
                        }
                    }
                    else if (roomController.roomType == MapRoomController.Type.Treasure) // TREASURE
                    {
                        if (neighbourRoomController.roomType == MapRoomController.Type.Boss)
                        {
                            roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                            neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                        }
                        else
                        {
                            float random = Random.value;
                            if (random > 0.3f) // locker
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.DoorLocked);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.DoorLocked);
                            }
                            else // SOLID WALL
                            {
                                roomController.SetWallType(roomWall_1, MapRoomController.Wall.Solid);
                                neighbourRoomController.SetWallType(roomWall_2, MapRoomController.Wall.Solid);
                            }
                        }
                    }
                }
            }
        }
    }