Exemplo n.º 1
0
        // 장애물 생성
        private void CreateObstacle(int count, int horizontal, int vertical)
        {
            List <DecoTileData> decoTileData = currentTileSet.DecoTileData;

            for (int i = 0; i < count; i++)
            {
                int    randX        = Random.Range(0, horizontal);
                int    randZ        = Random.Range(0, vertical);
                string randDecoTile = decoTileData[Random.Range(0, decoTileData.Count)].PrefabPath;

                PoolManager.Instance.CreateObjectPoolFromPath <DecorationTile>(randDecoTile, randDecoTile);
                DecorationTile decoTile = PoolManager.Instance.Create <DecorationTile>(randDecoTile);

                if (CheckDecoTileCollision(decoTile, randX, randZ))
                {
                    decoTile.init(new Vector3Int(randX, 1, randZ));
                    decoTileList.Add(new DecoTileListData(randDecoTile, decoTile));
                    for (int j = 0; j < decoTile.gameObject.transform.childCount; j++)
                    {
                        Vector3 pos = decoTile.gameObject.transform.GetChild(j).transform.localPosition;
                        tileList[(int)pos.x + randX][(int)pos.z + randZ].SetState(TileState.Obstacle);
                    }
                }
                else
                {
                    PoolManager.Instance.Release <DecorationTile>(randDecoTile, decoTile);
                }
            }
        }
Exemplo n.º 2
0
 // 물 and 다리 생성
 private void CreateWaterAndBridge(int x, int z)
 {
     if (tileList[x][z].GetState() == TileState.Obstacle)
     {
         PoolManager.Instance.CreateObjectPoolFromPath <DecorationTile>("Bridge", currentTileSet.BridgeData.PrefabPath);
         DecorationTile bridge = PoolManager.Instance.Create <DecorationTile>("Bridge");
         bridge.init(new Vector3Int(x, 0, z));
         decoTileList.Add(new DecoTileListData("Bridge", bridge));
         tileList[x][z].Init(TileState.Bridge, new Vector3(x, (float)-0.5, z), currentWaterMaterial[0], currentWaterMaterial[1], false);
     }
     else
     {
         tileList[x][z].Init(TileState.Water, new Vector3(x, (float)-0.5, z), currentWaterMaterial[0], currentWaterMaterial[1], false);
     }
 }
Exemplo n.º 3
0
        // 성 생성
        private void CreateCastle(int vertical, int horizontal)
        {
            monsterCastlePos = new Vector3Int(Random.Range(0, CASTLE_MAX_TILE_RANGE), 0, Random.Range(0, vertical));
            tileList[monsterCastlePos.x][monsterCastlePos.z].SetState(TileState.Castle);

            PoolManager.Instance.CreateObjectPoolFromPath <DecorationTile>("MonsterCastle", "Prefabs/Monster_Castle", 1);
            DecorationTile monsterCastle = PoolManager.Instance.Create <DecorationTile>("MonsterCastle");

            monsterCastle.init(new Vector3Int(monsterCastlePos.x, 0, monsterCastlePos.z));
            decoTileList.Add(new DecoTileListData("MonsterCastle", monsterCastle));

            playerCastlePos = new Vector3Int(Random.Range(horizontal - CASTLE_MAX_TILE_RANGE, horizontal), 0, Random.Range(0, vertical));
            tileList[playerCastlePos.x][playerCastlePos.z].SetState(TileState.Castle);

            PoolManager.Instance.CreateObjectPoolFromPath <DecorationTile>("PlayerCastle", "Prefabs/Player_Castle", 1);
            DecorationTile playerCastle = PoolManager.Instance.Create <DecorationTile>("PlayerCastle");

            playerCastle.init(new Vector3Int(playerCastlePos.x, 0, playerCastlePos.z));
            decoTileList.Add(new DecoTileListData("PlayerCastle", playerCastle));
        }