コード例 #1
0
        private void redrawPart(ItemInventory inventory, ISkillArgs args, ItemPosition ip, FreeData fd)
        {
            if (inventory.name == "w1" || inventory.name == "w2" || inventory.name == "w3")
            {
                int id = (int)((IntPara)ip.GetParameters().Get("itemId")).GetValue();

                WeaponResConfigItem config = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(id);
                if (config != null)
                {
                    HashSet <int> list = new HashSet <int>();

                    foreach (XmlConfig.EWeaponPartType part in SingletonManager.Get <WeaponPartsConfigManager>().GetAvaliablePartTypes(id))
                    {
                        list.Add(FreeWeaponUtil.GetWeaponPart(part));
                    }

                    List <string> showP = new List <string>();
                    List <string> hideP = new List <string>();

                    for (int i = 1; i <= 5; i++)
                    {
                        if (list.Contains(i))
                        {
                            showP.Add(i.ToString());
                        }
                        else
                        {
                            hideP.Add(i.ToString());
                        }
                    }

                    ShowPartAction show = new ShowPartAction();
                    show.show = true;
                    show.SetPlayer("current");
                    show.SetScope(1);
                    if (inventory.name == "w1")
                    {
                        show.weaponKey = "1";
                    }
                    else if (inventory.name == "w2")
                    {
                        show.weaponKey = "2";
                    }
                    else
                    {
                        show.weaponKey = "3";
                    }

                    show.parts = StringUtil.GetStringFromStrings(showP, ",");
                    show.Act(args);

                    show.show  = false;
                    show.parts = StringUtil.GetStringFromStrings(hideP, ",");
                    show.Act(args);
                }
                else
                {
                    Debug.LogError(ip.key.GetName() + " 没有定义配件.");
                }
            }
        }
コード例 #2
0
 public void UpdateItem(ISkillArgs args, ItemInventory inventory, ItemPosition ip)
 {
     ReDraw(args, inventory, true);
 }
コード例 #3
0
 public virtual bool IsInterrupted(ISkillArgs args)
 {
     return(condition != null && condition.Meet(args));
 }
コード例 #4
0
 public abstract ISkillTrigger.TriggerStatus Triggered(ISkillArgs args);
コード例 #5
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);
        }
コード例 #6
0
ファイル: FreeItem.cs プロジェクト: yangfan111/CsharpCode
 public virtual void Drop(ISkillArgs args, UnitPosition pos)
 {
 }
コード例 #7
0
        private static void ChangeItemStack(int delta, ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
        {
            if (ip.GetCount() <= delta)
            {
                RemoveItem(fromIn, ip, args);
                HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, true);

                old.SetCount(old.GetCount() + (int)MyMath.Min(delta, ip.GetCount()));
                toUI.UpdateItem(args, toIn, old);
            }
            else
            {
                old.SetCount(old.GetKey().GetItemStack());
                ip.SetCount(ip.GetCount() - delta);
                toUI.UpdateItem(args, toIn, old);
                fromUI.UpdateItem(args, fromIn, ip);
            }
        }
コード例 #8
0
 private static void RemoveItem(ItemInventory inventory, ItemPosition ip, ISkillArgs args)
 {
     inventory.RemoveItem(args, ip);
     RemoveUI(ip, args);
 }
コード例 #9
0
 private static void ExchangeItem(ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
 {
     if (fromIn.CanExchange(old, ip) && fromIn.IsCanDrop(old, args))
     {
         fromIn.ExchangeItemPosition(old, ip);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, true);
         HandleMoveAction(toIn, fromIn, toUI, fromUI, old, args, true);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, false);
         HandleMoveAction(toIn, fromIn, toUI, fromUI, old, args, false);
         if (fromIn == toIn)
         {
             fromUI.UpdateItem(args, fromIn, old);
             fromUI.UpdateItem(args, fromIn, ip);
         }
         else
         {
             fromUI.AddItem(args, fromIn, old);
             toUI.AddItem(args, toIn, ip);
         }
     }
     else
     {
         fromIn.ChangePosition(ip, fromIn, ip.GetX(), ip.GetY());
         if (fromUI.CanNotMoveAction != null)
         {
             fromUI.CanNotMoveAction.Act(args);
         }
         fromUI.UpdateItem(args, fromIn, ip);
     }
 }
