示例#1
0
    public unitStats LoadActor(string line)
    {
        //  Debug.Log("Loading actor\n");
        JSONObject pname    = new JSONObject();
        JSONObject pcost    = new JSONObject();
        JSONObject ptoytype = new JSONObject();
        //JSONObject pcost_runetype = new JSONObject ();
        JSONObject prune_type     = new JSONObject();
        JSONObject pcost_wishtype = new JSONObject();
        JSONParser p = new JSONParser(line);

        JSONObject ppermanent = new JSONObject();
        JSONObject pammo      = new JSONObject();
        JSONObject inv        = new JSONObject();



        JSONObject pmax_lvl          = new JSONObject();
        JSONObject exclude_skills    = new JSONObject();
        JSONObject required_building = new JSONObject();

        p.parse();
        p.root.TryGetValue("name", out pname);

        p.root.TryGetValue("cost", out pcost);

        p.root.TryGetValue("toy_type", out ptoytype);
        p.root.TryGetValue("rune_type", out prune_type);
        p.root.TryGetValue("cost_wishtype", out pcost_wishtype);
        p.root.TryGetValue("max_lvl", out pmax_lvl);


        p.root.TryGetValue("ammo", out pammo);
        p.root.TryGetValue("inventory", out inv);



        p.root.TryGetValue("islandtype", out ppermanent);
        p.root.TryGetValue("exclude_skills", out exclude_skills);
        p.root.TryGetValue("required_building", out required_building);
        unitStats test = Central.Instance.getToy(pname.value);


        if (test != null)
        {
            if (pmax_lvl != null)
            {
                test.setMaxLvl(int.Parse(pmax_lvl.value));
            }

            //    Debug.Log("Loading actor again\n");
            //thing has already been defined in a previous level. do not load most stats again

            return(test);
        }
        else
        {
            int cost = int.Parse(pcost.value);



            unitStats stats = new unitStats(pname.value);

            if (pmax_lvl != null)
            {
                stats.setMaxLvl(int.Parse(pmax_lvl.value));
            }
            stats.isUnlocked = false;
            RuneType rune_type = (prune_type != null) ? EnumUtil.EnumFromString(prune_type.value, RuneType.Null) : RuneType.Null;
            ToyType  toy_type  = (ptoytype != null) ? EnumUtil.EnumFromString(ptoytype.value, ToyType.Null) : ToyType.Null;
            //WishType wish_type = WishType.Null;
            CostType cost_type = CostType.Dreams;

            stats.toy_id.toy_type  = toy_type;
            stats.toy_id.rune_type = rune_type;



            cost_type = TowerStore.costType(rune_type, toy_type);

            //if (pcost_wishtype != null) wish_type = Get.WishTypeFromString(pcost_wishtype.value);
            if (required_building != null)
            {
                stats.required_building = (required_building.value);
            }
            stats.setCost(cost_type, cost);


            stats.island_type = ppermanent != null?EnumUtil.EnumFromString(ppermanent.value, IslandType.Permanent) : IslandType.Permanent;


            if (pammo != null)
            {
                stats.ammo = int.Parse(pammo.value);
            }
            Central.Instance.setUnitStats(stats, false);
            return(stats);
        }
    }
