void Shoot() { GameObject bulletGO = (GameObject)Instantiate(ProjectailPrefab, firePoint.position, firePoint.rotation); projectile bullet = bulletGO.GetComponent <projectile>(); if (bullet != null) { Stats.Shoot(bullet, target, bularc); } }
void UpdateTarget() { float ClosestTarget = 0f; GameObject[] enemies = GameObject.FindGameObjectsWithTag(EnemyTag); foreach (GameObject Enemy in enemies) { EnemyPath E_Path = Enemy.GetComponent <EnemyPath>(); float distanceToEnemy = Vector2.Distance(transform.position, Enemy.transform.position); if (distanceToEnemy <= range) { ClosestEnemy = E_Path.distanceTravelled; if (ClosestEnemy > ClosestTarget) { ClosestTarget = ClosestEnemy; TargetEnemy = Enemy; target = TargetEnemy.transform; } } } if (TargetEnemy != null) { if (Vector2.Distance(transform.position, TargetEnemy.transform.position) > range) { TargetEnemy = null; target = null; ClosestTarget = 0; } else { if (useChimical) { Chimical(); GameObject spawn = Instantiate(ChemTrail, TargetEnemy.transform.position, TargetEnemy.transform.rotation); Stats.Shoot(spawn.GetComponent <ChimicalTrail>()); } } } }
//dmg claclution void Damage(Transform Enemy) { Enemy.GetComponent <EnemyStats>().CalcDamage(Physic, Fire, Water, Air, Earth); Stats.Shoot(Enemy, 0.5f); }