コード例 #1
0
 public void SetSpawnInfo(int inSpawnRate, int inSpawnMinLvl, int inSpawnMaxLvl, AdventureArea inAreas)
 {
     _spawnRate     = inSpawnRate;
     _spawnMinLevel = inSpawnMinLvl;
     _spawnMaxLevel = inSpawnMaxLvl;
     _spawnAreas    = inAreas;
 }
コード例 #2
0
    public static List <Item> GetItemsForArea(AdventureArea inAdventureArea)
    {
        //SIMPLIFIED: since we only create a few items for testing purposes, return all of them instead of trying to only find ones for a specified area
        return(itemCollectionList.ToList());

        //validItems = itemCollectionList.Where(e => e.CanSpawnInArea(inAdventureArea));
        //return validItems.ToList();
    }
コード例 #3
0
    private void SetAreas(string[] inAreaIds)
    {
        areas = new List <AdventureArea>();
        string enumVal;

        for (int i = 0; i < inAreaIds.Length; i++)
        {
            enumVal = inAreaIds[i].ToUpper();
            AdventureArea parsedArea = (AdventureArea)Enum.Parse(typeof(AdventureArea), enumVal);
            areas.Add(parsedArea);
        }

        numBattlesUntilFullLoop = areas.Count * battlesPerArea;
    }
コード例 #4
0
    public static List <EnemyCharacterData> GetEnemiesForArea(AdventureArea inArea)
    {
        List <EnemyCharacterData> enemiesForArea = new List <EnemyCharacterData>();

        for (int i = 0; i < enemyCollectionList.Count; i++)
        {
            if (enemyCollectionList[i].SpawnsInArea(inArea) && !enemyCollectionList[i].isOre)
            {
                enemiesForArea.Add(enemyCollectionList[i]);
            }
        }

        return(enemiesForArea);
    }
コード例 #5
0
 public bool CanSpawnInArea(AdventureArea inArea)
 {
     return((spawnRate > 0) && (spawnAreas & inArea) == inArea);
 }
