예제 #1
0
    void onOpenTalentSlot(object data)
    {
        LobbyEvent.s_C2V_UpdateTalentForOpenSlot utfos = (LobbyEvent.s_C2V_UpdateTalentForOpenSlot)data;

        if (utfos.ret == CommonDefine.eRespResultType.SUCCESS)
        {
            //开槽成功
            TalentSlot tst = _talentSlotList[_openSlotId];
            tst.btnState = CommonDefine.TalentSlotState.TALENT_CAN_INSTALL;
            _talentSlotList [_openSlotId] = tst;

            saveTalentCfg(false);
            //刷新界面数据
            _userGold.text    = "" + utfos.gold;
            _userDiamond.text = "" + utfos.diamond;
            //utfos.currentTalentNum

            _talentItemList [_openSlotId].updateTalentItem(this, CommonDefine.eTalentType.TALENT_NONE, _openSlotId, "", "",
                                                           CommonDefine.TalentSlotState.TALENT_CAN_INSTALL);

            //此处失去选中焦点
            _installBtn.gameObject.SetActive(false);
            _uninstallBtn.gameObject.SetActive(false);
        }
        else
        {
        }
    }
예제 #2
0
    public TalentSlot GetTalentSlotHavingMaxLevel()
    {
        TalentSlot talent = talentSlots[0];

        for (int i = 0; i < talentSlots.Length; i++)
        {
            if (talentSlots[i].TALENT.level >= talent.TALENT.level)
            {
                talent = talentSlots[i];
            }
        }
        return(talent);
    }
예제 #3
0
    public void AddLevelRandom()
    {
        TalentSlot talentSlot = GetRandomTalentSlot();

        if (CharacterStatManager.instance != null)
        {
            talentSlot.TALENT.RemoveTalent(CharacterStatManager.instance);
        }
        talentSlot.TALENT.AddLevel(1);
        if (CharacterStatManager.instance != null)
        {
            talentSlot.TALENT.AddTalent(CharacterStatManager.instance);
        }
        talentSlot.TALENT = talentSlot.TALENT;
        talentManager.SaveTalentIntoPlayerPrefX();
    }
예제 #4
0
    public TalentSlot GetRandomTalentSlot()
    {
        TalentSlot        talent           = GetTalentSlotHavingMaxLevel();
        List <TalentSlot> talentRandomList = new List <TalentSlot>();

        for (int i = 0; i < talentSlots.Length; i++)
        {
            int distance = talent.TALENT.level - talentSlots[i].TALENT.level;
            if (distance > 2)
            {
                talentRandomList.Add(talentSlots[i]);
            }
        }
        if (talentRandomList.Count <= 0)
        {
            return(talent);
        }
        int j = UnityEngine.Random.Range(0, talentRandomList.Count);

        return(talentRandomList[j]);
    }
