예제 #1
0
        public static bool ModExt_NewPropsUI(CtrlMedicine __instance)
        {
            var mapping = Traverse.Create(__instance).Field("mapping");
            var sort    = Traverse.Create(__instance).Field("sort").GetValue <List <PropsInfo> >();

            mapping.SetValue(GlobalLib.GetUICharacterMapping());
            sort.Clear();
            foreach (KeyValuePair <string, InventoryData> keyValuePair in Game.GameData.Inventory)
            {
                string key   = keyValuePair.Key;
                Props  props = Game.Data.Get <Props>(key);
                if (props != null && props.PropsType == PropsType.Medicine)
                {
                    bool show = false;
                    if (props.CanUseID != null && props.CanUseID.Count > 0)
                    {
                        for (int i = 0; i < props.CanUseID.Count; i++)
                        {
                            string text = props.CanUseID[i];
                            if (!text.IsNullOrEmpty() && text == mapping.GetValue <CharacterMapping>().Id)
                            {
                                show = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        show = true;
                        if (props.PropsCategory >= PropsCategory.Fist_Secret_Scroll && props.PropsCategory <= PropsCategory.Throw_Secret_Scroll && key.StartsWith("p_scroll"))
                        {
                            foreach (var pe in props.PropsEffect)
                            {
                                if (pe is PropsLearnSkill pls)
                                {
                                    PropsCategory skillType = Game.Data.Get <Skill>(pls.Id).Type;
                                    if (!GlobalLib.HasSkillType(mapping.GetValue <CharacterMapping>().InfoId, skillType))
                                    {
                                        show = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (show)
                    {
                        PropsInfo propsInfo = new PropsInfo(key)
                        {
                            ConditionStatus = ((props.UseTime == PropsUseTime.Battle) ? PropsInfo.PropsConditionStatus.UseTimeFail_Battle : PropsInfo.PropsConditionStatus.AllPass)
                        };
                        sort.Add(propsInfo);
                    }
                }
            }
            var view = Traverse.Create(__instance).Field("view").GetValue <UIMedicine>();

            view.UpdateProps(sort.Count);
            if (sort.Count <= 0)
            {
                view.UpdatePropsIntroduction(null);
            }
            return(false);
        }
예제 #2
0
 public void OnUpdate()
 {
     if (teamManageOn.Value && TeamMemberObject != null && TeamMemberObject.activeInHierarchy)
     {
         var UIHome = Game.UI.Get <UIHome>();
         if (UIHome == null)
         {
             return;
         }
         if (Input.GetKeyDown(teamMemberAdd.Value))
         {
             CharacterMapping cm = GlobalLib.GetUICharacterMapping();
             if (cm != null && cm.Id != GameConfig.Player && !Game.GameData.Party.Contains(cm.Id))
             {
                 Game.GameData.Party.AddParty(cm.Id, false);
                 int count = Traverse.Create(UIHome).Property("controller").Field("characterMapping").Property("Count").GetValue <int>();
                 UIHome.UpdateCommunity(count);
             }
         }
         if (Input.GetKeyDown(teamMemberRemove.Value))
         {
             CharacterMapping cm = GlobalLib.GetUICharacterMapping();
             if (cm != null && cm.Id != GameConfig.Player && Game.GameData.Party.Contains(cm.Id))
             {
                 Game.GameData.Party.RemoveParty(cm.Id);
                 int count = Traverse.Create(UIHome).Property("controller").Field("characterMapping").Property("Count").GetValue <int>();
                 UIHome.UpdateCommunity(count);
             }
         }
         if (Input.GetKeyDown(teamMemberRemoveAll.Value))
         {
             foreach (var pi in Game.GameData.Party.GetRange(0, Game.GameData.Party.Count))
             {
                 if (pi != GameConfig.Player)
                 {
                     Game.GameData.Party.RemoveParty(pi);
                 }
             }
             int count = Traverse.Create(UIHome).Property("controller").Field("characterMapping").Property("Count").GetValue <int>();
             UIHome.UpdateCommunity(count);
         }
         if (Input.GetKeyDown(communityRemove.Value))
         {
             CharacterMapping cm = GlobalLib.GetUICharacterMapping();
             if (cm != null && cm.Id != GameConfig.Player)
             {
                 Game.GameData.Community[cm.Id].isOpen = false;
                 Game.GameData.NurturanceOrder.CloseCommunityOrder(cm.Id);
                 if (Game.GameData.Party.Contains(cm.Id))
                 {
                     Game.GameData.Party.RemoveParty(cm.Id);
                 }
                 Traverse.Create(UIHome).Property("controller").Method("OnShow").GetValue();
                 Traverse.Create(UIHome).Property("controller").Method("HideCommunity").GetValue();
                 Traverse.Create(UIHome).Property("controller").Method("UpdateCommunity").GetValue();
                 string joinPropsId = "p_npcj_" + cm.Id;
                 if (!Game.GameData.Inventory.ContainsKey(joinPropsId))
                 {
                     new RewardProps
                     {
                         method  = Method.Add,
                         propsId = "p_npcj_" + cm.Id,
                         value   = 1
                     }.GetValue();
                 }
             }
         }
     }
 }