public override void ShowDetail(PanelBuilder panel)
        {
            panel.AddHeaderLabel("Receipts");

            int  i     = 0;
            bool found = false;

            while (_holder.data.ContainsKey("craft" + i))
            {
                found = true;
                var    d  = SplitHelper.SplitInt(_holder.data["craft" + i]);
                Craft  c  = L.b.crafts[d.key];
                int    id = i;
                Button b  = panel.AddImageTextButton((d.value == -1?"Endless ":d.value + "x ") + c.Name(), c.Icon, () =>
                {
                    Remove(id);
                });

                i++;
            }

            if (!found)
            {
                panel.AddLabel("No active receipt found. You can add some from the left menu.");
            }
        }
示例#2
0
        public override ActionHolder Create(string setting)
        {
            ActionHolder conf = base.Create(setting);

            //add res
            string[] type = SplitHelper.Separator(setting);
            if (type[0] == "once")
            {
                conf.trigger = ActionEvent.FinishConstruct;
            }
            else if (type[0] == "turn")
            {
                conf.trigger = ActionEvent.NextRound;
            }

            for (int i = 1; i < type.Length; i++)
            {
                var d = SplitHelper.SplitInt(type[i]);
                if (d.value < 0)
                {
                    conf.req.Add("res", $">{d.value*-1}:{d.key}");
                }
                conf.data.Add("res-" + d.key, d.value.ToString());
            }

            return(conf);
        }
示例#3
0
        private void CreateCraft(Craft ele, string data)
        {
            var d = SplitHelper.SplitInt(data);

            if (d.value < 0)
            {
                ele.req.Add("res", $">{d.value*-1}:{d.key}");
            }
            ele.res.Add(d.key, d.value);
        }
示例#4
0
        protected void Res(Dictionary <string, int> res, string data)
        {
            var d = SplitHelper.SplitInt(data);

            res.Add(d.key, d.value);
        }
示例#5
0
        protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                        ActionHolder holder)
        {
            // show it
            if (evt == ActionEvent.Direct)
            {
                WindowBuilderSplit wbs = WindowBuilderSplit.Create("Craft", null);
                wbs.Add(new CraftStatusSplitElement(info, holder));

                //build it
                foreach (var craft in L.b.crafts.GetAllByCategory(holder.data["category"]))
                {
                    if (craft.req.Check(player, info, pos, true))
                    {
                        wbs.Add(new CraftSplitElement(craft, info, holder));
                    }
                }

                wbs.Finish();
                return;
            }

            //produce
            if (evt == ActionEvent.NextRound)
            {
                //has it?
                if (!holder.data.ContainsKey("craft0"))
                {
                    info.SetLastInfo("Nothing to craft");
                    return;
                }

                var c = SplitHelper.SplitInt(holder.data["craft0"]);

                //produce?
                Craft craft = L.b.crafts[c.key];

                foreach (var data in craft.res)
                {
                    if (!ProduceOneRes(evt, info, pos, data.Value, data.Key))
                    {
                        return;
                    }
                }

                //found it?
                if (c.value > 0)
                {
                    c.value--;
                    if (c.value > 0)
                    {
                        holder.data["craft0"] = SplitHelper.BuildSplit(c.key, c.value);
                    }
                    else
                    {
                        //delete it?
                        CraftMgmt.RebuildAfter(0, holder.data);
                    }
                }
            }
        }