Exemplo n.º 1
0
    public void ExchangeSlot(UISkillSlot draged, UISkillSlot surface)
    {
        if (draged == null || surface == null)
        {
            return;
        }
        UISkillSlot skillSlot = null;

        foreach (UISkillSlot slot in skillStorageArr)
        {
            if (slot != null && slot.SkillId == draged.SkillId)
            {
                skillSlot = slot;
                break;
            }
        }
        if (null == skillSlot)
        {
            return;
        }
        //如果surface与draged为同一个Slot,则不交换
        if (surface.SkillId == skillSlot.SkillId)
        {
            string iconName = draged.icon.spriteName;
            skillSlot.SetIcon(iconName);
            return;
        }
        if (surface.slotType == SlotType.SkillSetting)
        {
            LogicSystem.PublishLogicEvent("ge_swap_skill", "lobby", UISkillSetting.presetIndex, skillSlot.SkillId,
                                          skillSlot.slotIndex, surface.slotIndex);
        }
    }
Exemplo n.º 2
0
    public void OnUnloadedSkill(int slotIndex)
    {
        if (slotIndex <= 0 || slotIndex > c_SkillSlotNum)
        {
            return;
        }
        UISkillSlot skillSlot = skillStorageArr[slotIndex - 1];

        if (skillSlot != null)
        {
            skillSlot.SkillId = -1;
            skillSlot.SetName("可装备");
            skillSlot.SetIcon("");
        }
    }
Exemplo n.º 3
0
    public void InitSkillSetting(List <SkillInfo> skillInfoList)
    {
        if (skillInfoList == null)
        {
            return;
        }
        int currentPreset = UISkillSetting.presetIndex;

        foreach (SkillInfo info in skillInfoList)
        {
            if (info != null && info.Postions.Presets[currentPreset] != SlotPosition.SP_None)
            {
                int index = (int)info.Postions.Presets[currentPreset];
                if (index > 0 && index <= 4)
                {
                    UISkillSlot slot = skillStorageArr[index - 1];
                    if (slot == null || slot.SkillId != -1)
                    {
                        continue;
                    }
                    slot.SkillId = info.SkillId;
                    //没初始化Atlas则初始化
                    if (!m_IsAtlasInitialized)
                    {
                        InitSlotAtlas(info.SkillId);
                        m_IsAtlasInitialized = true;
                    }
                    SkillLogicData skillCfg = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_SKILL, info.SkillId) as SkillLogicData;
                    if (null != skillCfg)
                    {
                        slot.SetName(skillCfg.ShowName);
                        slot.SetIcon(skillCfg.ShowIconName);
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Start the dragging operation.
    /// </summary>

    void OnDragStart()
    {
        if (!enabled || mTouchID != int.MinValue)
        {
            return;
        }

        // If we have a restriction, check to see if its condition has been met first
        if (restriction != Restriction.None)
        {
            if (restriction == Restriction.Horizontal)
            {
                UnityEngine.Vector2 delta = UICamera.currentTouch.totalDelta;
                if (UnityEngine.Mathf.Abs(delta.x) < UnityEngine.Mathf.Abs(delta.y))
                {
                    return;
                }
            }
            else if (restriction == Restriction.Vertical)
            {
                UnityEngine.Vector2 delta = UICamera.currentTouch.totalDelta;
                if (UnityEngine.Mathf.Abs(delta.x) > UnityEngine.Mathf.Abs(delta.y))
                {
                    return;
                }
            }
            else if (restriction == Restriction.PressAndHold)
            {
                if (mPressTime + 1f > RealTime.time)
                {
                    return;
                }
            }
        }

        if (cloneOnDrag)
        {
            UnityEngine.Vector3 screenPos = new UnityEngine.Vector3(UICamera.currentTouch.pos.x, UICamera.currentTouch.pos.y, 0);
            UnityEngine.Vector3 pos       = UICamera.mainCamera.ScreenToWorldPoint(screenPos);
            //将clone放在UISkillSetting或者UISkillStorage下
            UnityEngine.GameObject clone        = null;
            UISkillSetting         skillSetting = NGUITools.FindInParents <UISkillSetting>(gameObject);
            if (skillSetting != null)
            {
                clone = NGUITools.AddChild(skillSetting.gameObject, gameObject);
            }
            else
            {
                UISkillStorage skillStorage = NGUITools.FindInParents <UISkillStorage>(gameObject);
                if (skillStorage != null)
                {
                    clone = NGUITools.AddChild(skillStorage.gameObject, gameObject);
                }
            }
            clone.transform.position      = pos;
            clone.transform.localRotation = transform.localRotation;
            clone.transform.localScale    = transform.localScale;

            UIButtonColor bc = clone.GetComponent <UIButtonColor>();
            if (bc != null)
            {
                bc.defaultColor = GetComponent <UIButtonColor>().defaultColor;
            }

            UICamera.Notify(UICamera.currentTouch.pressed, "OnPress", false);

            UICamera.currentTouch.pressed = clone;
            UICamera.currentTouch.dragged = clone;

            UIDragDropForSkill item      = clone.GetComponent <UIDragDropForSkill>();
            UISkillSlot        skillSlot = this.GetComponent <UISkillSlot>();
            if (null != skillSlot)
            {
                //如果拖动的Slot内不含有任何技能,则不允许拖动
                if (skillSlot.SkillId == -1 || (!skillSlot.m_IsUnlock && skillSlot.slotType == SlotType.SkillStorage))
                {
                    NGUITools.DestroyImmediate(clone);
                    return;
                }
                else
                {
                    skillSlot.SetIcon("");
                }
            }
            UISkillSlot cloneSlot = clone.GetComponent <UISkillSlot>();
            cloneSlot.SkillId  = skillSlot.SkillId;
            cloneSlot.slotType = skillSlot.slotType;
            item.Start();
            item.OnDragDropStart();
        }
        else
        {
            OnDragDropStart();
        }
    }