Beispiel #1
0
    private void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape) && !pauseMenu.activeInHierarchy &&
            !startGameBtn.gameObject.activeInHierarchy)
        {
            EnemyActivation(false);
            FreezeBullets(true);
            Cursor.visible = true;
            spaceShipController.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
            container.inPlayMode = false;
            pauseMenu.SetActive(true);
            return;
        }

        if (Input.GetKeyUp(KeyCode.Escape) && pauseMenu.activeInHierarchy &&
            !startGameBtn.gameObject.activeInHierarchy)
        {
            ResumeGame();
            return;
        }

        scoreText.text = string.Format("Score: {0:0}", container.score);

        if (container.paused)
        {
            spaceShipController.SetVelocity(new Vector3(0, 0, 0));
        }
    }
Beispiel #2
0
    IEnumerator SpinOutOfControl()
    {
        var timer = 0f;

        if (container.wingTag == "Right Wing")
        {
            InstantiateExplosion();
            Destroy(GameObject.FindWithTag("Right Wing"));
            spaceShipController.GetComponent <Rigidbody>().velocity = Vector3.forward * 50;

            while (timer < 2f)
            {
                print("spin to right" + container.wingTag);
                spaceShipController.transform.rotation =
                    Quaternion.Euler(0, 0, spaceShipController.transform.eulerAngles.z + 10);
                yield return(null);

                timer += Time.deltaTime;
            }

            FindObjectOfType <CameraFollow>().enabled = false;
        }

        if (container.wingTag == "Left Wing")
        {
            InstantiateExplosion();
            Destroy(GameObject.FindWithTag("Left Wing"));
            spaceShipController.GetComponent <Rigidbody>().velocity = Vector3.forward * 50;
            while (timer < 2f)
            {
                print("spin to right");
                spaceShipController.transform.rotation =
                    Quaternion.Euler(0, 0, spaceShipController.transform.eulerAngles.z + 10);
                yield return(null);

                timer += Time.deltaTime;
            }
        }
    }