Example #1
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);
        }
        protected bool CheckAllowed(Player player, MapElementInfo info, NVector pos, ActionHolder holder)
        {
            if (!holder.data.ContainsKey("allowed"))
            {
                return(false);
            }

            //load buildings
            WindowBuilderSplit b = WindowBuilderSplit.Create(holder.DataAction().Desc(), holder.DataAction().Name());

            foreach (string key in SplitHelper.Separator(holder.data["allowed"]))
            {
                AddObject(player, info, pos, key, b);
            }

            //has some?
            if (b.Count() >= 1)
            {
                b.Finish();
                return(true);
            }

            b.CloseWindow();
            info.UI().ShowPanelMessageError(S.T("tabNo", holder.DataAction().Desc()));
            return(true);
        }
Example #3
0
        protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                        ActionHolder holder)
        {
            string[] keys;
            if (holder.data.ContainsKey("upgrade"))
            {
                keys = SplitHelper.Separator(holder.data["upgrade"]);
            }
            else
            {
                keys = info.IsBuilding()?L.b.buildings.Keys().ToArray():L.b.units.Keys().ToArray();
            }

            //load buildings
            WindowBuilderSplit b = WindowBuilderSplit.Create(holder.DataAction().Desc(), holder.DataAction().Name());

            {
                foreach (string key in keys)
                {
                    BaseDataBuildingUnit build = info.IsBuilding()?(BaseDataBuildingUnit)L.b.buildings[key]:L.b.units[key];
                    if (build.req.Check(player, info, pos, true))
                    {
                        BuildUpgradeSplitElement be = new BuildUpgradeSplitElement(build, info, pos, b);
                        be.disabled = build.req.Desc(player, info, pos);
                        b.Add(be);
                        //win.AddBuilding(build.id);
                    }
                }
            }

            b.Finish();
        }
Example #4
0
        public (int min, int max) ResRange(string res)
        {
            if (!this.res.ContainsKey(res))
            {
                return(0, 0);
            }

            string[] c = SplitHelper.Separator(this.res[res])[0].Split('-');
            return(ConvertHelper.Int(c[0]), ConvertHelper.Int(c[1]));
        }
Example #5
0
        public override bool Check(Player player, string sett)
        {
            if (!LSys.tem.options["updateCheck"].Bool())
            {
                return(false);
            }

            string[] s = SplitHelper.Separator(PlayerPrefs.GetString("update.txt", "false"));
            return(!(s[0].Equals("false")));
        }
