public static void UnfreezeDynamicObjects() { singletonInstance.isFrozen = false; //Resume enemy spawning EnemySpawnerController.ResumeEnemySpawning(); //Unfreeze bullets for (int i = 0; i < singletonInstance.ammoPool.transform.childCount; i++) { if (singletonInstance.ammoPool.transform.GetChild(i).gameObject.activeSelf) { singletonInstance.ammoPool.transform.GetChild(i).GetComponent <Rigidbody2D>().velocity = singletonInstance.projectileVelocitiesAtFreeze[i]; } } singletonInstance.projectileVelocitiesAtFreeze.Clear(); //Reactivate player controller singletonInstance.logicController.GetComponent <PlayerController>().enabled = true; singletonInstance.logicController.GetComponent <WeaponsController>().enabled = true; GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>().enabled = true; //Reactivate enemy AI for (int i = 0; i < singletonInstance.enemyTankParentObject.transform.childCount; i++) { singletonInstance.enemyTankParentObject.transform.GetChild(i).GetComponent <EnemyAI>().enabled = true; singletonInstance.enemyTankParentObject.transform.GetChild(i).GetComponent <Animator>().enabled = true; singletonInstance.enemyTankParentObject.transform.GetChild(i).GetComponent <Rigidbody2D>().velocity = singletonInstance.tankVelocitiesAtFreeze[i]; singletonInstance.enemyTankParentObject.transform.GetChild(i).GetComponent <EnemyAI>().ResumeAI(); } }
private void Update() { if (Input.anyKeyDown) { fadingOut = true; isReady = true; LevelManager.SetPlayerReadyStatus(isReady); EnemySpawnerController.ResumeEnemySpawning(); } if (fadingOut) { float alphaScreen = gameObject.GetComponent <Image>().color.a; float alphaText = gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>().color.a; Color fadeOutScreenColor = new Color(0, 0, 0, alphaScreen - Time.deltaTime * alphaDeltaFadeOut); textColor.a = alphaText - Time.deltaTime * alphaDeltaFadeOut; gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>().color = textColor; gameObject.transform.GetChild(1).GetComponent <TextMeshProUGUI>().color = textColor; gameObject.transform.GetChild(2).GetComponent <TextMeshProUGUI>().color = textColor; gameObject.GetComponent <Image>().color = fadeOutScreenColor; if (fadeOutScreenColor.a <= 0) { Destroy(gameObject); } } if (continueBlinking) { float alpha = gameObject.transform.GetChild(1).GetComponent <TextMeshProUGUI>().color.a; Color blinkingColor = textColor; if (blinkFadingIn) { blinkingColor.a = alpha + Time.deltaTime * alphaDeltaBlinking; } else { blinkingColor.a = alpha - Time.deltaTime * alphaDeltaBlinking; } gameObject.transform.GetChild(1).GetComponent <TextMeshProUGUI>().color = blinkingColor; gameObject.transform.GetChild(2).GetComponent <TextMeshProUGUI>().color = blinkingColor; if (blinkingColor.a >= 1) { blinkFadingIn = false; } else if (blinkingColor.a <= 0) { blinkFadingIn = true; } } }