예제 #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
파일: UIOverlay.cs 프로젝트: tscheipel/BEER
        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);
        }