コード例 #1
0
    //SpriteRenderer heart1;


    void processRabbitDeath(HeroRabbit rabbit)
    {
        //Debug.Log("Inside processRabbitDeath");
        if (SceneManager.GetActiveScene().name == "LevelSelection")
        {
            return;
        }
        switch (rabbit.getLives())
        {
        case 0:
            SceneSwitcher.goToLevelSelection();
            break;

        case 1:
        {
            var go = healthBar.transform.Find("heart-2");
            var sr = go.GetComponent <SpriteRenderer>();
            //Debug.Log(sr);
            sr.sprite = lifeUsed;
            break;
        }

        case 2:
        {
            var go = healthBar.transform.Find("heart-3");
            var sr = go.GetComponent <SpriteRenderer>();
            sr.sprite = lifeUsed;
            break;
        }

        default:
            Debug.Log("processRabbitDeath() was somewhy called");
            break;
        }
    }
コード例 #2
0
 public void Respawn(HeroRabbit rabbit)
 {
     rabbit.transform.position = this.startingPosition;
     rabbit.setLives(rabbit.getLives() - 1);
     this.processRabbitDeath(rabbit);
 }