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); }
private void Equip(string id, string category, Button button) { if (_info.Town() == null) { UIHelper.ShowOk(S.T("itemEquipNew"), S.T("townNo")); return; } WindowBuilderSplit wbs = WindowBuilderSplit.Create(S.T("itemEquipNew"), "Equip"); wbs.Add(new ItemNoSelectSplitInfo(_info, button, id)); foreach (var item in L.b.items.GetAllByCategory(category)) { //has already? if (_info.data.items.ContainsValue(item.id)) { continue; } if (_info.Town().GetRes(item.id) >= 1) { wbs.Add(new ItemSelectSplitInfo(_info, button, id, item)); } } wbs.Finish(); }
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(); }
public virtual WindowBuilderSplit ShowInfoWindow() { WindowBuilderSplit win = WindowBuilderSplit.Create(gameObject.name, null); win.Add(new ActionDisplaySplitElement(this)); win.Add(new TerrainSplitElement(GameMgmt.Get().newMap.Terrain(Pos()), Pos())); if (data.townId != -1) { win.Add(new CameraTownSplitElement(win, Town())); } if (S.Debug()) { win.Add(new DebugMapElementSplitElement(this)); win.Add(new DebugSpellSplitElement(this)); } if (L.b.improvements.Has(Pos())) { win.Add(new LexiconSplitElement(L.b.improvements.At(Pos()))); } win.Add(new InfosSplitElement(data.info)); return(win); }
public void AddHelp(string category, WindowBuilderSplit wbs) { foreach (NHelp h in GetAllByCategory(category)) { wbs.Add(new LexiconSplitElement(h, $"About {h.Name()}", SpriteHelper.Load("lexicon"))); } }
protected override void ClickSecond() { //load options WindowBuilderSplit b = WindowBuilderSplit.Create("Interaction","Perform"); foreach(var action in mapElementInfo.data.action.actions) { FDataAction data = action.DataAction(); if (!data.mapElement || data.field != "near") continue; //found it? if (!action.req.Check(S.ActPlayer(), mapElementInfo, LastClickPos, true)) { continue; } ActionInteractSplitElement be = new ActionInteractSplitElement(mapElementInfo.data.action, action, mapElementInfo, LastClickPos); be.disabled = action.req.Desc(S.ActPlayer(), mapElementInfo, LastClickPos); be.audioPerform = data.sound; b.Add(be); } //is empty? if (b.Count() == 0) { mapElementInfo.UI().ShowPanelMessageError("No interaction with neighbors found."); b.CloseWindow(); return; } b.Finish(); }
protected override void Run(Player player) { WindowBuilderSplit b = WindowBuilderSplit.Create("Research window", null); b.Add(new ResearchStatusSplitElement()); b.Add(new ResearchFinishSplitElement()); b.Add(new InfosSplitElement(player.research.info)); LSys.tem.helps.AddHelp("research", b); b.Finish(); }
public static void Show() { WindowBuilderSplit w = WindowBuilderSplit.Create("Load the game", "Load"); //add files foreach (LoadSaveInfo info in LoadSaveMgmt.GetAllSaves()) { w.Add(new LoadWindowSplitElement(info, w)); } w.Finish(); }
public override WindowBuilderSplit ShowInfoWindow() { WindowBuilderSplit wbs = base.ShowInfoWindow(); wbs.Add(new BuildingLexiconInfo(this), true); wbs.Add(new MapElementSplitInfo(this), true); wbs.Add(new BuildingItemSplitInfo(this)); LSys.tem.helps.AddHelp("building", wbs); wbs.Finish(); return(wbs); }
public void ShowScenarios(Campaign campaign) { //load buildings WindowBuilderSplit b = WindowBuilderSplit.Create("Select your scenario", "Play"); foreach (Scenario s in campaign.Scenarios()) { if (s.req.Check(null)) { b.Add(new ScenarioSplitElement(s)); } } b.Finish(); }
public void ShowCampaigns() { //load buildings WindowBuilderSplit b = WindowBuilderSplit.Create("Select your campaign", "Play"); foreach (Campaign c in data.Values) { if (!c.Hidden) { b.Add(new CampaignSplitElement(c)); } } b.Finish(); }
public static void Show() { WindowBuilderSplit w = WindowBuilderSplit.Create("Save the game", "Overwrite"); UIHelper.CreateButton("Create new save", w.buttonPanel.transform, () => { w.Add(new SaveWindowSplitElement(LoadSaveMgmt.CreateNewSave(), w)); }); //add files foreach (LoadSaveInfo info in LoadSaveMgmt.GetAllSaves()) { w.Add(new SaveWindowSplitElement(info, w)); } w.Finish(); }
public void StartRound() { //need to develop? if (elements.Count >= points) { return; } //has max? if (elements.Count >= player.Nation().maxElement) { return; } //has some in nations? if (player.Nation().elements.Count > elements.Count) { Develop(player.Nation().elements[elements.Count]); return; } //ask the player WindowBuilderSplit wbs = WindowBuilderSplit.Create("Develop your nation", "Develop"); foreach (var ele in L.b.elements.Values()) { //has it? if (elements.Contains(ele.id)) { continue; } //can use it? if (ele.req.Check(player)) { wbs.Add(new PlayerDevelopmentSplitElement(ele, this)); } } LSys.tem.helps.AddHelp("element", wbs); wbs.Finish(); }
protected override void Run(Player player) { //load buildings WindowBuilderSplit b = WindowBuilderSplit.Create("Quest window", null); foreach (Quest q in S.ActPlayer().quests.quests) { if (q.IsFinish() || q.InProgress()) { b.Add(new QuestSplitElement(q)); } } if (S.Debug()) { b.Add(new DebugQuestSplitElement()); } b.Finish(); }
protected override void Run(Player player) { //load buildings WindowBuilderSplit b = WindowBuilderSplit.Create("Kingdom overview", null); b.Add(new PlayerInfoSplitElement(S.ActPlayer())); b.Add(new CameraUnitSplitElement(b)); //add all towns foreach (Town t in S.Towns().GetByActPlayer()) { b.Add(new CameraTownSplitElement(b, t)); } LSys.tem.helps.AddHelp("kingdom", b); b.Add(new InfosSplitElement(S.ActPlayer().info)); b.Add(new LexiconSplitElement(S.ActPlayer().Nation())); b.Add(new LexiconSplitElement(GameMgmt.Get().gameRound.GetRound())); b.Finish(); }
public void ShowDetails() { WindowBuilderSplit wbs = WindowBuilderSplit.Create($"Details about {name}", null); wbs.Add(new TownGeneralSplitElement(this)); if (S.Debug()) { wbs.Add(new DebugTownSplitElement(this)); } wbs.Add(new TownResSplitElement(this)); wbs.Add(new CameraUnitSplitElement(wbs, this)); wbs.Add(new CameraBuildingSplitElement(wbs, this)); wbs.Add(new InfosSplitElement(info)); if (L.b.gameOptions["usageTown"].Bool()) { wbs.Add(new TownUsageSplitElement(this)); } LSys.tem.helps.AddHelp("town", wbs); wbs.Finish(); }
public static void ShowOptionWindow() { //load buildings WindowBuilderSplit b = WindowBuilderSplit.Create("Options", null); b.Add(new BaseOptionSplitElement("game", "game", "logo")); b.Add(new BaseOptionSplitElement("audio", "audio", "audio")); b.Add(new BaseOptionSplitElement("graphics", "graphics", "graphics")); b.Add(new LanguageOptionSplitElement()); b.Add(new NetworkOptionSplitElement()); //todo dyn if (Application.platform != RuntimePlatform.Android) { b.Add(new InputOptionSplitElement()); } if (S.Debug()) { b.Add(new BaseOptionSplitElement("debug", "debug", "debug")); } b.Finish(); }
public CameraTownSplitElement(WindowBuilderSplit b, Town town) : base(town) { this.b = b; }
public CameraUnitSplitElement(WindowBuilderSplit b, Town town = null) : base("Units", "train") { this.b = b; this.town = town; }
public CameraBuildingSplitElement(WindowBuilderSplit b, Town town = null) : base("Buildings", "build") { this.b = b; this.town = town; }
public LoadWindowSplitElement(LoadSaveInfo info, WindowBuilderSplit w) : base(info.name, "file") { this.info = info; this.w = w; }
public SaveWindowSplitElement(LoadSaveInfo info, WindowBuilderSplit w) : base(info, w) { }
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); } } } }
public static void ShowBuildMaterialWindow(BaseDataBuildingUnit build, NVector pos, Action <Dictionary <string, int> > perform) { string need = null; Town town = S.Towns().NearestTown(S.ActPlayer(), pos, false); //todo support multiple //check if material need to replaced? foreach (var c in build.cost) { var res = L.b.res[c.Key]; if (!string.IsNullOrEmpty(res.combine)) { need = res.combine; break; } } //how much exist in this town? if (string.IsNullOrEmpty(need)) { //nothing found? Build it directly perform.Invoke(new Dictionary <string, int>(build.cost)); return; } //how much types is known? var found = L.b.res.GetAllByCategory(need).Where(r => town.KnowRes(r.id)).ToList(); //found nothing? if (found.Count == 0) { UIHelper.ShowOk(S.T("constructionMaterial"), TextHelper.RichText(S.T("constructionMaterialNothing", town.GetTownLevelName(), town.name), TextHelper.Header("material"), TextHelper.CommaSep(L.b.res.GetAllByCategory(need).Select(r => r.Name()).ToArray()))); return; } //found one? Build it directly if (found.Count == 1) { Dictionary <string, int> cost = new Dictionary <string, int>(build.cost); cost[found[0].id] = (cost.ContainsKey(found[0].id) ? cost[found[0].id] : 0) + cost[need]; cost.Remove(need); perform.Invoke(cost); return; } WindowBuilderSplit wbs = WindowBuilderSplit.Create(S.T("constructionMaterial"), S.T("constructionMaterialUse")); foreach (var res in L.b.res.GetAllByCategory(need)) { //have it? if (!town.KnowRes(res.id)) { continue; } Dictionary <string, int> cost = new Dictionary <string, int>(build.cost); cost[res.id] = (cost.ContainsKey(res.id) ? cost[res.id] : 0) + cost[need]; cost.Remove(need); wbs.Add(new MaterialSplitElement(res, build, pos, cost, perform)); } //add self wbs.Add(new MaterialSelfSplitElement(L.b.res[need], build, town, pos, new Dictionary <string, int>(build.cost), perform)); LSys.tem.helps.AddHelp("material", wbs); wbs.Finish(); }