Subversion Repository Public Repository

Nextrek

Diff Revisions 133 vs 134 for /3DSpace/Assets/Custum/Scripts/Missile.cs

Diff revisions: vs.
  @@ -11,17 +11,18 @@
11 11 private float _timer = 0;
12 12
13 13 private int autoDestructionCountDown = 5;
14 - private float _speed = 300;
14 + private float _speed = 350;
15 15
16 16 private static float ROTATION_SPEED = 1.0f;
17 17
18 - private float hitpower = 100000;
18 + private float hitPower = 100000;
19 19 //private bool isActive = false;
20 20
21 - public void SetTarget(GameObject trans)
22 - {
23 - target = trans;
24 - //isActive = true;
21 + private Transform firedBy;
22 +
23 + // "Fired By" Reference to ignore collision detection for the ship that fired the laser
24 + public void SetFiredBy(Transform who) {
25 + firedBy = who;
25 26 }
26 27
27 28 void Update()
  @@ -72,24 +73,14 @@
72 73 if (Physics.Raycast(startPosition, _direction, out _hit, _distance*5))
73 74 {
74 75 Debug.Log("raycast: " + _hit.transform.gameObject.tag);
75 - if (_hit.transform.gameObject.tag=="Enemy")
76 - {
77 - //Quaternion _rotation = Quaternion.FromToRotation(Vector3.up, _hit.normal);
78 - Instantiate(impactEffect, _hit.point, _hit.transform.rotation);
79 -
80 - EnemyShip es = _hit.transform.GetComponent<EnemyShip>();
81 - if(es!=null)
82 - {
83 - es.getHitted(hitpower);
84 - }
85 - else
86 - {
87 - BigEnemyFly bes = _hit.transform.GetComponent<BigEnemyFly>();
88 - if (bes != null)
89 - {
90 - //bes.getHitted(hitpower);
91 - }
92 - }
76 + if (_hit.transform != firedBy && !_hit.collider.isTrigger)
77 + {
78 +
79 + Quaternion _rotation = Quaternion.FromToRotation(Vector3.up, _hit.normal);
80 + Instantiate(impactEffect, _hit.point, _rotation);
81 +
82 + GameManager.HandleWeaponHit(_hit, hitPower, firedBy, explosionEffect, _rotation);
83 +
93 84 Destroy(gameObject);
94 85 }
95 86 }