Exemple #1
0
    public void DelGuidePointing(int skillId)
    {
        UISkillSlot skillSlot = GetSlotById(skillId);

        if (skillSlot == null)
        {
            skillSlot = skillStorageArr[0];
        }
        if (skillSlot != null)
        {
            UnityEngine.Transform tsPointing = skillSlot.transform.Find("GuideHand(Clone)");
            if (tsPointing != null)
            {
                NGUITools.Destroy(tsPointing.gameObject);
            }
            else
            {
                //已防玩家没有点击目标位置,导致小手不消失
                for (int i = 0; i < skillStorageArr.Length; ++i)
                {
                    if (skillStorageArr[i] != null)
                    {
                        UnityEngine.Transform ts = skillStorageArr[i].transform.Find("GuideHand(Clone)");
                        if (ts != null)
                        {
                            NGUITools.Destroy(ts.gameObject);
                        }
                    }
                }
            }
        }
    }
Exemple #2
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);
        }
    }
Exemple #3
0
    //点击操作装备技能
    public void SendMsg(int targetId, SlotPosition targetPos)
    {
        if (uiSkillInfo == null)
        {
            return;
        }
        //uiSkillInfo.SkillId为SourceId,==-1则返回
        if (uiSkillInfo.SkillId == -1)
        {
            return;
        }
        int         sourceId      = uiSkillInfo.SkillId;
        UISkillSlot sourceSlot    = uiSkillStorage.GetSlot(sourceId);
        int         currentPreset = UISkillSetting.presetIndex;

        if (sourceSlot != null)
        {
            if (sourceSlot.EquipedPos != null && sourceSlot.EquipedPos.Presets[currentPreset] == SlotPosition.SP_None)
            {
                LogicSystem.PublishLogicEvent("ge_mount_skill", "lobby", currentPreset, sourceId, targetPos);
            }
            else
            {
                LogicSystem.PublishLogicEvent("ge_swap_skill", "lobby", currentPreset, sourceId, sourceSlot.EquipedPos.Presets[UISkillSetting.presetIndex], targetPos);
            }
        }
    }
Exemple #4
0
    public void ExchangeSlot(UISkillSlot draged, UISkillSlot surface)
    {
        //NGUIDebug.Log(surface.name);
        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;
        }
        //被拖拽的技能之前没有被装备上
        if (skillSlot.EquipedPos != null && skillSlot.EquipedPos.Presets[UISkillSetting.presetIndex] == SlotPosition.SP_None)
        {
            //todo:发送消息通知装载操作
            LogicSystem.PublishLogicEvent("ge_mount_skill", "lobby", UISkillSetting.presetIndex, skillSlot.SkillId,
                                          surface.slotIndex);
        }
        else
        {
            LogicSystem.PublishLogicEvent("ge_swap_skill", "lobby", UISkillSetting.presetIndex, skillSlot.SkillId,
                                          (SlotPosition)skillSlot.EquipedPos.Presets[UISkillSetting.presetIndex], surface.slotIndex);
        }
    }
Exemple #5
0
    //升阶技能
    public void OnLiftSkill(int sourceSkillId, int curSkillId)
    {
        UISkillSlot slot = GetSlot(sourceSkillId);

        if (slot != null)
        {
            slot.UpgradeSkill(curSkillId);
        }
    }
Exemple #6
0
    //升级技能
    public void OnUpgradeSkill(int curSkillId, bool isUpgrade = false)
    {
        UISkillSlot slot = GetSlot(curSkillId);

        if (slot != null)
        {
            slot.UpgradeSkill(curSkillId, isUpgrade);
        }
    }
Exemple #7
0
    //解锁技能
    public void OnUnlockSkill(int skillId)
    {
        UISkillSlot slot = GetSlot(skillId);

        if (slot != null)
        {
            slot.PlayUnlockEffect();
        }
    }
