Beispiel #1
0
    //Creates Player and Monstars for battle system test purposes
    //Can delete when i'm done testing
    void InitialSimSetup()
    {
        Actor p1 = Actor.Create(new HeroDef());
        Actor p2 = Actor.Create(new HeroDef());
        Item i1 = Item.Create(new TestBladeDef());
        Item i2 = Item.Create(new TestBladeDef()); 
        p1.EquipItem(i1);
        p2.EquipItem(i2);
		p1.name += "1";
		p2.name += "2";
        partySim = new Actor[]{p1,p2};
        
        partyInventory = new ItemInventory();
        partyInventory.Add
        (
            Item.Create(new TestPotion()),
            Item.Create(new TestPotion()),
            Item.Create(new TestPotion()),
            Item.Create(new TestBladeDef())  
        );
        
        Actor m1 = Actor.Create(new Mon_GiantRatDef());
        Actor m2 = Actor.Create(new Mon_GiantRatDef());
		m1.name += "1";
		m2.name += "2";
        monLibSim = new Actor[]{m1,m2};
    }
Beispiel #2
0
 void Awake()
 {
     inventory = GameObject.FindWithTag("Player").GetComponent<ItemInventory>();
     if (inventory == null)
     {
         this.enabled = false;
         return;
     }
     //gameObject.layer = LayerMask.NameToLayer("Interactable");
 }
 public bool AttemptCraft(ItemInventory inventory)
 {
     foreach (BlueprintCondition condition in mConditions)
       {
      if (!condition.Check(inventory))
         return false;
       }
       foreach (BlueprintCondition condition in mConditions)
       {
      inventory.ConsumeItem(condition.Name, condition.Count);
       }
       return true;
 }
    public CharacterParameterBasis(ICharacterBasisParameter basisparam)
        : base(basisparam)
    {
        BasisParameter = basisparam;
        CurrentBuffs = new List<StatusBuffBasis>();
        Offset = new ParameterOffset();
        Inventory = new ItemInventory(basisparam.InventorySize);
        CurrentExp = 0;
        CurrentActionSpeed = BasisParameter.ActionSpeed;
        CurrentLevel = 1;
        MaxHP = basisparam.InitHP;
        CurrentHP = MaxHP;
        WallPenatrableThrow = false;
        MaxSTR = basisparam.STR;
        CurrentSTR = MaxSTR;

        Skin = new CharacterSkin(this.BasisParameter);//(basisparam.SpritePath, basisparam.AnimatorControllerPath);
        if(TalkTextPath.Length!=0)TalkText = TalkXMLReder.loadXML(TalkTextPath);
    }
 public PlayerParameter(IPlayerBasisParameter basisparam)
     : base(basisparam)
 {
     MaxHunger = basisparam.InitHunger;
     CurrentHunger = basisparam.InitHunger;
     CurrentHungerSpeed =   basisparam.InitHugerSpeed;
     NextHungerCount = InitHunger;
     Weapon = WeaponBasis.Dummy;
     Shield = ShieldBasis.Dummy;
     ShotItem = ShotItemBasis.Dummy;
     Bangles = new BangleBasis[] { BangleBasis.Dummy,BangleBasis.Dummy };
     SaveDataConverter.add(this);
     Name = basisparam.OriginalName;
     AutoHealSpeed = DefaultAutoHealSpeed;
     NextAutoHealCount = DefaultAutoHealSpeed;
     Pocket = 0;
     ObjectClairvoyant = new bool[clairvoyantlistlength];
     setLelelAtk();
     WareHouseInventory = new ItemInventory(WareHouseInventorySize);
 }
    void OnClickEquipmentOnBody(GameObject go)
    {
        FCUIInventorySlot slot = go.GetComponent <FCUIInventorySlot>();
        ItemInventory     item = slot.Item;

        if (null != item)
        {
            if (FCUIInventory.Instance.CurrentSelectionItem != item)
            {
                FCUIInventory.Instance.CurrentSelectionItem = item;
                FCUIInventory.Instance.OnSwithToItemInfo();
                if (null != _lastSelectSlot)
                {
                    _lastSelectSlot.GodIgnoreMe();
                }
                slot.GodSelectedMe();
            }
            else
            {
                FCUIInventory.Instance.CurrentSelectionItem = null;
                FCUIInventory.Instance.OnResumeDefaultLayout();
                if (null != _lastSelectSlot)
                {
                    _lastSelectSlot.GodIgnoreMe();
                }
            }
        }
        else
        {
            FCUIInventory.Instance.CurrentSelectionItem = null;
            FCUIInventory.Instance.OnResumeDefaultLayout();
            if (null != _lastSelectSlot)
            {
                _lastSelectSlot.GodIgnoreMe();
            }
        }
        _lastSelectSlot = slot;
    }
Beispiel #7
0
    public void SelectObject()
    {
        if (currentID == -1)
        {
            currentID   = int.Parse(eventSystem.currentSelectedGameObject.name);
            currentItem = CopyInventoryItem(Items[currentID]);
            movingObject.gameObject.SetActive(true);
            movingObject.GetComponent <Image>().sprite = Data.Items[currentItem.ID].Image;

            AddItem(currentID, Data.Items[0], 0);
        }
        else
        {
            ItemInventory II = Items[int.Parse(eventSystem.currentSelectedGameObject.name)];

            if (currentItem.ID != II.ID)
            {
                AddInventoryItem(currentID, II);

                AddInventoryItem(int.Parse(eventSystem.currentSelectedGameObject.name), currentItem);
            }
            else
            {
                if (II.Count + currentItem.Count <= MaxItemInOneCell)
                {
                    II.Count += currentItem.Count;
                }
                else
                {
                    AddItem(currentID, Data.Items[II.ID], II.Count + currentItem.Count - MaxItemInOneCell);
                    II.Count = MaxItemInOneCell;
                }
                II.Item.GetComponentInChildren <Text>().text = II.Count.ToString();
            }
            currentID = -1;
            movingObject.gameObject.SetActive(false);
        }
    }
