public virtual void receiveActions(string actions) { ObjectJSON actionsJSON = new ObjectJSON(actions); ArrayJSON actions0JSON = actionsJSON.getArrayJSON("actions0"); for (int i = 0; i < actions0JSON.Length; i++) { ObjectJSON actionJSON = actions0JSON.getObjectJSONAt(i); Data.Action action = Data.Action.fromJSON(actionJSON); actions0.Add(action); } ArrayJSON actions1JSON = actionsJSON.getArrayJSON("actions1"); for (int i = 0; i < actions1JSON.Length; i++) { ObjectJSON actionJSON = actions1JSON.getObjectJSONAt(i); Data.Action action = Data.Action.fromJSON(actionJSON); actions1.Add(action); } ArrayJSON actions2JSON = actionsJSON.getArrayJSON("actions2"); for (int i = 0; i < actions2JSON.Length; i++) { ObjectJSON actionJSON = actions2JSON.getObjectJSONAt(i); Data.Action action = Data.Action.fromJSON(actionJSON); actions2.Add(action); } }
public float resolveAction(Data.Action action) { Entity e; if (!entityList.TryGetValue(action.entityId, out e)) { Debug.LogError("resolveAction() - can't find entity with id " + action.entityId); } if (action is MovementAction) { if (!action.isActionSkiped()) { MovementAction movementAction = (MovementAction)action; solver.resolveMovement(e, movementAction.path); return(movementAction.path.Length * 0.2f); } // TODO else give MP } else if (action is SpellAction) { if (!action.isActionSkiped()) { SpellAction spellAction = (SpellAction)action; Cell target = grid.GetCell(spellAction.targetCellId); SpellData spell = DataManager.SPELL_DATA[spellAction.spellId]; solver.resolveSpell(spell, e, target, spellAction is QuickSpellAction); return(0.5f); } // TODO else give AP } return(0); }
private void registerMovementAction(List <Cell> path) { MovementAction newAction = new MovementAction(); newAction.path = new int[path.Count]; for (int i = 0; i < path.Count; i++) { newAction.path[i] = path[i].cellId; } currentAction = newAction; currentAction.entityId = localEntity.entityId; //resolveAction(currentAction); // add to local actions localActions.Enqueue(currentAction); }
public string actionListToArrayJSON(List <Data.Action> actions) { if (actions.Count == 0) { return("[]"); } string output = ""; Data.Action last = actions.Last(); foreach (Data.Action action in actions) { output += action.toJSON(); if (action != last) { output += ","; } } return("[" + output + "]"); }
public override string generateTurnActionsJSON() { string output = ""; for (int i = 0; i < 3; i++) { output += "\"actions" + i + "\":" + "["; if (localActions.Count > 0) { Data.Action action = localActions.Dequeue(); output += action.toJSON(); } output += "]"; if (i < 2) { output += ","; } } Debug.Log(output); return("{" + output + "}"); }
private void registerSpellAction(string spellId, Cell target) { if (isQuickSpelling) { QuickSpellAction newAction = new QuickSpellAction(); newAction.spellId = spellId; newAction.targetCellId = target.cellId; currentAction = newAction; } else if (isSlowSpelling) { SlowSpellAction newAction = new SlowSpellAction(); newAction.spellId = spellId; newAction.targetCellId = target.cellId; currentAction = newAction; } currentAction.entityId = localEntity.entityId; //resolveAction(currentAction); // add to local actions localActions.Enqueue(currentAction); }