Beispiel #1
0
    public void Spawn()
    {
        if (isActive && !GameManager.Instance.isGameComplete)
        {
            if (baseController.currentWaveID < unitWawes.Length)
            {
                if (unitWawes[baseController.currentWaveID].reserveUnits.Count > 0)
                {
                    MovingUnits unit = unitWawes[baseController.currentWaveID].reserveUnits[0];
                    if (unit != null)
                    {
                        unitWawes[baseController.currentWaveID].reserveUnits.Remove(unit);

                        unit.transform.SetParent(baseController.transform);
                        unit.transform.position = spawnPosition.position;
                        unit.gameObject.SetActive(true);
                        unit.ResetUnit();
                        unit.baseController = baseController;
                        baseController.AddUnit(unit);
                        StartCoroutine(Spawning());
                    }
                }
            }
            else
            {
                GameManager.Instance.CompleteGame();
            }
        }
    }