Esempio n. 1
0
        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())); });
        }