示例#1
0
        IEnumerator _UnitOverlay(Unit unit)
        {
            if (overlayedUnitList.Contains(unit))
            {
                yield break;
            }

            overlayedUnitList.Add(unit);

            UnitOverlay overlay = GetUnusedOverlay();

            overlay.rootObj.SetActive(true);

            while (unit != null && !unit.dead && unit.thisObj.activeInHierarchy)
            {
                overlay.barHP.value = unit.HP / unit.fullHP;
                Vector3 screenPos = mainCam.WorldToScreenPoint(unit.thisT.position + new Vector3(0, 0, 0));
                overlay.rootT.localPosition = (screenPos + new Vector3(0, 20, 0)) / UI.GetScaleFactor();

                yield return(null);
            }

            overlay.rootObj.SetActive(false);
            overlayedUnitList.Remove(unit);
        }
示例#2
0
        IEnumerator _ElectricityValueOverlay(Unit unit)
        {
            if (overlayedUnitList.Contains(unit))
            {
                yield break;
            }

            overlayedUnitList.Add(unit);

            UnitOverlay overlay = GetUnusedOverlay();

            overlay.rootObj.SetActive(true);

            // if (unit.defaultShield > 0) overlay.barShield.gameObject.SetActive(true);
            // disable shield
            overlay.barShield.gameObject.SetActive(false);

            while (unit != null)
            {
                overlay.barHP.value = unit.electricityCurrentlyStored / unit.GetMaxElectricity();
                // if (unit.defaultShield > 0) overlay.barShield.value = unit.shield / unit.fullShield;

                Vector3 screenPos = mainCam.WorldToScreenPoint(unit.thisT.position + new Vector3(0, 0, 0));
                overlay.rootT.localPosition = screenPos + new Vector3(0, 20, 0);

                // if (overlay.barHP.value == 1 && overlay.barShield.value == 1) break;

                yield return(null);
            }

            overlay.rootObj.SetActive(false);
            overlayedUnitList.Remove(unit);
        }
示例#3
0
		public UnitOverlay Clone(string name=""){
			UnitOverlay newOverlay=new UnitOverlay();
			newOverlay.rootObj=(GameObject)MonoBehaviour.Instantiate(rootObj);
			newOverlay.rootObj.name=name=="" ? rootObj.name+"(Clone)" : name;
			newOverlay.Init();
			
			newOverlay.rootT.SetParent(rootT.parent);
			newOverlay.rootT.localScale=rootT.localScale;
			
			return newOverlay;
		}
示例#4
0
        public UnitOverlay Clone(string name = "")
        {
            UnitOverlay newOverlay = new UnitOverlay();

            newOverlay.rootObj      = (GameObject)MonoBehaviour.Instantiate(rootObj);
            newOverlay.rootObj.name = name == "" ? rootObj.name + "(Clone)" : name;
            newOverlay.Init();

            newOverlay.rootT.SetParent(rootT.parent);
            newOverlay.rootT.localScale = rootT.localScale;

            return(newOverlay);
        }
示例#5
0
        UnitOverlay GetUnusedOverlay()
        {
            for (int i = 0; i < overlayList.Count; i++)
            {
                if (!overlayList[i].rootObj.activeInHierarchy)
                {
                    return(overlayList[i]);
                }
            }
            UnitOverlay overlay = overlayList[0].Clone();

            overlayList.Add(overlay);
            return(overlay);
        }
示例#6
0
        IEnumerator _UnitOverlay(Unit unit)
        {
            if (overlayedUnitList.Contains(unit))
            {
                yield break;
            }

            overlayedUnitList.Add(unit);

            UnitOverlay overlay = GetUnusedOverlay();

            overlay.rootObj.SetActive(true);

            if (unit.defaultShield > 0)
            {
                overlay.barShield.gameObject.SetActive(true);
            }
            else
            {
                overlay.barShield.gameObject.SetActive(false);
            }

            while (unit != null && !unit.dead && unit.thisObj.activeInHierarchy)
            {
                overlay.barHP.value = unit.HP / unit.fullHP;
                if (unit.defaultShield > 0)
                {
                    overlay.barShield.value = unit.shield / unit.fullShield;
                }

                Vector3 screenPos = mainCam.WorldToScreenPoint(unit.thisT.position + new Vector3(0, 0, 0));
                overlay.rootT.localPosition = screenPos + new Vector3(0, 20, 0);

                if (overlay.barHP.value == 1 && overlay.barShield.value == 1)
                {
                    break;
                }

                yield return(null);
            }

            overlay.rootObj.SetActive(false);
            overlayedUnitList.Remove(unit);
        }