Example #6
0
        public override bool Check(Player player, MapElementInfo onMap, string sett, NVector pos)
        {
            string[] terr = SplitHelper.Separator(sett);
            foreach (string terrain in terr)
            {
                if (GameMgmt.Get().newMap.Terrain(pos).category == terrain)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #7
0
        public override ActionHolder Create(string setting)
        {
            ActionHolder conf = base.Create(setting);

            conf.trigger = ActionEvent.Quest;

            foreach (var ele in SplitHelper.Separator(setting))
            {
                var s = SplitHelper.Split(ele);
                conf.data[s.key] = s.value;
            }

            return(conf);
        }
Example #8
0
        protected override void Run(Player player)
        {
            string[] s = SplitHelper.Separator(PlayerPrefs.GetString("update.txt", "false"));

            if (s[0].Equals("false"))
            {
                return;
            }

            WindowPanelBuilder w = WindowPanelBuilder.Create($"Update to {s[1]}");

            w.panel.AddLabel(s[2]);
            w.panel.AddButton($"Download {s[1]}", (() => Application.OpenURL("http://9nations.de/download")));
            w.AddClose();
            w.Finish();
        }
Example #9
0
        public override ActionHolder Create(string setting)
        {
            ActionHolder conf = base.Create(setting);

            conf.trigger = ActionEvent.Direct;

            var split = SplitHelper.Separator(setting);

            conf.data["type"] = split[0];
            if (split.Length >= 2)
            {
                conf.data["player"] = split[1];
            }

            return(conf);
        }
Example #10
0
        public int ResChance(string res)
        {
            if (!this.res.ContainsKey(res))
            {
                return(0);
            }

            string[] s = SplitHelper.Separator(this.res[res]);

            if (s.Length >= 2)
            {
                return((int)ConvertHelper.Proc(s[1]));
            }

            return(0);
        }
Example #11
0
        public override bool Check(Player player, MapElementInfo onMap, string sett, NVector pos)
        {
            if (S.Building().Free(pos))
            {
                return(false);
            }

            var bi = S.Building().At(pos).dataBuilding;

            string[] builds = SplitHelper.Separator(sett);
            foreach (var b in builds)
            {
                if (bi.id == b)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #12
0
        public override ActionHolder Create(string setting)
        {
            ActionHolder conf = base.Create(setting);

            conf.trigger = ActionEvent.Direct;

            if (!string.IsNullOrEmpty(setting))
            {
                conf.data["upgrade"] = setting;
                string[] keys = SplitHelper.Separator(setting);

                //add req
                foreach (string key in keys)
                {
                    conf.req.Add("upgrade", key);
                }
            }

            return(conf);
        }
Example #13
0
        public void FinishBuild()
        {
            //check generate
            if (terrains.Count == 0)
            {
                Assert.IsNotNull(generate, $"Data and generate for level {name} is missing.");
                LSys.tem.mapGeneration[generate].Generator().Generate(this);
            }

            //set res
            resGenerate = new Dictionary <string, int> [Width(), Height()];
            for (int x = 0; x < Width(); x++)
            {
                for (int y = 0; y < Height(); y++)
                {
                    DataTerrain bt = Terrain(x, y);
                    //has res?
                    if (bt.res.Count == 0)
                    {
                        continue;
                    }

                    //add it
                    resGenerate[x, y] = new Dictionary <string, int>();
                    foreach (KeyValuePair <string, string> r in bt.res)
                    {
                        string[] s = SplitHelper.Separator(r.Value);

                        //has chance?
                        if (s.Length >= 2 && Random.Range(0, 100) < ConvertHelper.Proc(s[1]))
                        {
                            continue;
                        }

                        var c = bt.ResRange(r.Key);
                        resGenerate[x, y].Add(r.Key, Random.Range(c.min, c.max));
                    }
                }
            }
        }
        protected void AddLast(Player player, MapElementInfo info, NVector pos, ActionHolder holder,
                               WindowTabBuilder wtb)
        {
            var last = L.b.playerOptions["last" + id];

            //add last used?
            if (!string.IsNullOrEmpty(last.Value()))
            {
                SplitElementTab set = new SplitElementTab(last.Name(), last.Icon, holder.DataAction().Name());
                foreach (string key in SplitHelper.Separator(last.Value()))
                {
                    if (string.IsNullOrEmpty(key))
                    {
                        continue;
                    }

                    AddObject(player, info, pos, key, set);
                }

                wtb.Add(set);
            }
        }
Example #15
0
        public void AddOption(PanelBuilder panel)
        {
            if (type == "bool")
            {
                panel.AddCheckbox(Bool(), Name(), s => { SetValue(Convert.ToString(s)); });
                return;
            }

            if (type.StartsWith("scale"))
            {
                panel.AddHeaderLabel(Name());
                var t = SplitHelper.SeparatorInt(SplitHelper.Delimiter(type).value);
                panel.AddSlider(t[0], t[1], PlayerPrefs.GetInt(id, Int32.Parse(Value())), s =>
                {
                    SetValue(s.ToString());
                });
                return;
            }

            if (type == "text")
            {
                panel.AddInput(Name(), Value(), SetValue);
            }

            if (type.StartsWith("dropdown"))
            {
                var           values = SplitHelper.Separator(SplitHelper.Delimiter(type).value);
                List <string> titles = new List <string>();
                foreach (var value in values)
                {
                    titles.Add(S.T(value));
                }
                panel.AddHeaderLabel(Name());
                panel.AddDropdown(values, Value(), titles.ToArray(), SetValue);
            }
        }
Example #16
0
 public override bool Check(Player player, MapElementInfo onMap, string sett, NVector pos)
 {
     string[] terr = SplitHelper.Separator(sett);
     return(terr.Any(terrain => GameMgmt.Get().newMap.Terrain(pos).id == terrain));
 }
Example #17
0
 public override bool Check(Player player, string sett)
 {
     return(SplitHelper.Separator(sett).Any(e => player.elements.Contains(e)));
 }
Example #18
0
        public override string Desc(Player player, string sett)
        {
            var l = SplitHelper.Separator(sett);

            return(S.T(LSys.tem.translations.GetPlural("reqElement", l.Length), L.b.elements.NameList(l)));
        }
Example #19
0
        public override string Desc(Player player, string sett)
        {
            var names = SplitHelper.Separator(sett).Select(s => L.b.researches[s].Name());

            return(S.T("reqResearch", TextHelper.CommaSep(names.ToArray())));
        }
Example #20
0
 public override bool Check(Player player, string sett)
 {
     string[] research = SplitHelper.Separator(sett);
     return(research.Any(res => player.research.IsFinish(res)));
 }
Example #21
0
        public override string Desc(Player player, string sett)
        {
            var l = SplitHelper.Separator(sett);

            return(S.T(LSys.tem.translations.GetPlural("reqUpgradeFieldPlural", l.Length), L.b.buildings.NameList(l)));
        }