Пример #1
0
    /// <summary>
    /// Instantiation of spawn logic per Transport
    /// </summary>
    private void Start()
    {
        // Grab the spawn point for this unit.
        _spawnController   = gameObject.GetComponent <TransportSpawnController>();
        _spawnPoint        = _spawnController.GetSpawnPoint();
        _destination       = _spawnController.GetDestination();
        _payloadMultiplier = _spawnController.PayloadMultiplier;
        _spawnController.TearDown();

        _navMapRef  = FindObjectOfType <PolyNav2D>();
        _myObstacle = gameObject.GetComponent <PolyNavObstacle>();

        // Move to spawn location.
        transform.position = _spawnPoint;

        // Apply movement towards destination.
        MoveToDestination();
    }
    /// <summary>
    /// Begin a new wave.
    /// </summary>
    private void StartWave()
    {
        #region variable initiation

        _waveStartTimer = waveDelay;
        _isWaveActive   = true;
        int transportCount = Random.Range(baseTransportCount, baseTransportCount * _currentWave);

        #endregion variable initiation

        _currentWave++;

        if (_currentWave > numberOfWaves)
        {
            // JK, leave this be.
            // TODO: Do some end-game shit here.
        }

        _uiWaveCounter.text = _currentWave.ToString();

        // Re-activate the destination collider so waypoints can be generated.
        _destinationColliderController.Activate();

        // Determine wave size.
        _spawnCheckerCloneCount = transportCount;

        for (int i = 0; i < transportCount; i++)
        {
            GameObject newTransport = Instantiate(transportPrefabList[Random.Range(0, transportPrefabList.Length)]);
            TransportSpawnController spawnController = newTransport.GetComponent <TransportSpawnController>();
            // TODO: Make the multiplier be friendly to floats.
            spawnController.PayloadMultiplier = _currentWave * enemyMultiplierPerWave;
        }

        // TODO: WORKAROUND CODE BELOW
        _isWaveActive = true;
        waveDelay    += 10f;
    }