Exemple #1
0
        /// <summary>
        /// 弓矢を装備する
        /// </summary>
        /// <param name="bagIndex"></param>
        /// <returns></returns>
        public bool EquipArrow(int bagIndex)
        {
            Item equipArrow = bag[bagIndex];

            if (!(equipArrow is ConsumptionItem))
            {
                return(false);
            }

            if (((ConsumptionItem)equipArrow).GetTypeText() != "矢")
            {
                return(false);
            }

            if (leftHand == null)
            {
                return(false);
            }

            WeaponItem.WeaponType type = leftHand.GetWeaponType();
            if (type != WeaponItem.WeaponType.Bow)
            {
                return(false);
            }

            if (arrow != null)
            {
                bag.Add(arrow);
            }

            arrow = (ConsumptionItem)equipArrow;
            bag.RemoveAt(bagIndex);
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// カバン内の弓矢を自動スタック処理
        /// </summary>
        /// <param name="arrow"></param>
        private void AddArrow(ConsumptionItem arrow)
        {
            foreach (Item i in bag)
            {
                if ((!(i is ConsumptionItem)))
                {
                    continue;
                }

                if (((ConsumptionItem)i).GetItemID() != arrow.GetItemID())
                {
                    continue;
                }

                int leftStock = ((ConsumptionItem)i).GetAmountLimit() - ((ConsumptionItem)i).GetStack();
                if (arrow.GetStack() <= leftStock)
                {
                    ((ConsumptionItem)i).AddStack(arrow.GetStack());
                    return;
                }
                else
                {
                    ((ConsumptionItem)i).AddStack(leftStock);
                    arrow.AddStack(-leftStock);
                }
            }

            bag.Add(arrow);
        }
Exemple #3
0
        public bool MoveDepositItemToBag(ItemManager itemManager, int id)
        {
            if (!itemDepository.ContainsKey(id) ||
                itemDepository[id] <= 0)
            {
                return(false);
            }

            ConsumptionItem item = (ConsumptionItem)itemManager.GetConsuptionItem(id);

            itemDepository[id]--;
            if (itemDepository[id] <= 0)
            {
                itemDepository.Remove(id);
            }

            if (item.GetTypeText() != "矢")
            {
                bag.Add(item);
                return(true);
            }

            AddArrow(item);
            return(true);
        }
Exemple #4
0
 /// <summary>
 /// 矢を一つ減少
 /// </summary>
 public void DecreaseArrow()
 {
     arrow.AddStack(-1);
     if (arrow.GetStack() <= 0)
     {
         arrow = null;
     }
 }
 //コピーコンストラクタ
 public ConsumptionItem(ConsumptionItem other)
     : base(other.itemID, other.itemName, other.itemExplanation,
            other.itemPrice, other.itemRare, other.itemWeight, other.amountLimit)
 {
     this.effectType = other.effectType;
     this.itemEffect = other.itemEffect;
     this.stack      = other.stack;
 }
Exemple #6
0
        public void RemoveArrow()
        {
            if (bag.Count >= MAX_ITEM_COUNT_BAG)
            {
                return;
            }

            AddArrow(arrow);
            arrow = null;
        }
Exemple #7
0
 /// <summary>
 /// ファイルからアイテムを復元
 /// </summary>
 /// <param name="saveData"></param>
 public void LoadFromFile(SaveData saveData)
 {
     armor           = saveData.GetArmor();
     leftHand        = saveData.GetLeftHand();
     rightHand       = saveData.GetRightHand();
     accessary       = saveData.GetAccessary();
     arrow           = saveData.GetArrow();
     money           = saveData.GetMoney();
     bag             = saveData.GetBagList();
     equipDepository = saveData.GetDepotEquipment();
     itemDepository  = saveData.GetDepotConsumption();
 }
Exemple #8
0
        private int money;                                   //所持金

        public Inventory(GameDevice gameDevice)
        {
            this.gameDevice = gameDevice;
            bag             = new List <Item>();
            tempBag         = new List <Item>();
            equipDepository = new List <Item>();
            itemDepository  = new Dictionary <int, int>();
            armor           = new ProtectionItem[4];
            for (int i = 0; i < armor.Length; i++)
            {
                armor[i] = null;
            }
            rightHand = null;
            leftHand  = null;
            arrow     = null;
            accessary = null;
        }
Exemple #9
0
        public void LoadConsumption(int selectID)
        {
            //消費アイテム読み込み
            FileStream   datefs         = new FileStream(consuptionFilename, FileMode.Open);
            StreamReader consuptionDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

            while (!consuptionDate.EndOfStream)
            {
                string   line  = consuptionDate.ReadLine();
                string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (items.Length != 9)
                {
                    continue;
                }

                int id = int.Parse(items[0]);

                if (selectID != id)
                {
                    continue;
                }

                string itemName        = items[1];
                string itemExplanation = items[2];
                itemExplanation = itemExplanation.Replace("nl", "\n");
                int    itemPrice   = int.Parse(items[3]);
                int    itemRare    = int.Parse(items[4]);
                float  itemWeight  = float.Parse(items[5]);
                int    amountLimit = int.Parse(items[6]);
                string type        = items[7];
                int    amount      = int.Parse(items[8]);

                if (type == "recovary")
                {
                    consumption[id] = new ConsumptionItem(id, itemName, itemExplanation,
                                                          itemPrice, itemRare, itemWeight, amountLimit,
                                                          ConsumptionItem.ItemEffectType.recovery,
                                                          new Recovery(amount));
                }
                else if (type == "damage")
                {
                    consumption[id] = new ConsumptionItem(id, itemName, itemExplanation,
                                                          itemPrice, itemRare, itemWeight, amountLimit,
                                                          ConsumptionItem.ItemEffectType.damage,
                                                          new Damage(amount));
                }
                else if (type == "arrow")
                {
                    consumption[id] = ((new ConsumptionItem(id, itemName, itemExplanation,
                                                            itemPrice, itemRare, itemWeight, amountLimit,
                                                            ConsumptionItem.ItemEffectType.arrow,
                                                            new ArrowEffect(amount))));
                }
                else
                {
                    consumption[id] = new ConsumptionItem(id, itemName, itemExplanation,
                                                          itemPrice, itemRare, itemWeight, amountLimit,
                                                          ConsumptionItem.ItemEffectType.noEffect,
                                                          new NoEffect());
                }
            }
            consuptionDate.Close();
            datefs.Close();
        }
Exemple #10
0
        public void Load(int[] equipmentIDs, int[] consuptionIDs)
        {
            Clear();

            //装備読み込み
            FileStream   datefs        = new FileStream(equipmentFilename, FileMode.Open);
            StreamReader equipmentDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

            //装備生成
            while (!equipmentDate.EndOfStream)
            {
                string   line  = equipmentDate.ReadLine();
                string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (items.Length != 17)
                {
                    continue;
                }

                int id = int.Parse(items[0]);

                if (!equipmentIDs.Contains(id))
                {
                    continue;
                }

                string itemName        = items[1];
                string itemExplanation = items[2];
                itemExplanation = itemExplanation.Replace("nl", "\n");
                int    itemPrice          = int.Parse(items[3]);
                int    itemRare           = int.Parse(items[4]);
                float  itemWeight         = float.Parse(items[5]);
                string type               = items[6];
                int    power              = int.Parse(items[7]);
                int    defence            = int.Parse(items[8]);
                int    reinforcement      = int.Parse(items[9]);
                int    reinforcementLimit = int.Parse(items[10]);
                int    upPower            = int.Parse(items[11]);
                int    upDefence          = int.Parse(items[12]);
                int    randMinP           = int.Parse(items[13]);
                int    randMaxP           = int.Parse(items[14]);
                int    randMinD           = int.Parse(items[15]);
                int    randMaxD           = int.Parse(items[16]);

                if (type == "Sword")
                {
                    equipments[id] = new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Sword,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Bow")
                {
                    equipments[id] = new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Bow,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Dagger")
                {
                    equipments[id] = new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Dagger,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Shield")
                {
                    equipments[id] = new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Shield,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Helm")
                {
                    equipments[id] = new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Helm,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Armor")
                {
                    equipments[id] = new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Armor,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Glove")
                {
                    equipments[id] = new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Glove,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else if (type == "Shoes")
                {
                    equipments[id] = new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Shoes,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
            }
            equipmentDate.Close();
            datefs.Close();


            //消費アイテム読み込み
            datefs = new FileStream(consuptionFilename, FileMode.Open);
            StreamReader consuptionDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

            while (!consuptionDate.EndOfStream)
            {
                string   line  = consuptionDate.ReadLine();
                string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (items.Length != 9)
                {
                    continue;
                }

                int id = int.Parse(items[0]);

                if (!consuptionIDs.Contains(id))
                {
                    continue;
                }

                string itemName        = items[1];
                string itemExplanation = items[2];
                itemExplanation = itemExplanation.Replace("nl", "\n");
                int    itemPrice   = int.Parse(items[3]);
                int    itemRare    = int.Parse(items[4]);
                float  itemWeight  = float.Parse(items[5]);
                int    amountLimit = int.Parse(items[6]);
                string type        = items[7];
                int    amount      = int.Parse(items[8]);

                if (type == "recovary")
                {
                    consumptions[id] = new ConsumptionItem(id, itemName, itemExplanation,
                                                           itemPrice, itemRare, itemWeight, amountLimit,
                                                           ConsumptionItem.ItemEffectType.recovery,
                                                           new Recovery(amount));
                }
                else if (type == "damage")
                {
                    consumptions[id] = new ConsumptionItem(id, itemName, itemExplanation,
                                                           itemPrice, itemRare, itemWeight, amountLimit,
                                                           ConsumptionItem.ItemEffectType.damage,
                                                           new Damage(amount));
                }
                else if (type == "arrow")
                {
                    consumptions[id] = ((new ConsumptionItem(id, itemName, itemExplanation,
                                                             itemPrice, itemRare, itemWeight, amountLimit,
                                                             ConsumptionItem.ItemEffectType.arrow,
                                                             new ArrowEffect(amount))));
                }
                else if (type == "noEffect")
                {
                    consumptions[id] = new ConsumptionItem(id, itemName, itemExplanation,
                                                           itemPrice, itemRare, itemWeight, amountLimit,
                                                           ConsumptionItem.ItemEffectType.noEffect,
                                                           new NoEffect());
                }
            }
            consuptionDate.Close();
            datefs.Close();

            //アクセサリーアイテム読み込み
            //datefs = new FileStream(accessaryFilename, FileMode.Open);
            //StreamReader accessaryDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

            //while (!accessaryDate.EndOfStream)
            //{
            //    string line = accessaryDate.ReadLine();
            //    string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
            //    if (items.Length != 9) continue;

            //    int id = int.Parse(items[0]);

            //    if (!accessaryIDs.Contains(id)) continue;

            //    string itemName = items[1];
            //    string itemExplanation = items[2];
            //    itemExplanation = itemExplanation.Replace("nl", "\n");
            //    int itemPrice = int.Parse(items[3]);
            //    int itemRare = int.Parse(items[4]);
            //    float itemWeight = float.Parse(items[5]);
            //    int amountLimit = int.Parse(items[6]);
            //    string type = items[7];
            //    int intType = -1;

            //    //アクセサリーアイテムの種類を追加したらここにif文を追加する。
            //    if (type == "Earring")
            //    {
            //        intType = 0;
            //    }

            //    accessarys[id] = (new AccessaryItem(id, itemName, itemExplanation, itemPrice, itemRare, itemWeight, amountLimit, intType));
            //}
            //accessaryDate.Close();
            //datefs.Close();
        }
Exemple #11
0
        //セーブデータからアイテム再現
        public List <Item> LoadSaveItem(List <string[]> saveItems)
        //saveItem{ 種類, id, addPower, addDefence, reinforcment }
        {
            List <Item> save = new List <Item>();

            for (int i = 0; i < saveItems.Count; i++)
            {
                //string配列読み込み
                string[] saveItem = saveItems[i];
                if (saveItem == null)
                {
                    save.Add(null);
                    continue;
                }
                string kind   = saveItem[0];
                int    saveID = int.Parse(saveItem[1]);

                if (kind == "Weapon" || kind == "Protection")
                {
                    int addPower      = int.Parse(saveItem[2]);
                    int addDefence    = int.Parse(saveItem[3]);
                    int reinforcement = int.Parse(saveItem[4]);

                    //装備読み込み
                    FileStream   datefs        = new FileStream(equipmentFilename, FileMode.Open);
                    StreamReader equipmentDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

                    //装備生成
                    while (!equipmentDate.EndOfStream)
                    {
                        string   line  = equipmentDate.ReadLine();
                        string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        if (items.Length != 17)
                        {
                            continue;
                        }

                        int id = int.Parse(items[0]);

                        if (saveID != id)
                        {
                            continue;
                        }

                        string itemName        = items[1];
                        string itemExplanation = items[2];
                        itemExplanation = itemExplanation.Replace("nl", "\n");
                        int    itemPrice          = int.Parse(items[3]);
                        int    itemRare           = int.Parse(items[4]);
                        float  itemWeight         = float.Parse(items[5]);
                        string type               = items[6];
                        int    power              = int.Parse(items[7]);
                        int    defence            = int.Parse(items[8]);
                        int    reinforcementLimit = int.Parse(items[10]);
                        int    upPower            = int.Parse(items[11]);
                        int    upDefence          = int.Parse(items[12]);

                        if (type == "Sword")
                        {
                            save.Add(new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Sword,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Bow")
                        {
                            save.Add(new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Bow,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Dagger")
                        {
                            save.Add(new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Dagger,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Shield")
                        {
                            save.Add(new WeaponItem(id, itemName, itemExplanation,
                                                    itemPrice, itemRare, itemWeight, WeaponItem.WeaponType.Shield,
                                                    power, defence, reinforcement, reinforcementLimit,
                                                    upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Helm")
                        {
                            save.Add(new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Helm,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Armor")
                        {
                            save.Add(new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Armor,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Glove")
                        {
                            save.Add(new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Glove,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, addPower, addDefence));
                        }
                        else if (type == "Shoes")
                        {
                            save.Add(new ProtectionItem(id, itemName, itemExplanation,
                                                        itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Shoes,
                                                        power, defence, reinforcement, reinforcementLimit,
                                                        upPower, upDefence, addPower, addDefence));
                        }
                    }
                    equipmentDate.Close();
                    datefs.Close();
                }
                else if (kind == "Consumption")
                {
                    int stack = int.Parse(saveItem[2]);

                    //消費アイテム読み込み
                    FileStream   datefs         = new FileStream(consuptionFilename, FileMode.Open);
                    StreamReader consuptionDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

                    while (!consuptionDate.EndOfStream)
                    {
                        string   line  = consuptionDate.ReadLine();
                        string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        if (items.Length != 9)
                        {
                            continue;
                        }

                        int id = int.Parse(items[0]);

                        if (saveID != id)
                        {
                            continue;
                        }

                        string itemName        = items[1];
                        string itemExplanation = items[2];
                        itemExplanation = itemExplanation.Replace("nl", "\n");
                        int    itemPrice   = int.Parse(items[3]);
                        int    itemRare    = int.Parse(items[4]);
                        float  itemWeight  = float.Parse(items[5]);
                        int    amountLimit = int.Parse(items[6]);
                        string type        = items[7];
                        int    amount      = int.Parse(items[8]);

                        if (type == "recovary")
                        {
                            save.Add(new ConsumptionItem(id, itemName, itemExplanation,
                                                         itemPrice, itemRare, itemWeight, amountLimit,
                                                         ConsumptionItem.ItemEffectType.recovery,
                                                         new Recovery(amount)));
                        }
                        else if (type == "damage")
                        {
                            save.Add(new ConsumptionItem(id, itemName, itemExplanation,
                                                         itemPrice, itemRare, itemWeight, amountLimit,
                                                         ConsumptionItem.ItemEffectType.damage,
                                                         new Damage(amount)));
                        }
                        else if (type == "arrow")
                        {
                            ConsumptionItem arrow = ((new ConsumptionItem(id, itemName, itemExplanation,
                                                                          itemPrice, itemRare, itemWeight, amountLimit,
                                                                          ConsumptionItem.ItemEffectType.arrow,
                                                                          new ArrowEffect(amount))));
                            arrow.SetStack(stack);
                            save.Add(arrow);
                        }
                        else if (type == "noEffect")
                        {
                            save.Add(new ConsumptionItem(id, itemName, itemExplanation,
                                                         itemPrice, itemRare, itemWeight, amountLimit,
                                                         ConsumptionItem.ItemEffectType.noEffect,
                                                         new NoEffect()));
                        }
                    }
                    consuptionDate.Close();
                    datefs.Close();
                }
                else if (kind == "Accessary")
                {
                    //アクセサリーアイテム読み込み
                    FileStream   datefs        = new FileStream(accessaryFilename, FileMode.Open);
                    StreamReader accessaryDate = new StreamReader(datefs, Encoding.GetEncoding("shift_jis"));

                    while (!accessaryDate.EndOfStream)
                    {
                        string   line  = accessaryDate.ReadLine();
                        string[] items = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        if (items.Length == 9)
                        {
                            continue;
                        }

                        int id = int.Parse(items[0]);

                        if (saveID != id)
                        {
                            continue;
                        }

                        string itemName        = items[1];
                        string itemExplanation = items[2];
                        itemExplanation = itemExplanation.Replace("nl", "\n");
                        int    itemPrice   = int.Parse(items[3]);
                        int    itemRare    = int.Parse(items[4]);
                        float  itemWeight  = float.Parse(items[5]);
                        int    amountLimit = int.Parse(items[6]);
                        string type        = items[7];
                        int    intType     = -1;

                        //アクセサリーアイテムの種類を追加したらここにif文を追加する。
                        if (type == "Necklace")
                        {
                            intType = (int)AccessaryItem.Type.Necklace;
                        }
                        else if (type == "Book")
                        {
                            intType = (int)AccessaryItem.Type.Book;
                        }
                        else if (type == "Pet")
                        {
                            intType = (int)AccessaryItem.Type.Pet;
                        }
                        else if (type == "Sheath")
                        {
                            intType = (int)AccessaryItem.Type.Sheath;
                        }
                        else if (type == "Amulet")
                        {
                            intType = (int)AccessaryItem.Type.Amulet;
                        }

                        save.Add(new AccessaryItem(id, itemName, itemExplanation, itemPrice, itemRare, itemWeight, amountLimit, intType));
                    }
                    accessaryDate.Close();
                    datefs.Close();
                }
            }

            return(save);
        }