Ejemplo n.º 1
0
 //
 public void HandleSwapSkill(int presetIndex, int skillId, SlotPosition sourcePos, SlotPosition targetPos, ArkCrossEngine.Network.GeneralOperationResult result)
 {
     try
     {
         if (ArkCrossEngine.Network.GeneralOperationResult.LC_Succeed == result)
         {
             string msg = string.Format("OnSwapSkill:{0},{1}", sourcePos, targetPos);
             Debug.Log(msg);
             int targetSkillId = uiSkillSetting.GetSkillId((int)targetPos);
             uiSkillSetting.ExchangeSlot(sourcePos, targetPos);
             uiSkillStorage.OnExchangeSkill(skillId, targetSkillId, sourcePos, targetPos);
         }
         else
         {
             string chn_desc = StrDictionaryProvider.Instance.GetDictString(364);
             LogicSystem.EventChannelForGfx.Publish("ge_screen_tip", "ui", chn_desc, UIScreenTipPosEnum.AlignTop, UnityEngine.Vector3.zero);
         }
     }
     catch (Exception ex)
     {
         ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Drop the item onto the specified object.
    /// </summary>

    protected virtual void OnDragDropRelease(UnityEngine.GameObject surface)
    {
        if (cloneOnDrag)
        {
            UISkillSlot dragedSlot = gameObject.GetComponent <UISkillSlot>();
            //判断dragedslot是属于SkillSeting下的还是SkillStorage下
            //从SkillSeting拖出
            if (dragedSlot.slotType == SlotType.SkillSetting)
            {
                UISkillSetting ddSkillSeting = null;
                UISkillPanel   skillPanel    = NGUITools.FindInParents <UISkillPanel>(gameObject);
                if (skillPanel != null)
                {
                    ddSkillSeting = skillPanel.uiSkillSetting;
                }
                if (ddSkillSeting == null)
                {
                    return;
                }
                if (surface == null)
                {
                    //通知卸载该技能
                    ddSkillSeting.UnloadSkill(dragedSlot);
                    NGUITools.Destroy(gameObject);
                    return;
                }
                UISkillSlot surfaceSlot = surface.GetComponent <UISkillSlot>();
                if (surfaceSlot != null)
                {
                    //surface含有UISkillSlot组件并属于SkillSeting或者SkillStorage时,进行交换
                    if (surfaceSlot.slotType == SlotType.SkillSetting)
                    {
                        ddSkillSeting.ExchangeSlot(dragedSlot, surfaceSlot);
                    }
                    else
                    {
                        //技能图标拖到非SkillSetting和非SkillStorage上时,卸载
                        ddSkillSeting.UnloadSkill(dragedSlot);
                    }
                }
                else
                {
                    //surface没有怪UISkillSlot时,卸载
                    ddSkillSeting.UnloadSkill(dragedSlot);
                }
                NGUITools.Destroy(gameObject);
            }
            //从SkillStorage拖出
            else if (dragedSlot.slotType == SlotType.SkillStorage)
            {
                UISkillStorage ddSkillStorage = NGUITools.FindInParents <UISkillStorage>(gameObject);
                if (null == ddSkillStorage)
                {
                    return;
                }
                //surface为空的话需要重置dragedslot
                if (surface == null)
                {
                    ddSkillStorage.ResetSlot(dragedSlot);
                    NGUITools.Destroy(gameObject);
                    return;
                }
                UISkillSlot surfaceSlot = surface.GetComponent <UISkillSlot>();
                if (surfaceSlot != null)
                {
                    if (surfaceSlot.slotType == SlotType.SkillSetting)
                    {
                        //从Storage拖到SkillSetting时,交换
                        ddSkillStorage.ExchangeSlot(dragedSlot, surfaceSlot);
                        ddSkillStorage.ResetSlot(dragedSlot);
                    }
                    else
                    {
                        //如果surface不是SkillSetting类型时,重置
                        ddSkillStorage.ResetSlot(dragedSlot);
                    }
                }
                else
                {
                    //surface中不含有UISkillSlot组件时,重置
                    ddSkillStorage.ResetSlot(dragedSlot);
                }
                NGUITools.Destroy(gameObject);
            }
        }
    }