// Update is called once per frame private void OnCollisionEnter(Collision other) { gameManager = GameObject.FindObjectOfType <GameManager>(); gameManager.shurikensHit += 1; if (Enable == true) { if (other.gameObject.tag == targetTag) { Debug.Log("TargetName Detected"); #region Default_Shuriken // If Score GameObject is Present if (GameObject.FindObjectOfType <Score>() != null) { score = GameObject.FindObjectOfType <Score>(); // Score + 1 score.Base_Score += 1; } // ComboSystem + 1 if (GameObject.FindObjectOfType <ComboSystem>() != null) { GameObject.FindObjectOfType <ComboSystem>().hitDetect(); } // Reset the Cooldown Upon hitting an Object, Detects if Either the TouchGameplay or the EditorGameplay is active. if (GameObject.FindObjectOfType <TouchGameplay>() != null && GameObject.FindObjectOfType <TouchGameplay>().enabled == true && Application.platform == RuntimePlatform.Android) { touchGameplay = GameObject.FindObjectOfType <TouchGameplay>(); touchGameplay.CurrentCooldown = 0; } else if (GameObject.FindObjectOfType <EditorGameplay>() != null && GameObject.FindObjectOfType <EditorGameplay>().enabled == true && Application.platform == RuntimePlatform.WindowsEditor) { editorGameplay = GameObject.FindObjectOfType <EditorGameplay>(); editorGameplay.CurrentCooldown = 0; } #endregion ShurikenPhysicsOnWood(other); } } }
private void PowerUpFunctions() { // Sync the PU1 Gauge with the amount PowerUpOneGauge.fillAmount = PowerUpOneMeter / PowerUpOneMeterMax; if (Application.platform == RuntimePlatform.Android) { touchGameplay = GameObject.FindObjectOfType <TouchGameplay>(); if (PowerUpOneMeter >= PowerUpOneMeterMax && touchGameplay.CurrentCooldown <= 0 && touchGameplay.enabled == true) { // Make the button interactable PowerUpOneGauge.gameObject.GetComponent <Button>().interactable = true; // The amount is locked to it's equivalent amount PowerUpOneMeter = PowerUpOneMeterMax; PowerUpRefill = false; } } if (Application.platform == RuntimePlatform.WindowsEditor) { editorGameplay = GameObject.FindObjectOfType <EditorGameplay>(); if (PowerUpOneMeter >= PowerUpOneMeterMax && editorGameplay.CurrentCooldown <= 0 && editorGameplay.enabled == true) { // Make the button interactable PowerUpOneGauge.gameObject.GetComponent <Button>().interactable = true; // The amount is locked to it's equivalent amount PowerUpOneMeter = PowerUpOneMeterMax; PowerUpRefill = false; } } // PowerUpActive is Set to True if (PowerUpRefill == true) { // Refill the Gauge over time PowerUpOneMeter += Time.deltaTime; } }
// Update is called once per frame void Update() { // ------------------------- // REFERENCE CALL // ------------------------- touchGameplay = GameObject.FindObjectOfType <TouchGameplay>(); editorGameplay = GameObject.FindObjectOfType <EditorGameplay>(); gameplayFunctions = GameObject.FindObjectOfType <GameplayFunctions>(); #region User Input if (activate == true) { Debug.Log("PowerUp Activated"); if (Application.platform == RuntimePlatform.WindowsEditor) { cursorPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); //--------------------- // LMB - PRESSED //--------------------- if (Input.GetKeyDown(KeyCode.Mouse0)) { InputTapped(cursorPosition); } //--------------------- // LMB - HELD //--------------------- if (Input.GetKey(KeyCode.Mouse0)) { InputHeld(cursorPosition); } //--------------------- // LMB - LIFTED //--------------------- if (Input.GetKeyUp(KeyCode.Mouse0)) { InputReleased(touchPosition); } } else if (Application.platform == RuntimePlatform.Android) { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); touchPosition = Camera.main.ScreenToWorldPoint(touch.position); //--------------------- // FIRST FINGER - TAPPED //--------------------- if (touch.phase == TouchPhase.Began) { InputTapped(touchPosition); } //--------------------- // FIRST FINGER - HELD //--------------------- if (touch.phase == TouchPhase.Moved) { InputHeld(touchPosition); } //--------------------- // FIRST FINGER - RELEASED //--------------------- if (touch.phase == TouchPhase.Ended) { InputReleased(touchPosition); } } } #endregion // If RELEASE is set to TRUE, the REGISTERED GAMEOBJECT starts hitting multiple targets. if (release == true) { // SHURIKEN SPRITE BACK AT FULL ALPHA if (editorGameplay != null && editorGameplay.enabled == true && Application.platform == RuntimePlatform.WindowsEditor) { editorGameplay.shurikenAlphaIndicator(editorGameplay.starAlphaNormal); } else if (touchGameplay != null && touchGameplay.enabled == true && Application.platform == RuntimePlatform.Android) { touchGameplay.shurikenAlphaIndicator(touchGameplay.starAlphaNormal); } // IF THERE ARE ENEMY OBJECTS IN THE LIST THAT ARE REFERENCED AND ASSIGNED IN ANY AMOUNT if (EnemiesTagged.Count > 0) { // REG GAMEOBJECT MOVES TOWARD THE SHURIKEN RegisteredShurikenGameObject.transform.position = Vector3.MoveTowards ( RegisteredShurikenGameObject.transform.position, EnemiesTagged[0].transform.position, objectSpeed * Time.deltaTime ); // CALCULATE THE CURRENT DISTANCE BETWEEN THE REG'D GAMEOBJECT AND THE TAGGED ENEMY GAMEOBJECT destroyDistance = Vector3.Distance(RegisteredShurikenGameObject.transform.position, EnemiesTagged[0].transform.position); // MAKE ALL PRESENT CROSS MARKERS FOLLOW THEIR ASSIGNED ENEMIES for (int i = 0; i < activeCrossMarkers.Count; i++) { activeCrossMarkers[i].transform.position = EnemiesTagged[i].transform.position + new Vector3(0, 0, CrossMarkerDistance); } // IF THE REGISTERED GAMEOBJECT IS NEAR THE ENEMY TAGGED OBJECTS if (destroyDistance <= destroyThreshold) { // Add Score to the player Scored(); // Play One Shot of the Sound if (WoodhitSound != null) { this.GetComponent <AudioSource>().PlayOneShot(WoodhitSound); } // REMOVE THE TARGET GAMEOBJECT ON LIST INDEX -> 0 Destroy(EnemiesTagged[0].gameObject); EnemiesTagged.Remove(EnemiesTagged[0]); // REMOVE THE CROSS PREFAB ON LIST INDEX -> 0 Destroy(activeCrossMarkers[0].gameObject); activeCrossMarkers.Remove(activeCrossMarkers[0]); } } // IF THERE ARE NO ENEMIES ASSIGNED AND REFERENCE WITH NO AMOUNT IN THE LIST else if (EnemiesTagged.Count <= 0) { // Enable Cooldown from the PowerUpActivator Class EnableCooldown(); // If EditorGameplay is Present if (editorGameplay != null) { // Enable its throw effect editorGameplay.EnabledThrowEffect = true; } // If EditorGameplay is Present if (touchGameplay != null) { // Enable its throw effect touchGameplay.EnabledThrowEffect = true; } // Destroy the Registered Shuriken GameObject Destroy(RegisteredShurikenGameObject); timeFreeze(5, true); DisablePowerUp(); } } } PowerUpFunctions(); }