Beispiel #8
0
        public static bool MoveOut(ItemInventory fromIn, ItemInventory toIn, ItemPosition ip, int countX, int countY, ISkillArgs args, FreeRuleEventArgs fr, IInventoryUI fromUI, IInventoryUI toUI)
        {
            if (fromIn == toIn)
            {
                // 竖格超出
                if (countY >= toIn.GetRow() || countY < 0)
                {
                    if (toUI.MoveOutAction != null)
                    {
                        ip.GetKey().SetCount(ip.GetCount());
                        fr.TempUse(PARA_ITEM, ip.GetKey());
                        fr.Resume(PARA_ITEM);
                        RemoveItem(fromIn, ip, args);

                        toUI.MoveOutAction.Act(args);
                        return(true);
                    }
                }
            }
            if (fromIn == toIn)
            {
                // 横格超出
                if (countX >= toIn.GetColumn() || countX < 0)
                {
                    if (toUI.MoveOutAction != null)
                    {
                        ip.GetKey().SetCount(ip.GetCount());
                        fr.TempUse(PARA_ITEM, ip.GetKey());
                        fr.Resume(PARA_ITEM);
                        RemoveItem(fromIn, ip, args);

                        toUI.MoveOutAction.Act(args);
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #9
0
        protected virtual void DoSave(int slotStart, int slotsCount, string dataFile)
        {
            string file = Path.Combine(ContainerFolder, dataFile);

            if (IsEmpty)
            {
                File.Delete(file);
                return;
            }
            try
            {
                using (FileStream fileStream = File.Create(file + ".tmp"))
                {
                    using (BigEndianStream bigEndianStream = new BigEndianStream(fileStream, StreamRole.Server))
                    {
                        ItemInventory stack = ItemHelper.Void;
                        for (int i = slotStart; i < slotsCount; i++)
                        {
                            stack = Slots[i];
                            if (stack != null)
                            {
                                stack.Write(bigEndianStream);
                            }
                            else
                            {
                                ItemHelper.Void.Write(bigEndianStream);
                            }
                        }
                        SaveExtraData(bigEndianStream);
                    }
                }
            }
            finally
            {
                File.Delete(file);
                File.Move(file + ".tmp", file);
            }
        }
Beispiel #10
0
        public async Task Delete()
        {
            try
            {
                await unitOfWork.InventoryRepository.DeleteAsync(SelectedObject.InventoryId);

                await unitOfWork.SaveAsync();

                GridCollection.Remove(SelectedObject);
                MessageBoxService.Show("Category record Deleted");
            }
            catch (Exception ex)
            {
                MessageBoxService.Show(ex.InnerException.Message);
            }
            finally
            {
                SelectedObject = new ItemInventory()
                {
                    InventoryId = new Guid(), ItemId = ItemsData.FirstOrDefault().ItemId, CostCenterId = SalesOutletData.FirstOrDefault().SalesOutletId, Reference = "Opening stock", OtherDetails = "Remarks"
                };
            }
        }
Beispiel #11
0
        public void ReDraw(ISkillArgs args, ItemInventory inventory, bool includeBack)
        {
            SimpleProto itemInfo = FreePool.Allocate();

            itemInfo.Key = FreeMessageConstant.ItemInfo;
            itemInfo.Ss.Add(inventory.name);

            if (inventory.posList.Count > 0)
            {
                ItemPosition ip = inventory.posList[0];
                itemInfo.Bs.Add(false);
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                itemInfo.Ins.Add(info.cat);
                itemInfo.Ins.Add(info.id);
                itemInfo.Ins.Add(ip.GetCount());
            }
            else
            {
                itemInfo.Bs.Add(true);
            }

            FreeMessageSender.SendMessage(args, "current", itemInfo);
        }
Beispiel #12
0
    public void AddGraphics()
    {
        for (int i = 0; i < maxCount; i++)
        {
            GameObject newItem = Instantiate(gameObject, InventoryMainObject.transform) as GameObject;

            newItem.name = i.ToString();

            ItemInventory ii = new ItemInventory();
            ii.itemGameObj = newItem;

            RectTransform rt = newItem.GetComponent <RectTransform>();
            rt.localPosition = new Vector3(0, 0, 0);
            rt.localScale    = new Vector3(1, 1, 1);
            newItem.GetComponentInChildren <RectTransform>().localScale = new Vector3(1, 1, 1);

            Button tempButton = newItem.GetComponent <Button>();

            tempButton.onClick.AddListener(delegate { SelectObject(); });

            items.Add(ii);
        }
    }
Beispiel #13
0
        private void handleFromGround(string from, string to, ServerRoom room, FreeData fd)
        {
            SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from);

            if (info.cat > 0)
            {
                ItemInventory inv = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagGround);

                if (inv != null)
                {
                    inv.Clear();
                    FreeItem item = FreeItemManager.GetItem(room.ContextsWrapper.FreeArgs, FreeItemConfig.GetItemKey(info.cat, info.id), info.count);
                    item.GetParameters().AddPara(new IntPara("entityId", info.entityId));
                    inv.AddItem(room.ContextsWrapper.FreeArgs, item, false);

                    DragGroundOne(fd, room, to);
                }
                else
                {
                    Debug.LogErrorFormat("inventory {0} not existed.", from);
                }
            }
        }
Beispiel #14
0
    private void UpdateBodySlots()
    {
        _slotDict = new Dictionary <EnumTattooPart, TattooBodySlot>();

        TattooBodySlot[] slots = this.GetComponentsInChildren <TattooBodySlot>();

        int playerLevel = PlayerInfo.Instance.CurrentLevel;

        Dictionary <EnumTattooPart, ItemInventory> dict = PlayerInfo.Instance.playerTattoos.tattooDict;

        foreach (TattooBodySlot slot in slots)
        {
            _slotDict.Add(slot.part, slot);

            ItemInventory ii = null;

            if (dict.ContainsKey(slot.part))
            {
                ii = dict[slot.part];
            }
            slot.SetData(ii, _uiTattoo);
        }
    }
Beispiel #15
0
        public ItemContainer(Item item, XElement element)
            : base(item, element)
        {
            Inventory = new ItemInventory(item, this, capacity, SlotsPerRow);

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "containable":
                    RelatedItem containable = RelatedItem.Load(subElement, returnEmpty: false, parentDebugName: item.Name);
                    if (containable == null)
                    {
                        DebugConsole.ThrowError("Error in item config \"" + item.ConfigFile + "\" - containable with no identifiers.");
                        continue;
                    }
                    ContainableItems.Add(containable);
                    break;
                }
            }

            InitProjSpecific(element);
        }
