Пример #1
0
 protected void SetRepeat(MapElementInfo info, NVector pos, ActionHolder holder)
 {
     info.SetRepeatAction(new ActionWaiting(holder, info.data.action, pos));
     OnMapUI.Get().UpdatePanel(info.Pos());
 }
Пример #2
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);
                    }
                }
            }
        }
Пример #3
0
 protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                 ActionHolder holder)
 {
     Perform(info, S.Unit().At(pos));
 }
Пример #4
0
 protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                 ActionHolder holder)
 {
     new ActionTradeWindow(info.Town(), holder.data["trade"]);
 }
Пример #5
0
 public ActionArgument(ActionEvent evt, ActionHolder holder, Player player, MapElementInfo onMap = null, NVector pos = null) : base(player, null, onMap, pos)
 {
 }
Пример #6
0
 public void PerformCheck(ActionEvent evt, Player player, ActionHolder holder)
 {
     Perform(evt, player, holder);
 }
Пример #7
0
 protected override void Perform(ActionEvent evt, Player player, ActionHolder holder)
 {
     L.b.gameButtons[holder.data["gameButton"]].Call(player);
 }
Пример #8
0
 public CraftSplitElement(Craft craft, MapElementInfo info, ActionHolder holder) : base(craft.Name(), craft.Icon)
 {
     _craft  = craft;
     _info   = info;
     _holder = holder;
 }
Пример #9
0
        protected override void Perform(ActionEvent evt, Player player, ActionHolder holder)
        {
            var v = SplitHelper.Split(holder.data["feature"]);

            player.SetFeature(v.key, v.value);
        }
Пример #10
0
 protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                 ActionHolder holder)
 {
     Perform(evt, player, holder);
 }
Пример #11
0
        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);
        }
Пример #12
0
        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();
        }
Пример #13
0
        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);
            }
        }
Пример #14
0
 protected abstract void PerformRepeat(Player player, MapElementInfo info, NVector pos,
                                       ActionHolder holder);
Пример #15
0
 public void PerformCheck(ActionEvent evt, Player player, [CanBeNull] MapElementInfo info, NVector pos, ActionHolder holder)
 {
     Perform(evt, player, info, pos, holder);
 }
Пример #16
0
 protected override void Perform(ActionEvent evt, Player player, ActionHolder holder)
 {
     S.CameraMove().MoveTo(new NVector(holder.data["pos"]));
 }
Пример #17
0
 protected abstract void Perform(ActionEvent evt, Player player, [CanBeNull] MapElementInfo info, NVector pos,
     ActionHolder holder);
Пример #18
0
        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();
        }
Пример #19
0
 protected abstract void Perform(ActionEvent evt, Player player, ActionHolder holder);
Пример #20
0
 protected override void PerformRepeat(Player player, MapElementInfo info, NVector pos, ActionHolder holder)
 {
 }
Пример #21
0
 protected override void PerformRepeat(Player player, MapElementInfo info, NVector pos,
                                       ActionHolder holder)
 {
     player.overlay.Set("res", pos, 1);
 }
Пример #22
0
 /// <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);
 }
Пример #23
0
 protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                 ActionHolder holder)
 {
     player.overlay.Set("frontier", pos, 1);
 }
Пример #24
0
 protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                 ActionHolder holder)
 {
     player.fog.Clear(pos, info.CalcVisibleRange(pos, 2));
 }
Пример #25
0
 public override bool Is(ActionHolder holder, ActionEvent type)
 {
     return(type == ActionEvent.Direct || type == ActionEvent.NextRound);
 }
Пример #26
0
 protected void CreateAddCount(ActionHolder holder, ActionEvent type, string count, bool wait)
 {
     holder.trigger = type;
     holder.triggerCount = ConvertHelper.Int(count);
     holder.triggerWait = wait;
 }
Пример #27
0
 protected override void Perform(ActionEvent evt, Player player, ActionHolder holder)
 {
     throw new System.NotImplementedException();
 }
Пример #28
0
 public virtual bool Is(ActionHolder holder, ActionEvent type)
 {
     return holder.trigger == type;
 }
Пример #29
0
 protected override void Perform(ActionEvent evt, Player player, ActionHolder holder)
 {
     player.status = "lose";
 }
Пример #30
0
 protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos,
                                 ActionHolder holder)
 {
     info.Town().Evolve(ConvertHelper.Int(holder.data["level"]));
 }