Esempio n. 1
0
 public virtual void ChangePosition(ItemPosition ip, com.wd.free.item.ItemInventory toIn, int toX, int toY)
 {
     for (int i = ip.GetX(); i < ip.GetX() + ip.GetKey().GetGridWidth(); i++)
     {
         for (int j = ip.GetY(); j < ip.GetY() + ip.GetKey().GetGridHeight(); j++)
         {
             ins[j][i] = false;
         }
     }
     for (int i_1 = toX; i_1 < toX + ip.GetKey().GetGridWidth(); i_1++)
     {
         for (int j = toY; j < toY + ip.GetKey().GetGridHeight(); j++)
         {
             toIn.ins[j][i_1] = true;
         }
     }
     // System.err.println(ip.getKey().getKey() + " " + ip.getX() + ","
     // + ip.getY() + "->" + toX + "," + toY);
     ip.SetX(toX);
     ip.SetY(toY);
     if (ip.inventory != toIn)
     {
         posList.Remove(ip);
         toIn.posList.Add(ip);
     }
     ip.inventory = toIn;
 }
Esempio n. 2
0
        public void StartUseItem(IEventArgs args, FreeData fd, ItemPosition ip, int sing, int sound)
        {
            PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            fd.Player.playerMove.InterruptAutoRun();

            SkillTimeTrigger trigger = (SkillTimeTrigger)itemSkill.trigger;

            trigger.SetTime(sing * 1000);
            trigger.Reset();

            UsingItemAction interAction = (UsingItemAction)trigger.interAction;

            interAction.fd = fd;
            interAction.ip = ip;

            UsingItemAction action = (UsingItemAction)itemSkill.GetEffect();

            action.fd = fd;
            action.ip = ip;

            StartCounter(args, sing, fd, true);

            startUse = true;

            FreeSoundUtil.Stop("use", args, fd);

            if (sound > 0)
            {
                FreeSoundUtil.PlayOnce("use", sound, args, fd);
            }
        }
Esempio n. 3
0
        private bool AddNewItem(ISkillArgs args, FreeItem item, bool useMove)
        {
            for (int i = 0; i <= row - item.GetGridHeight(); i++)
            {
                for (int j = 0; j <= column - item.GetGridWidth(); j++)
                {
                    bool filled = false;
                    for (int ii = i; ii < i + item.GetGridHeight(); ii++)
                    {
                        for (int jj = j; jj < j + item.GetGridWidth(); jj++)
                        {
                            if (ins[ii][jj])
                            {
                                filled = true;
                            }
                        }
                    }
                    if (!filled)
                    {
                        ItemPosition ip = new ItemPosition(item, j, i);
                        ip.inventory = this;
                        posList.Add(ip);
                        for (int ii_1 = i; ii_1 < i + item.GetGridHeight(); ii_1++)
                        {
                            for (int jj = j; jj < j + item.GetGridWidth(); jj++)
                            {
                                ins[ii_1][jj] = true;
                            }
                        }
                        if (inventoryUI != null && args != null)
                        {
                            inventoryUI.AddItem(args, this, ip);
                        }
                        //if ("default".Equals(name))
                        //{
                        args.TempUsePara(new StringPara("inventory", name));
                        item.Added(args);
                        if (inventoryUI != null && inventoryUI.MoveAction != null && useMove)
                        {
                            args.TempUsePara(new StringPara("to", this.name));
                            args.TempUse("item", ip);

                            inventoryUI.MoveAction.Act(args);

                            args.Resume("item");
                            args.ResumePara("to");
                        }
                        args.ResumePara("inventory");
                        //}
                        return(true);
                    }
                }
            }
            if (inventoryUI != null)
            {
                inventoryUI.Error(args, this, "物品栏已满");
            }
            return(false);
        }
Esempio n. 4
0
        public virtual bool CanMoveTo(ItemPosition ip, com.wd.free.item.ItemInventory toIn, int toX, int toY)
        {
            bool can = true;

            TempSetPosition(ip, false);
            can = IsEmpty(toIn, toX, toY, ip.GetKey().GetGridWidth(), ip.GetKey().GetGridHeight());
            TempSetPosition(ip, true);
            return(can);
        }
Esempio n. 5
0
        public void SetCurrentItem(ItemPosition currentItem, ISkillArgs args)
        {
            this.currentItem = currentItem;
            String cat = currentItem.GetKey().Cat;

            if (cat != null)
            {
                this.lastUseItem.Add(cat, currentItem);
            }
        }
Esempio n. 6
0
 private void TempSetPosition(ItemPosition ip, bool value)
 {
     for (int i = ip.GetX(); i < ip.GetX() + ip.GetKey().GetGridWidth(); i++)
     {
         for (int j = ip.GetY(); j < ip.GetY() + ip.GetKey().GetGridHeight(); j++)
         {
             ip.inventory.ins[j][i] = value;
         }
     }
 }
