public override void overrideUpdate() { tmpBar = this.Charge / 1f; if (tmpBar < 1f) { ChargeBar.transform.localScale = new Vector3((this.Charge / 1f), 1, 1); } if (this.Shooting) { this.Speed = 0f; this.Charge += Time.deltaTime; if (this.Charge >= 1) { this.createLaser(); this.Speed = 0; RaycastHit2D[] hit = Physics2D.RaycastAll(this.transform.position, this.transform.right, 200f); int size = hit.Length; for (int i = 0; i < size; i++) { if (this.tag == "PlayerShip") { if (hit[i].transform.tag == "Enemy") { ShipInterface enem = hit[i].transform.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; enem.TakeDamage(this.Damage); } } else if (this.tag == "Enemy") { if (hit[i].transform.tag == "PlayerShip") { ShipInterface playa = hit[i].transform.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; playa.TakeDamage(this.Damage); } } if (hit[i].transform.name == "boundwall4" || hit[i].transform.name == "boundwall2") { endpoint = (Vector2)hit[i].point; } } if (this.endpoint.x == 0f && this.endpoint.y == -10f) { this.endpoint = (Vector2)this.transform.position + new Vector2(this.transform.right.x * 100, 0); } LR.SetPosition(1, (Vector3)endpoint); } if (this.Charge >= 2) { LR.enabled = false; this.Charge = 0; this.Speed = .1f; this.Shooting = false; this.endpoint = new Vector2(0f, -10f); } } }
public void OnTriggerEnter2D(Collider2D coll) { if (String.Equals(coll.gameObject.tag, this.Foe)) { ShipInterface enem = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; enem.TakeDamage(this.Damage); Destroy(this.gameObject); } else if (coll.gameObject.tag == "endwall") { Destroy(this.gameObject); } }
public void OnTriggerEnter2D(Collider2D coll) { if (String.Equals(coll.gameObject.tag, "PlayerShip")) { ShipInterface player = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; player.TakeDamage(1); } else if (coll.gameObject.tag == "endwall" & passWall == true) { Destroy(this.gameObject); } else if (coll.gameObject.tag == "endwall") { this.passWall = true; } }
public virtual void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "endwall") { Destroy(this.gameObject); } if (coll.tag == "Enemy" && this.tag == "PlayerShip") { ShipInterface si = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; si.TakeDamage(1); } else if (coll.tag == "PlayerShip" && this.tag == "Enemy") { ShipInterface si = coll.gameObject.GetComponent(typeof(ShipInterface)) as ShipInterface; si.TakeDamage(1); } overrideOnTriggerEnter2D(coll); }