コード例 #6
0
    public static void CreateItems()
    {
        items = new Dictionary <string, Item>();

        //use this line to load from a json file
        //ItemMap map = Utils.LoadJsonFromPath<ItemMap>("data/item_data");

        /*
         *      {"id":"3:wooden_sword",                                              "type":"WEAPON",         "stats" : ["atk=2", "crit_chance=1","crit_bonus=10"],                                                           "spawn_rate":"15",        "min_spawn_lvl":"5",          "max_spawn_lvl":"0",          "area":"CAVERNS",                                         "attached_skill_ids":"",                                                                        "season":"ALL",                  "slots": [],                           "flags":"",                                               "explicit_rarity":"",                   "explicit_value":0},
         *      {"id":"4:buckler",                                                   "type":"SHIELD",         "stats" : ["hp=2"],                                                                                             "spawn_rate":"15",        "min_spawn_lvl":"5",          "max_spawn_lvl":"0",          "area":"CAVERNS",                                         "attached_skill_ids":"",                                                                        "season":"ALL",                  "slots": [],                           "flags":"",                                               "explicit_rarity":"",                   "explicit_value":0},
         *      {"id":"5:leather_armor",                                             "type":"ARMOR",          "stats" : ["hp=1"],                                                                                             "spawn_rate":"20",        "min_spawn_lvl":"5",          "max_spawn_lvl":"0",          "area":"CAVERNS",                                         "attached_skill_ids":"",                                                                        "season":"ALL",                  "slots": [],                           "flags":"",                                               "explicit_rarity":"",                   "explicit_value":0},
         *
         */

        //instead, create the data manually
        var woodenSwordData = new ItemRow()
        {
            id = "3:" + ItemId.WOODEN_SWORD, type = "WEAPON", stats = new string[] { "atk=2", "crit_chance=1", "crit_bonus=10" }, spawn_rate = 15, min_spawn_lvl = 5, max_spawn_lvl = 0, area = "CAVERNS", attached_skill_ids = "", slots = new string[] { }, flags = ""
        };
        var woodenShieldData = new ItemRow()
        {
            id = "4:" + ItemId.BUCKLER, type = "SHIELD", stats = new string[] { "hp=2" }, spawn_rate = 15, min_spawn_lvl = 5, max_spawn_lvl = 0, area = "CAVERNS", attached_skill_ids = "", slots = new string[] { }, flags = ""
        };
        var leatherArmorData = new ItemRow()
        {
            id = "5:" + ItemId.LEATHER_ARMOR, type = "ARMOR", stats = new string[] { "hp=1" }, spawn_rate = 20, min_spawn_lvl = 5, max_spawn_lvl = 0, area = "CAVERNS", attached_skill_ids = "", slots = new string[] { }, flags = ""
        };
        var peltData = new ItemRow()
        {
            id = "6:" + ItemId.PELT, type = "RESOURCE", stats = new string[] { }, spawn_rate = 0, min_spawn_lvl = 0, max_spawn_lvl = 0, area = "CAVERNS", attached_skill_ids = "", slots = new string[] { }, flags = ""
        };

        ItemMap map = new ItemMap();

        map.items = new ItemRow[] { woodenSwordData, woodenShieldData, leatherArmorData, peltData };

        ItemRow row;
        Item    tempItem;

        string[] idPieces;
        string   id;

        for (int i = 0; i < map.items.Length; i++)
        {
            row = map.items[i];

            //item ids are provied in a number:name format. the name is only present in the data file for readability, so we need to discard it
            idPieces = row.id.Split(':');
            id       = idPieces[0];

            if (!ItemId.IsValid(id))
            {
                throw new Exception("Item id '" + row.id + "' does not exist");
            }

            tempItem = new Item();
            tempItem.Init();

            tempItem.SetId(id);
            tempItem.DeriveBaseAndStorageId();
            ItemType parsedType = (ItemType)Enum.Parse(typeof(ItemType), row.type);
            tempItem.SetType(parsedType);

            Stats.ParseArrayIntoStatObject(row.stats, tempItem.baseStats);

            AdventureArea parsedAreas = Utils.ParseStringToFlagEnum <AdventureArea>(row.area, '|');
            tempItem.SetSpawnInfo(row.spawn_rate, row.min_spawn_lvl, row.max_spawn_lvl, parsedAreas);

            if (string.IsNullOrEmpty(row.explicit_rarity))
            {
                tempItem.DeriveRarity();
            }
            else
            {
                tempItem._rarity = (Rarity)Enum.Parse(typeof(Rarity), row.explicit_rarity);
            }

            char[] separators = new char[',']; //must define a separator array so that we can pass in the stringsplit option param
            tempItem.attachedSkillIds = row.attached_skill_ids.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            string curId;
            for (int j = 0; j < tempItem.attachedSkillIds.Length; j++)
            {
                curId = tempItem.attachedSkillIds[j];
                if (!SkillId.IsValid(curId))
                {
                    throw new Exception(curId + " is not a valid skill id to attach to an item");
                }
            }

            int numSlots = row.slots.Length;
            tempItem.slotPositions = new Vector2[numSlots];
            string[] coords;
            for (int j = 0; j < numSlots; j++)
            {
                coords = row.slots[j].Split(',');
                tempItem.slotPositions[j] = new Vector2(float.Parse(coords[0]), float.Parse(coords[1]));
            }

            tempItem.flags = Utils.ParseStringToFlagEnum <ItemFlags>(row.flags, ',');

            if (row.explicit_value == 0)
            {
                tempItem.CalculateValue();
            }
            else
            {
                tempItem.value = row.explicit_value;
            }


            items.Add(tempItem.id, tempItem);
        }

        //record the number of un-leveled items
        numBasicItemsInGame = items.Count;

        //create leveled items
        itemLevelBoosts = new Stats();
        itemLevelBoosts.Set(Stat.hp, 3);
        itemLevelBoosts.Set(Stat.mp, 4);
        itemLevelBoosts.Set(Stat.atk, 2);
        itemLevelBoosts.Set(Stat.crit_chance, 1);
        itemLevelBoosts.Set(Stat.crit_bonus, 1);
        itemLevelBoosts.Set(Stat.dmg_reduction, 1);
        itemLevelBoosts.Set(Stat.evade, 1);
        itemLevelBoosts.Set(Stat.gold_find, 3);
        itemLevelBoosts.Set(Stat.item_find, 2);
        itemLevelBoosts.Set(Stat.magic_boost, 2);
        itemLevelBoosts.Set(Stat.phys_boost, 2);
        itemLevelBoosts.Set(Stat.hp_boost, 1);
        itemLevelBoosts.Set(Stat.mp_boost, 1);
        itemLevelBoosts.Set(Stat.atk_boost, 1);
        itemLevelBoosts.Set(Stat.dmg_reflection, 2);
        itemLevelBoosts.Set(Stat.mastery_xp_boost, 2);

        itemTypesThatLevelUp = ItemType.WEAPON | ItemType.ARMOR | ItemType.SHIELD;
        List <Item> existingItems = items.Values.ToList();
        Item        newItem;
        int         spawnRange = 100;

        for (int i = 0; i < existingItems.Count; i++)
        {
            tempItem = existingItems[i];

            if (tempItem.IsTypeThatLevelsUp())
            {
                //TODO manually exclude some stuff from leveling up
                if (tempItem.id == ItemId.APHOTIC_BLADE || tempItem.id == ItemId.MOP || tempItem.id == ItemId.IRON_SKILLET)
                {
                    continue;
                }

                //force all items to have a max spawn level of min + 100
                tempItem._spawnMaxLevel = tempItem.spawnMinLevel + spawnRange;

                //right now just levels 2 to the "max"
                for (int j = 2; j <= GameContext.MAX_ITEM_LEVEL_WITHOUT_ENHANCING; j++)
                {
                    newItem = tempItem.GetCopy();
                    newItem.BoostItemToLevel(j);
                    items.Add(newItem.id, newItem);

                    //once item is level 5 or higher it can ALWAYS spawn, otherwise limit it
                    if (j > 4)
                    {
                        newItem._spawnMaxLevel = 0;
                    }
                    else
                    {
                        newItem._spawnMaxLevel = newItem.spawnMinLevel + spawnRange;
                    }
                }
            }
        }

        //copy ALL items into a parallel list for convenience
        itemCollectionList = items.Values.ToList();

        //create specialized lists
        foodItemIds = new List <string>()
        {
            ItemId.APPLE, ItemId.BACON, ItemId.CARROT, ItemId.CARAMEL, ItemId.EGGPLANT, ItemId.MUSHROOM, ItemId.RADISH
        };



        //build this dict to make status effect prevention checks much faster
        statusEffectToPreventionFlagMap = new Dictionary <StatusEffectType, ItemFlags>();
        statusEffectToPreventionFlagMap[StatusEffectType.BURN]       = ItemFlags.PREVENTS_BURN;
        statusEffectToPreventionFlagMap[StatusEffectType.STONE]      = ItemFlags.PREVENTS_STONE;
        statusEffectToPreventionFlagMap[StatusEffectType.SPEED_DOWN] = ItemFlags.PREVENTS_SPEED_DOWN;
        statusEffectToPreventionFlagMap[StatusEffectType.SLEEP]      = ItemFlags.PREVENTS_SLEEP;
    }
