private void LazerShoot(IGetDamage target) { IBullet bullet = new LazerBullet(lazerBulletType, currentLazerCanonStats.damage); target.GetDamage(bullet); lazerClip--; }
private void Shoot(IGetDamage target) { IBullet bullet = new MachineGunBullet(bulletType, currentMachineGunStats.damage); target.GetDamage(bullet); machineGunClip--; }
public void Fire(IGetDamage target) { if (heals < 0) { return; } if (_timeToNextMachineGunShoot < 0.01f) { Shoot(target); if (machineGunClip < 1) { _timeToNextMachineGunShoot = currentMachineGunStats.reloadDelay; StartCoroutine(ShootDelay(_timeToNextMachineGunShoot, () => machineGunClip = currentMachineGunStats.ammo)); } _timeToNextMachineGunShoot = currentMachineGunStats.shootDelay; StartCoroutine(ShootDelay(_timeToNextMachineGunShoot)); } if (_timeToNextLazerShoot < 0.01f) { LazerShoot(target); if (lazerClip < 1) { _timeToNextLazerShoot = currentLazerCanonStats.reloadDelay; StartCoroutine(ShootDelay(_timeToNextLazerShoot, () => lazerClip = currentLazerCanonStats.ammo)); } _timeToNextLazerShoot = currentLazerCanonStats.shootDelay; } StartCoroutine(ShootDelay(_timeToNextLazerShoot)); }
public virtual void UnderAttack(IAttack enemy) { if (target == null) //if (inAttackRadius(enemy.transform.position)) { target = enemy.parent.HealthController; if (parent.Type == Unit.UnitType.Zombie) { parent.MoveController.Target = enemy.transform; } } }
public virtual void Attack() { if (target != null && target.isLive && inAttackRadius(target.transform.position)) { isAttack = true; if (!isCoroutineStart) { StartCoroutine(DoAttack()); } return; } target = null; Enemys.Clear(); switch (myType) { case Unit.UnitType.Soldier: { Enemys.AddRange(MarkersManager.inst.enemys); break; } case Unit.UnitType.Zombie: { Enemys.AddRange(MarkersManager.inst.units); Enemys.Add(MarkersManager.inst.mainBase.transform.GetComponent <Unit>()); break; } } if (Enemys.Count > 0) { var minDistance = (float)AttackRadius; foreach (var e in Enemys) { var dist = Vector3.Distance(e.transform.position, transform.position); if (dist < minDistance) { minDistance = dist; target = e.HealthController; } } } if (target != null) { isAttack = true; StartCoroutine(DoAttack()); } else { isAttack = false; } }
private void Start() { if (anim == null) { anim = transform.GetComponentInChildren <Animator>(); } if (MoveController == null) { MoveController = GetComponent <IMove>(); } if (MoveController == null) { MoveController = transform.GetComponentInChildren <IMove>(); } if (MoveController != null) { MoveController.SetParent(this); } if (AttackController == null) { AttackController = transform.GetComponentInChildren <IAttack>(); } if (AttackController != null) { AttackController.SetParent(this); } if (HealthController == null) { HealthController = transform.GetComponentInChildren <IGetDamage>(); } if (HealthController != null) { HealthController.SetParent(this); } if (MoveController != null) { MoveController.Target = Target; } if (HPBar == null) { HPBar = transform.GetComponentInChildren <Image>(); } }