protected void SetRepeat(MapElementInfo info, NVector pos, ActionHolder holder) { info.SetRepeatAction(new ActionWaiting(holder, info.data.action, pos)); OnMapUI.Get().UpdatePanel(info.Pos()); }
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); } } } }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { Perform(info, S.Unit().At(pos)); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { new ActionTradeWindow(info.Town(), holder.data["trade"]); }
public ActionArgument(ActionEvent evt, ActionHolder holder, Player player, MapElementInfo onMap = null, NVector pos = null) : base(player, null, onMap, pos) { }
public void PerformCheck(ActionEvent evt, Player player, ActionHolder holder) { Perform(evt, player, holder); }
protected override void Perform(ActionEvent evt, Player player, ActionHolder holder) { L.b.gameButtons[holder.data["gameButton"]].Call(player); }
public CraftSplitElement(Craft craft, MapElementInfo info, ActionHolder holder) : base(craft.Name(), craft.Icon) { _craft = craft; _info = info; _holder = holder; }
protected override void Perform(ActionEvent evt, Player player, ActionHolder holder) { var v = SplitHelper.Split(holder.data["feature"]); player.SetFeature(v.key, v.value); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { Perform(evt, player, holder); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { Debug.Log(evt); if (evt == ActionEvent.Direct) { base.Perform(evt, player, info, pos, holder); return; } //move to point? MoveToPos(player, (UnitInfo)info, pos, holder); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { //get tilemap tileMap = GameMgmt.Get().newMap[pos.level].border.GetComponent <Tilemap>(); Points = new List <PPoint>(); //save caller this.player = player; mapElementInfo = info; this.initPos = pos; action = holder; //set as active action OnMapUI.Get().SetActiveAction(this, mapElementInfo.IsBuilding()); PreRun(); }
private void MoveToPos(Player player, UnitInfo unit, ActionHolder holder) { DataUnit dUnit = unit.dataUnit; NVector dPos = new NVector(holder.data["pos"]); int level = unit.Pos().level; //go to this field List <PPoint> points = S.Map().PathFinding(level).Path(player, dUnit.movement, unit.Pos(), dPos); NVector last = null; Debug.Log("Go to Goal " + unit.Pos() + " " + dPos); //find last possible point foreach (PPoint pp in points) { NVector p = new NVector(pp.x, pp.y, level); //free field? string s = unit.Passable(p); Debug.Log(p + ": " + s); if (s != null) { break; } //save it last = p; } Debug.Log("Go to Goal " + last); //move their? if (last == null) { if (holder.data.ContainsKey("posTried")) { unit.SetLastInfo(S.T("actionRepeatErrorMove", holder.DataAction().Name())); unit.SetRepeatAction(null); } else { unit.SetLastInfo(S.T("actionRepeatErrorPath", holder.DataAction().Name())); if (unit.data.ap == unit.data.apMax) { holder.data["posTried"] = "yes"; } } return; } //move their unit.MoveTo(last, true); holder.data.Remove("posTried"); if (dPos.Equals(last)) { //perform it holder.data.Remove("pos"); PerformRepeat(player, unit, dPos, holder); } //has enough ap for a next exploration? //todo dynamic if (dUnit.ap >= 10) { //Explore(player, unit, pos, holder); } }
protected abstract void PerformRepeat(Player player, MapElementInfo info, NVector pos, ActionHolder holder);
public void PerformCheck(ActionEvent evt, Player player, [CanBeNull] MapElementInfo info, NVector pos, ActionHolder holder) { Perform(evt, player, info, pos, holder); }
protected override void Perform(ActionEvent evt, Player player, ActionHolder holder) { S.CameraMove().MoveTo(new NVector(holder.data["pos"])); }
protected abstract void Perform(ActionEvent evt, Player player, [CanBeNull] MapElementInfo info, NVector pos, ActionHolder holder);
protected override void Run(Player player) { //create it WindowPanelBuilder p = WindowPanelBuilder.Create("Debug Window"); p.panel.AddButton("Give 500 gold", () => { Town t = S.Towns().GetByActPlayer().First(); t.AddRes("gold", 500, ResType.Gift); }); p.panel.AddButton("Trade", () => { ActionHolder ah = new ActionHolder(); ah.data["trade"] = null; LClass.s.GetNewAction("trade").PerformCheck(ActionEvent.Direct, S.ActPlayer(), ah); }); p.panel.AddButton("Give research", () => { Town t = S.Towns().GetByActPlayer()[0]; t.AddRes("research", 100, ResType.Gift); }); p.panel.AddButton("Finish all research", () => { foreach (Research r in L.b.researches.Values()) { S.ActPlayer().research.Set(r.id, true); } }); p.panel.AddButton("Unfinish all research", () => { foreach (Research r in L.b.researches.Values()) { S.ActPlayer().research.Set(r.id, false); } }); p.panel.AddButton("Switch Fog", () => { foreach (TileMapConfig16 t in S.ActPlayer().fog.tileMap) { t.gameObject.SetActive(!t.gameObject.activeSelf); } }); p.panel.AddButton("Show player features", () => { WindowPanelBuilder wp = WindowPanelBuilder.Create("features"); foreach (var fp in L.b.playerOptions.Values()) { wp.panel.AddLabel(fp.Name() + ": " + S.ActPlayer().GetFeature(fp.id) + " (" + fp.standard + ")"); } wp.Finish(); }); p.panel.AddButton("Show game features", () => { WindowPanelBuilder wp = WindowPanelBuilder.Create("features"); foreach (var fp in L.b.gameOptions.Values()) { wp.panel.AddLabel(fp.Name() + ": " + fp.Value() + " (" + fp.standard + ")"); } wp.Finish(); }); p.panel.AddButton("Reload game library", () => { GameMgmt.Get().ReloadGameLib(); p.Close(); }); p.panel.AddButton("Give unit", () => { WindowPanelBuilder wp = WindowPanelBuilder.Create("units"); if (S.Towns().GetByActPlayer().Count > 0 && S.Unit().Free(S.Towns().GetByActPlayer()[0].pos)) { foreach (var du in L.b.units.Values()) { wp.panel.AddImageTextButton(du.Name(), du.Sprite(), (() => { S.Unit().Create(S.ActPlayerID(), du.id, S.Towns().GetByActPlayer()[0].pos).FinishConstruct(); wp.Close(); p.Close(); })); } } else { wp.panel.AddLabel("Field is blocked"); } wp.Finish(); }); p.panel.AddButton("Reset round", () => { S.Players().ResetRound(); }); p.panel.AddLabel("DPI: " + Screen.dpi); p.Finish(); }
protected abstract void Perform(ActionEvent evt, Player player, ActionHolder holder);
protected override void PerformRepeat(Player player, MapElementInfo info, NVector pos, ActionHolder holder) { }
protected override void PerformRepeat(Player player, MapElementInfo info, NVector pos, ActionHolder holder) { player.overlay.Set("res", pos, 1); }
/// <summary> /// Add an action to call /// </summary> /// <param name="action"></param> /// <param name="sett"></param> /// <returns></returns> public Info AddAction(string action, string sett) { this.action = LClass.s.GetNewAction(action).Create(sett); return(this); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { player.overlay.Set("frontier", pos, 1); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { player.fog.Clear(pos, info.CalcVisibleRange(pos, 2)); }
public override bool Is(ActionHolder holder, ActionEvent type) { return(type == ActionEvent.Direct || type == ActionEvent.NextRound); }
protected void CreateAddCount(ActionHolder holder, ActionEvent type, string count, bool wait) { holder.trigger = type; holder.triggerCount = ConvertHelper.Int(count); holder.triggerWait = wait; }
protected override void Perform(ActionEvent evt, Player player, ActionHolder holder) { throw new System.NotImplementedException(); }
public virtual bool Is(ActionHolder holder, ActionEvent type) { return holder.trigger == type; }
protected override void Perform(ActionEvent evt, Player player, ActionHolder holder) { player.status = "lose"; }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { info.Town().Evolve(ConvertHelper.Int(holder.data["level"])); }