//Deactivate's target void DeactivateTarget() { if (_lastTarget.tag == "Mirror") { Mirror mirror = _lastTarget.gameObject.GetComponent <Mirror>(); mirror.Activate(false); } else if (_lastTarget.tag == "LaserIn") { LaserIn input = _lastTarget.gameObject.GetComponent <LaserIn>(); input.Activate(false); } else if (_lastTarget.tag == "Portal") { Portal portal = _lastTarget.gameObject.GetComponent <Portal>(); portal.Activate(false); } }
//Activate target void ActivateTarget(RaycastHit2D laserHit) { if (laserHit.collider != null)//check if raycast hits a target { //if laser isnt from a monster if (this.gameObject.tag != "Monster") { if (laserHit.collider.tag == "Mirror")//if target is a mirror, activate it { Mirror mirror = _lastTarget.gameObject.GetComponent <Mirror>(); mirror.Activate(true); mirror.LaserHit(_initPos, laserHit.point); } else if (laserHit.collider.tag == "LaserIn")//if target is a LaserIn, activate it { LaserIn input = _lastTarget.gameObject.GetComponent <LaserIn>(); input.Activate(true); } else if (_lastTarget.tag == "Portal") { Portal portal = _lastTarget.gameObject.GetComponent <Portal>(); portal.Activate(true); portal.LaserHit(_initPos, laserHit.point); } else if (laserHit.collider.tag == "Monster")//if target is a Monster, kill it { Monster monster = _lastTarget.gameObject.GetComponent <Monster>(); monster.Kill(); } } //If laser is from monster else { if (laserHit.collider.tag == "Player")//if target is a Player, kill it { Player player = _lastTarget.gameObject.GetComponent <Player>(); player.Kill(); } } } }