Esempio n. 7
0
 public virtual void UseItem(ISkillArgs args, ItemPosition ip)
 {
     if (ip.key.IsUseAll())
     {
         UseItem(args, ip, ip.count);
     }
     else
     {
         UseItem(args, ip, 1);
     }
 }
Esempio n. 8
0
        public virtual bool AddItem(ISkillArgs args, FreeItem item, bool useMove)
        {
            bool existed = (GetExisted(item) != null);

            if (existed)
            {
                if (item.IsUnique())
                {
                    if (inventoryUI != null)
                    {
                        inventoryUI.Error(args, this, "已存在唯一物品'" + item.GetName() + "'");
                    }
                    return(false);
                }
            }
            ItemPosition old = GetNotFullExisted(item);

            if (old != null)
            {
                int addCount = item.GetCount();
                old.SetKey(item);
                int removed = Math.Min(item.GetItemStack() - old.GetCount(), item.GetCount());
                old.SetCount(old.GetCount() + removed);
                if (inventoryUI != null && args != null)
                {
                    inventoryUI.UpdateItem(args, this, old);
                }

                if (removed < addCount)
                {
                    FreeItem clone = item.Clone();
                    clone.SetCount(addCount - removed);
                    AddNewItem(args, clone, false);
                }

                args.TempUsePara(new StringPara("inventory", name));
                item.Added(args);
                if (inventoryUI != null && inventoryUI.MoveAction != null && useMove)
                {
                    args.TempUsePara(new StringPara("to", this.name));
                    inventoryUI.MoveAction.Act(args);
                    args.ResumePara("to");
                }
                args.ResumePara("inventory");



                return(true);
            }
            else
            {
                return(AddNewItem(args, item, useMove));
            }
        }
Esempio n. 9
0
        public virtual void ExchangeItemPosition(ItemPosition p1, ItemPosition p2)
        {
            for (int i = p1.GetX(); i < p1.GetX() + p1.GetKey().GetGridWidth(); i++)
            {
                for (int j = p1.GetY(); j < p1.GetY() + p1.GetKey().GetGridHeight(); j++)
                {
                    p1.inventory.ins[j][i] = false;
                }
            }
            for (int i_1 = p2.GetX(); i_1 < p2.GetX() + p2.GetKey().GetGridWidth(); i_1++)
            {
                for (int j = p2.GetY(); j < p2.GetY() + p2.GetKey().GetGridHeight(); j++)
                {
                    p2.inventory.ins[j][i_1] = false;
                }
            }
            for (int i_2 = p1.GetX(); i_2 < p1.GetX() + p2.GetKey().GetGridWidth(); i_2++)
            {
                for (int j = p1.GetY(); j < p1.GetY() + p2.GetKey().GetGridHeight(); j++)
                {
                    p1.inventory.ins[j][i_2] = true;
                }
            }
            for (int i_3 = p2.GetX(); i_3 < p2.GetX() + p1.GetKey().GetGridWidth(); i_3++)
            {
                for (int j = p2.GetY(); j < p2.GetY() + p1.GetKey().GetGridHeight(); j++)
                {
                    p2.inventory.ins[j][i_3] = true;
                }
            }
            int oldX = p1.GetX();
            int oldY = p1.GetY();

            p1.SetX(p2.GetX());
            p1.SetY(p2.GetY());
            p2.SetX(oldX);
            p2.SetY(oldY);
            if (p1.inventory != p2.inventory)
            {
                p1.inventory.posList.Remove(p1);
                p2.inventory.posList.Remove(p2);
                p1.inventory.posList.Add(p2);
                p2.inventory.posList.Add(p1);
                com.wd.free.item.ItemInventory temp = p1.inventory;
                p1.inventory = p2.inventory;
                p2.inventory = temp;
            }
        }
Esempio n. 10
0
 private void UseItem(ItemPosition ip, FreeData fd, ISkillArgs fr)
 {
     if (ip != null)
     {
         fr.TempUse("item", ip.GetKey());
         if (ip.GetKey().Effect(fr))
         {
             ip.GetInventory().UseItem(fr, ip);
         }
         fr.Resume("item");
         if (!ip.GetKey().IsGoods())
         {
             fd.freeInventory.SetCurrentItem(ip, fr);
         }
     }
 }
Esempio n. 11
0
        public virtual bool IsCanDrop(ItemPosition ip, IEventArgs args)
        {
            if (StringUtil.IsNullOrEmpty(canDrop))
            {
                return(true);
            }
            if (canDropCondition == null || ((canDrop.IndexOf(FreeUtil.VAR_START_CHAR) > -1) && (canDrop.IndexOf(FreeUtil.VAR_END_CHAR) > -1)))
            {
                canDropCondition = new ExpParaCondition(canDrop);
            }
            args.TempUse("item", ip);
            bool can = canDropCondition.Meet(args);

            args.Resume("item");
            return(can);
        }
