Пример #1
0
    void Start()
    {
        GetComponent <Image>().enabled = true;
        gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = "Level " + LevelManager.GetCurrentLevel().ToString();
        gameObject.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = "Ready";
        //gameObject.transform.GetChild(2).GetComponent<TextMeshProUGUI>().text = "...";

        textColor = gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>().color;

        //StartCoroutine(AnimateReadyText());
        EnemySpawnerController.PauseEnemySpawning();
    }
Пример #2
0
    private IEnumerator BeginFreezingDynamicObjects()
    {
        //Pause enemy spawning
        EnemySpawnerController.PauseEnemySpawning();

        //Freeze bullets
        for (int i = 0; i < ammoPool.transform.childCount; i++)
        {
            Vector2 velocity = ammoPool.transform.GetChild(i).GetComponent <Rigidbody2D>().velocity;
            projectileVelocitiesAtFreeze.Add(velocity);

            if (ammoPool.transform.GetChild(i).gameObject.activeSelf)
            {
                ammoPool.transform.GetChild(i).GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
            }
        }

        //Deactivate player controller
        logicController.GetComponent <PlayerController>().enabled  = false;
        logicController.GetComponent <WeaponsController>().enabled = false;
        GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody2D>().velocity = Vector2.zero;
        GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>().enabled     = false;

        //Deactivate enemy AI
        do
        {
            tankVelocitiesAtFreeze.Clear();
            for (int i = 0; i < enemyTankParentObject.transform.childCount; i++)
            {
                enemyTankParentObject.transform.GetChild(i).GetComponent <EnemyAI>().PauseAI();
                enemyTankParentObject.transform.GetChild(i).GetComponent <Animator>().enabled = false;
                enemyTankParentObject.transform.GetChild(i).GetComponent <EnemyAI>().enabled  = false;

                Vector2 velocity = enemyTankParentObject.transform.GetChild(i).GetComponent <Rigidbody2D>().velocity;
                tankVelocitiesAtFreeze.Add(velocity);
                enemyTankParentObject.transform.GetChild(i).GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
            }
            yield return(new WaitForFixedUpdate());
        } while (isFrozen);
    }