Exemple #1
0
 //return an item, given an index of an unknown type (for inventory, etc)
 //should we use a lookup for index range, to know what list to use?
 public static Item getItemFromIndex(long index, GameDataSet gameDataSet)
 {
     if (index <= GameConstants.ITEMS_MAX_INDEX)
     {
         if (gameDataSet.itemDataDictionary.ContainsKey(index))
         {
             return getItemFromItemData(gameDataSet.itemDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary);
         }
        
     }
     else if (index <= GameConstants.USABLEITEMS_MAX_INDEX)
     {
         if (gameDataSet.usableItemDataDictionary.ContainsKey(index))
         {
             return getUsableItemFromData(gameDataSet.usableItemDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary);
         }
     }
     else if (index <= GameConstants.WEAPONS_MAX_INDEX)
     {
         if (gameDataSet.weaponDataDictionary.ContainsKey(index))
         {
             return getWeaponFromWeaponData(gameDataSet.weaponDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary);
         }
     }
     else if (index <= GameConstants.RANGEDWEAPONS_MAX_INDEX)
     {
         if (gameDataSet.rangedWeaponDataDictionary.ContainsKey(index))
         {
             return getRangedWeaponFromRangedWeaponData(gameDataSet.rangedWeaponDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary);
         }
     }
     else if (index <= GameConstants.AMMO_MAX_INDEX)
     {
         if (gameDataSet.ammoDataDictionary.ContainsKey(index))
         {
             return getAmmoFromAmmoData(gameDataSet.ammoDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary);
         }
     }
     else if (index <= GameConstants.ARMOR_MAX_INDEX)
     {
         if (gameDataSet.armorDataDictionary.ContainsKey(index))
         {
             return getArmorFromArmorData(gameDataSet.armorDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary);
         }
     }
     
         return null;
     
 }