Exemple #8
0
 private void SetEquipmentSkillSlots()
 {
     ClearEquipmentSkillSlotsContent();
     foreach (Skill s in playerSkills.equipmentSkills)
     {
         UISkillSlot newSlot = Instantiate(skillSlotPrefab, equipmentSkillSlotsContent.transform).GetComponent <UISkillSlot>();
         newSlot.Skill = s;
     }
 }
Exemple #9
0
 private void SetNaturalSkillSlots()
 {
     ClearNaturalSkillSlotsContent();
     foreach (Skill s in playerSkills.naturalSkills)
     {
         UISkillSlot newSlot = Instantiate(skillSlotPrefab, naturalSkillSlotsContent.transform).GetComponent <UISkillSlot>();
         newSlot.Skill = s;
     }
 }
Exemple #10
0
    public void AddGuidePointing(UnityEngine.GameObject goPointing, int skillId)
    {
        DelGuidePointing(skillId);
        UISkillSlot skillSlot = GetSlot(skillId);

        if (skillSlot != null && goPointing != null)
        {
            goPointing = NGUITools.AddChild(skillSlot.gameObject, goPointing);
            goPointing.transform.position = skillSlot.transform.position;
        }
    }
Exemple #11
0
    public void ResetSkillSlot(UISkillSlot slot)
    {
        //根据已经装备的技能信息设置技能图标、技能名等属性
        slot.m_EquipedPos.Presets[UISkillSetting.presetIndex] = ArkCrossEngine.SlotPosition.SP_None;
        slot.SkillId = -1;
        UISprite sp = slot.GetComponent <UISprite>();

        if (sp != null)
        {
            sp.spriteName = "";
        }
    }
Exemple #12
0
    //


    //初始化每个英雄技能背包里的技能
    public void InitSkillStorage(List <SkillInfo> skillPresets)
    {
        if (skillPresets == null || skillPresets.Count <= 0)
        {
            return;
        }
        //初始化滑动
        m_TransLeft  = 0;
        m_TransRight = skillPresets.Count - c_ShowNum;
        if (btnLeft != null)
        {
            NGUITools.SetActive(btnLeft.gameObject, false);
        }
        if (m_TransRight <= 0)
        {
            m_TransRight = 0;
            if (btnRight != null)
            {
                NGUITools.SetActive(btnRight.gameObject, false);
            }
        }

        List <SkillInfo> skillList = skillPresets;

        for (int index = 0; index < skillList.Count; ++index)
        {
            SkillInfo info = skillList[index];
            if (info != null && goGrid != null && goSlot != null)
            {
                UnityEngine.GameObject goChild = NGUITools.AddChild(goGrid, goSlot);
                if (goChild != null)
                {
                    UISkillSlot slotScript = goChild.GetComponent <UISkillSlot>();
                    if (slotScript != null)
                    {
                        slotScript.InitSlot(info);
                        if (index < c_SkillSlotNum)
                        {
                            skillStorageArr[index] = slotScript;
                        }
                    }
                }
            }
        }
        if (goGrid != null)
        {
            UIGrid grid = goGrid.GetComponent <UIGrid>();
            if (grid != null)
            {
                grid.Reposition();
            }
        }
    }
Exemple #13
0
 //卸下技能
 public void UnloadSkill(UISkillSlot skill)
 {
     if (skill == null)
     {
         return;
     }
     foreach (UISkillSlot slot in skillStorageArr)
     {
         if (slot != null && slot.SkillId == skill.SkillId)
         {
             LogicSystem.PublishLogicEvent("ge_unmount_skill", "lobby", presetIndex, slot.slotIndex);
         }
     }
 }
Exemple #14
0
 public void ResetSlot(UISkillSlot draged)
 {
     foreach (UISkillSlot slot in skillStorageArr)
     {
         if (slot != null && slot.SkillId == draged.SkillId)
         {
             if (slot.icon != null && draged.icon != null)
             {
                 slot.SetIcon(draged.icon.spriteName);
             }
             break;
         }
     }
 }
Exemple #15
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("");
        }
    }
