//使用快捷键技能
 void UseShutCutSkill(ShortCutItem shutCutItem)
 {
     if (shutCutItem.shutCutType == ShutCutType.Skill)
     {
         Skill skill = SkillInfoData.GetInstance().GetSkillInfoById(shutCutItem.shutCutGoodsId);
         playerAttack.UseSkill(skill);
     }
     else if (shutCutItem.shutCutType == ShutCutType.Drug)
     {
         //ObjectsInfoClass info = ObjectsInfo._instance.GetObjectsInfoById(id);
         //if ((info.hp != 0 && playerStatus.hp == 100) || (info.mp != 0 && playerStatus.mp == 100)) return; //玩家满血或者满篮
         //playerStatus.AddHpMp(info.hp, info.mp);
         //BagItemCtr bagItem = null;
         //foreach (BagItemCtr temp in BagBarCtr._instance.bagItemList)
         //{
         //    if (temp.id == id)
         //    {
         //        bagItem = temp;
         //        break;
         //    }
         //}
         //bagItem.plusNum(-1);
         //if (bagItem.num == 0)
         //{
         //   Destroy(bagItem.GetComponentInChildren<GoodsItemCtr>().gameObject);
         //   bagItem.ClearInfo();
         //   this.transform.Find("ShutCutIcon").GetComponent<UISprite>().enabled = false;
         //}
     }
 }
    public void OnKeyDown_QuickBar(int inputIndex)
    {
        if (inputIndex < 0 || inputIndex >= (mItems.Count - 1))
        {
            return;
        }

        if (mItems[inputIndex + 1].IsForbiden())
        {
            return;
        }

        int          index  = inputIndex + this.GetCurPageIndex();
        ShortCutItem scItem = mCutSlotList.GetItem(index);

        if (scItem != null)
        {
            ItemObject item = mCutSlotList.GetItemObj(index);
            //lz-2016.08.10 不允许快捷栏操作当前包裹正在操作的Item
            if (GameUI.Instance.mItemPackageCtrl.EqualUsingItem(item))
            {
                return;
            }
            UseItem(item);
        }
    }
    //拖拽结束
    private void OnEndDrag(GameObject go, PointerEventData eventData)
    {
        GameObject point = eventData.pointerEnter;                                                //拖拽结束后,判断鼠标点击到的物体

        if (null != point && point.tag == Tags.ShutCut)                                           //判断是否放在了技能背景框上
        {
            CanvasGroup  groupOther       = point.GetComponent <CanvasGroup>();                   //获取点击到快捷键图片上的CanvasGroup
            ShortCutItem otherShutCutItem = point.transform.parent.GetComponent <ShortCutItem>(); //获取快捷键上的ShutCutItem脚本
            if (0 == groupOther.alpha)                                                            //当前快捷键为空,将之前快捷键移到现在的位置
            {
                otherShutCutItem.AddSkillIcon(this.shutCutGoodsId);                               //显示快捷
                this.RemoveSkill();                                                               //将被拖动的快捷键信息滞空
            }
            else//已经有快捷键,调换快捷键位置
            {
                switch (this.shutCutType)//当前快捷键类型
                {
                case ShutCutType.Skill:
                    if (ShutCutType.Skill == otherShutCutItem.shutCutType)    //替换位置快捷键类型
                    {
                        int shutCutGoodsIdTemp = otherShutCutItem.shutCutGoodsId;
                        otherShutCutItem.AddSkillIcon(this.shutCutGoodsId);
                        this.AddSkillIcon(shutCutGoodsIdTemp);
                    }
                    else if (ShutCutType.Drug == otherShutCutItem.shutCutType)
                    {
                    }
                    break;

                case ShutCutType.Drug:
                    if (ShutCutType.Skill == otherShutCutItem.shutCutType)
                    {
                    }
                    else if (ShutCutType.Drug == otherShutCutItem.shutCutType)
                    {
                    }
                    break;
                }
            }
        }
        else//拖放到了快捷键其他的位置
        {
            this.shutCutImg.transform.SetParent(this.transform);
            this.shutCutImg.transform.localPosition = Vector3.zero;
        }
        shutCutImg.GetComponent <CanvasGroup>().blocksRaycasts = true;//忽略射线
    }
    void OnShortCutUpdate()
    {
        if (mCutSlotList != null)
        {
            int        starIndex = this.GetCurPageIndex();
            ItemObject Iobj;
            for (int i = 1; i < mBoxBar.ItemCount; i++)
            {
                //log:lz-2016.05.04 第一个格子不计算,数据下标前推
                ShortCutItem item = mCutSlotList.GetItem(starIndex + (i - 1));
                mItems[i].SetItem(item);

                Iobj = mCutSlotList.GetItemObj(starIndex + (i - 1));
                mItems[i].SetDurabilityBg(Iobj);
            }
        }
    }
    public void OnDropItem(Grid_N grid)
    {
        //lz-2016.11.14 Crush bug
        if (null == SelectItem_N.Instance || null == SelectItem_N.Instance.ItemSample || null == GameUI.Instance || null == mCutSlotList || null == grid)
        {
            return;
        }

        //lz-2016.08.10 不允许快捷栏操作当前包裹正在操作的Item
        if (null != GameUI.Instance.mItemPackageCtrl && GameUI.Instance.mItemPackageCtrl.EqualUsingItem(SelectItem_N.Instance.ItemSample))
        {
            return;
        }

        if (e_OnDropItemTask != null && SelectItem_N.Instance.ItemSample.protoId == 916)
        {
            e_OnDropItemTask();
        }

        if (GameConfig.IsMultiMode)
        {
            int selectIndex = SelectItem_N.Instance.Index + GetCurPageIndex();
            int gridIndex   = grid.ItemIndex + GetCurPageIndex();

            int srcIndex = -1;
            int objId    = -1;
            if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_HotKeyBar)
            {
                ShortCutItem item = mCutSlotList.GetItem(selectIndex);
                if (null != item)
                {
                    srcIndex = selectIndex;
                    objId    = item.itemInstanceId;
                }
            }
            else
            {
                if (SelectItem_N.Instance.ItemObj == null)
                {
                    Debug.Log("UIMainMidCtrl.OnDropItem SelectItem_N.Instance.ItemObj == null");
                    return;
                }
                srcIndex = -1;
                objId    = SelectItem_N.Instance.ItemObj.instanceId;
            }

            if (null != PlayerNetwork.mainPlayer)
            {
                PlayerNetwork.mainPlayer.RequestSetShortcuts(objId, srcIndex, gridIndex, SelectItem_N.Instance.Place);
            }

            SelectItem_N.Instance.SetItem(null);
        }
        else
        {
            switch (SelectItem_N.Instance.Place)
            {
            case ItemPlaceType.IPT_HotKeyBar:
                if (grid.Item == null)
                {
                    int selectIndex = SelectItem_N.Instance.Index + GetCurPageIndex();
                    int gridIndex   = grid.ItemIndex + GetCurPageIndex();
                    mCutSlotList.PutItem(mCutSlotList.GetItem(selectIndex), gridIndex);
                    mCutSlotList.PutItem(null, selectIndex);
                }
                else
                {
                    int          selectIndex = SelectItem_N.Instance.Index + GetCurPageIndex();
                    ShortCutItem selectedCut = mCutSlotList.GetItem(selectIndex);
                    int          gridIndex   = grid.ItemIndex + GetCurPageIndex();
                    ShortCutItem gridCut     = mCutSlotList.GetItem(gridIndex);

                    if (selectedCut != null)
                    {
                        mCutSlotList.PutItem(selectedCut, gridIndex);
                    }

                    mCutSlotList.PutItem(gridCut, selectIndex);
                }
                SelectItem_N.Instance.SetItem(null);
                break;

            case ItemPlaceType.IPT_Equipment:
                break;

            case ItemPlaceType.IPT_Bag:
            {
                int  pakageIndex = 0;
                bool isMission   = false;
                if (null != GameUI.Instance.mItemPackageCtrl)
                {
                    if (!GameUI.Instance.mItemPackageCtrl.isMission)
                    {
                        pakageIndex = ItemPackage.CodeIndex((ItemPackage.ESlotType)GameUI.Instance.mItemPackageCtrl.CurrentPickTab, SelectItem_N.Instance.Index);
                    }
                    else
                    {
                        pakageIndex = ItemPackage.CodeIndex(ItemPackage.ESlotType.Item, SelectItem_N.Instance.Index);
                        isMission   = true;
                    }
                    if (null != mPackageCmpt)
                    {
                        mPackageCmpt.PutItemToShortCutList(pakageIndex, grid.ItemIndex + GetCurPageIndex(), isMission);
                    }
                }
                SelectItem_N.Instance.SetItem(null);
            }
            break;
            }
        }
    }
