Пример #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         /*PlayerControllerAnimation.playerCurrentHealth += 20;
          * if (PlayerControllerAnimation.playerCurrentHealth > 100) {
          *  PlayerControllerAnimation.playerCurrentHealth = 100;
          * }*/
         PlayerControllerAnimation sc = other.gameObject.GetComponent <PlayerControllerAnimation>();
         sc.playerCurrentHealth += 20;
         if (sc.playerCurrentHealth > 100)
         {
             sc.playerCurrentHealth = 100;
         }
         Destroy(gameObject);
     }
 }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if(player == null){
         player = GameObject.Find("PlagueDoctor(Clone)");
         if(player != null)
             sc = player.gameObject.GetComponent<PlayerControllerAnimation>();
     }else{
         //this.gameObject.transform.localScale.x = (sc.playerCurrentHealth/sc.playerMaxHealth)*barScale;*
         if (sc.playerCurrentHealth != 0)
         {
             this.gameObject.transform.parent.gameObject.transform.localScale = new Vector3(((float)sc.playerCurrentHealth / sc.playerMaxHealth) * barScale, 1, 1);
         }
         else {
             this.gameObject.transform.parent.gameObject.transform.localScale = new Vector3(0 * barScale, 1, 1);
         }
     }
 }