Exemple #16
0
    public void DelGuidePointing(int skillId)
    {
        UISkillSlot skillSlot = GetSlot(skillId);

        if (skillSlot != null)
        {
            UnityEngine.Transform tsPointing = skillSlot.transform.Find("GuideHand(Clone)");
            if (tsPointing != null)
            {
                Destroy(tsPointing.gameObject);
            }
            else
            {
                //防止玩家没按要求操作
                for (int i = 0; i < skillStorageArr.Length; ++i)
                {
                    if (skillStorageArr[i] != null)
                    {
                        tsPointing = skillStorageArr[i].transform.Find("GuideHand(Clone)");
                        if (tsPointing != null)
                        {
                            Destroy(tsPointing.gameObject);
                            break;
                        }
                    }
                }
            }
        }
        else
        {
            //防止玩家没按要求操作
            UnityEngine.Transform tsPointing = null;
            for (int i = 0; i < skillStorageArr.Length; ++i)
            {
                if (skillStorageArr[i] != null)
                {
                    tsPointing = skillStorageArr[i].transform.Find("GuideHand(Clone)");
                    if (tsPointing != null)
                    {
                        Destroy(tsPointing.gameObject);
                        break;
                    }
                }
            }
        }
    }
Exemple #17
0
        public void OnEndDrag(PointerEventData data)
        {
            List <GameObject> hoveredList = data.hovered;

            foreach (GameObject go in hoveredList)
            {
                UISkillSlot uiSkillSlot = go.GetComponent <UISkillSlot>();
                if (uiSkillSlot)
                {
                    Debug.Log("found uiskillslot");
                    uiSkillSlot.Init(skill);
                }
                else
                {
                    Debug.Log("did NOT found uiskillslot");
                }
            }

            Destroy(draggedSkill);
        }
Exemple #18
0
    public void ExchangeSlot(SlotPosition sourcePos, SlotPosition targetPos)
    {
        int sourceIndex = (int)sourcePos;
        int targetIndex = (int)targetPos;

        if (sourceIndex <= 0 || sourceIndex > 4 || targetIndex <= 0 || targetIndex > 4)
        {
            return;
        }
        UISkillSlot draged  = skillStorageArr[sourceIndex - 1];
        UISkillSlot surface = skillStorageArr[targetIndex - 1];

        if (draged == null || surface == null)
        {
            return;
        }
        int surfaceSkillId = surface.SkillId;

        surface.SkillId = draged.SkillId;
        surface.SetSlotIconById(surface.SkillId);
        draged.SkillId = surfaceSkillId;
        draged.SetSlotIconById(surfaceSkillId);
    }
Exemple #19
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);
                    }
                }
            }
        }
    }
Exemple #20
0
    public void OnLoadedSkill(int presetIndex, int skillId, int slotPositon)
    {
        if (slotPositon <= 0 || slotPositon > c_SkillSlotNum)
        {
            return;
        }
        UISkillSlot skillSlot = skillStorageArr[slotPositon - 1];

        if (skillSlot != null && skillSlot.SkillId == -1)
        {
            skillSlot.SkillId = skillId;
            skillSlot.SetSlotIconById(skillId);
        }
        else if (skillSlot != null && skillSlot.SkillId != -1)
        {
            UISkillPanel skillPanel = NGUITools.FindInParents <UISkillPanel>(this.gameObject);
            if (null != skillPanel)
            {
                skillPanel.OnUnloadedSkill(skillSlot.SkillId);
                skillSlot.SkillId = skillId;
                skillSlot.SetSlotIconById(skillId);
            }
        }
    }
