コード例 #1
0
ファイル: Core.cs プロジェクト: rezistal/qmobi_test
    void Update()
    {
        //If there is no other ufo and ufo spawn allowed
        if (ufo == null && !denyUfoSpawn)
        {
            ufoSpawnTimer += Time.deltaTime;
            //Every 10 seconds
            if (ufoSpawnTimer > 10f)
            {
                //Appears a chance to create Ufo
                //float createChance = UnityEngine.Random.Range(0.0f, 1.0f);
                if (UnityEngine.Random.value + incChance >= 0.99999)
                {
                    //Nullify timer and chance increaser
                    ufoSpawnTimer = 0;
                    incChance     = 0;

                    SpawnUfo();
                }
                //If ufo didnt created - we increase a chance every frame
                incChance += 0.00001f;
            }
        }

        //Check is there more asteroids on a scene
        CheckAsteroids();

        //Detecting user input after gameover
        if (playerInputText != null && playerInputText.activeSelf == true)
        {
            string playerName = playerInputText.GetComponent <Text>().text;
            if (playerName.Length == 3 && Input.GetKeyDown(KeyCode.Return))
            {
                scoreboardManager.AddResult(playerName, scoreManager.GetScoreValue());
                SceneManager.LoadScene("Menu");
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene("Menu");
        }
    }