Esempio n. 1
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         FIO.FadeToBlack();
         Invoke("LoadUI", t);
     }
 }
    public void ChangeHealth(float change)
    {
        float curHealth = health;

        curHealth += change;

        if (curHealth <= maxHealth)
        {
            health += change;
            UpdateHealthBar();

            if (isAlive == true && health <= 0)
            {
                print(gameObject.name + " Has been Killed!");
                lives -= 1;


                isAlive = false;
                ResetHealth();
                //add experience to another player when it gets killed by another player
                if (gameObject.tag == "Player")
                {
                    metrics.setDeaths(gameObject.GetComponent <PlayerController>().myPlayerID, 1);

                    if (gameObject.GetComponent <PlayerController>().myPaintState == ColorState.Blue)
                    {
                        redPlayer.GetComponent <ExpController>().AddExp(200);
                        metrics.setKills(1, 1);
                    }
                    else if (gameObject.GetComponent <PlayerController>().myPaintState == ColorState.Red)
                    {
                        bluePlayer.GetComponent <ExpController>().AddExp(200);
                        metrics.setKills(0, 1);
                    }

                    transform.GetChild(1).gameObject.SetActive(false);
                    print("TURNED OFF" + transform.GetChild(2).gameObject.name);
                    gameObject.GetComponent <PlayerController>().enabled = false;
                    gameObject.GetComponent <CapsuleCollider>().enabled  = false;
                    if (GetComponentInChildren <GiantProjController>())
                    {
                        Destroy(GetComponentInChildren <GiantProjController>().gameObject);
                        print("destroy giangt proojjjjjsdjsjd");
                    }
                    healthBar.SetActive(false);
                    amoBar.SetActive(false);

                    if (fadeInOut != null)
                    {
                        fadeInOut.FadeToBlack(true);
                        print("Start fading to black");
                    }
                }
                else
                {
                    gameObject.SetActive(false);
                }
            }
        }
        else if (curHealth > maxHealth)
        {
            health = maxHealth;
            UpdateHealthBar();
        }
        else if (curHealth < 0)
        {
            curHealth = 0;
            UpdateHealthBar();
        }
    }
Esempio n. 3
0
 public void ChangeScene(string nextLevel)
 {
     currentSceneIndex = sceneList.IndexOf(nextLevel);
     fade.FadeToBlack();
 }