示例#1
0
 public static void UnitElementPatch2(WgBar __instance, BattleProperty prop)
 {
     if (__instance != null)
     {
         Slider hp = Traverse.Create(__instance).Field("hp").GetValue <Slider>();
         if (hp != null && hp.transform != null)
         {
             var trans = hp.transform.Find("ElementImage");
             if (prop == BattleProperty.Element && trans != null && __instance.Unit != null)
             {
                 var element = trans.gameObject.GetComponent <Image>();
                 element.sprite = Game.Resource.Load <Sprite>(string.Format(GameConfig.ElementPath, __instance.Unit.Element));
             }
         }
     }
 }
示例#2
0
        // 5 血条显示五行
        public static void ProcessElementDisplay(WgBar wgbar)
        {
            Image  element;
            Text   name;
            Slider hp     = Traverse.Create(wgbar).Field("hp").GetValue <Slider>();
            var    trans  = hp.transform.Find("ElementImage");
            var    trans2 = hp.transform.Find("UnitName");

            if (trans == null && wgbar.Unit != null)
            {
                GameObject gameObject = new GameObject("ElementImage");
                gameObject.transform.SetParent(hp.transform, false);
                element = gameObject.AddComponent <Image>();
                element.rectTransform.sizeDelta = new Vector2(50f, 50f);
                element.color = new Color(1f, 1f, 1f, 0.8f);
                element.transform.localPosition = elementPos.Value;
                element.sprite = Game.Resource.Load <Sprite>(string.Format(GameConfig.ElementPath, wgbar.Unit.Element));
                GameObject gameObject2 = new GameObject("UnitName");
                gameObject2.transform.SetParent(hp.transform, false);
                name           = gameObject2.AddComponent <Text>();
                name.text      = wgbar.Unit.FullName;
                name.font      = Game.Resource.Load <Font>("Assets/Font/kaiu.ttf");
                name.fontSize  = 18;
                name.alignment = TextAnchor.MiddleLeft;
                name.rectTransform.sizeDelta = new Vector2(120f, 20f);
                name.transform.localPosition = elementTextPos.Value;
            }
            else
            {
                element = trans.gameObject.GetComponent <Image>();
                name    = trans2.gameObject.GetComponent <Text>();
            }
            if (elementShow)
            {
                element.gameObject.SetActive(true);
                element.transform.localPosition = elementPos.Value;
                name.gameObject.SetActive(true);
                name.transform.localPosition = elementTextPos.Value;
            }
            else
            {
                element.gameObject.SetActive(false);
                name.gameObject.SetActive(false);
            }
        }
示例#3
0
 public static void UnitElementPatch(WgBar __instance)
 {
     ProcessElementDisplay(__instance);
 }