public void Init() { baseObject = GetComponentInChildren <ABaseObject>(); if (!baseObject) { GetComponent <ABaseObject>(); } healthBarValue = baseObject.MaxHealth; overlay = GetComponentInChildren <UIObjectOverlay>(); if (overlay) { print(gameObject.name + " has an overlay!"); } oldHealth = baseObject.Health; if (baseObject.GetComponentInChildren <AEnemy>()) { currentType = ObjType.Enemy; } else if (baseObject.GetComponentInChildren <ATurret>()) { currentType = ObjType.Turret; } else if (baseObject.GetComponent <MainPlayer>()) { currentType = ObjType.Loco; } //print("I am " + _baseObject.name + " and my type is " + _currentType); HideOverlay(); timer = new Timer(); }
public void CountAmmo() { if (baseObject && currentType == ObjType.Turret) { ammoPrefabBarValue = baseObject.GetComponentInChildren <AWeapon>().CurrentAmmoInClip / baseObject.GetComponentInChildren <AWeapon>().ClipSize; overlay.CurrentAmmo = ammoPrefabBarValue; } }