Exemple #1
0
        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);
            }
        }
Exemple #2
0
        new public static QuickSpellAction fromJSON(ObjectJSON json)
        {
            QuickSpellAction output = new QuickSpellAction();

            output.entityId     = json.getInt("entityId");
            output.spellId      = json.getString("spellId");
            output.targetCellId = json.getInt("targetCellId");
            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));
        }
    }
Exemple #4
0
        public static BuffData buildBuff(ObjectJSON buff)
        {
            BuffData output = new BuffData();

            output.id          = buff.getString("id");
            output.name        = buff.getString("name");
            output.iconPath    = buff.getString("iconPath");
            output.description = buff.getString("description");
            output.effects     = buildEffectBuffs(buff.getArrayJSON("effects"));
            return(output);
        }
Exemple #5
0
        public static CellData buildCellType(ObjectJSON cellType)
        {
            CellData output = new CellData();

            output.id               = cellType.getString("id");
            output.name             = cellType.getString("name");
            output.modelPath        = cellType.getString("modelPath");
            output.blockMovement    = cellType.getBool("blockMovement");
            output.blockLineOfSight = cellType.getBool("blockLineOfSight");
            return(output);
        }
Exemple #6
0
        public static MapData buildMap(ObjectJSON map)
        {
            MapData output = new MapData();

            output.id     = map.getString("id");
            output.name   = map.getString("name");
            output.width  = map.getInt("width");
            output.height = map.getInt("height");
            output.cells  = buildMapCells(map.getArrayJSON("cells"));
            output.spawns = buildMapSpawns(map.getArrayJSON("spawns"));
            output.buildCellDataIdList();
            return(output);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        public static EffectSpell buildEffectSpell(ObjectJSON effect)
        {
            EffectSpell output = new EffectSpell();

            output.affectAlly   = effect.getBoolArray("affectAlly");
            output.affectEnemy  = effect.getBoolArray("affectEnemy");
            output.affectSelf   = effect.getBoolArray("affectSelf");
            output.affectCell   = effect.getBoolArray("affectCell");
            output.minArea      = effect.getIntArray("minArea");
            output.maxArea      = effect.getIntArray("maxArea");
            output.areaType     = SpellData.stringToRangeAreaType(effect.getStringArray("areaType"));
            output.quickHandler = buildEffectHandler(effect.getObjectJSON("quickHandler"));
            output.slowHandler  = buildEffectHandler(effect.getObjectJSON("slowHandler"));
            output.conditions   = buildEffectConditions(effect.getArrayJSON("conditions"));
            return(output);
        }
Exemple #9
0
        public static Action fromJSON(ObjectJSON json)
        {
            switch (json.getString("class"))
            {
            case "QuickSpellAction":
                return(QuickSpellAction.fromJSON(json));

            case "MovementAction":
                return(MovementAction.fromJSON(json));

            case "SlowSpellAction":
                return(SlowSpellAction.fromJSON(json));

            default:
                return(null);
            }
        }
Exemple #10
0
        public static SpellData buildSpell(ObjectJSON spell)
        {
            SpellData output = new SpellData();

            output.id          = spell.getString("id");
            output.name        = spell.getString("name");
            output.iconPath    = spell.getString("iconPath");
            output.description = spell.getStringArray("description");
            output.cost        = spell.getIntArray("cost");
            output.cooldown    = spell.getIntArray("cooldown");
            output.minRange    = spell.getIntArray("minRange");
            output.maxRange    = spell.getIntArray("maxRange");
            output.rangeType   = SpellData.stringToRangeAreaType(spell.getStringArray("rangeType"));
            output.priority    = spell.getIntArray("priority");
            output.effects     = buildEffectSpells(spell.getArrayJSON("effects"));
            return(output);
        }
Exemple #11
0
        private void Start()
        {
            user = new User();
            try {
                ObjectJSON ID = ParserJSON.getObjectJSONFromAsset("ID");
                userId   = (ulong)ID.getLong("userId");
                userName = ID.getString("userName");
                Debug.Log("Using custom ID loaded from file.");
            } catch (Exception) {
                Debug.Log("Using default ID.");
            }
            user.userId   = userId;
            user.userName = userName;
            InitializeClient();

            // TEMP
            // TODO : REMOVE AND INJECT CLASSIC IDENTIFICATION ROUTINE

            /*GameLogicClient game = new GameLogicClient("M002");
             * game.gameId = 1;
             * game.currentTurn = 0;
             * user.currentGameId = game.gameId;
             * for (int i = 0; i < 2; i++) {
             *  ulong playerId = (ulong)i;
             *  int cellId = DataManager.MAP_DATA["M002"].getSpawns(2)[i];
             *  int entityId = i;
             *  string displayedName = "Player " + i;
             *  float r = 255;
             *  float g = 255 * i;
             *  float b = 255 - 255 * i;
             *
             *  Player temp = CreatePlayer(playerId, cellId, entityId, displayedName, r, g, b);
             *  if (user.userId == playerId) {
             *      user.player = temp;
             *  }
             *  temp.playerEntity.initSpell(new string[4] { "S001", "S002", "S003", "S004" });
             *  temp.playerEntity.teamId = i;
             * }
             * GUIManager.gui.linkWithLocalEntity(game.localEntity);
             * GameLogicClient.game.prepareNewTurn(DateTime.UtcNow.AddSeconds(5).ToFileTimeUtc());*/
            // END TODO : REMOVE
        }
Exemple #12
0
        public static EffectBuff buildEffectBuff(ObjectJSON effect)
        {
            EffectBuff output = new EffectBuff();

            output.affectAlly         = effect.getBool("affectAlly");
            output.affectEnemy        = effect.getBool("affectEnemy");
            output.affectSelf         = effect.getBool("affectSelf");
            output.affectCell         = effect.getBool("affectCell");
            output.minArea            = effect.getInt("minArea", 0);
            output.maxArea            = effect.getInt("maxArea", 0);
            output.areaType           = SpellData.stringToRangeAreaType(effect.getString("areaType", ""));
            output.onGainedHandler    = buildEffectHandler(effect.getObjectJSON("onGainedHandler"));
            output.onLostHandler      = buildEffectHandler(effect.getObjectJSON("onLostHandler"));
            output.onDamageHandler    = buildEffectHandler(effect.getObjectJSON("onDamageHandler"));
            output.onHealHandler      = buildEffectHandler(effect.getObjectJSON("onHealHandler"));
            output.onSpellHandler     = buildEffectHandler(effect.getObjectJSON("onSpellHandler"));
            output.onBuffedHandler    = buildEffectHandler(effect.getObjectJSON("onBuffedHandler"));
            output.onEnterHandler     = buildEffectHandler(effect.getObjectJSON("onEnterHandler"));
            output.onLeaveHandler     = buildEffectHandler(effect.getObjectJSON("onLeaveHandler"));
            output.onTurnStartHandler = buildEffectHandler(effect.getObjectJSON("onTurnStartHandler"));
            output.onTurnEndHandler   = buildEffectHandler(effect.getObjectJSON("onTurnEndHandler"));
            output.conditions         = buildEffectConditions(effect.getArrayJSON("conditions"));
            return(output);
        }
Exemple #13
0
        public static EffectHandler buildEffectHandler(ObjectJSON effectHandler)
        {
            EffectHandler output;

            if (effectHandler != null && effectHandler.containsValue("class"))   // should always contain it
            {
                string className = effectHandler.getString("class");
                if (className == "EffectHandlerDirectDamage")
                {
                    output = new EffectHandlerDirectDamage();
                    ((EffectHandlerDirectDamage)output).damage = effectHandler.getInt("damage");
                }
                else if (className == "EffectHandlerIndirectDamage")
                {
                    output = new EffectHandlerIndirectDamage();
                    ((EffectHandlerIndirectDamage)output).damage = effectHandler.getInt("damage");
                }
                else if (className == "EffectHandlerHeal")
                {
                    output = new EffectHandlerHeal();
                    ((EffectHandlerHeal)output).heal = effectHandler.getInt("heal");
                }
                else if (className == "EffectHandlerBuff")
                {
                    output = new EffectHandlerBuff();
                    ((EffectHandlerBuff)output).buffId   = effectHandler.getString("buffId");
                    ((EffectHandlerBuff)output).duration = effectHandler.getInt("duration");
                }
                else if (className == "EffectHandlerModMP")
                {
                    output = new EffectHandlerModMP();
                    ((EffectHandlerModMP)output).MP        = effectHandler.getInt("MP");
                    ((EffectHandlerModMP)output).direction = effectHandler.getInt("direction");
                }
                else if (className == "EffectHandlerModAP")
                {
                    output = new EffectHandlerModAP();
                    ((EffectHandlerModAP)output).AP        = effectHandler.getInt("AP");
                    ((EffectHandlerModAP)output).direction = effectHandler.getInt("direction");
                }
                else if (className == "EffectHandlerModRange")
                {
                    output = new EffectHandlerModRange();
                    ((EffectHandlerModRange)output).range = effectHandler.getInt("range");
                }
                else if (className == "EffectHandlerStun")
                {
                    output = new EffectHandlerStun();
                }
                else if (className == "EffectHandlerUnstun")
                {
                    output = new EffectHandlerUnstun();
                }
                else if (className == "EffectHandlerPush")
                {
                    output = new EffectHandlerPush();
                    ((EffectHandlerPush)output).distance = effectHandler.getInt("distance");
                }
                else if (className == "EffectHandlerPull")
                {
                    output = new EffectHandlerPull();
                    ((EffectHandlerPull)output).distance = effectHandler.getInt("distance");
                }
                else if (className == "EffectHandlerDash")
                {
                    output = new EffectHandlerDash();
                }
                else if (className == "EffectHandlerWarp")
                {
                    output = new EffectHandlerWarp();
                }
                else
                {
                    output = null;
                }
                return(output);
            }
            else
            {
                return(null);
            }
        }
Exemple #14
0
        public static EffectCondition buildEffectCondition(ObjectJSON condition)
        {
            EffectCondition output;

            if (condition != null && condition.containsValue("class"))   // should always contain it
            {
                string className = condition.getString("class");
                if (className == "EffectConditionTurnNumberAbove")
                {
                    output = new EffectConditionTurnNumberAbove();
                    ((EffectConditionTurnNumberAbove)output).turnNumber = condition.getInt("turnNumber");
                }
                else if (className == "EffectConditionTurnNumberBelow")
                {
                    output = new EffectConditionTurnNumberBelow();
                    ((EffectConditionTurnNumberBelow)output).turnNumber = condition.getInt("turnNumber");
                }
                else if (className == "EffectConditionHealthAbove")
                {
                    output = new EffectConditionHealthAbove();
                    ((EffectConditionHealthAbove)output).target  = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionHealthAbove)output).health  = condition.getInt("health");
                    ((EffectConditionHealthAbove)output).percent = condition.getBool("percent");
                }
                else if (className == "EffectConditionHealthBelow")
                {
                    output = new EffectConditionHealthBelow();
                    ((EffectConditionHealthBelow)output).target  = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionHealthBelow)output).health  = condition.getInt("health");
                    ((EffectConditionHealthBelow)output).percent = condition.getBool("percent");
                }
                else if (className == "EffectConditionAPAbove")
                {
                    output = new EffectConditionAPAbove();
                    ((EffectConditionAPAbove)output).target  = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionAPAbove)output).AP      = condition.getInt("AP");
                    ((EffectConditionAPAbove)output).percent = condition.getBool("percent");
                }
                else if (className == "EffectConditionAPBelow")
                {
                    output = new EffectConditionAPBelow();
                    ((EffectConditionAPBelow)output).target  = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionAPBelow)output).AP      = condition.getInt("AP");
                    ((EffectConditionAPBelow)output).percent = condition.getBool("percent");
                }
                else if (className == "EffectConditionMPAbove")
                {
                    output = new EffectConditionMPAbove();
                    ((EffectConditionMPAbove)output).target  = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionMPAbove)output).MP      = condition.getInt("MP");
                    ((EffectConditionMPAbove)output).percent = condition.getBool("percent");
                }
                else if (className == "EffectConditionMPBelow")
                {
                    output = new EffectConditionMPBelow();
                    ((EffectConditionMPBelow)output).target  = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionMPBelow)output).MP      = condition.getInt("MP");
                    ((EffectConditionMPBelow)output).percent = condition.getBool("percent");
                }
                else if (className == "EffectConditionHasBuff")
                {
                    output = new EffectConditionHasBuff();
                    ((EffectConditionHasBuff)output).target = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionHasBuff)output).buffId = condition.getString("buffId");
                }
                else if (className == "EffectConditionHasNotBuff")
                {
                    output = new EffectConditionHasNotBuff();
                    ((EffectConditionHasNotBuff)output).target = EffectConditionTarget.stringToConditionTarget(condition.getString("target"));
                    ((EffectConditionHasNotBuff)output).buffId = condition.getString("buffId");
                }
                else
                {
                    output = null;
                }
                return(output);
            }
            else
            {
                return(null);
            }
        }
Exemple #15
0
        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);
                }
            }
        }