Ejemplo n.º 1
0
    /// <summary>
    /// 刷新所有技能展示界面;
    /// 默认选中技能处改变,从而技能说明处改变;
    /// </summary>
    /// <param name="ev">Ev.</param>
    public void PageShowSkill(EventBase ev)
    {
        if (skillSB == null)
        {
#if UNITY_EDITOR
            Debug.LogError("Scrollbar not found");
#endif
            return;
        }

        //几个技能评分scrollView 1.0f;
        int   der   = MySkillModule.GetAllSkillsNum() - mMaxShowSkillNum;
        float ratio = 1.0f / der;
        skillSB.value = (CurPageNum - 1) * mMaxShowSkillNum * ratio;
        foreach (EventDelegate ed in skillSB.onChange)
        {
            if (ed != null && ed.isValid)
            {
                ed.Execute();
            }
        }

        //当前显示页数之前技能和之后技能不显示;
        //当前是第2页,第一页*每页6个(skillsList索引0-5是隐藏的,6-11是显示的,12到最后一个技能是隐藏的)
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 刷新技能槽上技能的信息,参数技能槽索引,有效范围[0..3]
    /// </summary>
    void UpdateEquipSkill(int slotIdx)
    {
        SkillItemUI item = equipSkills[slotIdx] as SkillItemUI;

        if (item == null)
        {
            return;
        }

        //锁定状态;
        if (MySkillModule.IsSlotLocked(slotIdx + 1))
        {
            item.SLockType  = SkillLockType.Locked;
            item.IsShowIcon = false;
            item.IsTrigger  = false;//停止响应点击事件;
        }
        else
        {
            int skillID = MySkillModule.GetEquipSkillID(slotIdx);

            SkillLearnTableItem slti = MySkillModule.GetDetailBySkillId(skillID);
            if (slti == null)
            {
                item.SetSkillIcon("");
                item.SLockType = SkillLockType.UnLocked;
                return;
            }

            item.SetSkillIcon(slti.skill_icon);
            item.SLockType  = SkillLockType.UnLocked;
            item.IsShowIcon = true;
            item.IsTrigger  = true;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 更新指定技能ID的信息,技能列表中,技能索引减1即列表索引;
    /// </summary>
    /// <param name="skillId">Skill identifier.</param>
    void UpdateSkillInfo(int skillId)
    {
        if (!MySkillModule.IsLegalSkillID(skillId))
        {
            return;
        }

        //		if(skillId > skillsList.Count || skillId < 1)
        //			return;

        SkillItemUI item = skillsList[skillId - 1] as SkillItemUI;

        if (item == null)
        {
            return;
        }

        int  skillLv = MySkillModule.GetSkillLvBySkillID(skillId);
        bool canOpen = MySkillModule.canOpen(skillId);

        if (skillLv == 0 && !canOpen)//锁定状态;
        {
            item.SLockType         = SkillLockType.Locked;
            item.IsShowEquiSlotNum = false;
            item.IsShowLv          = false;
            int openLv = MySkillModule.GetSkillUnlockLvByID(skillId);
            item.SetShowHint(openLv.ToString() + "级解锁");
            return;
        }

        else if (skillLv == 0 && canOpen)//可解锁状态;
        {
            item.SLockType         = SkillLockType.Opened;
            item.IsShowEquiSlotNum = false;
            item.IsShowLv          = false;
            item.SetShowHint("可解锁");
            return;
        }

        else
        {
            item.SLockType = SkillLockType.UnLocked;
            item.SetShowLevel(skillLv);
            item.IsShowHint = false;

            int slotIdx = -1;
            if (MySkillModule.GetSlotIdxBySkillID(skillId, ref slotIdx))
            {
                item.IsShowEquiSlotNum = true;
                item.SetShowEquipNum(slotIdx + 1);
            }
            else
            {
                item.IsShowEquiSlotNum = false;
            }
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// invalid 是否无效;
    /// </summary>
    /// <param name="skillId"></param>
    /// <param name="invalid"></param>
    void CreateSkill(int skillId, bool invalid = false)
    {
        GameObject go = UIResourceManager.Instance.CloneGameObject(skillItemprefab);

        if (go == null)
        {
            Debug.LogError("SkillItemUI Prefab Not Found");
            return;
        }

        UIEventListener.Get(go).onDrag = onSkillItemDrag;
        go.SetActive(true);
        go.name                 = SKILL_ITEM_NAME + skillId.ToString();
        go.transform.parent     = skillRoot.transform;
        go.transform.localScale = Vector3.one;//防止缩放;

        SkillItemUI item = new SkillItemUI(go);

        if (item == null)
        {
            Debug.LogError("SkillItemUI Component Not Found");
            return;
        }

        //item.onDragScrollView = onSkillItemDrag;

        //		UIEventListener.Get(skillRoot.transform.parent.gameObject).onPress = onSkillItemPress;
        //		UIEventListener.Get(skillRoot.transform.parent.gameObject).onDrag = onSkillItemDrag;

        //		UIEventListener.Get(go).onDrag = onSkillItemDrag;

        if (invalid)//无效的技能;
        {
            go.GetComponent <UIButton>().normalSprite = "touming";
            go.GetComponent <UISprite>().spriteName   = "touming";
            for (int m = 0, n = go.transform.childCount; m < n; m++)
            {
                go.transform.GetChild(m).gameObject.SetActive(false);
            }
        }
        else
        {
            //图标是不需要变的放在这里进行处理;
            item.SetSkillIcon(MySkillModule.GetSkillIconByID(skillId));

            UIEventListener.Get(go).onClick = onSkillItemClick;

            skillsList.Add(item);
        }
    }
Ejemplo n.º 5
0
    void SetEquipSlotAniActive(int skillID)
    {
        int idx = 0;

        bool isShow = !MySkillModule.GetSlotIdxBySkillID(skillID, ref idx);

        for (int i = 0, j = mEquiAnis.Length; i < j; i++)
        {
            if (isShow)
            {
                mEquiAnis[i].Reset();
            }
            mEquiAnis[i].gameObject.SetActive(isShow);
        }
    }
Ejemplo n.º 6
0
    void onEquipItemClick(GameObject go)
    {
        ///范围[1...4]
        int slotIdx = System.Convert.ToInt32(go.name.Replace(SKILL_ITEM_NAME, ""));

        if (mCanEquip)
        {
            MySkillModule.EquipSkill(slotIdx, CurSkillId);
            SetSelect(CurSkillId);
        }
        else
        {
            CurSkillId = MySkillModule.GetEquipSkillID(slotIdx - 1);
        }

        CanEquip = false;
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 技能解锁;
    /// </summary>
    void UnLock()
    {
        SkillItemUI item = skillsList[CurSkillId - 1] as SkillItemUI;

        if (item == null)
        {
            return;
        }
        if (item.SLockType == SkillLockType.Opened)
        {
            MySkillModule.UnLock(CurSkillId);
        }
        else
        {
            //人物等级不足,解锁失败!;
            PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, StringHelper.GetString("skill_unlock_nolv")));
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 设置当前选中的技能id
    /// </summary>
    /// <param name="skillId">Skill identifier.</param>
    void SetSelect(int skillId)
    {
        if (skillId <= 0 || skillId > skillsList.Count)
        {
            return;
        }

        int pageNum = GetPageNumBySkillID(skillId);

        //打开到指定页,并将该技能ID对应的技能设置为选中状态;
        GoToPage(pageNum);
        for (int i = 0, j = skillsList.Count; i < j; i++)
        {
            skillsList[i].IsSelected = false;
        }
        skillsList[skillId - 1].IsSelected = true;

        for (int i = 0, j = jianTous.Length; i < j; i++)
        {
            jianTous[i].SetActive(false);
        }
        int jIdx = (skillId - 1) % mMaxShowSkillNum;

        jianTous[jIdx].SetActive(true);

        SetJianTousActive(pageNum == mCurPageNum);

        //如果该技能ID在技能槽中,也选中;
        int slotIdx = 0;

        for (int i = 0, j = equipSkills.Count; i < j; i++)
        {
            equipSkills[i].IsSelected = false;
        }
        if (MySkillModule.GetSlotIdxBySkillID(skillId, ref slotIdx))
        {
            equipSkills[slotIdx].IsSelected = true;
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// 读档创建所有技能列表;
    /// </summary>
    void InitSkills()
    {
        int i = 0, j = 0;

        for (j = MySkillModule.GetAllSkillsNum(); i < j; i++)
        {
            CreateSkill(i + 1);
        }

        int num   = j % 6 == 0 ? j / 6 : j / 6 + 1;
        int total = num * 6;

        for (; j < num * 6; j++)
        {
            CreateNullSkill(j + 1);
        }

        UIGrid grid = skillRoot.GetComponent <UIGrid>();

        if (grid != null)
        {
            grid.repositionNow = true;
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 刷新技能说明处显示信息;
    /// </summary>
    void UpdateDetails(bool needTypeWriterEffect)
    {
        SkillLearnTableItem learnItem = MySkillModule.GetDetailBySkillId(CurSkillId);

        if (learnItem == null)
        {
            return;
        }

        SkillLevelTableItem levelItem = null;
        int levelId = 0;

        int lv = MySkillModule.GetSkillLvBySkillID(CurSkillId);

        if (lv < 0)
        {
            return;
        }

        skillName.text = learnItem.skill_name;

        if (lv == 0)                                //锁定状态/可解锁状态;
        {
            if (!MySkillModule.canOpen(CurSkillId)) //锁定;
            {
                skillLV.text = StringHelper.StringWithColor(FontColor.Red, "未解锁");
            }
            else
            {
                skillLV.text = "[079d6a]可解锁[-]";
            }

            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, 1);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);
            if (levelItem == null)
            {
                Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                return;
            }
            detail1.text = learnItem.skill_desc + "\n" + levelItem.skill_desc.Replace("\\n", "\n");

            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, 2);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);
            if (levelItem == null)
            {
                Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                return;
            }
            detail2.text = levelItem.skill_desc.Replace("\\n", "\n");

            needLvLb.gameObject.SetActive(true);
            int lvUpLv = SkillModule.GetPlayerLvBySkillLevelId(levelId);
            if (lvUpLv > 0)
            {
                PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                if (pdm == null)
                {
                    GameDebug.LogError("f**k");
                    return;
                }

                if (pdm.GetLevel() < lvUpLv)
                {
                    needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Red), lvUpLv);
                }
                else
                {
                    needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Green), lvUpLv);
                }
            }
            else
            {
                needLvLb.text = "";
            }
        }

        else
        {
            skillLV.text = "Lv. " + lv.ToString();

            //levelItem = MySkillModule.GetDetailByCurLvSkillID(CurSkillId, MySkillModule.GetSkillLvBySkillID(CurSkillId) - 1);
            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, lv);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);

            if (levelItem == null)
            {
                Debug.LogError("error le");
                return;
            }

            detail1.text = learnItem.skill_desc + "\n" + levelItem.skill_desc.Replace("\\n", "\n");

            if (MySkillModule.IsFullLv(CurSkillId))
            {
                detail2.text = StringHelper.GetString("skill_full_lv");
                needLvLb.gameObject.SetActive(false);
            }

            else
            {
                levelId   = SkillModule.SkillLearnToLevel(CurSkillId, lv + 1);
                levelItem = MySkillModule.GetDetailByLevelID(levelId);

                if (levelItem == null)
                {
                    Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                    return;
                }

                needLvLb.gameObject.SetActive(true);
                int lvUpLv = SkillModule.GetPlayerLvBySkillLevelId(levelId);
                if (lvUpLv > 0)
                {
                    PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                    if (pdm == null)
                    {
                        GameDebug.LogError("f**k");
                        return;
                    }

                    if (pdm.GetLevel() < lvUpLv)
                    {
                        needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Red), lvUpLv);
                    }
                    else
                    {
                        needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Green), lvUpLv);
                    }
                }
                else
                {
                    needLvLb.text = "";
                }

                detail2.text = levelItem.skill_desc.Replace("\\n", "\n");
            }
        }


        TypewriterEffect te1 = null, te2 = null;

        if (UIEffectManager.IsUIEffectActive <TypewriterEffect>(detail1.gameObject, ref te1))
        {
            if (needTypeWriterEffect)
            {
                te1.ReStart();
            }
            else
            {
                te1.SetProcessText();
            }
        }
        else
        {
            if (needTypeWriterEffect)
            {
                detail1.gameObject.AddMissingComponent <TypewriterEffect>();
            }
        }
        if (UIEffectManager.IsUIEffectActive <TypewriterEffect>(detail2.gameObject, ref te2))
        {
            if (needTypeWriterEffect)
            {
                te2.ReStart();
            }
            else
            {
                te2.SetProcessText();
            }
        }
        else
        {
            if (needTypeWriterEffect)
            {
                detail2.gameObject.AddMissingComponent <TypewriterEffect>();
            }
        }
    }
