Exemplo n.º 1
0
        private void Update()
        {
            Vector3 moveDir;

            if (m_targetEnemy != null)
            {
                moveDir             = (m_targetEnemy.transform.position - transform.position).normalized;
                m_lastMoveDirection = moveDir;
            }
            else
            {
                moveDir = m_lastMoveDirection;
            }

            transform.position   += moveDir * m_moveSpeed * Time.deltaTime;
            transform.eulerAngles = new Vector3(0f, 0f, UtilsClass.GetAngleFromVector(moveDir));

            m_timeToDie -= Time.deltaTime;

            if (m_timeToDie <= 0f)
            {
                Destroy(gameObject);
            }
        }
Exemplo n.º 2
0
 private void Update()
 {
     transform.position = UtilsClass.GetMouseWorldPosition();
 }
Exemplo n.º 3
0
        private void HandleNearestEnemyPositionIndicator()
        {
            Collider2D[] colliders2DArray = Physics2D.OverlapCircleAll(m_mainCamera.transform.position, 99999f);

            Enemy targetEnemy = null;

            foreach (Collider2D collider2D in colliders2DArray)
            {
                Enemy enemy = collider2D.GetComponent <Enemy>();

                if (enemy != null)
                {
                    if (targetEnemy == null)
                    {
                        targetEnemy = enemy;
                    }
                    else
                    {
                        if (Vector3.Distance(m_mainCamera.transform.position, enemy.transform.position) <
                            Vector3.Distance(m_mainCamera.transform.position, targetEnemy.transform.position))
                        {
                            targetEnemy = enemy;
                        }
                    }
                }
            }

            if (targetEnemy != null)
            {
                Vector3 directionToNearestEnemyPos = (targetEnemy.transform.position - m_mainCamera.transform.position).normalized;
                m_nearestEnemyPositionIndicator.anchoredPosition = directionToNearestEnemyPos * m_nearestEnemyIndicatorOffset;
                m_nearestEnemyPositionIndicator.eulerAngles      = new Vector3(0f, 0f, UtilsClass.GetAngleFromVector(directionToNearestEnemyPos));

                float distanceToNearestEnemyPos = Vector3.Distance(targetEnemy.transform.position, m_mainCamera.transform.position);

                m_nearestEnemyPositionIndicator.gameObject.SetActive(distanceToNearestEnemyPos > m_mainCamera.orthographicSize * 1.5f);
            }
            else
            {
                m_nearestEnemyPositionIndicator.gameObject.SetActive(false);
            }
        }
Exemplo n.º 4
0
        private void HandleEnemyWaveSpawnPositionIndicator()
        {
            Vector3 directionToNextSpawnPos = (m_enemyWaveManager.GetNextSpawnPosition() - m_mainCamera.transform.position).normalized;

            m_enemyWaveSpawnPositionIndicatorRect.anchoredPosition = directionToNextSpawnPos * m_enemyWaveSpawnPositionIndicatorOffset;
            m_enemyWaveSpawnPositionIndicatorRect.eulerAngles      = new Vector3(0f, 0f, UtilsClass.GetAngleFromVector(directionToNextSpawnPos));

            float distanceToNextSpawnPos = Vector3.Distance(m_enemyWaveManager.GetNextSpawnPosition(), m_mainCamera.transform.position);

            m_enemyWaveSpawnPositionIndicatorRect.gameObject.SetActive(distanceToNextSpawnPos > m_mainCamera.orthographicSize * 1.5f);
        }
Exemplo n.º 5
0
 private void EnemyWaveManager_OnWaveNumberChanged(object sender, System.EventArgs e)
 {
     SetWaveNumberText($"{UtilsClass.FirstLetterToUpper(GameManager.Instance.WaveDisplayName)} {m_enemyWaveManager.GetWaveNumber()}");
 }
Exemplo n.º 6
0
 private void Start()
 {
     m_mainCamera = Camera.main;
     m_enemyWaveManager.OnWaveNumberChanged += EnemyWaveManager_OnWaveNumberChanged;
     SetWaveNumberText($"{UtilsClass.FirstLetterToUpper(GameManager.Instance.WaveDisplayName)} {m_enemyWaveManager.GetWaveNumber()}");
 }