Пример #1
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();
        }
Пример #2
0
        public void LoadAccessary(int selectID)
        {
            //消費アイテム読み込み
            FileStream   datefs         = new FileStream(accessaryFilename, 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 intType = -1;
                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;
                }

                accessary[id] = new AccessaryItem(id, itemName, itemExplanation,
                                                  itemPrice, itemRare, itemWeight, amountLimit, intType);
            }
            consuptionDate.Close();
            datefs.Close();
        }
Пример #3
0
 public void RemoveAccessary()
 {
     if (bag.Count < MAX_ITEM_COUNT_BAG)
     {
         bag.Add(accessary);
         accessary = null;
     }
 }
Пример #4
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();
 }
Пример #5
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;
 }
Пример #6
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;
        }
Пример #7
0
        public bool EquipAccessary(int bagIndex)
        {
            Item item = bag[bagIndex];

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

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

            accessary = (AccessaryItem)item;          //装備する
            bag.RemoveAt(bagIndex);
            return(true);
        }
Пример #8
0
 //コピーコンストラクタ
 public AccessaryItem(AccessaryItem other)
     : base(other.itemID, other.itemName, other.itemExplanation,
            other.itemPrice, other.itemRare, other.itemWeight, other.amountLimit)
 {
     this.type = other.type;
 }