Пример #1
0
        /// <summary>
        /// 右手に装備する
        /// </summary>
        /// <param name="bagIndex">バッグ内のIndex</param>
        public bool EquipRightHand(int bagIndex)
        {
            Item item = bag[bagIndex];

            if (!(item is WeaponItem))             //エラー対策
            {
                return(false);
            }

            WeaponItem.WeaponType type = ((WeaponItem)item).GetWeaponType();
            if (type == WeaponItem.WeaponType.Bow) //右手は弓を装備できない
            {
                return(false);
            }


            if (leftHand != null && leftHand.GetWeaponType() == WeaponItem.WeaponType.Bow) //弓は同時装備できない
            {
                bag.Add(leftHand);                                                         //バッグに戻す
                leftHand = null;
            }

            if (rightHand != null)                 //装備している状態
            {
                bag.Add(rightHand);                //バッグに戻す
            }

            rightHand = (WeaponItem)item;          //装備する
            bag.RemoveAt(bagIndex);
            return(true);
        }
Пример #2
0
        /// <summary>
        /// 持ち帰れないアイテムを削除
        /// </summary>
        public void RemoveTempItem()
        {
            foreach (Item temp in tempBag)
            {
                bag.RemoveAll(i => i.GetUniqueID() == temp.GetUniqueID());
                for (int i = 0; i < armor.Length; i++)
                {
                    if (armor[i] != null && armor[i].GetUniqueID() == temp.GetUniqueID())
                    {
                        armor[i] = null;
                    }
                }

                if (leftHand != null && leftHand.GetUniqueID() == temp.GetUniqueID())
                {
                    leftHand = null;
                }
                if (rightHand != null && rightHand.GetUniqueID() == temp.GetUniqueID())
                {
                    rightHand = null;
                }
                if (accessary != null && accessary.GetUniqueID() == temp.GetUniqueID())
                {
                    accessary = null;
                }
            }

            tempBag.Clear();
        }
Пример #3
0
 public void RemoveLeftHand()
 {
     if (bag.Count < MAX_ITEM_COUNT_BAG)
     {
         bag.Add(leftHand);
         leftHand = null;
     }
 }
Пример #4
0
 public void RemoveRightHand()
 {
     if (bag.Count < MAX_ITEM_COUNT_BAG)
     {
         bag.Add(rightHand);
         rightHand = null;
     }
 }
Пример #5
0
        //コピーコンストラクタ
        public WeaponItem(WeaponItem other)
            : base(other.itemID, other.itemName, other.itemExplanation,
                   other.itemPrice, other.itemRare, other.itemWeight, other.amountLimit)
        {
            this.weaponType = other.weaponType;

            effect = new EquipmentEffect(other.itemPower, other.itemDefense, other.reinforcementLimit,
                                         other.upPower, other.upDefense, other.randomMinP, other.randomMaxP, other.randomMinD, other.randomMaxD);
        }
Пример #6
0
        public override Item UniqueClone()
        {
            WeaponItem newItem = new WeaponItem(itemID, itemName, itemExplanation,
                                                itemPrice, itemRare, itemWeight, weaponType,
                                                effect.GetPower() - effect.GetAddPower(), effect.GetDefense() - effect.GetAddDefense(),
                                                effect.GetReinforcement(), effect.GetReinforcementLimit(), effect.GetUpPower(), effect.GetUpDefence(),
                                                effect.GetAddPower(), effect.GetAddDefense());

            return(newItem);
        }
Пример #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();
 }
Пример #8
0
 /// <summary>
 /// すべて削除
 /// </summary>
 public void RemoveAll()
 {
     bag.Clear();
     tempBag.Clear();
     bag     = new List <Item>();
     tempBag = new List <Item>();
     armor   = new ProtectionItem[4];
     for (int i = 0; i < armor.Length; i++)
     {
         armor[i] = null;
     }
     rightHand = null;
     leftHand  = null;
     accessary = null;
 }
Пример #9
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;
        }
Пример #10
0
        /// <summary>
        /// 左手に装備する
        /// </summary>
        /// <param name="bagIndex">バッグ内のIndex</param>
        public bool EquipLeftHand(int bagIndex)
        {
            Item item = bag[bagIndex];

            if (!(item is WeaponItem))
            {
                                                 //エラー対策
                return(false);
            }


            WeaponItem.WeaponType type = ((WeaponItem)item).GetWeaponType();
            if (type == WeaponItem.WeaponType.Bow)     //弓は両手
            {
                if (rightHand != null && leftHand != null &&
                    bag.Count + 2 > MAX_ITEM_COUNT_BAG)      //両手いっぱいで、弓を装備する場合はカバンの容量をチェック
                {
                    return(false);
                }

                if (leftHand != null)                 //装備している状態
                {
                    bag.Add(leftHand);                //バッグに戻す
                }

                if (rightHand != null)                 //装備している状態
                {
                    bag.Add(rightHand);                //バッグに戻す
                    rightHand = null;
                }
            }
            else
            {
                if (leftHand != null)                 //装備している状態
                {
                    bag.Add(leftHand);                //バッグに戻す
                }
            }

            leftHand = (WeaponItem)item;          //装備する
            bag.RemoveAt(bagIndex);
            return(true);
        }
Пример #11
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();
        }
Пример #12
0
        //指定されたアイテムをロード
        public void LoadEquipment(int selectID)
        {
            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 (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]);
                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")
                {
                    equipment[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")
                {
                    equipment[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")
                {
                    equipment[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")
                {
                    equipment[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")
                {
                    equipment[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")
                {
                    equipment[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")
                {
                    equipment[id] = new ProtectionItem(id, itemName, itemExplanation,
                                                       itemPrice, itemRare, itemWeight, ProtectionItem.ProtectionType.Glove,
                                                       power, defence, reinforcement, reinforcementLimit,
                                                       upPower, upDefence, randMinP, randMaxP, randMinD, randMaxD);
                }
                else
                {
                    equipment[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();
        }