Пример #1
0
    protected override IEnumerator FindEnemies()
    {
        if (Placed)
        {
            Hit = Physics2D.OverlapCircleAll(transform.position, Radius / 1.9f);
            float Distance = 0;
            foreach (Collider2D enemy in Hit)
            {
                if (enemy.tag == "Enemy" && Distance <= enemy.GetComponent <BaseEnemy>().DistanceTravelled)
                {
                    if (enemy.GetComponent <BaseEnemy>().isCamo == false)
                    {
                        Enemy    = enemy.GetComponent <BaseEnemy>();
                        Distance = Enemy.DistanceTravelled;
                        GetEnemy();
                    }
                    else if (enemy.GetComponent <BaseEnemy>().isCamo == true && canSeeCamo == true)
                    {
                        Enemy    = enemy.GetComponent <BaseEnemy>();
                        Distance = Enemy.DistanceTravelled;
                        GetEnemy();
                    }
                }
            }

            if (Enemy != null)
            {
                Enemy.GetComponent <IDamagable>().TakeDamage(Damage, MoneyUpgrade);
                KillCount++;
                Player.UpdateKillCount();
                Enemy = null;
            }
        }
        yield return(new WaitForSeconds(FireRate));

        if (ShootAnim != null)
        {
            ShootAnim.SetActive(false);
        }
        if (DualHeads)
        {
            TurretHead1Anim.SetActive(false);
            TurretHead2Anim.SetActive(false);
        }
        StartCoroutine(FindEnemies());
    }
Пример #2
0
    private void GetEnemy()
    {
        Vector3    relativePos = Enemy.transform.position - transform.position;
        Quaternion rotation    = Quaternion.LookRotation(relativePos, Vector3.back);

        if (!DualHeads)
        {
            TurretHead.transform.rotation = rotation;
        }
        else
        {
            DualTurretHead.transform.rotation = rotation;
        }
        if (ShootAnim != null)
        {
            ShootAnim.SetActive(true);
        }
        if (DualHeads)
        {
            TurretHead1Anim.SetActive(true);
            TurretHead2Anim.SetActive(true);
        }
    }