コード例 #1
0
    public void OnClickTalentHasInstallBtn(int id)
    {
        //显示已经装备的天赋
        _installBtn.gameObject.SetActive(false);
        _uninstallBtn.gameObject.SetActive(false);


        if (!isBaseSelected)
        {
            _uninstallBtn.gameObject.SetActive(true);
        }

        if (isBaseSelected)
        {
            _talentType = _talentList[id].talentType;
        }
        else
        {
            _talentType = _talentSlotList [id].talentType;
        }

        checkSwitchTalentBtn();

        onUpdateSelectTalent();
    }
コード例 #2
0
    public void OnClickTalentCanInstallBtn(int id)
    {
        //装备当前选中的天赋
        if (getIfSlotInstalled(_talentType))
        {
            // 此处需要切换
            for (int i = (int)CommonDefine.eTalentType.TALENT_B3; i <= (int)CommonDefine.eTalentType.TALENT_C1; i++)
            {
                if (!getIfSlotInstalled(_talentList [i - 1].talentType))
                {
                    //切换到这个
                    _talentType = _talentList [i - 1].talentType;

                    onUpdateSelectTalent();
                    hightlightSelect();
                    checkSwitchTalentBtn();

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

                    _canInstallId = id;

                    break;
                }
            }
        }
        else
        {
            _installBtn.gameObject.SetActive(true);
            _uninstallBtn.gameObject.SetActive(false);

            _canInstallId = id;
            //此处最好对该按钮做一定的动画或者高亮操作
        }
    }
