Beispiel #1
0
        public void ConfigureButton(int i, string text, UnityAction fn, bool enabled)
        {
            bool lastButton = i == Math.Abs(numShown) - 1;

            if (numShown > 0)
            {
                i = (numShown - 1) - i;
            }
            var btn = buttons.Get(i);

            btn.text.text = text;
            if (btn.text.preferredWidth > longestText)
            {
                longestText = btn.text.preferredWidth;
            }

            btn.button.onClick.RemoveAllListeners();
            btn.button.onClick.AddListener(fn);
            btn.button.interactable = enabled;

            if (lastButton)
            {
                pane.sizeDelta = new Vec2(Math.Min(maxWidth - 20, longestText) + 20, 0);
            }
        }
Beispiel #2
0
        public void ConfigureButton(int i, string main, string sub, UnityAction cbFn)
        {
            var btn = btnsB.Get(i);

            btn.textMain.text = main;
            btn.textSub.text  = sub;
            btn.button.onClick.RemoveAllListeners();
            btn.button.onClick.AddListener(cbFn);
        }
Beispiel #3
0
 public void SetRecipes(RecipeDef[] recipes, Action <RecipeDef> cbFn)
 {
     btnsA.Hide();
     btnsA.Show(recipes.Length);
     for (int i = 0; i < recipes.Length; ++i)
     {
         var btn = btnsA.Get(i);
         var rec = recipes[i];
         btn.textMain.text = rec.description;
         var mat  = rec.materials[0]; // TODO: multi
         var prod = rec.product[0];
         btn.textSub.text =
             $"{mat.def.name} x{mat.amt} -> {prod.def.name} x{prod.amt}";
         btn.button.onClick.RemoveAllListeners();
         btn.button.onClick.AddListener(() => cbFn(rec));
     }
 }
Beispiel #4
0
    public static void initBusinessmanNPC(List <GameObject> listFlagNpcs, UIPool poolFlagNpcs, Vector3 scale)
    {
        for (int i = 0; i < listFlagNpcs.get_Count(); i++)
        {
            poolFlagNpcs.ReUse(listFlagNpcs.get_Item(i));
        }
        listFlagNpcs.Clear();
        List <ActorNPC> nPCLogicList = NPCManager.Instance.NPCLogicList;

        for (int j = 0; j < nPCLogicList.get_Count(); j++)
        {
            ActorNPC actorNPC = nPCLogicList.get_Item(j);
            string   name     = actorNPC.get_name();
            int      num      = 0;
            try
            {
                num = Convert.ToInt32(name);
            }
            catch
            {
                Debug.LogWarning("字符串转整形异常...");
            }
            NPC nPC = null;
            if (DataReader <NPC> .Contains(num))
            {
                nPC = DataReader <NPC> .Get(num);
            }
            if (nPC != null && nPC.function.get_Count() > 0 && RadarMapUIView.isShowNpcFlag(nPC.function.get_Item(0)))
            {
                GameObject gameObject = poolFlagNpcs.Get(string.Empty);
                int        mapPic     = nPC.mapPic;
                if (mapPic == 0)
                {
                    Debug.LogWarning("npc表没有配置mapPic字段,id=" + num);
                }
                ResourceManager.SetSprite(gameObject.GetComponent <Image>(), GameDataUtils.GetIcon(mapPic));
                Vector2 anchoredPosition = RadarManager.Instance.WorldPosToMapPosWithRotation(actorNPC.get_transform().get_position().x, actorNPC.get_transform().get_position().z, RadarManager.size_mapImage_minmap);
                (gameObject.get_transform() as RectTransform).set_anchoredPosition(anchoredPosition);
                (gameObject.get_transform() as RectTransform).set_localScale(scale);
                listFlagNpcs.Add(gameObject);
            }
        }
    }