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(); }
public void AddNewActionButton(ActionHolders holder, ActionHolder action, MapElementInfo info, GameObject actionPanel) { if (action == null) { throw new MissingMemberException($"Action for {info} is missing."); } //BasePerformAction ba = action.PerformAction(); FDataAction da = action.DataAction(); //can add under construction? if (info.IsUnderConstruction() && !da.useUnderConstruction) { return; } //can add from diff player? if (da.onlyOwner && !info.Owner(S.ActPlayerID())) { return; } //can add final? if (!action.req.Check(S.ActPlayer(), info, info.Pos(), true)) { return; } Button button = UIElements.CreateImageButton(da.Sprite(), actionPanel.transform, () => { PerformAction(holder, action, info); }, da.sound); UIHelper.HoverEnter(button, () => { ShowPanelMessage(S.T("actionTooltip", LSys.tem.inputs.ActionName(da), action.cost, info.data.ap)); }, () => { ShowPanelMessage(info.Status(S.ActPlayerID())); }); }