public void Launch(GameObject Source, ICAPTarget target) { Target = target.GetGameObject(); Agent.Warp(CalculateClosest(Source.GetComponent <Collider>(), target.GetGameObject().transform)); transform.LookAt(Target.transform.position); Agent.SetDestination(Target.transform.position); Agent.angularSpeed = .01f; Agent.speed = 14f; }
// Update is called once per frame public void Update() { ResetTarget(); foreach (Turret t in turrets) { if (target != null && t.tType == TurretType.CAPITAL) { t.Target = target.GetGameObject(); } try{ if (pdtarget != null && t.tType == TurretType.PD) { t.Target = pdtarget.GetGameObject(); } } catch { Debug.Log("<color=red>Avoiding Target Lockup Error: Turret</color> This warning can be safely ignored."); t.Target = null; } pdTargetsCount = pdTargets.Count; } }
public virtual void Fire() { if (tType == TurretType.CAPITAL) { if (!CanFire || target == null || !self.shipClass.Power.UsePower(powerCost)) { return; } // Debug.DrawLine (self.transform.position, target.GetGameObject().transform.position, lineC, .05f); lr.SetPositions(new Vector3[] { self.transform.position, target.GetGameObject().transform.position }); if (ForceMagnitude > 0f) { target.DealPhysicsDamage(Damage, self.transform.position, ForceMagnitude, self.transform, Pattern); } else { target.DealDamage(Damage, self.transform.position, self.transform, Pattern); } StartCoroutine("Reload"); CanFire = false; if (light) { StartCoroutine("MuzzleFlash"); } } if (tType == TurretType.PD) { if (!CanFire || pdTarget == null || !self.shipClass.Power.UsePower(powerCost)) { return; } // Debug.DrawLine (self.transform.position, pdTarget.GetGameObject().transform.position, lineC, .05f); pdTarget.HitByPD((int)Damage); StartCoroutine("Reload"); CanFire = false; } }
public void Detonate(ICAPTarget targ) { targ.DealDamage(12f - (2f * Vector3.Distance(targ.GetGameObject().transform.position, transform.position)), transform.position, transform, MissileWarhead.Pattern); MissileWarhead.armed = false; StartCoroutine("Destroy"); }