Ejemplo n.º 11
0
 ///技能升级;
 void Upgrade()
 {
     MySkillModule.Upgrade(CurSkillId);
 }
Ejemplo n.º 12
0
    /// <summary>
    /// 刷新技能升级消耗显示、按钮内容显示
    /// </summary>
    void UpdateUpgradeAndCost()
    {
        int lv = MySkillModule.GetSkillLvBySkillID(CurSkillId);

        //非法数据;
        if (lv < 0)
        {
            return;
        }

        //锁定状态;
        if (lv == 0 && !MySkillModule.canOpen(CurSkillId))
        {
            int unlockLv = MySkillModule.GetSkillUnlockLvByID(CurSkillId);
            if (unlockLv < 1)
            {
                return;
            }

            //			costLb.gameObject.SetActive(false);
            fullLvSp.gameObject.SetActive(false);
            costLb.transform.parent.gameObject.SetActive(false);
            upgradeBtn.gameObject.SetActive(false);
            equipRoot.SetActive(false);

            unlockBtn.gameObject.SetActive(true);
            //			unlockBtn.isEnabled = false;

            openSp.gameObject.SetActive(true);
            openLvLb.gameObject.SetActive(true);
            openLvLb.text = StringHelper.StringWithColor(FontColor.Red, "LV" + unlockLv.ToString()) + "才可以解锁此技能!";

            return;
        }
        //可解锁状态;
        else if (0 == lv && MySkillModule.canOpen(CurSkillId))
        {
            //			costLb.gameObject.SetActive(false);
            fullLvSp.gameObject.SetActive(false);
            costLb.transform.parent.gameObject.SetActive(false);
            upgradeBtn.gameObject.SetActive(false);
            equipRoot.SetActive(false);

            unlockBtn.gameObject.SetActive(true);
            //			unlockBtn.isEnabled = true;

            openSp.gameObject.SetActive(true);
            openLvLb.gameObject.SetActive(true);
            openLvLb.text = "可以解锁此技能!";
        }

        //有等级状态;
        else
        {
            equipRoot.SetActive(true);
            openSp.gameObject.SetActive(false);
            openLvLb.gameObject.SetActive(false);
            unlockBtn.gameObject.SetActive(false);

            //满级了;
            if (MySkillModule.IsFullLv(CurSkillId))
            {
                //				costLb.gameObject.SetActive(false);
                costLb.transform.parent.gameObject.SetActive(false);
                upgradeBtn.gameObject.SetActive(false);

                fullLvSp.gameObject.SetActive(true);
            }
            else
            {
                fullLvSp.gameObject.SetActive(false);

                //				costLb.gameObject.SetActive(true);
                costLb.transform.parent.gameObject.SetActive(true);
                upgradeBtn.gameObject.SetActive(true);

                SkillLevelTableItem slti = MySkillModule.GetDetailByCurLvSkillID(CurSkillId);
                if (slti == null)
                {
                    return;
                }

                UIAtlasHelper.SetSpriteByMoneyType(costTypeSp, (ProceedsType)slti.money_type, false);
                //if (slti.money_type == 0)
                //{
                //    //costTypeSp.spriteName = "jinbi";
                //}
                //else if (slti.money_type == 1)
                //    costTypeSp.spriteName = "zuanshi";
                //				costTypeSp.MakePixelPerfect();

                PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                if (pdm == null)
                {
                    GameDebug.LogError(@"PlayerData没了");
                }

                uint      curMoney = pdm.GetProceeds((ProceedsType)slti.money_type);
                FontColor color    = curMoney < slti.money_num ? FontColor.Red : FontColor.Green;
                costLb.text = StringHelper.StringWithColor(color, slti.money_num.ToString());
            }
        }
    }