예제 #1
0
                // TODO: Insta reload ?
                // TODO: A class Die ?
                private IEnumerator Die()
                {
                    Destroy(GetComponent <Rigidbody2D>());
                    Destroy(GetComponent <Controller>());
                    Destroy(GetComponent <Jump>());

                    foreach (Collider2D col in GetComponents <Collider2D>())
                    {
                        Destroy(col);
                    }

                    Destroy(GetComponent <Collider2D>());

                    GameObject deathGO = GameObject.Find("death");

                    deathGO.transform.GetChild(0).gameObject.SetActive(true);

                    Image deathImg = deathGO.GetComponent <Image>();
                    Text  deathTxt = deathGO.GetComponentInChildren <Text>();

                    deathTxt.text = Lang.GetString("player.death");

                    // A fade-in black screen

                    int remainingTime = 255;

                    while (remainingTime > 0)
                    {
                        deathImg.color = new Color(0, 0, 0, deathImg.color.a + 2 / 255F);
                        remainingTime -= 2;

                        if (remainingTime % 3 == 0)
                        {
                            deathTxt.fontSize++;
                        }

                        yield return(new WaitForSeconds(0.02F));
                    }

                    // Black screen for 2 secs for reloading the game

                    yield return(new WaitForSeconds(2F));

                    // TODO: Insta reload ?
                    MasterClass.InitializeTheGame();
                    UnityEngine.SceneManagement.SceneManager.LoadScene(0);
                    MasterClass.InitializeAwakes();
                }