Exemple #6
0
            public InnerContentPage(XElement xMenu)
            {
                //一级菜单名称
                string title = xMenu.Attribute("Mc").Value;

                List <ShortCutItem> items = new List <ShortCutItem>();

                foreach (XElement xSubMenu in xMenu.Elements("Menu"))
                {
                    items.Add(
                        new ShortCutItem()
                    {
                        Label = xSubMenu.Attribute("Mc").Value,
                        Value = xSubMenu.Attribute("Gnbh").Value,
                        Icon  = xSubMenu.Attribute("Icon2").Value,
                    });
                }


                this.BackgroundColor = Color.Transparent;

                //Header
                UcHeaderTitle headerTitle = new UcHeaderTitle(title);

                //StackLayout headLayout = new StackLayout()
                //{
                //    HorizontalOptions = LayoutOptions.FillAndExpand,
                //    VerticalOptions = LayoutOptions.Start,
                //    Padding = 5,
                //    BackgroundColor = Color.Black,// .White,
                //    Opacity = 0.7
                //};

                //Label header = new Label() { Text = title,TextColor = Color.White,FontSize = Device.GetNamedSize(NamedSize.Small,typeof(Label)) , HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center };

                //headLayout.Children.Add(header);

                //Main Grid
                Grid grid = new Grid()
                {
                    ColumnSpacing = 10, RowSpacing = 10
                };

                //图标设置3列
                int colCount = 3;

                int rowCount = (int)Math.Ceiling(items.Count / (double)colCount);

                for (int i = 0; i < colCount; i++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                }


                for (int i = 0; i < rowCount; i++)
                {
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });
                }


                for (int i = 0; i < rowCount; i++)
                {
                    for (int j = 0; j < colCount; j++)
                    {
                        if (i * colCount + j < items.Count)
                        {
                            ShortCutItem item = items[i * colCount + j];

                            UcShortCut shortCut = new UcShortCut(item, item.Icon);

                            shortCut.Click += new EventHandler <HsEventArgs <IHsLabelValue> >((sender, e) =>
                            {
                                this.ItemClick?.Invoke(this, e);
                            });

                            grid.Children.Add(shortCut, j, i);
                        }
                    }
                }

                StackLayout layout = new StackLayout();

                layout.Children.Add(headerTitle);
                layout.Children.Add(
                    new ScrollView()
                {
                    Content = grid
                });


                Content = layout;
            }