Ejemplo n.º 1
0
    void Update()
    {
        // Wave will attack in -> text
        if (waveManager.GetWaveTimeToAttack() < 10f)
        {
            SetMessageText($"Next Wave In {waveManager.GetWaveTimeToAttack().ToString("F1")}s!");
        }
        else
        {
            SetMessageText(string.Empty);
        }

        // Arrow - Spawner - Rotation
        normlizedArrowCache = (waveManager.GetNextSpawnPosition() -
                               mainCam.transform.position).normalized;
        nextWaveArrow.anchoredPosition = normlizedArrowCache * 400f;
        arrowRotationCache.z           = UtilitiesClass.GetAngleFromVector(
            normlizedArrowCache);
        nextWaveArrow.eulerAngles = arrowRotationCache;
        nextWaveArrow.gameObject.SetActive(
            (waveManager.GetNextSpawnPosition() - mainCam.transform.position).magnitude >
            mainCam.orthographicSize * 1.5f
            );

        // Arrow - Enemy - Rotation
        if (Time.timeSinceLevelLoad > timerToNextEnemyCheck)
        {
            LocalizeEnemyTarget();
            timerToNextEnemyCheck = Time.timeSinceLevelLoad + 0.1f;
        }
        if (targetEnemy != null)
        {
            enemyPositionCache  = targetEnemy.transform.position;
            normlizedArrowCache = (enemyPositionCache -
                                   mainCam.transform.position).normalized;
            closestEnemyArrow.anchoredPosition = normlizedArrowCache * 350f;
            arrowRotationCache.z = UtilitiesClass.GetAngleFromVector(
                normlizedArrowCache);
            closestEnemyArrow.eulerAngles = arrowRotationCache;
            closestEnemyArrow.gameObject.SetActive(
                (enemyPositionCache - mainCam.transform.position).magnitude >
                mainCam.orthographicSize * 1.5f
                );
        }
        else
        {
            closestEnemyArrow.gameObject.SetActive(false);
        }
    }