コード例 #3
0
    public TalentCostItem createTalentCostItem(GameObject root, CommonDefine.eTalentType type, int id, string name, int cost)
    {
        TalentCostItem talentItem = Instantiate(_talentCostPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        talentItem.transform.SetParent(root.transform);

        talentItem.transform.localPosition = new Vector3(0, -id * _talentCostInteral, 0);

        talentItem.updateTalentItem(type, name, cost);

        talentItem.transform.localScale = talentItem.transform.localScale * CommonUtil.Util.getScreenScale();

        return(talentItem);
    }
コード例 #4
0
    public TalentItem createTalentItem(CommonDefine.eTalentType type, int id, string name, string des, CommonDefine.TalentSlotState btnState)
    {
        TalentItem talentItem = Instantiate(_talentPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        talentItem.transform.SetParent(_talentItemRoot.transform);

        talentItem.transform.localPosition = new Vector3(0, -id * _talentInteral, 0);

        talentItem.updateTalentItem(this, type, id, name, des, btnState);

        talentItem.transform.localScale = talentItem.transform.localScale * CommonUtil.Util.getScreenScale();

        return(talentItem);
    }
コード例 #5
0
    //高级天赋
    public void OnClickHighTalentBtn()
    {
        if (!isBaseSelected)
        {
            return;
        }

        _talentType     = CommonDefine.eTalentType.TALENT_B3;    //每次进来默认显示b3
        _prevTalentType = _talentType;
        _canInstallId   = -1;

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

        _toLeftSwitchBtn.interactable  = false;
        _toRightSwitchBtn.interactable = true;

        _currentAndTotal.text = ((int)_talentType - (int)CommonDefine.eTalentType.TALENT_B3 + 1) + "/" + ((int)CommonDefine.eTalentType.TALENT_C1 - (int)CommonDefine.eTalentType.TALENT_B3 + 1);


        if (!isBaseSelected && getIfSlotInstalled(_talentType))
        {
            _uninstallBtn.gameObject.SetActive(true);
        }

        removeAllTalent();

        RectTransform rt = _talentItemRoot.gameObject.GetComponent <RectTransform>();

        rt.sizeDelta = new Vector2(rt.sizeDelta.x, ((int)CommonDefine.eTalentType.TALENT_C1 - (int)CommonDefine.eTalentType.TALENT_B3) * _talentInteral);

        //_talentSlotList 生成界面
        for (int i = 0; i < _talentSlotList.Count; i++)
        {
            CommonDefine.eTalentType ttp = _talentSlotList[i].talentType;
            string name = "";
            string des  = "";
            if (ttp != CommonDefine.eTalentType.TALENT_NONE)
            {
                name = _talentList[(int)ttp - 1].name;
                des  = _talentList[(int)ttp - 1].des;
            }
            _talentItemList.Add(createTalentItem(ttp, _talentSlotList[i].id, name, des, _talentSlotList[i].btnState));
        }

        //if(self.talent != )

        onUpdateSelectTalent();
    }
コード例 #6
0
 bool getIfSlotInstalled(CommonDefine.eTalentType ttp)
 {
     for (int i = 0; i < _talentSlotList.Count; i++)
     {
         if (_talentSlotList[i].talentType == ttp)
         {
             if (_talentSlotList [i].btnState == CommonDefine.TalentSlotState.TALENT_INSTALLED)
             {
                 return(true);
             }
             return(false);
         }
     }
     return(false);
 }
コード例 #7
0
    //------------------------------以下界面事件传出-----------------------------------------------
    //基础天赋
    public void OnClickBaseTalentBtn()
    {
        if (isBaseSelected)
        {
            return;
        }

        _talentType     = CommonDefine.eTalentType.TALENT_A1;    //每次进来默认显示A1
        _prevTalentType = _talentType;

        isBaseSelected = true;

        //基础天赋,不显示高亮按钮

        _currentAndTotal.text = (int)_talentType + "/" + ((int)CommonDefine.eTalentType.TALENT_B2 - (int)CommonDefine.eTalentType.TALENT_A1 + 1);

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

        _toLeftSwitchBtn.interactable  = false;
        _toRightSwitchBtn.interactable = true;

        removeAllTalent();

        RectTransform rt = _talentItemRoot.gameObject.GetComponent <RectTransform>();

        rt.sizeDelta = new Vector2(rt.sizeDelta.x, ((int)CommonDefine.eTalentType.TALENT_B3 - (int)CommonDefine.eTalentType.TALENT_A1) * _talentInteral);
        //根据_talentList 生成界面
        for (int i = (int)CommonDefine.eTalentType.TALENT_A1; i < (int)CommonDefine.eTalentType.TALENT_B3; i++)
        {
            _talentItemList.Add(createTalentItem(_talentList[i - 1].talentType,
                                                 i - 1,
                                                 _talentList[i - 1].name,
                                                 _talentList[i - 1].des,
                                                 CommonDefine.TalentSlotState.TALENT_INSTALLED));
        }

        onUpdateSelectTalent();
    }
コード例 #8
0
    public void OnClickSwitchTalentBtn(bool left)
    {
        if (left)
        {
            if (isBaseSelected)
            {
                if ((int)_talentType == (int)CommonDefine.eTalentType.TALENT_A1)
                {
                    _toLeftSwitchBtn.interactable  = false;
                    _toRightSwitchBtn.interactable = true;
                }
                else
                {
                    _talentType = (CommonDefine.eTalentType)((int)_talentType - 1);
                    _toLeftSwitchBtn.interactable  = true;
                    _toRightSwitchBtn.interactable = true;
                }
            }
            else
            {
                //
                if ((int)_talentType == (int)CommonDefine.eTalentType.TALENT_B3)
                {
                    _toLeftSwitchBtn.interactable  = false;
                    _toRightSwitchBtn.interactable = true;
                }
                else
                {
                    _talentType = (CommonDefine.eTalentType)((int)_talentType - 1);
                    _toLeftSwitchBtn.interactable  = true;
                    _toRightSwitchBtn.interactable = true;
                }
            }
        }
        else
        {
            if (isBaseSelected)
            {
                if ((int)_talentType == (int)CommonDefine.eTalentType.TALENT_B2)
                {
                    _toLeftSwitchBtn.interactable  = true;
                    _toRightSwitchBtn.interactable = false;
                }
                else
                {
                    _talentType = (CommonDefine.eTalentType)((int)_talentType + 1);
                    _toLeftSwitchBtn.interactable  = true;
                    _toRightSwitchBtn.interactable = true;
                }
            }
            else
            {
                //
                if ((int)_talentType == (int)CommonDefine.eTalentType.TALENT_C1)
                {
                    _toLeftSwitchBtn.interactable  = true;
                    _toRightSwitchBtn.interactable = false;
                }
                else
                {
                    _talentType = (CommonDefine.eTalentType)((int)_talentType + 1);
                    _toLeftSwitchBtn.interactable  = true;
                    _toRightSwitchBtn.interactable = true;
                }
            }
        }

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

        if (!isBaseSelected)
        {
            //_uninstallBtn.gameObject.SetActive (true);//切换默认丢失焦点,不显示安装卸载
        }

        checkSwitchTalentBtn();
        onUpdateSelectTalent();
    }
コード例 #9
0
 public void OnClickHightlightBtn(int index)
 {
     _talentType = (CommonDefine.eTalentType)(index + CommonDefine.eTalentType.TALENT_B3);
     onUpdateSelectTalent();
 }