コード例 #7
0
 public static string GetLocalizedName(this AdventureArea source)
 {
     return(Locale.Get("AREA_" + source.ToString() + "_NAME"));
 }
コード例 #8
0
 public static string GetMusicIdForArea(AdventureArea inArea)
 {
     return(areaMusicIds[inArea]);
 }
コード例 #9
0
 public bool SpawnsInArea(AdventureArea inArea)
 {
     return((spawnAreas & inArea) == inArea);
 }
コード例 #10
0
    public static void FillSpawnPattern(SpawnPattern inPattern, long inBattleNum, AdventureArea inAdventureArea, int inAreaProgress)
    {
        //HIDDEN: This is the normal routine for filling a spawn pattern from a large collection of enemies

        /*
         * //this will fill a spawn pattern. it WILL NOT, however, apply any boosts that would be needed as the dungeon gets harder
         * //first pick out all valid enemies for this pattern
         * validSpawns = enemyCollectionList.Where(e => e.SpawnsInArea(inAdventureArea) && e.CanSpawnForAreaCompletion(inAreaProgress) && e.spawnRate > 0);
         *
         * //next, pick a default enemy to use in case our spawn selection times out
         * EnemyCharacterData defaultEnemy = validSpawns.OrderBy(e => e.spawnRate).First();
         *
         * //fill each spawn position indivdually
         * EnemyCharacterData potentialEnemy;
         * int tryCounter;
         * int roll;
         * for(int i=0; i<inPattern.spawnPoints.Count; i++)
         * {
         *  tryCounter = 0;
         *  SpawnPoint tempPoint = inPattern.spawnPoints[i];
         *  validSpawnSubset = validSpawns.Where( e => tempPoint.EnemyFitsSpawnPointRequirements(e) ).ToList();
         *
         *  while (tempPoint.isEmpty)
         *  {
         *      potentialEnemy = validSpawnSubset.GetRandomElement();
         *      roll = Utils.RandomInRange(1, potentialEnemy.spawnRate);
         *
         *      if(roll == 1)
         *      {
         *          tempPoint.characterId = potentialEnemy.id;
         *          break;
         *      }
         *
         *      tryCounter++;
         *      if(tryCounter > 100)
         *      {
         *          tempPoint.characterId = defaultEnemy.id;
         *          break;
         *      }
         *  }
         * }
         */

        //SIMPLIFIED: for demo purposes I've only created one enemy for each enemy rank, which will always be returned here
        for (int i = 0; i < inPattern.spawnPoints.Count; i++)
        {
            SpawnPoint tempPoint = inPattern.spawnPoints[i];

            if (tempPoint.allowedRank == EnemyRank.NORM)
            {
                tempPoint.characterId = EnemyId.RAT;
            }
            else if (tempPoint.allowedRank == EnemyRank.MBOS)
            {
                tempPoint.characterId = EnemyId.TUNNELER;
            }
            else if (tempPoint.allowedRank == EnemyRank.BOSS)
            {
                tempPoint.characterId = EnemyId.DRAGON;
            }
        }
    }