Beispiel #16
0
        private static void DropItem(string inv, FreeData fd, ServerRoom room)
        {
            Debug.LogFormat("inv {0}", inv);
            int           c3 = fd.freeInventory.GetInventoryManager().GetInventory(inv).posList.Count;
            ItemInventory w3 = fd.freeInventory.GetInventoryManager().GetInventory(inv);

            if (c3 > 0)
            {
                ItemPosition ip = w3.posList[0];

                w3.RemoveItem(room.FreeArgs, ip);

                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());

                if (info.cat > 0)
                {
                    room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                        (ECategory)info.cat,
                        info.id,
                        ip.GetCount(), fd.Player.position.Value);
                }
            }
        }
Beispiel #17
0
    /// <summary>
    /// Отрисовка инвентаря
    /// </summary>
    void AddGraphics()
    {
        for (int i = 0; i < maxCount; i++)
        {
            GameObject newItem = Instantiate(gameObjShow, InventoryMainObject.transform) as GameObject; //Создание видимого объекта

            newItem.name = i.ToString();                                                                //Объект получает имя равное его порядковому номеру

            ItemInventory ii = new ItemInventory();                                                     //Реализуем ячейку инвентаря
            ii.itemGameObj = newItem;                                                                   //Записываем ссылку на объект

            RectTransform rt = newItem.GetComponent <RectTransform>();                                  //Информация о положении, размере, привязке и опоре для прямоугольника
            rt.localPosition = new Vector3(0, 0, 0);                                                    //Текущее положение
            rt.localScale    = new Vector3(1, 1, 1);                                                    //Текущий размер
            newItem.GetComponentInChildren <RectTransform>().localScale = new Vector3(1, 1, 1);         //Масштаб при использовании

            Button tempbutton = newItem.GetComponent <Button>();                                        //Придание свойств кнопки объекту

            tempbutton.onClick.AddListener(delegate { SelectObject(); });                               // Создание слушателя нажатия кнопки?

            items.Add(ii);                                                                              //Добавление объекта в список элементов инвентаря
        }
    }
Beispiel #18
0
        protected override void DropItems(EntityBase entity, StructBlock block, List <ItemInventory> overridedLoot = null)
        {
            var player = entity as Player;

            if (player != null)
            {
                if ((player.Inventory.ActiveItem is ItemWoodenShovel ||
                     player.Inventory.ActiveItem is ItemStoneShovel ||
                     player.Inventory.ActiveItem is ItemIronShovel ||
                     player.Inventory.ActiveItem is ItemGoldShovel ||
                     player.Inventory.ActiveItem is ItemDiamondShovel) &&
                    block.World.Server.Rand.Next(10) == 0)
                {
                    overridedLoot = new List <ItemInventory>(1);
                    ItemInventory item = ItemHelper.GetInstance((short)BlockData.Items.Flint);
                    item.Count = 1;
                    overridedLoot.Add(item);
                    base.DropItems(entity, block, overridedLoot);
                    return;
                }
            }
            base.DropItems(entity, block);
        }
Beispiel #19
0
    public void SelectObject()
    {
        if (currentID == -1)
        {
            currentID   = int.Parse(es.currentSelectedGameObject.name);
            currentItem = CopyInventoryItem(items[currentID]);
            movingObject.gameObject.SetActive(true);
            movingObject.GetComponent <Image>().sprite = data.items[currentItem.id].img;
            currentItem.stuck = data.items[currentItem.id].stuck;
            AddItem(currentID, data.items[0], 0);
        }
        else
        {
            ItemInventory II = items[int.Parse(es.currentSelectedGameObject.name)];
            if (currentItem.id != II.id)
            {
                AddInventoryItem(currentID, II);
                AddInventoryItem(int.Parse(es.currentSelectedGameObject.name), currentItem);
            }
            else
            {
                if (II.count + currentItem.count <= currentItem.stuck)
                {
                    II.count += currentItem.count;
                }
                else
                {
                    AddItem(currentID, data.items[II.id], II.count + currentItem.count - currentItem.stuck);
                    II.count = currentItem.stuck;
                }
                II.itemGameObj.GetComponentInChildren <Text>().text = II.count.ToString();
            }
            currentID = -1;

            movingObject.gameObject.SetActive(false);
        }
    }