예제 #5
0
    void loadTalentCfg()
    {
        //加载天赋配置文件
        JsonObject talentJsonCfg = CommonUtil.Util.getTalentConfig();

        _talentList = new List <TalentData> ();
        for (int i = (int)CommonDefine.eTalentType.TALENT_A1; i <= (int)CommonDefine.eTalentType.TALENT_C1; i++)
        {
            TalentData td;
            td.talentType = (CommonDefine.eTalentType)i;

            System.Object v;
            System.Object name;
            System.Object des;
            System.Object cost;

            if (talentJsonCfg.TryGetValue("" + i, out v))
            {
                JsonObject tt = (JsonObject)v;
                tt.TryGetValue("name", out name);
                td.name = (string)name;
                tt.TryGetValue("des", out des);
                td.des = (string)des;

                tt.TryGetValue("cost", out cost);
                td.cost = System.Convert.ToInt32(cost);

                _talentList.Add(td);
            }
        }

        //加载配置信息
        _talentSlotList = new List <TalentSlot> ();
        for (int i = (int)CommonDefine.eTalentType.TALENT_B3; i <= (int)CommonDefine.eTalentType.TALENT_C1; i++)
        {
            TalentSlot ts;
            ts.talentType = CommonDefine.eTalentType.TALENT_NONE;
            ts.id         = i - (int)CommonDefine.eTalentType.TALENT_B3;
            ts.btnState   = CommonDefine.TalentSlotState.TALENT_LOCK;
            _talentSlotList.Add(ts);
        }

        string btnStateStr = CommonUtil.Util.getPlayerPrefs(CommonDefine.CONST.TALENT_SLOT_STATE, "");

        if (btnStateStr != "")
        {
            string [] btnStates = btnStateStr.Split(',');
            foreach (string st in btnStates)
            {
                string[] data = st.Split('#');

                for (int i = 0; i < _talentSlotList.Count; i++)
                {
                    if (_talentSlotList [i].id == int.Parse(data [1]))
                    {
                        TalentSlot tst = _talentSlotList [i];
                        tst.talentType      = (CommonDefine.eTalentType) int.Parse(data [0]);
                        tst.btnState        = (CommonDefine.TalentSlotState)(int.Parse(data [2]));
                        _talentSlotList [i] = tst;
                    }
                }
            }
        }
    }
예제 #6
0
    public void OnClickInstallBtn(bool isInstall)
    {
        if (isInstall)
        {
            //安装
            //装备当前选中的天赋
            if (getIfSlotInstalled(_talentType))
            {
                //不能装备已经装备的
                CommonUtil.Util.showDialog("温馨提示", "【" + _talentList[(int)_talentType - 1].name + "】已经装备过了!");
            }
            else
            {
                _installBtn.gameObject.SetActive(false);
                _uninstallBtn.gameObject.SetActive(true);

                if (_canInstallId == -1)
                {
                    return;
                }

                if (_talentSlotList [_canInstallId].talentType == CommonDefine.eTalentType.TALENT_NONE &&
                    _talentSlotList [_canInstallId].btnState == CommonDefine.TalentSlotState.TALENT_CAN_INSTALL)
                {
                    TalentSlot tst = _talentSlotList [_canInstallId];

                    tst.talentType = _talentType;
                    tst.id         = _canInstallId;
                    tst.btnState   = CommonDefine.TalentSlotState.TALENT_INSTALLED;
                    _talentSlotList [_canInstallId] = tst;

                    _talentItemList [_canInstallId].updateTalentItem(this,
                                                                     _talentType,
                                                                     _canInstallId,
                                                                     _talentList[(int)_talentType - 1].name,
                                                                     _talentList[(int)_talentType - 1].des,
                                                                     CommonDefine.TalentSlotState.TALENT_INSTALLED);

                    saveTalentCfg(true);

                    onUpdateTalentCost();
                }

                _canInstallId = -1;
            }
        }
        else
        {
            //卸载
            for (int i = 0; i < _talentSlotList.Count; i++)
            {
                if (_talentSlotList [i].talentType == _talentType &&
                    _talentSlotList [i].btnState == CommonDefine.TalentSlotState.TALENT_INSTALLED)
                {
                    //卸载这个天赋
                    TalentSlot tst = _talentSlotList [i];
                    tst.btnState        = CommonDefine.TalentSlotState.TALENT_CAN_INSTALL;
                    tst.talentType      = CommonDefine.eTalentType.TALENT_NONE;
                    _talentSlotList [i] = tst;

                    _talentItemList [_talentSlotList [i].id].updateTalentItem(this,
                                                                              CommonDefine.eTalentType.TALENT_NONE,
                                                                              i,
                                                                              "",
                                                                              "",
                                                                              CommonDefine.TalentSlotState.TALENT_CAN_INSTALL);

                    _installBtn.gameObject.SetActive(false);
                    _uninstallBtn.gameObject.SetActive(false);

                    saveTalentCfg(true);

                    onUpdateTalentCost();

                    break;
                }
            }
        }
    }