IEnumerator OnTriggerEnter2D(Collider2D other)
    {
        score = GameObject.Find("Score").GetComponent<ScoreController>();

        if (other.tag == "Rock")
        {

            yield return new WaitForSeconds(hellaWait);
            if(tag == "Player")
            {
                objectPos = transform.FindChild("turtle_shell").transform.position;
                score.Add();
            }
            else
            {
                objectPos = transform.position;
                score.Subtract();
            }
            objectScale = transform.localScale;

            Destroy (gameObject);

            Quaternion randomRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));

            // Instantiate the explosion where the rock is with the random rotation. also scale according to turtle scale
            explosion.transform.localScale = new Vector3(objectScale.x*expSizeFactor, objectScale.y*expSizeFactor, 1f);
            Instantiate(explosion, objectPos, randomRotation);

        }
    }
Beispiel #2
0
        private void AskUsername()
        {
            string username = "";

            while (username.Length > 15 || username.Length == 0)
            {
                Console.CursorTop--;
                DisplayCentered(CURSOR + " Enter your name to save the score (max 15 char.): ", false);
                username = Console.ReadLine();
            }
            _score.PlayerName = username;

            _scoreController.Add(_score);
            ScoreController.Save(_scoreController);
        }