void Update() { bool hitOthers = false; //check if missile is within a tank's collider Tank oppTank = Match.instance.GetOppositeTank(Team); if (oppTank != null && oppTank.IsDead == false) { if (oppTank.IsInFireCollider(Position)) { hitOthers = true; oppTank.TakeDamage(m_Owner); Utils.PlayParticle("CFX3_Hit_SmokePuff", Position); Match.instance.RemoveMissile(this); } } Vector3 newPos = Position + m_InitVelocity * Time.deltaTime; if (hitOthers == false) { //check if missile will hit some collider RaycastHit hitInfo; if (Physics.Linecast(Position, newPos, out hitInfo, PhysicsUtils.LayerMaskCollsion)) { bool hitOwner = false; if (PhysicsUtils.IsFireCollider(hitInfo.collider)) { //hit player FireCollider fc = hitInfo.collider.GetComponent <FireCollider>(); if (fc != null && fc.Owner != null) { if (fc.Owner.Team != Team) { fc.Owner.TakeDamage(m_Owner); } else { hitOwner = true; } } Utils.PlayParticle("CFX3_Hit_SmokePuff", hitInfo.point); } else { Utils.PlayParticle("CFX3_Hit_SmokePuff_Wall", hitInfo.point); } if (hitOwner == false) { Match.instance.RemoveMissile(this); hitOthers = true; } } } if (hitOthers == false) { transform.position = newPos; } }
void Awake() { m_NavAgent = GetComponent <NavMeshAgent>(); m_TurretTF = Find(transform, "Turret"); m_FirePosTF = Find(transform, "FirePos"); Transform hptf = Find(transform, "HPRecoveryEffect"); m_HPRecoveryEffectGO = hptf.gameObject; m_HPRecoveryEffectGO.SetActive(false); Transform tf = Find(transform, "FireCollider"); m_FireCollider = tf.GetComponent <FireCollider>(); m_FireCollider.Owner = this; OnAwake(); }
void OnTriggerEnter(Collider other) { if (PhysicsUtils.IsFireCollider(other) == false) { return; } if (m_Taken == true) { return; } m_Taken = true; FireCollider fc = other.GetComponent <FireCollider>(); if (fc != null && fc.Owner != null) { fc.Owner.TakeStar(m_IsSuperStar); Match.instance.SendStim( Stimulus.CreateStimulus((int)EStimulusType.StarTaken, ESensorType.Hearing, Position, this)); Match.instance.RemoveStar(this); } }
void Update() { Vector3 newPos = Position + m_InitVelocity * Time.deltaTime; RaycastHit hitInfo; if (Physics.Linecast(Position, newPos, out hitInfo, PhysicsUtils.LayerMaskCollsion)) { bool hitOwner = false; if (PhysicsUtils.IsFireCollider(hitInfo.collider)) { //hit player FireCollider fc = hitInfo.collider.GetComponent <FireCollider>(); if (fc != null && fc.Owner != null) { if (fc.Owner.Team != Team) { fc.Owner.TakeDamage(m_Owner); } else { hitOwner = true; } } Utils.PlayParticle("CFX3_Hit_SmokePuff", Position); } else { Utils.PlayParticle("CFX3_Hit_SmokePuff_Wall", Position); } if (hitOwner == false) { Match.instance.RemoveMissile(this); } } else { transform.position = newPos; } }