void OnCollisionEnter2D(Collision2D col) { if (col.gameObject == null) { } else { stopMovement(); ////////Debug.Log ("WEAPON HIT SOMETHING" + col.gameObject.name); if (col.gameObject.tag == "Player") { CameraController.me.hitByBullet(new Vector2(this.transform.position.x, this.transform.position.y)); } PersonHealth ph = col.gameObject.GetComponent <PersonHealth> (); if (ph == null) { } else { ph.dealDamage(damage, false); //stun npc if (ph.healthValue > 0 && this.gameObject.tag == "NPC") { NPCController npc = col.collider.gameObject.GetComponent <NPCController> (); npc.knockOutNPC(); } Inventory i = ph.gameObject.GetComponent <Inventory> (); if (i.leftArm == null) { } else { Item toDrop = i.leftArm; i.unequipItem(toDrop); i.dropItem(toDrop); } if (i.rightArm == null) { } else { Item toDrop = i.rightArm; i.unequipItem(toDrop); i.dropItem(toDrop); } } //Destroy (this.gameObject); } }
void OnTrigger2DEnter(Collider2D other) { PersonHealth ph = other.gameObject.transform.parent.GetComponent <PersonHealth> (); if (ph == null) { } else { ph.dealDamage(2500, true); } }
void control() { damageTimer -= Time.deltaTime; lifetime -= Time.deltaTime; if (damageTimer <= 0) { ph.dealDamage(50, false); damageTimer = damageReset; } if (lifetime <= 0) { Destroy(this.gameObject); } }