public ActionReq(int inPlayer, int targetPlayer, pAction inAction, Vector2[] inCoords) { p = inPlayer; t = targetPlayer; a = inAction; loc = inCoords; }
//Function to artificially set cooldown of action public void SetCooldown(pAction action, int cooldown) { if (cooldown < 0) { Debug.LogError("Don't set cd to < 0: " + cooldown.ToString()); return; } this.actionCooldowns[action] = cooldown; }
public ActionParam(pAction action, Faction faction, int factionCost, int cooldown, int maxUses, bool enabled, ReportType reportType) { this.action = action; this.faction = faction; this.factionCost = factionCost; this.cooldown = cooldown; // 0 means no cooldown this.maxUses = maxUses; // 0 means no more uses, -1 means no limit this.enabled = enabled; // false means player can't cause this this.reportType = reportType; }
int GetUsesLeft(pAction action) { int actionUses = this.GetUseCount(action); if (actionParams[action].maxUses >= 0 && actionParams[action].maxUses < actionUses) { Debug.LogError("Player used action: " + action.ToString() + " " + actionUses.ToString() + " times when max was " + actionParams[action].maxUses.ToString()); } return(actionParams[action].maxUses <= 0 ? -1 : actionParams[action].maxUses - actionUses); //Calc uses left (-1 means unlimited) }
//Highlight public void ActionSelectButtonGrpHighlight(pAction action) { foreach (ActionSelectButton asb in this.lasb) { if (asb.action == action) { asb.Highlight(true); } else { asb.Highlight(false); } } }
//Buttons should either call this so we know what we're supposed to do when clicking on the grid or... public void SetActionContext(pAction action) { List <pAction> noTarget = new List <pAction> { pAction.hellFire, pAction.blockingShot, pAction.flare }; this.actionContext = action; this.pb2d.actionContext = this.actionContext; UIController.instance.ActionSelectButtonGrpHighlight(action); if (noTarget.Contains(action)) //No target for this action, just set it and move on with your life { switch (this.apc) { case ActionProcState.reject: case ActionProcState.multiTower: Debug.Log("APC Reject: Ignoring input from SetTargetlessAction"); break; case ActionProcState.basicActions: Debug.Log("Setting single action: " + action.ToString()); //Right now, all non targeted actions hit enemy, may need to change in the future ActionReq newAR = new ActionReq(this.report.playerId, this.report.enemyId, action, new Vector2[0]); if (this.v.Validate(newAR, this.report.latestPlayerGrid, this.report.latestEnemyGrid, new Vector2(pb2d.sizex, pb2d.sizey), this.report.latestCapitolLocs)) //TODO do we really need to validate here? { Debug.Log("Validated action: " + newAR.ToString()); this.queuedActions[1] = newAR; this.pb2d.SetActions(this.queuedActions); //clear old action selection UIController.instance.ActionDisplayUpdateAction(newAR); } else { Debug.Log("Bad action: " + newAR.ToString()); } break; default: Debug.LogError("SetActionContext unhandled actionprocstate: " + this.apc.ToString()); break; } } }
public void SetAction(pAction newAction) { this.action = newAction; this.updateButton(); }
pRules.Add(pAction.Rule);
public void SetActionCooldown(int playerId, pAction action, int cooldown) { this.pats[playerId].SetCooldown(action, cooldown); }
public bool HasUsesLeft(pAction action) { int usesLeft = this.GetUsesLeft(action); return(usesLeft != 0); // Less than zero we ignore, more than 0 means uses are left }
int GetUseCount(pAction action) { return(this.actionHistory.Count(a => a == action)); }