void check_if_sinking() { if (health <= 0) { FloatScript floatScript = GetComponent <FloatScript>(); floatScript.enabled = false; if (gameObject.tag == "aiship") { NavMeshAgent agent = GetComponent <NavMeshAgent>(); agent.enabled = false; } if (transform.position.y < -40.0f) { Destroy(gameObject); } } }
public void incrementPlayerScore(int playerNum, int scoreToAdd, Transform textPos) { if (!gameOver) { if (playerNum == 1) { p1Score += scoreToAdd; p1Text.text = p1Score.ToString(); p1Text.rectTransform.localScale = baseScale; p1Text.gameObject.transform.DOPunchScale(Vector3.one * punchScale, punchDuration); tmp = Instantiate(spawnTextObject, textPos.position, Quaternion.identity); if (tmp.GetComponent <FloatScript>() != null) { FloatScript pointsText = tmp.GetComponent <FloatScript> (); //alter values for the heads up pointsText.points = scoreToAdd; //pointsText.textObj.color = p1TextColor; } if (p1Score >= goalPoints) { winString = "PLAYER 1 WINS!"; goalText.text = winString; gameOver = true; //startText.enabled = true; startText.fontSize = startSize; //pseudo enable for (int i = 0; i < inscriptions.Length; ++i) { inscriptions[i].enabled = false; } //slowmo? Time.timeScale = .5f; startText.text = endString; startText.fontSize = endSize; p1Won = true; } } else if (playerNum == 2) { p2Score += scoreToAdd; p2Text.text = p2Score.ToString(); p1Text.rectTransform.localScale = baseScale; p1Text.gameObject.transform.DOPunchScale(Vector3.one * punchScale, punchDuration); tmp = Instantiate(spawnTextObject, textPos.position, Quaternion.identity); if (tmp.GetComponent <FloatScript>() != null) { FloatScript pointsText = tmp.GetComponent <FloatScript> (); //alter values for the heads up pointsText.points = scoreToAdd; //pointsText.textObj.color = p2TextColor; } if (p2Score >= goalPoints) { winString = "PLAYER 2 WINS!"; goalText.text = winString; gameOver = true; //startText.enabled = true; startText.fontSize = startSize; //pseudo enable for (int i = 0; i < inscriptions.Length; ++i) { inscriptions[i].enabled = false; } Time.timeScale = .5f; startText.text = endString; startText.fontSize = endSize; p1Won = false; } } } }