Beispiel #20
0
        public void DestroyItem(ItemEntity item)
        {
            if (this.IsItemLoaded(item.ID) == false)
            {
                throw new ArgumentException("Cannot destroy an item that was not loaded by this item manager");
            }

            // remove the item from the list
            this.mItemList.Remove(item.ID);

            // check if there are inventories loaded for this item
            if (this.IsItemLoaded(item.LocationID) == true)
            {
                ItemInventory inventory = this.GetItem(item.LocationID) as ItemInventory;

                // remove the item from the inventory
                inventory.RemoveItem(item);

                // try to remove from meta inventories too
                try
                {
                    ItemInventory metaInventory =
                        this.MetaInventoryManager.GetOwnerInventoriesAtLocation(item.LocationID, item.OwnerID);

                    metaInventory.RemoveItem(item);
                }
                catch (ArgumentOutOfRangeException)
                {
                }
            }

            // set the item to the recycler location
            item.LocationID = this.LocationRecycler.ID;

            // finally remove the item off the database
            item.Destroy();
        }
        public static void MoveItem(string key, FreeData fd, ISkillArgs args, int x, int y, int toGlobalX, int toGlobalY, int stageWidth, int stageHeigth, int fromGlobalX, int fromGlobalY)
        {
            toGlobalY   = stageHeigth - toGlobalY;
            fromGlobalY = stageHeigth - fromGlobalY;
            ItemPosition ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager());

            if (ip != null)
            {
                InventoryManager     invManager = fd.freeInventory.GetInventoryManager();
                ItemInventory        fromInv    = ip.GetInventory();
                ItemInventory        toInv      = null;
                FreeUIUtil.Rectangle rec        = null;
                foreach (string inv in invManager.GetInventoryNames())
                {
                    ItemInventory ii = invManager.GetInventory(inv);
                    if (ii != null && ii.IsOpen())
                    {
                        rec = ((SimpleInventoryUI)ii.GetInventoryUI()).GetItemRegion(args, stageWidth, stageHeigth);
                        if (rec.In(toGlobalX, toGlobalY))
                        {
                            toInv = ii;
                            break;
                        }
                    }
                }
                if (toInv == fromInv || toInv == null)
                {
                    ItemInventoryUtil.MovePosition(ip.GetInventory(), ip.GetInventory(), (SimpleInventoryUI)fromInv.GetInventoryUI(), (SimpleInventoryUI)fromInv.GetInventoryUI(), ip, x, y, args);
                }
                else
                {
                    FreeUIUtil.Rectangle itemRec = ((SimpleInventoryUI)fromInv.GetInventoryUI()).GetItemRegion(fromInv, args, stageWidth, stageHeigth, ip);
                    ItemInventoryUtil.MovePosition(ip.GetInventory(), invManager.GetInventory(toInv.GetName()), (SimpleInventoryUI)fromInv.GetInventoryUI(), (SimpleInventoryUI)toInv.GetInventoryUI(), ip, toGlobalX - rec.x - (fromGlobalX - itemRec.x), toGlobalY
                                                   - rec.y - (fromGlobalY - itemRec.y), args);
                }
            }
        }
Beispiel #22
0
        public int SpoilItemsAndReturnCount()
        {
            if (DebuggingVariables.FishDoNotGoBadAtEndOfTheDay)
            {
                return(0);
            }

            var itemKeys           = ItemInventory.Keys.ToArray();
            var numberKeys         = itemKeys.Count();
            var numberSpoiledItems = 0;

            for (int i = numberKeys - 1; i >= 0; i--)
            {
                var  keyToCheckForFish = itemKeys[i];
                bool isFish            = GlobalContent.ItemDefinition[keyToCheckForFish].IsFish;
                if (isFish)
                {
                    numberSpoiledItems += ItemInventory[keyToCheckForFish];
                    ItemInventory.RemoveAll(keyToCheckForFish);
                }
            }

            return(numberSpoiledItems);
        }
Beispiel #23
0
        private void ExchangeWeapon(ISkillArgs args, FreeData fd, string from, string to)
        {
            string fromWeapon = from.Split(',')[0].Trim();
            string toWeapon   = to.Split(',')[0].Trim();

            if (fromWeapon != toWeapon)
            {
                ItemInventory fromInv = fd.freeInventory.GetInventoryManager().GetInventory(fromWeapon);
                ItemInventory toInv   = fd.freeInventory.GetInventoryManager().GetInventory(toWeapon);

                ExchangeInv(args, fromInv, toInv);

                string fromKey = fromWeapon.Substring(1, 1);
                string toKey   = toWeapon.Substring(1, 1);

                for (int i = 1; i <= 5; i++)
                {
                    ExchangeInv(args, fd.freeInventory.GetInventoryManager().GetInventory("w" + fromKey + i),
                                fd.freeInventory.GetInventoryManager().GetInventory("w" + toKey + i));
                }

                fd.Player.ModeController().ExchangePlayerWeapon(fd.Player);
            }
        }
 public List<ItemBasis> getMultiSelectedItemList(ItemInventory targetinv)
 {
     List<ItemBasis> ret = new List<ItemBasis>();
     foreach (int[] idxs in Window.MultiSelectedIndexListToInt) {
         int idx = idxs[0] + idxs[2] * Window.RowSize;
         ret.Add(targetinv[idx]);
         Debug.Log(string.Format("[{0}]:", idx) + targetinv[idx]);
     }
     return ret;
 }
Beispiel #25
0
 void Awake()
 {
     Instance = this;
     Initialize();
 }
Beispiel #26
0
 private static void HandleMoveAction(ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, IEventArgs args)
 {
     HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, true);
     HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, false);
 }
Beispiel #27
0
        public static void Move(ItemInventory fromIn, ItemInventory toIn, ItemPosition ip, int countX, int countY, ISkillArgs args, FreeRuleEventArgs fr, IInventoryUI fromUI, IInventoryUI toUI)
        {
            if (fromIn != toIn)
            {
                fr.TempUse(PARA_ITEM, ip);
                bool canDrop = toIn.IsCanDrop(ip, args);
                // 如果toIn 不可以拖入物品
                if (!canDrop)
                {
                    fromUI.UpdateItem(args, fromIn, ip);
                    if (toIn.GetDropAction() != null)
                    {
                        toIn.GetDropAction().Act(args);
                    }
                    //HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args);
                    fr.Resume(PARA_ITEM);
                    return;
                }
                fr.Resume(PARA_ITEM);
            }
            // 已有
            ItemPosition[] olds = toIn.GetItem(countX, countY, ip.GetKey().GetGridWidth(), ip.GetKey().GetGridHeight());
            ItemPosition   old  = null;

            if (olds.Length == 1)
            {
                old = olds[0];
                if (old != ip)
                {
                    fr.TempUse(PARA_ITEM, ip);
                    if (old.GetKey().GetKey().Equals(ip.GetKey().GetKey()))
                    {
                        int delta = old.GetKey().GetItemStack() - old.GetCount();
                        if (delta > 0)
                        {
                            // 堆叠物品
                            ChangeItemStack(delta, fromIn, toIn, fromUI, toUI, ip, old, args);
                        }
                        else
                        {
                            // 交换物品位置
                            ExchangeItem(fromIn, toIn, fromUI, toUI, ip, old, args);
                        }
                    }
                    else
                    {
                        if (!ip.DragTo(args, old))
                        {
                            ExchangeItem(fromIn, toIn, fromUI, toUI, ip, old, args);
                        }
                        else
                        {
                            if (ip.GetInventory() != null)
                            {
                                fromUI.UpdateItem(args, fromIn, ip);
                            }
                        }
                    }
                    fr.Resume(PARA_ITEM);
                    return;
                }
            }
            fr.TempUse(PARA_ITEM, ip);
            MoveItem(countX, countY, fromIn, toIn, fromUI, toUI, ip, old, args);
            fr.Resume(PARA_ITEM);
        }