示例#2
0
    public static unitStats getBasicStats(RuneType runetype, ToyType toytype)

    {
        unitStats stats = null;

        switch (runetype)
        {
        case RuneType.Sensible:
            if (toytype != ToyType.Hero)
            {
                stats = new unitStats("sensible_tower", runetype, toytype);
                stats.setCost(costType(runetype, toytype), 40);
            }
            else
            {
                stats = new unitStats("sensible_tower_hero", runetype, toytype);
                stats.setCost(costType(runetype, toytype), 1);
            }
            stats.island_type = IslandType.Permanent;

            break;


        case RuneType.Airy:
            if (toytype != ToyType.Hero)
            {
                stats = new unitStats("airy_tower", runetype, toytype);
                stats.setCost(costType(runetype, toytype), 30);
            }
            else
            {
                stats = new unitStats("airy_tower_hero", runetype, toytype);
                stats.setCost(costType(runetype, toytype), 1);
            }
            stats.island_type = IslandType.Permanent;
            break;

        case RuneType.Vexing:
            if (toytype != ToyType.Hero)
            {
                stats = new unitStats("vexing_tower", runetype, toytype);
                stats.setCost(costType(runetype, toytype), 50);
            }
            else
            {
                stats = new unitStats("vexing_tower_hero", runetype, toytype);
                stats.setCost(costType(runetype, toytype), 1);
            }
            stats.island_type = IslandType.Permanent;
            break;

        case RuneType.Castle:
            stats = new unitStats("castle", runetype, toytype);
            stats.setCost(costType(runetype, toytype), 9999);
            stats.island_type = IslandType.Permanent;
            break;

        case RuneType.SensibleCity:
            stats = new unitStats("sensible_city", runetype, toytype);
            stats.setCost(costType(runetype, toytype), 20);
            stats.island_type = IslandType.Permanent;
            break;

        case RuneType.Modulator:
            stats = new unitStats("modulator", runetype, toytype);
            stats.setCost(costType(runetype, toytype), 5);
            stats.island_type = IslandType.Either;
            break;

        case RuneType.Fast:
            stats = new unitStats("sensible_tower_ghost", runetype, toytype);
            stats.setCost(costType(runetype, toytype), 2);
            stats.island_type       = IslandType.Temporary;
            stats.required_building = "sensible_city";
            stats.ammo = 5;
            break;

        case RuneType.Slow:
            stats = new unitStats("slow_ghost", runetype, toytype);
            stats.setCost(costType(runetype, toytype), 2);
            stats.island_type       = IslandType.Temporary;
            stats.required_building = "sensible_city";
            stats.ammo = 5;
            break;

        case RuneType.Time:
            stats = new unitStats("time_ghost", runetype, toytype);
            stats.setCost(costType(runetype, toytype), 2);
            stats.island_type       = IslandType.Temporary;
            stats.required_building = "sensible_city";
            stats.ammo = 5;
            break;
        }
        stats.isUnlocked = false;

        /*
         *
         * { "name":"castle", "toy_type": "hero", "cost":"9999", "scale":{ "x":"2","z":"2"},"rune_type":"Castle"}
         * { "name":"sensible_city", "toy_type": "normal", "cost":"20", "scale":{ "x":"2","z":"2"},"rune_type":"SensibleCity"}
         * { "name":"sensible_tower",      "toy_type": "normal",   "cost":"40", "rune_type":"Sensible"}
         * { "name":"airy_tower",          "toy_type": "normal",   "cost":"30", "rune_type":"Airy"}
         * { "name":"vexing_tower",        "toy_type": "normal",   "cost":"50", "rune_type":"Vexing"}
         * { "name":"sensible_tower_hero", "toy_type": "hero",     "cost":"1", "rune_type":"Sensible"}
         * { "name":"airy_tower_hero",     "toy_type": "hero",     "cost":"1","rune_type":"Airy"}
         * { "name":"vexing_tower_hero",   "toy_type": "hero",     "cost":"1","rune_type":"Vexing"}
         * { "name":"sensible_tower_ghost","toy_type": "temporary","cost":"2","ammo":"5", "required_building":"sensible_city","islandtype":"temporary","rune_type":"Fast"}
         * { "name":"slow_ghost",          "toy_type": "temporary","cost":"2","ammo":"5", "required_building":"sensible_city","islandtype":"temporary","rune_type":"Slow"}
         * { "name":"time_ghost",          "toy_type": "temporary","cost":"2","ammo":"5","required_building":"sensible_city","islandtype":"temporary","rune_type":"Duration"}
         * { "name":"modulator",           "toy_type": "normal"   ,"cost":"5","islandtype":"either","rune_type":"Modulator"}
         */

        return(stats);
    }