Exemplo n.º 1
0
        protected override bool PutItemCore(Item item)
        {
            //持ってない
            if (!Items.Contains(item))
            {
                return(false);
            }
            //何かあったら置けない
            if (dungeon.Objects.Any(x => x.Position == this.Position))
            {
                return(false);
            }

            if (Equips.ContainsKey(item.Category) && Equips[item.Category] == item)
            {
                Equips[item.Category] = null;
            }
            Items.Remove(item);

            dungeon.AddObject(item, this.Position);
            item.InstantiateObject(dungeon.DungeonPrefabs.ObjectPrefab, dungeon.ObjectRoot);

            this.IsAction = true;
            return(true);
        }
Exemplo n.º 2
0
        public ushort GetEquipBySlot(ItemSlot slot)
        {
            if (Equips.ContainsKey((byte)slot))
            {
                return(Equips[(byte)slot]);
            }

            return(ushort.MaxValue);
        }
Exemplo n.º 3
0
 public void LoadEqupippet()
 {
     foreach (var eqp in this.Inventory.EquippedItems.Where(eq => eq.Slot < 0))
     {
         byte realslot = (byte)(eqp.Slot * -1);
         if (Equips.ContainsKey(realslot))
         {
             Log.WriteLine(LogLevel.Warn, "{0} has duplicate equip in slot {1}", eqp.EquipID, realslot);
             Equips.Remove(realslot);
         }
         Equips.Add(realslot, (ushort)eqp.EquipID);
     }
 }
Exemplo n.º 4
0
 public static void ReadItemNames()
 {
     foreach (var node in pFile.BaseNode["String"]["Item.img"])
     {
         if (node.Name == "Eqp")
         {
             foreach (var cat in node)
             {
                 ProcessNames(cat, (i, s) =>
                 {
                     if (!Equips.ContainsKey(i))
                     {
                         Trace.WriteLine($"Found name {s} for equip {i}, but equip did not exist!");
                     }
                     else
                     {
                         Equips[i].Name = s;
                     }
                 });
             }
         }
         else if (node.Name == "Pet")
         {
             ProcessNames(node, (i, s) =>
             {
                 if (!Pets.ContainsKey(i))
                 {
                     Trace.WriteLine($"Found name {s} for pet {i}, but pet did not exist!");
                 }
                 else
                 {
                     Pets[i].Name = s;
                 }
             });
         }
         else
         {
             ProcessNames(node, (i, s) =>
             {
                 if (!Items.ContainsKey(i))
                 {
                     Trace.WriteLine($"Found name {s} for item {i}, but item did not exist!");
                 }
                 else
                 {
                     Items[i].Name = s;
                 }
             });
         }
     }
 }
Exemplo n.º 5
0
        public override bool ThrowItem(Item item)
        {
            //持ってない
            if (!Items.Contains(item))
            {
                return(false);
            }

            var result = ThrowItemCore(item);

            if (result)
            {
                //アイテムを持ち物から消去or矢弾なら数を減らす
                if (item.Category == ItemCategory.Arrow)
                {
                    if (item.CountValue > 1)
                    {
                        item.CountValue--;
                    }
                    else
                    {
                        if (Equips.ContainsKey(item.Category) && Equips[item.Category] == item)
                        {
                            Equips[item.Category] = null;
                        }
                        Items.Remove(item);
                    }
                }
                else
                {
                    if (Equips.ContainsKey(item.Category) && Equips[item.Category] == item)
                    {
                        Equips[item.Category] = null;
                    }
                    Items.Remove(item);
                }
            }
            this.IsAction |= result;
            return(result);
        }
Exemplo n.º 6
0
        private bool EquipItemCore(Item item)
        {
            //装備できないカテゴリのアイテム
            if (!Equips.ContainsKey(item.Category))
            {
                StaticData.Message.ShowMessage(string.Format("それは装備できない"), false);
                return(false);
            }

            //装備中のアイテムなら外す
            if (Equips[item.Category] == item)
            {
                Equips[item.Category] = null;
                StaticData.Message.ShowMessage(string.Format("{0}を外した", item.Name), false);
                return(true);
            }

            //装備する
            Equips[item.Category] = item;
            StaticData.Message.ShowMessage(string.Format("{0}を装備した", item.Name), false);
            return(true);
        }
Exemplo n.º 7
0
        public static void Reload()
        {
            bool unload = false;

            if (pFile == null)
            {
                StartInit();
                unload = true;
            }

            Commodity.Clear();

            foreach (var node in pFile.BaseNode["Etc"]["Commodity.img"])
            {
                var snId   = node["SN"].ValueInt32();
                var itemId = node["ItemId"].ValueInt32();


                var ci = Commodity[snId] = new CommodityInfo
                {
                    Count        = node["Count"].ValueInt16(),
                    Gender       = (CommodityGenders)node["Gender"].ValueByte(),
                    ItemID       = itemId,
                    Period       = node["Period"].ValueInt16(),
                    OnSale       = node["OnSale"].ValueBool(),
                    Price        = node["Price"].ValueInt16(),
                    SerialNumber = snId
                };

                if (!Items.ContainsKey(itemId) &&
                    !Equips.ContainsKey(itemId) &&
                    !Pets.ContainsKey(itemId))
                {
                    Program.MainForm.LogAppend("Ignoring commodity SN {0} as it contains unknown itemid {1}", snId, itemId);

                    ci.OnSale     = false;
                    ci.StockState = StockState.NotAvailable;
                }

                if (ci.Price == 18000 && ci.OnSale)
                {
                    Program.MainForm.LogAppend("Making SN {0} itemid {1} not OnSale because its price is 18k", ci.SerialNumber, ci.ItemID);
                    ci.OnSale     = false;
                    ci.StockState = StockState.NotAvailable;
                }
            }

            Program.MainForm.LogAppend("Loaded {0} commodity items!", Commodity.Count);

            Packages.Clear();


            foreach (var node in pFile.BaseNode["Etc"]["CashPackage.img"])
            {
                var sn       = int.Parse(node.Name);
                var contents = node["SN"].Select(x => x.ValueInt32()).ToArray();
                var error    = false;
                foreach (var commoditySN in contents)
                {
                    if (Commodity.ContainsKey(commoditySN) == false)
                    {
                        error = true;
                        Program.MainForm.LogAppend("Ignoring Package {0} as it contains invalid commodity id {1}", sn, commoditySN);
                        break;
                    }
                }
                if (!error)
                {
                    Packages[sn] = contents;
                }
            }


            Program.MainForm.LogAppend("Loaded {0} cash packages!", Packages.Count);

            if (unload)
            {
                FinishInit();
            }
        }