public void OnShoot(Transform shot) { teleBallRef = shot; teleBallRefAnim = teleBallRef.GetComponent <ChildAnimationController>(); var collideAlert = teleBallRef.GetComponent <CollideAlert>(); if (collideAlert != null) { collideAlert.OnCollideEnter.AddListener(TeleBallCollidedWithSomething); collideAlert.OnCollideExit.AddListener(TeleBallStoppedCollidingWithSomething); collideAlert.OnCollideStay.AddListener(TeleBallStillCollidingWithSomething); } }
void Update() { if (shooter.canShoot) { _haloEvent.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); } switch (phase) { case AIM_PHASE: if (startAiming && Input.GetMouseButton(0)) { // TODO: initiate aim prediction shooter.Shoot(TeleBallPredictorPrefab); GetComponentInChildren <Animator>().Play("Aim"); } else if (Input.GetMouseButtonDown(0)) { startAiming = true; } else if (Input.GetMouseButtonUp(0) && startAiming) { startAiming = false; // TODO: shoot at mouse _haloEvent = FMODUnity.RuntimeManager.CreateInstance(_haloSoundPath); _haloEvent.start(); foreach (var predictor in GameObject.FindGameObjectsWithTag("TelePredictor")) { Destroy(predictor.gameObject); } shooter.Shoot(TeleBallPrefab, true); GetComponentInChildren <Animator>().Play("Throw"); phase = TELE_PHASE; shooter.canShoot = false; teleporter.canTeleport = true; } break; case TELE_PHASE: if (teleBallRef == null || !teleBallRef.gameObject.activeSelf) { phase = AIM_PHASE; teleBallRef = null; teleBallRefAnim = null; shooter.canShoot = true; teleBallPositionIsValid = false; } else if (Input.GetMouseButton(0)) { // TODO: allow physics to proceed? if (teleBallRef) { teleBallRefAnim.SetOn(false); _haloEvent.setParameterValue("Active", 0); } } else { if (teleBallRef) { teleBallRefAnim.SetOn(true); _haloEvent.setParameterValue("Active", 1); } if (teleBallPositionIsValid) { // TODO: teleport once position on teleBall is valid TeleportToBall(); } } break; } }