Beispiel #28
0
        public PyDataType Add(PyInteger itemID, PyInteger quantity, PyInteger flag, CallInformation call)
        {
            if (itemID == call.Client.ShipID)
            {
                throw new CantMoveActiveShip();
            }

            // TODO: ADD CONSTRAINTS CHECKS FOR THE FLAG
            if (this.ItemManager.IsItemLoaded(itemID) == false)
            {
                // not loaded item, the steps are simpler as the server doesn't really know much about it
                ItemEntity item = this.ItemManager.LoadItem(itemID);

                if (quantity < item.Quantity)
                {
                    // subtract the quantities and create the new item
                    item.Quantity -= quantity;
                    item.Persist();

                    // create a new item with the same specs as the original
                    ItemEntity clone = this.ItemManager.CreateSimpleItem(item.Type, item.OwnerID, this.mInventory.ID, (ItemFlags)(int)flag, quantity,
                                                                         item.Contraband, item.Singleton);

                    // persist it to the database
                    clone.Persist();
                    // notify the client of the new item
                    call.Client.NotifyNewItem(clone);
                    // and notify the amount change
                    call.Client.NotifyItemQuantityChange(item, item.Quantity + quantity);
                }
                else
                {
                    int       oldLocation = item.LocationID;
                    ItemFlags oldFlag     = item.Flag;

                    // simple, move the item
                    item.LocationID = this.mInventory.ID;
                    item.Flag       = (ItemFlags)(int)flag;

                    item.Persist();

                    // add it to the inventory
                    this.mInventory.AddItem(item);

                    // notify the client
                    call.Client.NotifyItemLocationChange(item, oldFlag, oldLocation);
                }
            }
            else
            {
                ItemEntity item = this.ItemManager.GetItem(itemID);

                // ensure there's enough quantity in the stack to split it
                if (quantity > item.Quantity)
                {
                    return(null);
                }

                if (quantity == item.Quantity)
                {
                    // the item is being moved completely, the easiest way is to remove from the old inventory
                    // and put it in the new one

                    // this means we require access to the original inventory to remove the item from there
                    // and thus we have to be extra careful
                    if (this.ItemManager.IsItemLoaded(item.LocationID) == true)
                    {
                        ItemInventory inventory = this.ItemManager.GetItem(item.LocationID) as ItemInventory;

                        // remove the item from the inventory
                        inventory.RemoveItem(item);

                        // TODO: TAKE INTO ACCOUNT META INVENTORIES
                    }

                    int       oldLocationID = item.LocationID;
                    ItemFlags oldFlag       = item.Flag;

                    item.LocationID = this.mInventory.ID;
                    item.Flag       = (ItemFlags)(int)flag;

                    item.Persist();
                    this.mInventory.AddItem(item);
                    // notify the client of the location change
                    call.Client.NotifyItemLocationChange(item, oldFlag, oldLocationID);
                }
                else
                {
                    // create a new item with the same specs as the original
                    ItemEntity clone = this.ItemManager.CreateSimpleItem(item.Type, item.OwnerID, this.mInventory.ID, (ItemFlags)(int)flag, quantity,
                                                                         item.Contraband, item.Singleton);

                    // subtract the quantity off the original item
                    item.Quantity -= quantity;
                    // notify the changes to the client
                    call.Client.NotifyItemQuantityChange(item, item.Quantity + quantity);
                    call.Client.NotifyNewItem(clone);
                    // persist the item changes in the database
                    clone.Persist();
                    item.Persist();
                }
            }

            return(null);
        }
Beispiel #29
0
 void Start()
 {
     inventory = FindObjectOfType<ItemInventory>();
 }