Esempio n. 12
0
        public void StartUseItem(IEventArgs args, FreeData fd, ItemPosition ip, int sing, int sound)
        {
            PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            fd.Player.autoMoveInterface.PlayerAutoMove.StopAutoMove();

            SkillTimeTrigger trigger = (SkillTimeTrigger)itemSkill.trigger;

            trigger.SetTime(sing * 1000);
            trigger.Reset();

            itemSkill.inter       = null;
            itemSkill.interAction = null;
            if (ip.key.GetClickSkill() != null)
            {
                PlayerActionSkill skill = ip.key.GetClickSkill() as PlayerActionSkill;
                if (skill != null && skill.inter != null)
                {
                    itemSkill.inter       = skill.inter;
                    itemSkill.interAction = skill.interAction;
                }
            }

            UsingItemAction interAction = (UsingItemAction)trigger.interAction;

            interAction.fd = fd;
            interAction.ip = ip;

            UsingItemAction action = (UsingItemAction)itemSkill.GetEffect();

            action.fd = fd;
            action.ip = ip;

            StartCounter(args, sing, fd, true);
            startUse = true;
            SetCurrentItem(ip, (ISkillArgs)args);
            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.PlaySound;
            data.Ks.Add(0);
            data.Ins.Add(FreeUtil.ReplaceInt("{item.itemId}", args));
            fd.Player.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, data);
            PlayerStateUtil.AddPlayerState(EPlayerGameState.UseItem, fd.Player.gamePlay);
        }
Esempio n. 13
0
        public virtual void UseItem(ISkillArgs args, ItemPosition ipos, int count)
        {
            ItemPosition remove = null;
            ItemPosition useIp  = null;

            foreach (ItemPosition ip in posList)
            {
                if (ip.GetX() == ipos.x && ip.GetY() == ipos.y)
                {
                    useIp = ip;
                    if (ip.GetKey().IsConsume())
                    {
                        ip.count = ip.count - count;
                    }
                    if (ip.count <= 0 && ipos.key.IsConsume())
                    {
                        remove = ip;
                    }
                }
            }
            if (remove != null)
            {
                RemoveItemPosition(remove);
            }
            if (inventoryUI != null && ipos.key.IsConsume())
            {
                if (remove != null)
                {
                    inventoryUI.DeleteItem(args, this, remove);
                }
                else
                {
                    if (useIp != null)
                    {
                        inventoryUI.UpdateItem(args, this, useIp);
                    }
                }
            }
            if (inventoryUI != null && useIp != null)
            {
                inventoryUI.UseItem(args, this, useIp);
            }
        }
Esempio n. 14
0
        public virtual void RemoveItem(ISkillArgs args, ItemPosition ip)
        {
            ip.key.Removed(args);
            RemoveItemPosition(ip);
            if (inventoryUI != null)
            {
                inventoryUI.DeleteItem(args, this, ip);
            }
            if (inventoryUI != null && inventoryUI.MoveAction != null)
            {
                args.TempUsePara(new StringPara("from", this.name));
                args.TempUse("item", ip);

                inventoryUI.MoveAction.Act(args);

                args.ResumePara("from");
                args.Resume("item");
            }
        }
Esempio n. 15
0
        /// <summary>清空两边的格子,先尝试把p1放入p2起始位置,如果可以,则先占有此格子,再判断p2是否可以放入p1开始位置</summary>
        /// <param name="ipFrom"/>
        /// <param name="ipTo"/>
        /// <returns/>
        public virtual bool CanExchange(ItemPosition ipFrom, ItemPosition ipTo)
        {
            bool can = false;

            TempSetPosition(ipFrom, false);
            TempSetPosition(ipTo, false);
            if (IsEmpty(ipFrom.inventory, ipFrom.GetX(), ipFrom.GetY(), ipTo.GetKey().GetGridWidth(), ipTo.GetKey().GetGridHeight()))
            {
                TempSetPosition(ipFrom.inventory, ipFrom.GetX(), ipFrom.GetY(), ipTo.GetKey().GetGridWidth(), ipTo.GetKey().GetGridHeight(), true);
                if (IsEmpty(ipTo.inventory, ipTo.GetX(), ipTo.GetY(), ipFrom.GetKey().GetGridWidth(), ipFrom.GetKey().GetGridHeight()))
                {
                    can = true;
                }
                TempSetPosition(ipFrom.inventory, ipFrom.GetX(), ipFrom.GetY(), ipTo.GetKey().GetGridWidth(), ipTo.GetKey().GetGridHeight(), false);
            }
            TempSetPosition(ipFrom, true);
            TempSetPosition(ipTo, true);
            return(can);
        }
Esempio n. 16
0
 private void RemoveItemPosition(ItemPosition ip)
 {
     posList.Remove(ip);
     ip.Remove();
 }