Exemple #2
0
        //return an item, given an index of an unknown type (for inventory, etc)
        //should we use a lookup for index range, to know what list to use?
        public static Item getItemFromIndex(long index, GameDataSet gameDataSet)
        {
            if (index <= GameConstants.ITEMS_MAX_INDEX)
            {
                if (gameDataSet.itemDataDictionary.ContainsKey(index))
                {
                    return(getItemFromItemData(gameDataSet.itemDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                }
            }
            else if (index <= GameConstants.USABLEITEMS_MAX_INDEX)
            {
                if (gameDataSet.usableItemDataDictionary.ContainsKey(index))
                {
                    return(getUsableItemFromData(gameDataSet.usableItemDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                }
            }
            else if (index <= GameConstants.WEAPONS_MAX_INDEX)
            {
                if (gameDataSet.weaponDataDictionary.ContainsKey(index))
                {
                    return(getWeaponFromWeaponData(gameDataSet.weaponDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                }
            }
            else if (index <= GameConstants.RANGEDWEAPONS_MAX_INDEX)
            {
                if (gameDataSet.rangedWeaponDataDictionary.ContainsKey(index))
                {
                    return(getRangedWeaponFromRangedWeaponData(gameDataSet.rangedWeaponDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                }
            }
            else if (index <= GameConstants.AMMO_MAX_INDEX)
            {
                if (gameDataSet.ammoDataDictionary.ContainsKey(index))
                {
                    return(getAmmoFromAmmoData(gameDataSet.ammoDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                }
            }
            else if (index <= GameConstants.ARMOR_MAX_INDEX)
            {
                if (gameDataSet.armorDataDictionary.ContainsKey(index))
                {
                    return(getArmorFromArmorData(gameDataSet.armorDataDictionary[index], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                }
            }

            return(null);
        }
Exemple #3
0
        public static BattleGameData getBattleGameDataFromZoneTree(List<GameCharacter> playerCharacterList, BattleTree battleTree, GameDataSet gameDataSet, TileMapData tileMapData)
        {
            BattleGameData retval = new BattleGameData();

            retval.tileMapData = tileMapData;

            //load player

            retval.gameCharacterList.AddRange(playerCharacterList);

            //load enemies
            foreach (var enemyNode in battleTree.getEnemyNodeList())
            {
                if(gameDataSet.gameCharacterDataDictionary.ContainsKey(enemyNode.content.linkIndex)){
                       var enemyData = gameDataSet.gameCharacterDataDictionary[enemyNode.content.linkIndex];
                       retval.gameCharacterList.Add(CharacterFactory.getGameCharacterFromGameCharacterData(enemyData, gameDataSet));
                }
             
            }
            return retval;
        }
        public static GameCharacter getGameCharacterFromGameCharacterData(GameCharacterData data, GameDataSet gameDataSet)
        {
            GameCharacter character = new GameCharacter()
            {
                level  = data.level,
                ac     = data.ac,
                ap     = data.ap,
                attack = data.attack,
                characterSpriteIndex     = data.characterSpriteIndex,
                characterSpritesheetName = data.characterSpritesheetName,
                hp                      = data.hp,
                displayChar             = data.displayChar,
                name                    = data.name,
                portraitSpriteIndex     = data.portraitSpriteIndex,
                portraitSpritesheetName = data.portraitSpritesheetName,
                totalAP                 = data.ap,
                totalHP                 = data.hp,
                type                    = data.type,
                x            = 0,
                y            = 0,
                strength     = data.strength,
                agility      = data.agility,
                endurance    = data.endurance,
                spirit       = data.spirit,
                xp           = ExperienceHelper.getXPAtLevel(data.level),
                talentPoints = 0,
                statPoints   = 0
            };

            if (data.abilityList.Count > 0)
            {
                List <Ability> abilityList = new List <Ability>();
                foreach (var l in data.abilityList)
                {
                    if (gameDataSet.abilityDataDictionary.ContainsKey(l))
                    {
                        abilityList.Add(AbilityFactory.getAbilityFromAbilityData(gameDataSet.abilityDataDictionary[l], gameDataSet.effectDataDictionary));
                    }
                }
                character.abilityList = abilityList;
            }

            if (data.inventory.Count > 0)
            {
                List <Item> itemList = new List <Item>();
                foreach (var i in data.inventory)
                {
                    Item tempItem = ItemFactory.getItemFromIndex(i, gameDataSet);
                    if (tempItem != null)
                    {
                        if (tempItem.type == ItemType.Ammo)
                        {
                            character.inventory.Add(tempItem);
                            character.Ammo = ItemHelper.getItemSet(character.inventory, tempItem);
                        }
                        else
                        {
                            itemList.Add(tempItem);
                        }
                    }
                }

                character.usableItemList = itemList;

                //character.inventory = itemList;
            }

            if (data.equippedArmor.Count > 0)
            {
                List <Armor> armorList = new List <Armor>();
                foreach (var a in data.equippedArmor)
                {
                    if (gameDataSet.armorDataDictionary.ContainsKey(a))
                    {
                        armorList.Add(ItemFactory.getArmorFromArmorData(gameDataSet.armorDataDictionary[a], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                    }
                }
                character.equippedArmor = armorList;
            }

            if (data.weapon > 0)
            {
                Item i = ItemFactory.getItemFromIndex(data.weapon, gameDataSet);

                Weapon w = (Weapon)ItemFactory.getItemFromIndex(data.weapon, gameDataSet);

                if (w.weaponType == WeaponType.OneHandRanged || w.weaponType == WeaponType.TwoHandRanged)
                {
                    w = (RangedWeapon)w;
                }


                character.weapon = w;
            }

            if (data.activeEffects.Count > 0)
            {
                List <ActiveEffect> aeList = new List <ActiveEffect>();

                foreach (long l in data.activeEffects)
                {
                    if (gameDataSet.effectDataDictionary.ContainsKey(l))
                    {
                        aeList.Add(AbilityFactory.getActiveEffectFromEffectData(gameDataSet.effectDataDictionary[l]));
                    }
                }
                character.activeEffects = aeList;
            }

            if (data.passiveEffects.Count > 0)
            {
                List <PassiveEffect> peList = new List <PassiveEffect>();

                foreach (long l in data.passiveEffects)
                {
                    if (gameDataSet.effectDataDictionary.ContainsKey(l))
                    {
                        peList.Add(AbilityFactory.getPassiveEffectFromEffectData(gameDataSet.effectDataDictionary[l]));
                    }
                }
                character.passiveEffects = peList;
            }


            if (data.type == CharacterType.Enemy)
            {
                character = getEnemyFromGameCharacter(character, data.enemyType);
            }

            return(character);
        }
        public static GameCharacter getGameCharacterFromGameCharacterData(GameCharacterData data, GameDataSet gameDataSet)
        {
            GameCharacter character = new GameCharacter()
            {
                level = data.level,
                ac = data.ac,
                ap = data.ap,
                attack = data.attack,
                characterSpriteIndex = data.characterSpriteIndex,
                characterSpritesheetName = data.characterSpritesheetName,
                hp = data.hp,
                displayChar = data.displayChar,
                name = data.name,
                portraitSpriteIndex = data.portraitSpriteIndex,
                portraitSpritesheetName = data.portraitSpritesheetName,
                totalAP = data.ap,
                totalHP = data.hp,
                type = data.type,
                x = 0,
                y = 0,
                strength = data.strength,
                agility = data.agility,
                endurance = data.endurance,
                spirit = data.spirit,
                xp = ExperienceHelper.getXPAtLevel(data.level),
                talentPoints = 0,
                statPoints = 0

            };

            if (data.abilityList.Count > 0)
            {
                List<Ability> abilityList = new List<Ability>();
                foreach (var l in data.abilityList)
                {
                    if(gameDataSet.abilityDataDictionary.ContainsKey(l)){
                         abilityList.Add(AbilityFactory.getAbilityFromAbilityData(gameDataSet.abilityDataDictionary[l],gameDataSet.effectDataDictionary));
                    }
                   
                }
                character.abilityList = abilityList;
            }

            if(data.inventory.Count > 0){
                List<Item> itemList = new List<Item>();
                foreach (var i in data.inventory)
                {
                    Item tempItem = ItemFactory.getItemFromIndex(i, gameDataSet);
                    if (tempItem != null)
                    {
                        if (tempItem.type == ItemType.Ammo)
                        {
                            character.inventory.Add(tempItem);
                            character.Ammo = ItemHelper.getItemSet(character.inventory, tempItem);
                        }
                        else
                        {
                            itemList.Add(tempItem);
                        }
                    }
                }

                character.usableItemList = itemList;

                //character.inventory = itemList;
            }

            if (data.equippedArmor.Count > 0)
            {
                List<Armor> armorList = new List<Armor>();
                foreach (var a in data.equippedArmor)
                {
                    if(gameDataSet.armorDataDictionary.ContainsKey(a)){
                        armorList.Add(ItemFactory.getArmorFromArmorData(gameDataSet.armorDataDictionary[a], gameDataSet.abilityDataDictionary, gameDataSet.effectDataDictionary));
                    }
                  
                }
                character.equippedArmor = armorList;
            }

            if (data.weapon > 0)
            {
                Item i = ItemFactory.getItemFromIndex(data.weapon, gameDataSet);
                
                Weapon w = (Weapon)ItemFactory.getItemFromIndex(data.weapon, gameDataSet);

                if (w.weaponType == WeaponType.OneHandRanged || w.weaponType == WeaponType.TwoHandRanged)
                {
                    w = (RangedWeapon)w;
                }
                

                character.weapon = w;
            }

            if (data.activeEffects.Count > 0)
            {
                List<ActiveEffect> aeList = new List<ActiveEffect>();

                foreach (long l in data.activeEffects)
                {
                    if (gameDataSet.effectDataDictionary.ContainsKey(l))
                    {
                        aeList.Add(AbilityFactory.getActiveEffectFromEffectData(gameDataSet.effectDataDictionary[l]));
                    }
                }
                character.activeEffects = aeList;
            }

            if (data.passiveEffects.Count > 0)
            {
                List<PassiveEffect> peList = new List<PassiveEffect>();

                foreach (long l in data.passiveEffects)
                {
                    if (gameDataSet.effectDataDictionary.ContainsKey(l))
                    {
                        peList.Add(AbilityFactory.getPassiveEffectFromEffectData(gameDataSet.effectDataDictionary[l]));
                    }

                }
                character.passiveEffects = peList;
            }


            if (data.type == CharacterType.Enemy)
            {
                character = getEnemyFromGameCharacter(character, data.enemyType);
            }

            return character;
            
        }
Exemple #6
0
        public static BattleGameData getBattleGameDataFromZoneTree(List <GameCharacter> playerCharacterList, BattleTree battleTree, GameDataSet gameDataSet, TileMapData tileMapData)
        {
            BattleGameData retval = new BattleGameData();

            retval.tileMapData = tileMapData;

            //load player

            retval.gameCharacterList.AddRange(playerCharacterList);

            //load enemies
            foreach (var enemyNode in battleTree.getEnemyNodeList())
            {
                if (gameDataSet.gameCharacterDataDictionary.ContainsKey(enemyNode.content.linkIndex))
                {
                    var enemyData = gameDataSet.gameCharacterDataDictionary[enemyNode.content.linkIndex];
                    retval.gameCharacterList.Add(CharacterFactory.getGameCharacterFromGameCharacterData(enemyData, gameDataSet));
                }
            }
            return(retval);
        }
Exemple #7
0
         private List<StoreItem> getStoreItemListFromItemIdList(List<long> itemIdList, GameDataSet gameDataSet, int count, float priceAdjustment)
         {
             List<StoreItem> storeItemList = new List<StoreItem>(); 
             foreach(long id in itemIdList){
                 var item = ItemFactory.getItemFromIndex(id, gameDataSet);
                 if (item.price > 0)
                 {
                     StoreItem tempStoreItem = new StoreItem();
                     tempStoreItem.item = item;
                     tempStoreItem.count = count;
                     tempStoreItem.price = (long)Math.Round(tempStoreItem.item.price * priceAdjustment);
                     tempStoreItem.selected = 1;

                     storeItemList.Add(tempStoreItem);
                 }
              
             }

             return storeItemList;

             
         }
Exemple #8
0
         //returning a random list of items of type at less than rarityIndex (price)
         private List<StoreItem> getSellItemTypeList(ItemType type, float priceAdjustment, int count, long rarityIndex, GameDataSet gameDataSet, Random r)
         {
             List<StoreItem> storeItemList = new List<StoreItem>();
             var itemCount = r.Next(9)+1; //TODO: Do we want this hardcoded here?
             switch(type){
                 case ItemType.Weapon:
                      List<long> weaponIdList = gameDataSet.weaponDataDictionary.Where(x=>x.Value.price <= rarityIndex).Select(x=>x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList();
                      storeItemList.AddRange(getStoreItemListFromItemIdList(weaponIdList, gameDataSet, count, priceAdjustment));
                     break;
                 case ItemType.Ammo:
                     List<long> ammoIdList = gameDataSet.ammoDataDictionary.Where(x=>x.Value.price <= rarityIndex).Select(x=>x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList();
                     storeItemList.AddRange(getStoreItemListFromItemIdList(ammoIdList, gameDataSet, count, priceAdjustment));
                     break;
                 case ItemType.Armor:
                     List<long> armorIdList = gameDataSet.armorDataDictionary.Where(x => x.Value.price <= rarityIndex).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList();
                     storeItemList.AddRange(getStoreItemListFromItemIdList(armorIdList, gameDataSet, count, priceAdjustment));
                     break;
                 case ItemType.Potion:
                     List<long> potionIdList = gameDataSet.usableItemDataDictionary.Where(x => x.Value.price <= rarityIndex && x.Value.type == ItemType.Potion).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList();
                     storeItemList.AddRange(getStoreItemListFromItemIdList(potionIdList, gameDataSet, count, priceAdjustment));
                     break;
                 case ItemType.Thrown:
                      List<long> thrownIdList = gameDataSet.usableItemDataDictionary.Where(x => x.Value.price <= rarityIndex && x.Value.type == ItemType.Thrown).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList();
                      storeItemList.AddRange(getStoreItemListFromItemIdList(thrownIdList, gameDataSet, count, priceAdjustment));
                     break;
                 case ItemType.Wand:
                      List<long> wandIdList = gameDataSet.usableItemDataDictionary.Where(x => x.Value.price <= rarityIndex && x.Value.type == ItemType.Wand).Select(x => x.Key).OrderBy(x => r.Next()).Take(itemCount).ToList();
                      storeItemList.AddRange(getStoreItemListFromItemIdList(wandIdList, gameDataSet, count, priceAdjustment));
                     break;
                 default:
                     break;
             }

             return storeItemList;
         }
Exemple #9
0
 private StoreItem getSellItem(long itemID, float priceAdjustment, int count, GameDataSet gameDataSet)
 {
     StoreItem storeItem = null;
     Item i = ItemFactory.getItemFromIndex(itemID, gameDataSet);
     if (i != null)
     {
         storeItem = new StoreItem();
         storeItem.item = i;
         storeItem.count = count;
         storeItem.price = (long)Math.Round(i.price  * priceAdjustment);
         storeItem.selected = 1;
         return storeItem;
     }
     return storeItem;
 }
Exemple #10
0
         //given a gameDataSet, and global flags, return the list of items (and prices) sold
         //dont return items with 0 price (specials, etc)
         public List<StoreItem> getSellList(GameDataSet gameDataSet, Random r)
         {
             List<StoreItem> storeList = new List<StoreItem>();

             var infoNode = treeNodeDictionary[1];
             foreach (var branch in infoNode.getBranchList(this))
             {
                 StoreTreeNode storeNode = (StoreTreeNode)this.getNode(branch.linkIndex);
                 if (storeNode.content.nodeType == StoreNodeType.ItemClass)
                 {
                     storeList.AddRange(getSellItemTypeList(storeNode.content.itemType, storeNode.content.sellPrice, storeNode.content.count, storeNode.content.linkIndex, gameDataSet, r));
                 }
                 else if (storeNode.content.nodeType == StoreNodeType.ItemIndex)
                 {
                     storeList.Add(getSellItem(storeNode.content.linkIndex, storeNode.content.sellPrice, storeNode.content.count, gameDataSet));
                 }
             }
             return storeList;
         }
Exemple #11
0
         //lookup the item in the store list and return the price, otherwise default to .5f
         public long getBuyPrice(Item i, GameDataSet gameDataSet)
         {
             float buyPrice = 0.0f;

             var infoNode = treeNodeDictionary[1];
             List<StoreTreeNode> storeNodeList = new List<StoreTreeNode>();
             foreach (var branch in infoNode.getBranchList(this))
             {
                 var storeNode = (StoreTreeNode)this.getNode(branch.linkIndex);

                 if(storeNode.content.nodeType == StoreNodeType.ItemIndex){
                     if(storeNode.content.linkIndex == i.ID){
                         if(storeNode.content.buyPrice > buyPrice){
                             buyPrice = storeNode.content.buyPrice;
                         }
                     }
                 }
                 else if(storeNode.content.nodeType == StoreNodeType.ItemClass){
                     if (storeNode.content.itemType == i.type && i.price <= storeNode.content.linkIndex)
                     {
                         if (storeNode.content.buyPrice > buyPrice)
                         {
                             buyPrice = storeNode.content.buyPrice;
                         }
                     }
                 }
             }

             if (buyPrice < .5)
             {
                 buyPrice = .5f;
             }

             return (long)Math.Round( i.price * buyPrice);

         }
Exemple #12
0
         public List<Item> getWinItemList(GameDataSet gameDataSet)
         {
             List<Item> itemList = new List<Item>();

             var winNode = getWinNode();
             var itemActionList = winNode.actionList.Where(x => x.actionType == NodeActionType.AddItem);
             foreach (var itemAction in itemActionList)
             {
                 itemList.Add(ItemFactory.getItemFromIndex(itemAction.index, gameDataSet));

             }

             return itemList;

         }