Exemplo n.º 1
0
        public static void WaitRound(ActionHolders holder, ActionHolder action, MapElementInfo info, NVector pos, int cost = -1, string sett = null, ActionEvent evt = ActionEvent.Direct)
        {
            FDataAction da = action.DataAction();

            cost = cost == -1 ? action.cost : cost;
            int round = (int)Math.Ceiling((1f * cost - info.data.ap) / info.data.apMax);

            WindowPanelBuilder wpb = WindowPanelBuilder.Create($"Wait for {da.Name()}?");

            wpb.panel.RichText(da.Desc());
            wpb.panel.AddImageLabel($"Action {da.Name()} need {cost - info.data.ap} AP more. You can wait {round} rounds.",
                                    "round");
            wpb.panel.AddButton($"Wait {round} rounds", () =>
            {
                var aw   = new ActionWaiting(action, holder, pos);
                aw.apMax = cost;
                aw.sett  = sett;
                aw.evt   = evt;
                info.SetWaitingAction(aw);
                L.b.animations.Create("sandClock", pos);

                OnMapUI.Get().UpdatePanel(info.Pos());
                wpb.Close();
            });
            wpb.AddClose();
            wpb.Finish();
        }
Exemplo n.º 2
0
        public virtual void BuildPanel(ActionDisplaySettings sett)
        {
            FDataAction da = L.b.actions[id];
            string h = sett.header ?? (S.Debug() ? $"{da.Name()} ({id})" : da.Name());

            if (sett.compact)
            {
                sett.panel.AddImageLabel(h, da.Icon);
                return;
            }
            
            sett.panel.AddHeaderLabel(h);

            if (S.Debug())
            {
                sett.panel.AddSubLabel("triggerWait",sett.holder.triggerWait.ToString());
            }

            if (sett.holder.triggerCount > 0)
            {
                string s = sett.holder.triggerWait ? " in" : " ";
                if (sett.holder.trigger == ActionEvent.NextRound)
                {
                    sett.panel.AddImageLabel($"Action will be performed{s} {sett.holder.triggerCount} rounds.", "build");
                } 
                else if (sett.holder.trigger == ActionEvent.Direct)
                {
                    sett.panel.AddLabel($"You can perform this action{s} {sett.holder.triggerCount} times.");
                }
            }
            else
            {
                switch (sett.holder.trigger)
                {
                    case ActionEvent.Direct:
                        sett.panel.AddImageLabel($"You can performed it directly for {sett.holder.cost} AP","ap");
                        break;
                    case ActionEvent.FinishConstruct:
                        sett.panel.AddLabel("It will be performed after finish construction.");
                        break;
                    case ActionEvent.NextRound:
                        sett.panel.AddLabel("It will be performed every round.");
                        break;
                    default:
                        sett.panel.AddLabel($"It will be performed {sett.holder.trigger}");
                        break;
                }
            }
            
            //add req?
            if (sett.addReq)
            {
                if (sett.pos == null)
                    sett.holder.req.BuildPanel(sett.panel);
                else
                    sett.holder.req.BuildPanel(sett.panel, sett.mapElement, sett.pos);
            }
                
        }
Exemplo n.º 3
0
        public void StartPlayerRound()
        {
            //has a waiting round?
            if (data.waiting == null)
            {
                return;
            }

            ActionHolder a  = data.action.actions[data.waiting.actionPos];
            FDataAction  da = a.DataAction();

            //perform every turn?
            if (data.waiting.endless)
            {
                if (da.interaction)
                {
                    AddNoti(S.T("actionInteraction", data.name, da.Name()), da.Icon);
                    data.waiting.needPerform = true;
                }
                else
                {
                    string erg2 = data.action.Perform(a, ActionEvent.NextRound, Player(), this, data.waiting.pos);
                    AddNoti(S.T("actionPerform", data.name, da.Name(), erg2), da.Icon);
                }

                return;
            }

            //wait more?
            if (data.waiting.apMax > data.ap + data.waiting.ap)
            {
                data.waiting.ap += data.ap;
                data.ap          = 0;
                return;
            }

            Debug.Log(da.Name() + da.interaction);

            if (da.interaction)
            {
                AddNoti(S.T("actionInteraction", data.name, da.Name()), da.Icon);
                data.waiting.needPerform = true;
            }
            else
            {
                PerformWaitingAction();
            }
        }
