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) }
//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; } } }