コード例 #10
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);
        }
コード例 #11
0
        public static void MoveItem(int countX, int countY, ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
        {
            //if (fromIn.CanMoveTo(ip, toIn, countX, countY))
            //{
            fromIn.ChangePosition(ip, toIn, countX, countY);
            HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args);
            if (fromIn == toIn)
            {
                fromUI.UpdateItem(args, fromIn, ip);
            }
            else
            {
                fromUI.DeleteItem(args, fromIn, ip);
                toUI.AddItem(args, toIn, ip);
            }

            /*}
             * else
             * {
             *  fromIn.ChangePosition(ip, fromIn, ip.GetX(), ip.GetY());
             *  if (fromUI.CanNotMoveAction != null)
             *  {
             *      fromUI.CanNotMoveAction.Act(args);
             *  }
             *  fromUI.UpdateItem(args, fromIn, ip);
             * }*/
        }
コード例 #12
0
        public static void MovePosition(ItemPosition ip, ItemInventory toIn, int x, int y, ISkillArgs args)
        {
            ItemInventory     fromIn = ip.GetInventory();
            IInventoryUI      fromUI = fromIn.GetInventoryUI();
            IInventoryUI      toUI   = toIn.GetInventoryUI();
            FreeRuleEventArgs fr     = (FreeRuleEventArgs)args;

            Move(fromIn, toIn, ip, x, y, args, fr, fromUI, toUI);
        }
コード例 #13
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);
        }
コード例 #14
0
 public override void Drop(ISkillArgs args, UnitPosition pos)
 {
 }
コード例 #15
0
        private void redrawPart(ItemInventory inventory, ISkillArgs args, ItemPosition ip, FreeData fd)
        {
            if (inventory.name == ChickenConstant.BagPrimeWeapon || inventory.name == ChickenConstant.BagSecondaryWeapon || inventory.name == ChickenConstant.BagPistolWeapon)
            {
                int id = (int)((IntPara)ip.GetParameters().Get("itemId")).GetValue();

                WeaponAllConfigs configs = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(id);
                if (configs != null)
                {
                    HashSet <int> list = new HashSet <int>();

                    foreach (XmlConfig.EWeaponPartType part in configs.ApplyPartsSlot)
                    {
                        list.Add(FreeWeaponUtil.GetWeaponPart(part));
                    }

                    List <string> showP = new List <string>();
                    List <string> hideP = new List <string>();

                    for (int i = 1; i <= 5; i++)
                    {
                        if (list.Contains(i))
                        {
                            showP.Add(i.ToString());
                        }
                        else
                        {
                            hideP.Add(i.ToString());
                        }
                    }

                    ShowPartAction show = new ShowPartAction();
                    show.show = true;
                    show.SetPlayer("current");
                    show.SetScope(1);
                    if (inventory.name == ChickenConstant.BagPrimeWeapon)
                    {
                        show.weaponKey = "1";
                    }
                    else if (inventory.name == ChickenConstant.BagSecondaryWeapon)
                    {
                        show.weaponKey = "2";
                    }
                    else
                    {
                        show.weaponKey = "3";
                    }

                    show.parts = StringUtil.GetStringFromStrings(showP, ",");
                    show.Act(args);

                    show.show  = false;
                    show.parts = StringUtil.GetStringFromStrings(hideP, ",");
                    show.Act(args);
                }
                else
                {
                    Debug.LogError(ip.key.GetName() + " 没有定义配件.");
                }
            }
        }