Exemplo n.º 4
0
        public static Quest Action(string id)
        {
            FDataAction da = L.b.actions[id];
            Quest       q  = new Quest(da.id, da.Name(), da.Icon).AddAction(id, "");

            return(q);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Show the action with the key, if possible
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public string ActionName(FDataAction action)
        {
            //has the action an input?
            if (!ContainsKey(action.id))
            {
                return(action.Name());
            }

            return(this[action.id].Name());
        }
Exemplo n.º 6
0
        public string Status(int playerId)
        {
            string text = " ";

            if (!Owner(playerId))
            {
                return($"{gameObject.name} belongs to {Player().name}");
            }

            if (IsUnderConstruction())
            {
                return($"{gameObject.name} under construction ({(int) (GetComponent<Construction>().GetConstructionProcent()*100)}%) {data.info.LastInfo()}");
            }

            if (data.waiting != null)
            {
                ActionHolder a  = data.action.actions[data.waiting.actionPos];
                FDataAction  da = a.DataAction();
                text += $"Prepare {da.Name()}";

                if (data.waiting.endless)
                {
                    text += $" (repeat unlimited).";
                }
                else
                {
                    text += $" ({TextHelper.Proc(data.waiting.ap, data.waiting.apMax)}).";
                }


                if (S.Debug())
                {
                    text += data.ap + "/" + data.waiting.ap + "/" + data.waiting.apMax;
                }
            }

            //add hp?
            string hp = data.hp < data.hpMax ? $"HP:{data.hp}/{data.hpMax}, " : "";

            return($"{gameObject.name} {hp}AP:{data.ap}/{data.apMax}{text} {data.info.LastInfo()}");
        }
Exemplo n.º 7
0
        public void PerformWaitingAction()
        {
            //has a waiting round?
            if (data.waiting == null)
            {
                return;
            }

            ActionHolder a  = data.action.actions[data.waiting.actionPos];
            FDataAction  da = a.DataAction();

            data.ap           = data.waiting.apMax - data.waiting.ap;
            data.ap          += data.waiting.ap;
            a.data["waiting"] = data.waiting.sett;
            string erg = data.action.Perform(a, data.waiting.evt, Player(), this, data.waiting.pos);

            a.data.Remove("waiting");
            data.ap = data.waiting.apMax - data.waiting.ap;
            AddNoti(S.T("actionPerform", data.name, da.Name(), erg), da.Icon);
            data.waiting = null;
        }
Exemplo n.º 8
0
        protected void AddButtons()
        {
            //remove actions
            UIHelper.ClearChild(actions);

            //has active action?
            if (ActiveAction != null)
            {
                ShowPanelMessage(ActiveAction.PanelMessage());
                FDataAction action = ActiveAction.DataAction();
                UIHelper.CreateImageTextButton(S.T("actionCancel", action.Name()), action.Sprite(), actions.transform,
                                               () => { OnMapUI.Get().SetActiveAction(null, active.GetComponent <BuildingInfo>() != null); },
                                               "cancel");
                return;
            }

            //has waiting action?
            if (active.data.waiting != null)
            {
                //can perform?
                if (active.data.waiting.needPerform)
                {
                    active.PerformWaitingAction();
                    return;
                }

                ActionHolder a = active.data.action.actions[active.data.waiting.actionPos];
                UIHelper.CreateImageTextButton(S.T("actionWaitingCancel"), a.DataAction().Sprite(), actions.transform,
                                               () =>
                {
                    active.data.ap = Math.Max(0, Math.Min(active.data.waiting.ap, active.data.apMax));
                    active.SetWaitingAction(null);
                    OnMapUI.Get().UpdatePanel(active.Pos());
                }, "cancel");
                return;
            }

            AddAllActionButtons();
        }