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); } }
void onEnemyWIS(SocketIOEvent obj) { Debug.Log("enemy WIS"); //HEAL ENEMY ArrayJSON wis_arr = ArrayJSON.createFromJson(obj.data.ToString()); Debug.Log("Enemy heal wizard: " + wis_arr.wizard_index + " with heal: " + wis_arr.heal_point); wizardOfPlayer2Test [wis_arr.wizard_index] += wis_arr.heal_point; }
public static EffectBuff[] buildEffectBuffs(ArrayJSON effects) { EffectBuff[] output = new EffectBuff[effects.Length]; for (int i = 0; i < effects.Length; i++) { output[i] = buildEffectBuff((ObjectJSON)effects[i]); } return(output); }
public static SpellData[] buildSpells(ArrayJSON array) { SpellData[] output = new SpellData[array.Length]; for (int i = 0; i < array.Length; i++) { output[i] = buildSpell(array.getObjectJSONAt(i)); } return(output); }
public static CellData[] buildCellTypes(ArrayJSON array) { CellData[] output = new CellData[array.Length]; for (int i = 0; i < array.Length; i++) { output[i] = buildCellType(array.getObjectJSONAt(i)); } return(output); }
public static BuffData[] buildBuffs(ArrayJSON array) { BuffData[] output = new BuffData[array.Length]; for (int i = 0; i < array.Length; i++) { output[i] = buildBuff(array.getObjectJSONAt(i)); } return(output); }
public static int[] buildMapSpawns(ArrayJSON array) { int[] output = new int[array.Length]; for (int i = 0; i < array.Length; i++) { output[i] = int.Parse(array.getStringAt(i)); } return(output); }
public static CellData[] buildMapCells(ArrayJSON array) { CellData[] output = new CellData[array.Length]; for (int i = 0; i < array.Length; i++) { output[i] = DataManager.CELL_DATA[array.getStringAt(i)]; } return(output); }
public static MapData[] buildMaps(ArrayJSON array) { MapData[] output = new MapData[array.Length]; for (int i = 0; i < array.Length; i++) { output[i] = buildMap(array.getObjectJSONAt(i)); } return(output); }
public void SetLoadoutJSON(string json) { ObjectJSON obj = new ObjectJSON(json); ArrayJSON array = obj.getArrayJSON("spells"); for (int i = 0; i < array.Length; i++) { SetSpell(i, array.getStringAt(i)); } }
void onEnemyINT(SocketIOEvent obj) { Debug.Log("enemy INT"); //INT FROM ENEMY ArrayJSON int_arr = ArrayJSON.createFromJson(obj.data.ToString()); for (int i = 0; i < int_arr.int_arr.Length; i++) { Debug.Log("Enemy int_arr: " + int_arr.int_arr[i]); wizardArr [i].GetComponent <WitchController>().curHR -= int_arr.int_arr [i]; } }
public static EffectCondition[] buildEffectConditions(ArrayJSON conditions) { if (conditions != null) { EffectCondition[] output = new EffectCondition[conditions.Length]; for (int i = 0; i < conditions.Length; i++) { output[i] = buildEffectCondition(conditions.getObjectJSONAt(i)); } return(output); } return(new EffectCondition[0]); }
public static EffectSpell[] buildEffectSpells(ArrayJSON effects) { if (effects != null) { EffectSpell[] output = new EffectSpell[effects.Length]; for (int i = 0; i < effects.Length; i++) { output[i] = buildEffectSpell(effects.getObjectJSONAt(i)); } return(output); } return(new EffectSpell[0]); }
void onEnemyATK(SocketIOEvent obj) { Debug.Log("enemy ATK"); //ATK FROM ENEMY ArrayJSON atk_arr = ArrayJSON.createFromJson(obj.data.ToString()); for (int i = 0; i < atk_arr.atk_arr.Length; i++) { Debug.Log("Enemy atk_arr: " + atk_arr.atk_arr[i]); wizardArr [i].GetComponent <WitchController>().curHR -= atk_arr.atk_arr [i]; } }
new public static MovementAction fromJSON(ObjectJSON json) { MovementAction output = new MovementAction(); output.entityId = json.getInt("entityId"); ArrayJSON path = json.getArrayJSON("path"); output.path = new int[path.Length]; for (int i = 0; i < path.Length; i++) { output.path[i] = path.getIntAt(i); } return(output); }
void onTimerToFight(SocketIOEvent obj) { // Debug.Log (obj.data.ToString ()); ArrayJSON timeJSON = ArrayJSON.createFromJson(obj.data.ToString()); timerToFight = float.Parse(obj.data.GetField("time").ToString()); Debug.Log("Timer: " + timerToFight); if (timerToFight == 0) { startRitualPhase(); timerToFight_text.enabled = false; // timerToFight = -1; } timerToFight_text.text = "Time Left: " + (int)timerToFight; }
void onStartFightPhase(SocketIOEvent obj) { isFightPhase = true; ArrayJSON wizardJSON = ArrayJSON.createFromJson(obj.data.ToString()); // wizardOfPlayer2Test = new float[int.Parse(JsonToString(obj.data.GetField("numb_wizard").ToString(), "\""))]; wizardOfPlayer2Test = new float[wizardJSON.hp_wizard.Length]; Debug.Log("wizardOfPlayer2Test length: " + wizardOfPlayer2Test.Length); for (int i = 0; i < wizardJSON.hp_wizard.Length; i++) { Debug.Log("Enemy wizard " + i + " HP: " + wizardJSON.hp_wizard [i]); wizardOfPlayer2Test [i] = wizardJSON.hp_wizard [i]; } addWizardForPlayer2(); }
public static ArrayJSON createFromJson(string json) { ArrayJSON info = JsonUtility.FromJson <ArrayJSON>(json); return(info); }
public static void loadDataJSON() { ObjectJSON data = ParserJSON.getObjectJSONFromAsset("DATA"); ArrayJSON buffs = data.getArrayJSON("buffs"); ArrayJSON spells = data.getArrayJSON("spells"); ArrayJSON cellTypes = data.getArrayJSON("cellTypes"); ArrayJSON maps = data.getArrayJSON("maps"); // parse and save data foreach (SpellData s in buildSpells(spells)) { if (s != null) { DataManager.registerData(s.id, s); } } foreach (BuffData b in buildBuffs(buffs)) { if (b != null) { DataManager.registerData(b.id, b); } } foreach (CellData ct in buildCellTypes(cellTypes)) { if (ct != null) { DataManager.registerData(ct.id, ct); } } foreach (MapData m in buildMaps(maps)) { if (m != null) { DataManager.registerData(m.id, m); } } // fill description macro foreach (SpellData s in DataManager.SPELL_DATA.Values) { for (int i = 0; i < 2; i++) { string macro = StringParsingTool.getNextMacro(s.description[i]); while (macro != "") { s.description[i] = s.description[0].Replace(macro, getMacroContent(StringParsingTool.getBetweenMacro(macro))); macro = StringParsingTool.getNextMacro(s.description[i]); } } } foreach (BuffData b in DataManager.BUFF_DATA.Values) { string macro = StringParsingTool.getNextMacro(b.description); while (macro != "") { b.description = b.description.Replace(macro, getMacroContent(StringParsingTool.getBetweenMacro(macro))); macro = StringParsingTool.getNextMacro(b.description); } } }