public IEnumerator YourturnMenu(int turn) { try { Debug.Log($"TurnDisplay : Debug - Start Setting {turnCounter.turnMenu}"); //Check Blue or Red team Turn, change text //0 is Red turn , 1 is Blue turn. //Go Next for later if (turn == 0) { try { if (redCD != skillSystem.redCD) { if (skillSystem.tempRedCD != skillSystem.redCD || skillSystem.tempRedCD == 0) { redCD = skillSystem.redCD; if (redCD > 0) { int temp = redCD - 1; skillSystem.CmdSetTempCD(false, temp); skillSystem.CmdSetCD(false, temp); } if (skillSystem.tempBlueCD > 0) { int temp = skillSystem.tempBlueCD - 1; skillSystem.CmdSetTempCD(true, temp); } } } } catch (Exception ex) { //Debug } Youturn.GetComponent <Text>().color = Color.red; Youturn.text = "Red Team is now your Turn"; Youturn.gameObject.SetActive(true); panel.gameObject.SetActive(true); } else if (turn == 1) { try { if (blueCD != skillSystem.blueCD) { if (skillSystem.tempBlueCD != skillSystem.blueCD || skillSystem.tempBlueCD == 0) { blueCD = skillSystem.blueCD; if (blueCD > 0) { int temp = blueCD - 1; skillSystem.CmdSetTempCD(true, temp); skillSystem.CmdSetCD(true, temp); } if (skillSystem.tempRedCD > 0) { int temp = skillSystem.tempRedCD - 1; skillSystem.CmdSetTempCD(false, temp); } } } } catch (Exception ex) { //Debug } Youturn.GetComponent <Text>().color = Color.blue; Youturn.text = "Blue Team is now your Turn"; Youturn.gameObject.SetActive(true); panel.gameObject.SetActive(true); } turnCounter.TurnDisplay(true); Debug.Log($"TurnDisplay : Debug - SetTurn {turnCounter.turnMenu}"); } catch { } yield return(new WaitForSeconds(1.5f)); try { turnCounter.TurnDisplay(false); Debug.Log($"TurnDisplay : Debug - SetTurn {turnCounter.turnMenu}"); } catch (Exception e) { //Avoid crash } turnCounter.DragShot(false); }
private void DragAndShoot() { //Do drag and release shoot #region drag and shoot script try { /*If released mouse button and startpos not equal 0,0 which is same as the reset values * ( Prevent Mouse hold while player is still moving , * player movement direction will affected by holding mouse button when no control allows and release when got control back) * It will prevent player to shot to the unexpected direction. */ if (Input.GetMouseButtonDown(0)) { Debug.Log("Left click down detected"); //Set start position /* * Check if it is click on an object. * Require to click to an object to drag and release. */ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "Player" || hit.transform.tag == "Enemy") { startPos = Input.mousePosition; Debug.LogWarning("Start Mouse Position = " + startPos); } else { return; } } } if (Input.GetMouseButtonUp(0)) { if (startPos == Vector2.zero) { return; } else { Debug.Log("Left clicked up , and startpos has got"); endPos = Input.mousePosition; Debug.LogWarning("End Mouse Position = " + endPos); ForcePos = startPos - endPos; } /*Add Force * It follow the world direction * This game only use X and Z direction * Y direction is jump in 3D , jump is not implement in this game. * -Camera Angle- * +X for upward , -X for downward , +Z for Left and -Z for Right Direction. */ if ((turnCounter.currentTurn == 1 && gameObject.GetComponent <MeshRenderer>().material.color != Color.white || turnCounter.currentTurn == 0 && gameObject.GetComponent <MeshRenderer>().material.color != Color.yellow) || ForcePos == Vector2.zero) { startPos = Vector2.zero; endPos = Vector2.zero; ForcePos = Vector2.zero; return; } else { Debug.Log("Trying to Add force"); Rigidbody newSelectedSpeed = colorSystem.newSelect.GetComponent <Rigidbody>(); Rigidbody movingObjectSpeed = colorSystem.movingObject.GetComponent <Rigidbody>(); Rigidbody ballSpeed = speedControl.rb; if (newSelectedSpeed.velocity == Vector3.zero && movingObjectSpeed.velocity == Vector3.zero && ballSpeed.velocity == Vector3.zero) { //change.newSelect.GetComponent<PhysicsUpdate>().ApplyForce(new Vector3(ForcePos.y * ReleasePower * Time.deltaTime, 0, ForcePos.x * -1 * ReleasePower * Time.deltaTime), ForceMode.Force); ApplyForce(colorSystem.newSelect, new Vector3(ForcePos.y * ReleasePower * Time.deltaTime, 0, ForcePos.x * -1 * ReleasePower * Time.deltaTime), ForceMode.Force); turnCounter.DragShot(true); if (turnCounter.currentTurn == 1) { colorSystem.newSelect.GetComponent <MeshRenderer>().material.color = Color.blue; //For Next team round SyncTurn(0); } else if (turnCounter.currentTurn == 0) { colorSystem.newSelect.GetComponent <MeshRenderer>().material.color = Color.red; //For Next team round SyncTurn(1); } colorSystem.newSelect = null; colorSystem.oldSelect = null; controllPoint.line.gameObject.SetActive(false); } //Reset Values Debug.Log("Resetting values"); startPos = Vector2.zero; endPos = Vector2.zero; ForcePos = Vector2.zero; } } } catch (UnassignedReferenceException app) { Debug.LogWarning("Waiting for newSelected Obecj assign! But it is fine if none selected"); } #endregion }