public void UpdateWorldObjectStats(WorldObject unitWithStats) { if (unitStatsPair.ContainsKey(unitWithStats)) { hpRect = unitStatsPair [unitWithStats].transform.GetChild(0).GetChild(2) as RectTransform; float hpBarheight = hpRect.sizeDelta.y; float targetHPBarWidth = originalHPBarWidth * unitWithStats.paramManager.HealthPercentage; hpRect.sizeDelta = new Vector2(targetHPBarWidth, hpBarheight); float manaPercentage = 0.0f; if (unitWithStats.transform.GetComponent <Unit> () != null) { if (unitWithStats.transform.GetComponent <Unit> () != null) { manaPercentage = unitWithStats.transform.GetComponentInChildren <Unit> ().paramManager.ManaPercentage; } mpRect = unitStatsPair [unitWithStats].transform.GetChild(1).GetChild(2) as RectTransform; float mpBarHeight = mpRect.sizeDelta.y; float targetMPBarWidth = originalMPBarWidth * manaPercentage; mpRect.sizeDelta = new Vector2(targetMPBarWidth, mpBarHeight); ManaScript manaScript = unitStatsPair [unitWithStats].transform.GetComponentInChildren <ManaScript> (); if (manaScript) { if (manaPercentage == 1.0f) { manaScript.enabled = true; } else { manaScript.enabled = false; } } } } }
void FindObjects(){ playerHpScr = GameObject.Find("testplayer").GetComponent<PlayerHpScript>(); abilitySwitchScr = GameObject.Find("AbilitySwitch").GetComponent<AbilitySwitchScript>(); manaScr = GameObject.Find("Mana Bar").GetComponent<ManaScript>(); enemiesManagerScr = GameObject.Find("enemyManager").GetComponent<EnemiesManagerScript>(); playerManagerScr = GameObject.Find("name").GetComponent<PlayerManager>(); pickupScr = GameObject.Find("name").GetComponent<Pickup>(); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
// Use this for initialization void Start() { m_instance = this; manaBar = GameObject.Find("ManaBar").GetComponent <Image> (); SetMana(maxMana); }
// Use this for initialization void Start() { m_instance = this; manaBar = GameObject.Find ("ManaBar").GetComponent<Image> (); SetMana(maxMana); }
private void Awake() { HP = GameObject.Find("HealthBar").GetComponent <HealthSystem>();//Ищем наш хп бар MP = GameObject.Find("ManaBar").GetComponent <ManaScript>(); }