Beispiel #30
0
 void Awake()
 {
     groundCheck = transform.GetComponent<PlayerGroundCheck>();
     inventory = transform.GetComponent<ItemInventory>();
     inputScript = transform.GetComponent<InputScript>();
     rigidbody = transform.GetComponent<Rigidbody2D>();
     topCollider = transform.GetComponent<BoxCollider2D>();
     spriteAnimator = transform.GetComponent<SpriteAnimator>();
 }
 public static void AllItemAppraised(ItemInventory inv)
 {
     foreach (var item in inv.toArray())
     {
         GameController.DungeonInformation.updateItemDetectionLevel(item.GetType(),ItemBasis.DetectionLevel.CORRECT);
         var hasinv = item as IHasInventoryItem;
         if (hasinv != null) AllItemAppraised(hasinv.getInventory());
     }
 }
 public override ItemBasis tradeItem(ItemBasis invitem, ItemInventory targetinv)
 {
     autoremoveEquipment(invitem);
     var equiping = equiped(invitem as EquipmentItemBasis);
     if (!(equiping && invitem.IsCursed)) {
         ItemBasis pickup = base.tradeItem(invitem, targetinv);
         GameController.SoundController.playSE(SoundNameList.Character_PickUpItem);
         GameController.PlayingLogger.tradeItem(this, invitem, pickup);
         return pickup;
     }
     return null;
 }
 public override void throwItem(ItemBasis item, ItemInventory targetinv, Action callback = null)
 {
     //if (item is EquipmentItemBasis && equiped(item as EquipmentItemBasis)) Parameter.removeEquipment(item.Code);
     autoremoveEquipment(item);
     bool equiping = this.equiped(item as EquipmentItemBasis);
     if (!(equiping && item.IsCursed))
     {
         base.throwItem(item, targetinv, callback);
     }
     else {
         callback();
     }
 }
 public override void putItem(ItemBasis item, ItemInventory targetinv)
 {
     base.putItem(item, targetinv);
     autoremoveEquipment(item);
     GameController.SoundController.playSE(SoundNameList.Character_PutItem);
     GameController.PlayingLogger.putItem(this, item);
 }
 public static void testWrite()
 {
     if (!Directory.Exists(savedir)) {
         Debug.LogError("Save Directory is None!");
         Directory.CreateDirectory(savedir);
     }
     LocalSaveData test = new LocalSaveData();
     test.Player.Position = new Vector2(3, 7);
     test.Player.PlayerName = "たかし";
     var ken = new IronSword();
     ken.init(3);
     var arrow = new WoodArrow();
     arrow.init(12);
     var tubo = new HOZON();
     tubo.init(4);
     tubo.putinItem(arrow);
     Debug.Log("Pot: "+tubo.showInventory());
     ItemInventory inv = new ItemInventory(10);
     inv.add(ken,tubo,arrow);
     test.Player.ParameterData.Inventory = ItemData.convert(inv);
     test.Player.ParameterData.InventorySize = inv.InventorySize;
     string json =  JsonUtility.ToJson(test,true);
     Debug.Log(json);
     string savepath = savedir + @"\saveTest";
     using (FileStream fs = new FileStream(savepath,FileMode.Create,FileAccess.Write)) {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(fs, json);
     }
     testLoad();
 }
 public CMD_ThrowItem(PlayerController owner, ItemBasis target,ItemInventory targetinv)
     : base(owner)
 {
     Target = target;
     TargetInventory = targetinv;
 }
		public CharacterDatabaseData(DataRow row)
			: base() {
			Skills = new CharacterSkillTree();
			Storage = new ItemStorage();
			Inventory = new ItemInventory();
			Cart = new ItemInventoryCart();
			Hotkeys = new CharacterHotkey[Global.MAX_HOTKEYS];
			Friends = new CharacterFriendList();

			if (row != null) {
				LoadFromDatabase(row);
			}
		}
Beispiel #38
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);
            eventKey.SetValue(message.Ss[0]);
            room.FreeArgs.GetDefault().GetParameters().TempUse(eventKey);

            room.GameRule.HandleFreeEvent(room.RoomContexts, player, message);

            string key = message.Ss[0];

            Debug.LogFormat("click item {0}. ", key);
            if (message.Bs[0])
            {
                // 显示拆分UI
                if (message.Bs[1])
                {
                    PickupItemUtil.ShowSplitUI(room, fd, key);
                    return;
                }
                if (key.StartsWith("ground"))
                {
                    SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, key);
                    if (info.cat > 0)
                    {
                        if (CanChangeBag(room, fd, key))
                        {
                            PickupItemUtil.AddItemToPlayer(room, player, info.entityId, info.cat, info.id, info.count);
                        }
                    }
                }
                else if (key.StartsWith("default"))
                {
                    ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                    if (info.cat == (int)ECategory.WeaponPart)
                    {
                        string inv = PickupItemUtil.AutoPutPart(fd, FreeItemConfig.GetItemInfo(info.cat, info.id));
                        if (inv != null && inv != "default")
                        {
                            ItemInventoryUtil.MovePosition(ip,
                                                           fd.GetFreeInventory().GetInventoryManager().GetInventory(inv), 0, 0, room.FreeArgs);
                        }
                    }
                    else
                    {
                        FreeItemManager.UseItem(key, fd, room.FreeArgs);
                    }
                }
                // 点击装配好的配件,自动进背包
                else if (key.StartsWith("w") && key.Length == 3)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(key);
                    ItemInventory defaultInventory = fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory();

                    if (ii != null && ii.posList.Count > 0)
                    {
                        ItemPosition ip = ii.posList[0];
                        if (BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, ip))
                        {
                            int[] xy = defaultInventory.GetNextEmptyPosition(ip.GetKey());
                            ItemInventoryUtil.MovePosition(ip,
                                                           defaultInventory, xy[0], xy[1], room.FreeArgs);
                        }
                    }
                }
                else
                {
                    FreeItemManager.UseItem(key, fd, room.FreeArgs);
                }
            }

            room.FreeArgs.Resume(PARA_PLAYER_CURRENT);
            room.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY);
        }
Beispiel #39
0
	public override void Fire (ItemInventory caller) {
		//But first, let me take a selfie.
	}
 // Use this for initialization
 void Start()
 {
     inventory = GameObject.FindGameObjectWithTag("Manager").GetComponent<ItemInventory>();
 }
Beispiel #41
0
 void Awake()
 {
     inventory = GameObject.FindWithTag("Player").GetComponent<ItemInventory>();
 }
 public virtual void throwItem(ItemBasis item, ItemInventory targetinv, Action callback = null)
 {
     ItemEntity entity;
     GameController.SoundController.playSE(SoundNameList.Item_Throw);
     //GameController.PlayingLogger.addLog((targetinv != null).ToString());
     if (targetinv != null && targetinv.contains(item))
     {
         targetinv.remove(item);
         entity = ObjectEntityFactory.enableItemEntity(item, this.CurrentPosition); //ItemEntityFactory.instantiateItemEntity(item, this.CurrentPosition);
         //Debug.Log("Erase!"+item.Erase);
     }
     else
     {
         entity = ccm.OnItemEntity;
         entity.Object = item;
     }
     entity.throwItem(CurrentDirection, Parameter.WallPenatrableThrow, this,callback);
     GameController.PlayingLogger.thorwItem(this, item);
 }
    public virtual void putItem(ItemBasis item, ItemInventory targetinv)
    {
        if (targetinv.contains(item))
        {
            //Debug.Log("Put Item!");
            //Parameter.Inventory.remove(item);
            targetinv.remove(item);
            ObjectEntityFactory.enableItemEntity(item, this.CurrentPosition);

        }
    }
