Advertisement
Guest User

Untitled

a guest
May 30th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. //this is the script the player sends the damage to, and the text only shows ontop of eachother, or actually it keeps repeating on the same line
  2.  
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System.Collections;
  6.  
  7. public class DamageLogBox : MonoBehaviour {
  8.  
  9.     public static DamageLogBox Instance;
  10.  
  11.     private PlayerMovement player;
  12.     private EnemyController eC;
  13.     public Text textHolder;
  14.  
  15.     public string logText;
  16.  
  17.     void Start()
  18.     {
  19.         eC = FindObjectOfType<EnemyController>();
  20.         player = FindObjectOfType<PlayerMovement>();
  21.         Instance = this;
  22.         textHolder = GetComponentInChildren<Text>();
  23.     }
  24.  
  25.     void Update()
  26.     {
  27.         if(logText.Contains(player.name))
  28.         {
  29.             textHolder.color = Color.green;
  30.  
  31.         }
  32.         else if(logText.Contains(eC.name))
  33.         {
  34.             textHolder.color = Color.red;
  35.         }
  36.         textHolder.text = logText;
  37.     }
  38. }
  39.  
  40. //this is hte code in the player script
  41. DamageLogBox.Instance.logText = this.name + " did " + PlayerStats.Instance.damage.ToString() + " damage to " + hit.collider.gameObject.name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement