Пример #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;
 }
Пример #2
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);
        }
Пример #3
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;
         }
     }
 }
Пример #4
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;
            }
        }
Пример #5
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);
         }
     }
 }
Пример #6
0
        public void SetCurrentItem(ItemPosition currentItem, ISkillArgs args)
        {
            this.currentItem = currentItem;
            String cat = currentItem.GetKey().Cat;

            if (cat != null)
            {
                this.lastUseItem.Add(cat, currentItem);
            }
        }
Пример #7
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);
        }