コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: ActionUpgrade.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #4
0
ファイル: MapElementInfo.cs プロジェクト: TrutzX/9Nations
        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);
        }
コード例 #5
0
ファイル: HelpMgmt.cs プロジェクト: TrutzX/9Nations
 public void AddHelp(string category, WindowBuilderSplit wbs)
 {
     foreach (NHelp h in GetAllByCategory(category))
     {
         wbs.Add(new LexiconSplitElement(h, $"About {h.Name()}", SpriteHelper.Load("lexicon")));
     }
 }
コード例 #6
0
ファイル: ActionInteract.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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();
        }
コード例 #9
0
ファイル: BuildingInfo.cs プロジェクト: TrutzX/9Nations
        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);
        }
コード例 #10
0
ファイル: CampaignMgmt.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #11
0
ファイル: CampaignMgmt.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #12
0
        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();
        }
コード例 #13
0
        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();
        }
コード例 #14
0
ファイル: QuestGameButtonRun.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #15
0
        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();
        }
コード例 #16
0
ファイル: Town.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #17
0
ファイル: OptionHelper.cs プロジェクト: TrutzX/9Nations
        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();
        }
コード例 #18
0
 public CameraTownSplitElement(WindowBuilderSplit b, Town town) : base(town)
 {
     this.b = b;
 }
コード例 #19
0
 public CameraUnitSplitElement(WindowBuilderSplit b, Town town = null) : base("Units", "train")
 {
     this.b    = b;
     this.town = town;
 }
コード例 #20
0
 public CameraBuildingSplitElement(WindowBuilderSplit b, Town town = null) : base("Buildings", "build")
 {
     this.b    = b;
     this.town = town;
 }
コード例 #21
0
 public LoadWindowSplitElement(LoadSaveInfo info, WindowBuilderSplit w) : base(info.name, "file")
 {
     this.info = info;
     this.w    = w;
 }
コード例 #22
0
 public SaveWindowSplitElement(LoadSaveInfo info, WindowBuilderSplit w) : base(info, w)
 {
 }
コード例 #23
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);
                    }
                }
            }
        }
コード例 #24
0
ファイル: MaterialWindow.cs プロジェクト: TrutzX/9Nations
        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();
        }