public void DecreaseMonsterCountAtRoom(int col, int row)
 {
     sessionArray[row, col].movingEnemyCount--;
     if (sessionArray[row, col].movingEnemyCount <= 0)
     {
         if (sessionArray[row, col].roomType == RoomType.boss)
         {
             HeroController.S.isClearSession = true;
         }
         else
         {
             sessionArray[row, col].movingEnemyCount = 0;
             sessionArray[row, col].monsterList.Clear();
             DoorController tempDoorController = null;
             foreach (var door in sessionArray[row, col].doorsInRoomDic)
             {
                 tempDoorController = door.Value.transform.Find("Door").GetComponent <DoorController>();
                 if (tempDoorController != null)
                 {
                     tempDoorController.DoorOpen();
                 }
             }
         }
     }
 }
Пример #2
0
 private void Update()
 {
     if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0)
     {
         doorController.DoorOpen();
     }
 }
Пример #3
0
    private void Update()
    {
        if (roomChange)
        {
            if (FadeInOut.S.fadeInFinish)
            {
                colWithDoor = true;
                roomChange  = false;
            }

            if (FadeInOut.S.fadeOutFinish)
            {
                Vector3 doorPosTemp = nextRoomDoorGO.transform.position;
                doorPosTemp.x     += 0.5f;
                transform.position = doorPosTemp;
                MiniMapCamFollow.S.SetCamPos(roomIdx);
                MainCameraController.S.SetRoom((int)roomIdx.y, (int)roomIdx.x);
                FadeInOut.S.fadeSpeed = 600;
                FadeInOut.S.fadeOut   = false;
                SessionDrawController.S.ChangeMonsterState(roomIdx, Enemy.EnemyState.patroll);
            }
        }

        if (colWithDoor && Input.GetKeyDown(KeyCode.UpArrow) && FadeInOut.S.fadeInFinish && doorController.isOpen)
        {
            switch (doorController.doorDir)
            {
            case DoorDirInRoom.up:
                roomIdx.y     -= 2;
                nextRoomDoorGO = SessionDrawController.S.GetSessionArray()[(int)roomIdx.y, (int)roomIdx.x].doorsInRoomDic[DoorDirInRoom.down];
                break;

            case DoorDirInRoom.down:
                roomIdx.y     += 2;
                nextRoomDoorGO = SessionDrawController.S.GetSessionArray()[(int)roomIdx.y, (int)roomIdx.x].doorsInRoomDic[DoorDirInRoom.up];
                break;

            case DoorDirInRoom.left:
                roomIdx.x     -= 2;
                nextRoomDoorGO = SessionDrawController.S.GetSessionArray()[(int)roomIdx.y, (int)roomIdx.x].doorsInRoomDic[DoorDirInRoom.right];
                break;

            case DoorDirInRoom.right:
                roomIdx.x     += 2;
                nextRoomDoorGO = SessionDrawController.S.GetSessionArray()[(int)roomIdx.y, (int)roomIdx.x].doorsInRoomDic[DoorDirInRoom.left];
                break;

            default:
                break;
            }

            SessionDrawController.S.OpenMiniMapIcon((int)roomIdx.x, (int)roomIdx.y);
            doorController = nextRoomDoorGO.transform.Find("Door").GetComponent <DoorController>();
            doorController.DoorOpen();
            FadeInOut.S.fadeSpeed = 600;
            FadeInOut.S.fadeOut   = true;
            roomChange            = true;
        }
    }
    void InitDoor(ref List <GameObject> blockListTemp, ref GameObject blockTemp, int sessionRow, int sessionCol, DoorDirInRoom doorDirInRoom, RoomType roomType)
    {
        blockListTemp = tilePrefabList[(int)BlockType.door].tilePrfabs;
        blockTemp     = Instantiate <GameObject>(blockListTemp[0]);
        DoorController doorController = blockTemp.transform.Find("Door").GetComponent <DoorController>();

        doorController.doorDir = doorDirInRoom;
        sessionArray[sessionRow, sessionCol].doorsInRoomDic.Add(doorDirInRoom, blockTemp);
        switch (roomType)
        {
        case RoomType.town:
        case RoomType.camp:
        case RoomType.eventRoom:
            doorController.DoorOpen();
            break;

        case RoomType.monster:
        case RoomType.boss:
            break;

        default:
            break;
        }
    }
    void DrawSession()
    {
        RoomType          roomTypeTemp;
        DoorDirInRoom     doorDirTemp;
        List <string[, ]> tempRoomList;
        int randIdx = 0;

        string[,] roomStrTemp;
        GameObject blockTemp      = null;
        GameObject roomAnchorTemp = null;

        List <GameObject> blockListTemp = null;
        int randTileIdx;


        for (int sessionRow = 0; sessionRow < sessionArray.GetLength(0); sessionRow += 2)
        {
            for (int sessionCol = 0; sessionCol < sessionArray.GetLength(1); sessionCol += 2)
            {
                roomTypeTemp = sessionArray[sessionRow, sessionCol].roomType;
                if (roomTypeTemp == RoomType.none)
                {
                    continue;
                }

                if (roomTypeTemp == RoomType.boss)//DEBUG!!!!!!!!!
                {
                    bossRoomIdx = new Vector2(sessionCol, sessionRow);
                }

                doorDirTemp    = sessionArray[sessionRow, sessionCol].doorDir;
                tempRoomList   = roomList[(int)roomTypeTemp][doorDirTemp];
                randIdx        = Random.Range(0, tempRoomList.Count);
                roomStrTemp    = tempRoomList[randIdx];
                blockTemp      = null;
                blockListTemp  = null;
                roomAnchorTemp = Instantiate <GameObject>(RoomAnchorPrefab);
                roomAnchorTemp.transform.SetParent(SessionAnchorTrans);
                roomAnchorTemp.transform.localPosition = new Vector3(sessionCol / 2 * mapOffset, -(sessionRow / 2 * mapOffset), 0);

                sessionArray[sessionRow, sessionCol].size.y = roomStrTemp.GetLength(0);
                sessionArray[sessionRow, sessionCol].size.x = roomStrTemp.GetLength(1);
                roomAnchorTemp.name = "RoomAnchor" + sessionRow + sessionCol;
                if (sessionRow == 0 && sessionCol == 0)
                {
                    MainCameraController.S.SetRoom(0, 0);
                }

                for (int row = 0; row < roomStrTemp.GetLength(0); row++)
                {
                    for (int col = 0; col < roomStrTemp.GetLength(1); col++)
                    {
                        switch (roomStrTemp[row, col])
                        {
                        case "W":
                            blockListTemp = tilePrefabList[(int)BlockType.wall].tilePrfabs;
                            break;

                        case "G":
                            blockListTemp = tilePrefabList[(int)BlockType.ground].tilePrfabs;
                            break;

                        case "JG":
                            blockListTemp = tilePrefabList[(int)BlockType.jumpGround].tilePrfabs;
                            break;

                        case "T":
                            blockListTemp = tilePrefabList[(int)BlockType.tile].tilePrfabs;
                            break;

                        case "TW":
                            blockListTemp = tilePrefabList[(int)BlockType.tileWall].tilePrfabs;
                            break;

                        case "LH":
                            blockListTemp = tilePrefabList[(int)BlockType.hill].tilePrfabs;
                            blockTemp     = Instantiate <GameObject>(blockListTemp[0]);
                            break;

                        case "RH":
                            blockListTemp = tilePrefabList[(int)BlockType.hill].tilePrfabs;
                            blockTemp     = Instantiate <GameObject>(blockListTemp[1]);
                            break;

                        case "I":
                            blockListTemp = tilePrefabList[(int)BlockType.itme].tilePrfabs;
                            break;

                        case "M":
                            blockListTemp = tilePrefabList[(int)BlockType.monster].tilePrfabs;
                            break;

                        case "NP":
                            blockListTemp = tilePrefabList[(int)BlockType.npc].tilePrfabs;
                            break;

                        case "DU":
                            InitDoor(ref blockListTemp, ref blockTemp, sessionRow, sessionCol, DoorDirInRoom.up, roomTypeTemp);
                            break;

                        case "DD":
                            InitDoor(ref blockListTemp, ref blockTemp, sessionRow, sessionCol, DoorDirInRoom.down, roomTypeTemp);
                            break;

                        case "DL":
                            InitDoor(ref blockListTemp, ref blockTemp, sessionRow, sessionCol, DoorDirInRoom.left, roomTypeTemp);
                            break;

                        case "DR":
                            InitDoor(ref blockListTemp, ref blockTemp, sessionRow, sessionCol, DoorDirInRoom.right, roomTypeTemp);
                            break;

                        default:
                            break;
                        }

                        if (blockListTemp != null)
                        {
                            if (roomStrTemp[row, col] != "LH" && roomStrTemp[row, col] != "RH" && roomStrTemp[row, col] != "DU" &&
                                roomStrTemp[row, col] != "DD" && roomStrTemp[row, col] != "DL" && roomStrTemp[row, col] != "DR")
                            {
                                if (roomStrTemp[row, col] == "W")
                                {
                                    if (row == 0 && col == 0)
                                    {
                                        blockTemp = Instantiate <GameObject>(blockListTemp[blockListTemp.Count - 1]);
                                        blockTemp.transform.Rotate(new Vector3(0, 0, 90));
                                    }
                                    else if (row == 0 && col == roomStrTemp.GetLength(1) - 1)
                                    {
                                        blockTemp = Instantiate <GameObject>(blockListTemp[blockListTemp.Count - 1]);
                                        blockTemp.transform.Rotate(new Vector3(0, 0, 180));
                                    }
                                    else if (row == roomStrTemp.GetLength(0) - 1 && col == roomStrTemp.GetLength(1) - 1)
                                    {
                                        blockTemp = Instantiate <GameObject>(blockListTemp[blockListTemp.Count - 1]);
                                        blockTemp.transform.Rotate(new Vector3(0, 0, 270));
                                    }
                                    else if (row == roomStrTemp.GetLength(0) - 1 && col == 0)
                                    {
                                        blockTemp = Instantiate <GameObject>(blockListTemp[blockListTemp.Count - 1]);
                                    }
                                    else if (row == 0)
                                    {
                                        randTileIdx = Random.Range(0, blockListTemp.Count - 1);
                                        blockTemp   = Instantiate <GameObject>(blockListTemp[randTileIdx]);
                                        blockTemp.transform.Rotate(new Vector3(0, 0, 180));
                                    }
                                    else if (row == roomStrTemp.GetLength(0) - 1)
                                    {
                                        randTileIdx = Random.Range(0, blockListTemp.Count - 1);
                                        blockTemp   = Instantiate <GameObject>(blockListTemp[randTileIdx]);
                                    }
                                    else if (col == 0)
                                    {
                                        randTileIdx = Random.Range(0, blockListTemp.Count - 1);
                                        blockTemp   = Instantiate <GameObject>(blockListTemp[randTileIdx]);
                                        blockTemp.transform.Rotate(new Vector3(0, 0, 90));
                                    }
                                    else if (col == roomStrTemp.GetLength(1) - 1)
                                    {
                                        randTileIdx = Random.Range(0, blockListTemp.Count - 1);
                                        blockTemp   = Instantiate <GameObject>(blockListTemp[randTileIdx]);
                                        blockTemp.transform.Rotate(new Vector3(0, 0, 270));
                                    }
                                    else
                                    {
                                        blockTemp = Instantiate <GameObject>(blockListTemp[blockListTemp.Count - 1]);
                                    }
                                }
                                else
                                {
                                    randTileIdx = Random.Range(0, blockListTemp.Count);
                                    blockTemp   = Instantiate <GameObject>(blockListTemp[randTileIdx]);
                                }
                            }

                            blockTemp.transform.SetParent(roomAnchorTemp.transform);
                            blockTemp.transform.localPosition = new Vector3(col, row, 0);
                            GameObject tempGO = null;
                            switch (roomStrTemp[row, col])
                            {
                            case "I":
                                tempGO = blockTemp.GetComponent <ItemTile>().SetItem();
                                tempGO.transform.position = blockTemp.transform.position;
                                Destroy(blockTemp);
                                break;

                            case "M":
                                if (roomTypeTemp == RoomType.boss)
                                {
                                    blockTemp.GetComponent <MonsterTile>().Boss = true;
                                }
                                tempGO = blockTemp.GetComponent <MonsterTile>().SetMonster();

                                if (roomTypeTemp == RoomType.boss)
                                {
                                    Vector3 tempBlockPos = blockTemp.transform.position;
                                    tempBlockPos.y           += 1;
                                    tempGO.transform.position = tempBlockPos;
                                }
                                else
                                {
                                    tempGO.transform.position = blockTemp.transform.position;
                                }

                                MovingEnemy movingEnemy = tempGO.GetComponent <MovingEnemy>();
                                if (movingEnemy != null)
                                {
                                    movingEnemy.SetRoomIndex(sessionCol, sessionRow);
                                    sessionArray[sessionRow, sessionCol].monsterList.Add(tempGO);
                                    sessionArray[sessionRow, sessionCol].movingEnemyCount =
                                        sessionArray[sessionRow, sessionCol].monsterList.Count;
                                }

                                Destroy(blockTemp);
                                break;

                            case "NP":
                                break;

                            default:
                                break;
                            }
                        }

                        blockListTemp = null;
                        blockTemp     = null;
                    }
                }

                if (sessionArray[sessionRow, sessionCol].movingEnemyCount == 0)
                {
                    DoorController tempDoorController = null;
                    foreach (var door in sessionArray[sessionRow, sessionCol].doorsInRoomDic)
                    {
                        tempDoorController = door.Value.transform.Find("Door").GetComponent <DoorController>();
                        if (tempDoorController != null)
                        {
                            tempDoorController.DoorOpen();
                        }
                    }
                }
            }
        }
    }