Beispiel #44
0
	public abstract void Fire (ItemInventory caller);
 public virtual ItemBasis tradeItem(ItemBasis invitem, ItemInventory targetinv)
 {
     ItemBasis pickup = ccm.OnItemEntity.Object;
     targetinv.trade(invitem, ccm.OnItemEntity);
     ccm.OnItemEntity.Object = invitem;
     //Debug.LogFormat("Trade:{0},{1}", invitem.Name, invitem.Erase);
     //Debug.LogFormat("PickUp:{0},{1}", pickup.Name, pickup.Erase);
     //Debug.LogFormat("OnEntity:{0},{1}", ccm.OnItemEntity.Entity.Name, ccm.OnItemEntity.Entity.Erase);
     return pickup;
 }
Beispiel #46
0
    public void SetData(ItemInventory itemInventory)
    {
        _itemData = itemInventory.ItemData;

        SetData(_itemData, itemInventory.Count);
    }
Beispiel #47
0
 protected reprocessingSvc(ReprocessingDB reprocessingDb, StandingDB standingDb, Corporation corporation, Station station, ItemInventory inventory, ItemFactory itemFactory, BoundServiceManager manager, Client client) : base(manager, client)
 {
     this.ReprocessingDB = reprocessingDb;
     this.StandingDB     = standingDb;
     this.mCorporation   = corporation;
     this.mStation       = station;
     this.mInventory     = inventory;
     this.ItemFactory    = itemFactory;
 }
Beispiel #48
0
	public override void Fire (ItemInventory caller) {
		//Take a swing, brah.
		//TODO: Deal damage to the struck enemy/object.
		swinging = true;
	}
Beispiel #49
0
 // Use this for initialization
 void Start()
 {
     itemScript = GameObject.FindGameObjectWithTag("Canvas2").GetComponent <ItemInventory>();
     dooranim   = gameObject.GetComponent <Animator>();
 }
Beispiel #50
0
 //ItemInteraction[] items;
 //DoorKnob[] doors;
 // Use this for initialization
 void Start()
 {
     inventory = FindObjectOfType<ItemInventory>();
     //items = FindObjectsOfType<ItemInteraction>();
     //doors = FindObjectsOfType<DoorKnob>();
 }
        public static void DragItem(string key, FreeData fd, ISkillArgs args, string toKey)
        {
            ItemPosition ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager());

            if (ip == null)
            {
                ItemInventory inv = fd.freeInventory.GetInventoryManager().GetInventory(key.Trim());
                if (inv != null && inv.GetInventoryUI() is UnityOneInventoryUi)
                {
                    if (inv.posList.Count > 0)
                    {
                        ip = inv.posList[0];
                    }
                }
            }
            ItemPosition toIp = null;

            if (!StringUtil.IsNullOrEmpty(toKey))
            {
                toIp = GetItemPosition(args, toKey, fd.freeInventory.GetInventoryManager());
            }
            if (ip != null)
            {
                InventoryManager invManager = fd.freeInventory.GetInventoryManager();
                ItemInventory    fromInv    = ip.GetInventory();

                ItemInventory toInv = null;
                if (toIp != null)
                {
                    toInv = toIp.GetInventory();
                }
                else
                {
                    string[] ss = toKey.Split(',');
                    toInv = fd.freeInventory.GetInventoryManager().GetInventory(ss[0].Trim());
                }

                int x = -1;
                int y = -1;
                if (toIp != null)
                {
                    x = toIp.x;
                    y = toIp.y;
                }
                else if (toInv != null)
                {
                    if (toInv.GetName() == ChickenConstant.BagDefault)
                    {
                        foreach (ItemPosition old in toInv.GetItems())
                        {
                            if (old.GetKey().GetKey() == ip.GetKey().GetKey() && old.GetCount() < ip.GetKey().GetItemStack())
                            {
                                x = old.GetX();
                                y = old.GetY();
                                break;
                            }
                        }
                    }

                    if (x < 0)
                    {
                        int[] pos = toInv.GetNextEmptyPosition(ip.GetKey());
                        x = pos[0];
                        y = pos[1];
                    }
                }

                if (toInv != null && fromInv != toInv)
                {
                    if (toInv.GetName() == ChickenConstant.BagDefault)
                    {
                        if (BagCapacityUtil.CanAddToBag(args, fd, ip))
                        {
                            ItemInventoryUtil.Move(fromInv, toInv, ip, x, y, args, (FreeRuleEventArgs)args, fromInv.GetInventoryUI(), toInv.GetInventoryUI());
                        }
                    }
                    else
                    {
                        ItemInventoryUtil.Move(fromInv, toInv, ip, x, y, args, (FreeRuleEventArgs)args, fromInv.GetInventoryUI(), toInv.GetInventoryUI());
                    }
                }
                else
                {
                    if (toInv == null)
                    {
                        //fromInv.GetInventoryUI().ReDraw(args, fromInv, true);
                    }
                    else
                    {
                        //fromInv.GetInventoryUI().ReDraw(args, fromInv, true);
                    }
                }
            }
        }
 public static void removeAllCommodities(ItemInventory inventory)
 {
     foreach (var item in inventory.toArray()) {
         var hasinv = item as IHasInventoryItem;
         if (hasinv != null) removeAllCommodities(hasinv.getInventory());
     }
     inventory.removeAll(item => item.IsCommodity);
 }
