// Update is called once per frame void Update() { if (timingFire > 0) { timingFire -= Time.deltaTime; } // avoid fire if Mario is aout of range or is inside safe zone if (rangeFiredetector.getTarget() == null || piranhaSafeZone.isInside()) { piranhaAnim.enabled = true; } // get current piranha fire if (piranhaLookAnim.getCurrentPiranhaFire() == null) { return; } // check if this doesn't match the active piranha fire PiranhaFire current = piranhaLookAnim.getCurrentPiranhaFire().GetComponent <PiranhaFire>(); if (current.quad != quad) { return; } // only fires when target is in radio of fire, piranha is idle and totally out of tube, and target isn't in dead zone if ((rangeFiredetector.getTarget() != null) && piranhaAnim.isOut() && !piranhaSafeZone.isInside()) { // disable piranha anim so it stays out of the tube for firing piranhaAnim.enabled = false; // controls the rate of fire if (timingFire <= 0f) { fire(current); timingFire = rateOfFire; } } }
// Update is called once per frame void Update() { target = detector.getTarget(); // only look to target if it exists if (target != null) { EnumQuadrant quad = GetTargetQuadrant(target.position, transform.position); currentPiranhaFire = ActivatePiranhaImage(quad, piranhas); } else { currentPiranhaFire = null; } }