Exemple #21
0
    void Update()
    {
        Player player = Player.localPlayer;

        if (player)
        {
            // hotkey (not while typing in chat, etc.)
            if (Input.GetKeyDown(hotKey) && !UIUtils.AnyInputActive())
            {
                panel.SetActive(!panel.activeSelf);
            }

            // only update the panel if it's active
            if (panel.activeSelf)
            {
                // instantiate/destroy enough slots
                // (we only care about non status skills)
                UIUtils.BalancePrefabs(slotPrefab.gameObject, player.skills.skills.Count, content);

                // refresh all
                for (int i = 0; i < player.skills.skills.Count; ++i)
                {
                    UISkillSlot slot  = content.GetChild(i).GetComponent <UISkillSlot>();
                    Skill       skill = player.skills.skills[i];

                    bool isPassive = skill.data is PassiveSkill;

                    // set state
                    slot.dragAndDropable.name     = i.ToString();
                    slot.dragAndDropable.dragable = skill.level > 0 && !isPassive;

                    // can we cast it? checks mana, cooldown etc.
                    bool canCast = player.skills.CastCheckSelf(skill);

                    // if movement does NOT support navigation then we need to
                    // check distance too. otherwise distance doesn't matter
                    // because we can navigate anywhere.
                    if (!player.movement.CanNavigate())
                    {
                        canCast &= player.skills.CastCheckDistance(skill, out Vector3 _);
                    }

                    // click event
                    slot.button.interactable = skill.level > 0 &&
                                               !isPassive &&
                                               canCast;

                    int icopy = i;
                    slot.button.onClick.SetListener(() => {
                        // try use the skill or walk closer if needed
                        ((PlayerSkills)player.skills).TryUse(icopy);
                    });

                    // image
                    if (skill.level > 0)
                    {
                        slot.image.color  = Color.white;
                        slot.image.sprite = skill.image;
                    }

                    // description
                    slot.descriptionText.text = skill.ToolTip(showRequirements: skill.level == 0);

                    // learn / upgrade
                    if (skill.level < skill.maxLevel && ((PlayerSkills)player.skills).CanUpgrade(skill))
                    {
                        slot.upgradeButton.gameObject.SetActive(true);
                        slot.upgradeButton.GetComponentInChildren <Text>().text = skill.level == 0 ? "Learn" : "Upgrade";
                        slot.upgradeButton.onClick.SetListener(() => { ((PlayerSkills)player.skills).CmdUpgrade(icopy); });
                    }
                    else
                    {
                        slot.upgradeButton.gameObject.SetActive(false);
                    }

                    // cooldown overlay
                    float cooldown = skill.CooldownRemaining();
                    slot.cooldownOverlay.SetActive(skill.level > 0 && cooldown > 0);
                    slot.cooldownText.text         = cooldown.ToString("F0");
                    slot.cooldownCircle.fillAmount = skill.cooldown > 0 ? cooldown / skill.cooldown : 0;
                }

                // skill experience
                skillExperienceText.text = ((PlayerSkills)player.skills).skillExperience.ToString();
            }
        }
        else
        {
            panel.SetActive(false);
        }
    }
    void Update()
    {
        Player player = Utils.ClientLocalPlayer();

        if (!player)
        {
            return;
        }

        // hotkey (not while typing in chat, etc.)
        if (Input.GetKeyDown(hotKey) && !UIUtils.AnyInputActive())
        {
            panel.SetActive(!panel.activeSelf);
        }

        // only update the panel if it's active
        if (panel.activeSelf)
        {
            // instantiate/destroy enough slots
            // (we only care about non status skills)
            UIUtils.BalancePrefabs(slotPrefab.gameObject, player.skills.Count, content);

            // refresh all
            for (int i = 0; i < player.skills.Count; ++i)
            {
                UISkillSlot slot  = content.GetChild(i).GetComponent <UISkillSlot>();
                Skill       skill = player.skills[i];

                bool isPassive = skill.data is PassiveSkill;

                // drag and drop name has to be the index in the real skill list,
                // not in the filtered list, otherwise drag and drop may fail
                int skillIndex = player.skills.FindIndex(s => s.name == skill.name);
                slot.dragAndDropable.name = skillIndex.ToString();

                // click event
                slot.button.interactable = skill.level > 0 &&
                                           !isPassive &&
                                           player.CastCheckSelf(skill); // checks mana, cooldown etc.
                slot.button.onClick.SetListener(() => {
                    player.CmdUseSkill(skillIndex);
                });

                // set state
                slot.dragAndDropable.dragable = skill.level > 0 && !isPassive;

                // image
                if (skill.level > 0)
                {
                    slot.image.color  = Color.white;
                    slot.image.sprite = skill.image;
                }

                // description
                slot.descriptionText.text = skill.ToolTip(showRequirements: skill.level == 0);

                // learn / upgrade
                if (skill.level < skill.maxLevel)
                {
                    slot.upgradeButton.gameObject.SetActive(true);
                    slot.upgradeButton.GetComponentInChildren <Text>().text = skill.level == 0 ? "Learn" : "Upgrade";
                    slot.upgradeButton.interactable = player.CanUpgradeSkill(skill);
                    slot.upgradeButton.onClick.SetListener(() => { player.CmdUpgradeSkill(skillIndex); });
                }
                // otherwise no button needed
                else
                {
                    slot.upgradeButton.gameObject.SetActive(false);
                }

                // cooldown overlay
                float cooldown = skill.CooldownRemaining();
                slot.cooldownOverlay.SetActive(skill.level > 0 && cooldown > 0);
                slot.cooldownText.text         = cooldown.ToString("F0");
                slot.cooldownCircle.fillAmount = skill.cooldown > 0 ? cooldown / skill.cooldown : 0;
            }

            // skill experience
            skillExperienceText.text = player.skillExperience.ToString();
        }
    }