Beispiel #53
0
        public PyDataType Add(PyInteger itemID, CallInformation call)
        {
            if (itemID == call.Client.ShipID)
            {
                throw new CantMoveActiveShip();
            }

            // the item has to be moved to this inventory completely
            if (this.ItemManager.IsItemLoaded(itemID) == false)
            {
                ItemEntity item = this.ItemManager.LoadItem(itemID);

                // get old information
                int       oldLocationID = item.LocationID;
                ItemFlags oldFlag       = item.Flag;

                // set the new location for the item
                item.LocationID = this.mInventory.ID;
                item.Flag       = this.mFlag;

                call.Client.NotifyItemLocationChange(item, oldFlag, oldLocationID);

                // finally add the item to this inventory
                this.mInventory.AddItem(item);

                item.Persist();
            }
            else
            {
                ItemEntity item = this.ItemManager.GetItem(itemID);

                // remove item off the old inventory
                if (this.ItemManager.IsItemLoaded(item.LocationID) == true)
                {
                    ItemInventory inventory = this.ItemManager.GetItem(item.LocationID) as ItemInventory;

                    inventory.RemoveItem(item);
                }

                // remove item off the meta inventories
                try
                {
                    this.ItemManager.MetaInventoryManager
                    .GetOwnerInventoriesAtLocation(item.LocationID, item.OwnerID)
                    .RemoveItem(item);
                }
                catch (ArgumentOutOfRangeException)
                {
                }

                // get old information
                int       oldLocationID = item.LocationID;
                ItemFlags oldFlag       = item.Flag;

                // set the new location for the item
                item.LocationID = this.mInventory.ID;
                item.Flag       = this.mFlag;

                call.Client.NotifyItemLocationChange(item, oldFlag, oldLocationID);

                // finally add the item to this inventory
                this.mInventory.AddItem(item);

                item.Persist();
            }

            return(null);
        }
 public static ItemInventory convert(int size,ItemData[] itemdatas)
 {
     ItemInventory ret = new ItemInventory(size);
     ItemBasis item;
     foreach (ItemData itemdata in itemdatas) {
         item = itemdata.toItem();
         item.IsInitalized = true;
         Debug.LogFormat("Data:{0}, Item:{1}",itemdata.type,item.Name);
         ret.add(item,true);
     }
     return ret;
 }
Beispiel #55
0
        public static void MovePosition(ItemInventory fromIn, ItemInventory toIn, SimpleInventoryUI fromUI, SimpleInventoryUI toUI, ItemPosition ip, int x, int y, ISkillArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;
            int oneX             = toUI.GetWidth(args) / toIn.GetColumn();
            int countX           = x / (oneX);
            int remain           = x % (oneX);

            if (fromIn == toIn)
            {
                if (MyMath.Abs(remain) > oneX / 2)
                {
                    if (remain > 0)
                    {
                        countX++;
                    }
                    else
                    {
                        countX--;
                    }
                }
                countX = countX + ip.GetX();
            }
            else
            {
                if (countX < 0)
                {
                    countX = 0;
                }
            }
            int oneY   = toUI.GetHeight(args) / toIn.GetRow();
            int countY = y / (oneY);

            remain = y % (oneY);
            if (fromIn == toIn)
            {
                if (MyMath.Abs(remain) > oneY / 2)
                {
                    if (remain > 0)
                    {
                        countY++;
                    }
                    else
                    {
                        countY--;
                    }
                }
                countY = countY + ip.GetY();
            }
            else
            {
                if (countY < 0)
                {
                    countY = 0;
                }
                //countY = toIn.row - countY - 1;
            }
            if (MoveOut(fromIn, toIn, ip, countX, countY, args, fr, fromUI, toUI))
            {
                return;
            }
            Move(fromIn, toIn, ip, countX, countY, args, fr, fromUI, toUI);
        }
 public static ItemInventory create(int size,ItemBasis[] items)
 {
     ItemInventory ret =  new ItemInventory(size);
     ret.add(items);
     return ret;
 }
Beispiel #57
0
 private static void RemoveItem(ItemInventory inventory, ItemPosition ip, ISkillArgs args)
 {
     inventory.RemoveItem(args, ip);
     RemoveUI(ip, args);
 }
 public void init(ItemInventory target)
 {
     TargetInventory = target;
     Items = target.toArray();//WindowOwner.Parameter.Inventory.toArray();
     //if (Items.Length == 0) return;
     WindowText[,] itemname = new WindowText[Window.RowSize, 1];
     for (int i = 0; i < itemname.Length; i++)
     {
         itemname[i, 0] = new WindowText(SelectableWindow.EOL, Window.TextAreaPosition + new Vector2(10, WindowConfigure.fontScale(scale * i)));
         itemname[i, 0].TextAreaSize = new Vector2(Window.TextAreaSize.x - WindowConfigure.fontScale(1.25f), WindowConfigure.fontScale(scale));
     }
     Window.setText(itemname);
     MaxPageNum = (int)Mathf.Ceil(Items.Length / (float)Window.RowSize);
     //Debug.Log(MaxPageNum);
     CurrentPageNum = 0;
     setOnePageTexts();
 }
Beispiel #59
0
        public override void DoAction(IEventArgs args)
        {
            IGameUnit player = GetPlayer(args);

            if (player != null)
            {
                if (StringUtil.IsNullOrEmpty(name))
                {
                    name = InventoryManager.DEFAULT;
                }
                ItemInventory    ii  = ((FreeData)player).freeInventory.GetInventoryManager().GetInventory(name);
                FreeUIShowAction fui = new FreeUIShowAction();
                fui.SetScope(SendMessageAction.SCOPE_PLYAER);
                fui.SetPlayer(this.player);
                if (alwaysOpen)
                {
                    fui.SetTime(FreeUIShowAction.ALWAYS);
                    ii.SetOpen(true);
                }
                else
                {
                    if (alwaysClose)
                    {
                        fui.SetTime(FreeUIShowAction.HIDE);
                        ii.SetOpen(false);
                    }
                    else
                    {
                        if (ii.IsOpen())
                        {
                            fui.SetTime(FreeUIShowAction.HIDE);
                            ii.SetOpen(false);
                        }
                        else
                        {
                            fui.SetTime(FreeUIShowAction.ALWAYS);
                            ii.SetOpen(true);
                        }
                    }
                }
                if (ii.IsOpen())
                {
                    // ii.reDraw(fr);
                    if (ii.GetOpenAction() != null)
                    {
                        ii.GetOpenAction().Act(args);
                    }
                }
                else
                {
                    if (ii.GetCloseAction() != null)
                    {
                        ii.GetCloseAction().Act(args);
                    }
                }
                fui.SetKey(ii.GetUIKey());
                fui.Act(args);
                foreach (ItemPosition ip in ii.GetItems())
                {
                    fui.SetKey(ip.GetUIKey());
                    fui.Act(args);
                }
            }
        }
 public bool Check(ItemInventory inventory)
 {
     return (inventory.CheckItemCount(mName) >= mCount);
 }