Пример #1
0
        private IEnumerator Detonate(float value)
        {
            yield return(new WaitForSeconds(value));

            explotionEffect.Play();
            mesh.SetActive(false);
            List <GameObject> units = UnitHolder.instance.units;

            for (int i = 0; i < units.Count; i++)
            {
                if (units[i] != null)
                {
                    if (Vector3.Distance(transform.position, units[i].transform.position) <= 5)
                    {
                        Debug.DrawLine(transform.position, units[i].transform.position, Color.red, 2f);
                        Debug.DrawRay(gameObject.transform.position, units[i].transform.position - transform.position, Color.green, 2f);

                        RaycastHit hit;
                        if (Physics.Raycast(transform.position, units[i].transform.position - transform.position, out hit))
                        {
                            if (hit.transform.GetComponent <ActorController>())
                            {
                                ActorController enemy = hit.transform.GetComponent <ActorController>();

                                if (enemy.stats.health - explotionDamage * m_Owner.stats.damageCaused <= 0)
                                {
                                    enemy.TakeDamage(explotionDamage * m_Owner.stats.damageCaused);
                                    BattleGrounObserver.instance.AddKill(new KillList {
                                        Killer = owner.nickname, Weapon = grenadeIcon, Victum = enemy.nickname
                                    });
                                    enemy.Death();
                                }
                                else
                                {
                                    enemy.TakeDamage(explotionDamage * m_Owner.stats.damageCaused);
                                }
                            }
                        }
                    }
                }
            }
            Invoke(nameof(Destroy), 1f);
        }
Пример #2
0
        void SingleBulletEffect(Vector3 direction, WeaponData weaponData)
        {
            RaycastHit hit;

            if (Physics.Raycast(shootPoint.position, direction, out hit))
            {
                if (hit.transform.GetComponent <ActorController>())
                {
                    ActorController enemy = hit.transform.GetComponent <ActorController>();
                    if (enemy.stats.health - weaponData.Damage <= 0)
                    {
                        enemy.stats.health -= weaponData.Damage;
                        BattleGrounObserver.instance.AddKill(new KillList {
                            Killer = shooter.nickname, Weapon = weaponData.icon, Victum = enemy.nickname
                        });
                        enemy.Death();
                    }
                    else
                    {
                        enemy.stats.health -= weaponData.Damage;
                    }
                }
            }
        }
Пример #3
0
 private void Awake()
 {
     m_Owner    = GetComponentInParent <ActorController>();
     m_Rotation = transform.rotation;
 }
Пример #4
0
 void Start()
 {
     m_Index = 0;
     StartCoroutine(Detonate(1f));
     m_Owner = owner as ActorController;
 }