Exemple #23
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);
            }
        }
    }
Exemple #24
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();
        }
    }
Exemple #25
0
    void Update()
    {
        GameObject player = Player.player;

        if (!player)
        {
            return;
        }

        PlayerSkills skills = player.GetComponent <PlayerSkills>();
        PlayerLook   look   = player.GetComponent <PlayerLook>();

        // instantiate/destroy enough slots
        // (we only care about non status skills)
        UIUtils.BalancePrefabs(slotPrefab.gameObject, skills.skills.Count, content);

        // refresh all
        for (int i = 0; i < skills.skills.Count; ++i)
        {
            UISkillSlot slot  = content.GetChild(i).GetComponent <UISkillSlot>();
            Skill       skill = skills.skills[i];

            bool isPassive = skill.data is PassiveSkill;

            // drag and drop name has to be the index in the real skill list,
            // not in the filtered list, otherwise drag and drop may fail
            slot.dragAndDropable.name = i.ToString();

            // click event
            slot.button.interactable = skill.level > 0 &&
                                       !isPassive &&
                                       skill.CanCast(player) && // checks mana, cooldown etc.
                                       !look.IsFreeLooking();
            int icopy = i;
            slot.button.onClick.SetListener(() => {
                // try use the skill or walk closer if needed
                skills.StartCast(icopy);
            });

            // set state
            slot.dragAndDropable.dragable = skill.level > 0 && !isPassive;

            // image
            if (skill.level > 0)
            {
                slot.image.color  = Color.white;
                slot.image.sprite = skill.image;
            }

            // description
            slot.descriptionText.text = skill.ToolTip(showRequirements: skill.level == 0);

            // learn / upgrade
            if (skill.level < skill.maxLevel && skills.CanUpgrade(skill))
            {
                slot.upgradeButton.gameObject.SetActive(true);
                slot.upgradeButton.GetComponentInChildren <Text>().text = skill.level == 0 ? "Learn" : "Upgrade";
                slot.upgradeButton.onClick.SetListener(() => { skills.Upgrade(icopy); });
            }
            else
            {
                slot.upgradeButton.gameObject.SetActive(false);
            }

            // cooldown overlay
            float cooldown = skill.CooldownRemaining();
            slot.cooldownOverlay.SetActive(skill.level > 0 && cooldown > 0);
            slot.cooldownText.text         = cooldown.ToString("F0");
            slot.cooldownCircle.fillAmount = skill.cooldown > 0 ? cooldown / skill.cooldown : 0;
        }

        // skill experience
        skillExperienceText.text = skills.skillExperience.ToString();
    }