Beispiel #1
0
    public void GenerateEnemyWaves()
    {
        if (roomStats != null)
        {
            if (isActive && !isFinished && currentEnemyWaveIndex < roomStats.enemyWaveGroups.GetLength(0) && isStarted && enemies.Count == 0)
            {
                var activeEnemyWaves = roomStats.enemyWaveGroups[currentEnemyWaveIndex++].enemyWaves;

                waveText.text = $"Wave: {currentEnemyWaveIndex} / {roomStats.enemyWaveGroups.GetLength(0)}";

                foreach (var enemyWave in activeEnemyWaves)
                {
                    for (var i = 0; i < enemyWave.enemyCount; i++)
                    {
                        GenerateEnemy(enemyWave.enemyType);
                    }
                }
            }

            if (!isFinished && currentEnemyWaveIndex == roomStats.enemyWaveGroups.GetLength(0) && enemies.Count == 0 && isStarted)
            {
                onRoomFinished(gridPos, isLastRoom);
                notificationUIManager.ShowNotification("RoomCleared");
                isFinished = true;

                if (isLastRoom)
                {
                    var floorGemObj = Instantiate(floorGemPrefab, new Vector3(transform.position.x, 1, transform.position.z), Quaternion.identity);
                    floorGem = floorGemObj.GetComponent <FloorGem>();
                    floorGem.onDeathDelegate += OnFloorGemDestroyed;
                }

                if (roomStats.hasChest)
                {
                    var chest       = Instantiate(chestPrefab, new Vector3(transform.position.x, 5, transform.position.z + 5), Quaternion.identity);
                    var chestScript = chest.GetComponent <Chest>();

                    chestScript.noOfGems  = roomStats.chestGem;
                    chestScript.noOfCoins = roomStats.chestCoin;

                    chest.transform.SetParent(transform);
                }

                // floorGem.onDeathDelegate
            }
        }
    }
 public void FloorFinished()
 {
     notification.ShowNotification("Destroy the Floor Gem");
     ShowFloorCompleted();
     // onFloorFinishedDelegate();
 }