| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Friday, November 10, 2017 |
| | | //-------------------------------------------------------- |
| | | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using TableConfig; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | |
| | | public class SkillPassWin : Window |
| | | { |
| | | [SerializeField] FlipScroll flipScroll; |
| | | [SerializeField] RectTransform m_ContainerSkillDetails; |
| | | [SerializeField] RectTransform m_ContainerUnselect; |
| | | [SerializeField] Text m_SkillNameTxt; |
| | | [SerializeField] Text m_SkillSourceTxt; |
| | | [SerializeField] Text m_SkillDescTxt; |
| | | [SerializeField] Text m_CoolDownTxt; |
| | | [SerializeField] Button m_LeftBtn; |
| | | [SerializeField] Button m_RightBtn; |
| | | [SerializeField] List<SkillCell> equipPassSkills = new List<SkillCell>(); |
| | | [SerializeField] Image m_DragImg; |
| | | [SerializeField] Image m_DragSkillImg; |
| | | [SerializeField] List<Button> m_PageBtns = new List<Button>(); |
| | | [Header("GetWay")] |
| | | [SerializeField] |
| | | Button m_GetWayBtn; |
| | | [SerializeField] ScrollerController scrollerController; |
| | | [SerializeField] RectTransform m_ContainerGetWay; |
| | | [SerializeField] ClickScreenOtherSpace clickOtherSpace; |
| | | private List<SkillConfig> skillListPass = new List<SkillConfig>(); |
| | | private int presentSltEquipIndex = -1; |
| | | SkillModel m_Model; |
| | | SkillModel model |
| | | { |
| | | get |
| | | { |
| | | return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<SkillModel>()); |
| | | } |
| | | } |
| | | |
| | | RolePromoteModel m_PromoteModel; |
| | | RolePromoteModel promoteModel |
| | | { |
| | | get |
| | | { |
| | | return m_PromoteModel ?? (m_PromoteModel = ModelCenter.Instance.GetModel<RolePromoteModel>()); |
| | | } |
| | | } |
| | | |
| | | VipModel m_VipModel; |
| | | VipModel vipModel |
| | | { |
| | | get |
| | | { |
| | | return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>()); |
| | | } |
| | | } |
| | | |
| | | static readonly Color equipHoleLimitColor = new Color32(250, 3, 3, 255); |
| | | static readonly Color equipHoleUnLimitColor = new Color32(51, 8, 0, 255); |
| | | #region Built-in |
| | | protected override void BindController() |
| | | { |
| | | |
| | | } |
| | | |
| | | protected override void AddListeners() |
| | | { |
| | | flipScroll.OnRefreshData += OnRefreshPassSkill; |
| | | flipScroll.OnTweenCompt += OnTweenCompt; |
| | | m_LeftBtn.onClick.AddListener(flipScroll.FlipLeft); |
| | | m_RightBtn.onClick.AddListener(flipScroll.FlipRight); |
| | | for (int i = 0; i < m_PageBtns.Count; i++) |
| | | { |
| | | int index = i; |
| | | m_PageBtns[i].onClick.AddListener(() => |
| | | { |
| | | OnClickPage(index); |
| | | }); |
| | | } |
| | | for (int i = 0; i < equipPassSkills.Count; i++) |
| | | { |
| | | int index = i; |
| | | equipPassSkills[i].skillData.m_SkillBtn.onClick.AddListener(() => |
| | | { |
| | | OnClickEquipHole(index); |
| | | }); |
| | | } |
| | | scrollerController.OnRefreshCell += OnRefreshCell; |
| | | m_GetWayBtn.onClick.AddListener(OnGetWayBtn); |
| | | clickOtherSpace.AddListener(() => |
| | | { |
| | | m_ContainerGetWay.gameObject.SetActive(false); |
| | | }); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | m_DragImg.gameObject.SetActive(false); |
| | | m_ContainerGetWay.gameObject.SetActive(false); |
| | | m_GetWayBtn.gameObject.SetActive(false); |
| | | flipScroll.locked = false; |
| | | PlayerSkillDatas.OnRefreshSkill += OnRefreshSkill; |
| | | model.OnRefreshSltSkill += OnRefreshSltSkill; |
| | | model.UpdatePassEquipSkillEvent += UpdatePassEquipSkillEvent; |
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnRefreshPlayerInfo; |
| | | model.presentSltPage = model.presentEquipPage; |
| | | Input.multiTouchEnabled = false; |
| | | GetSkillList(); |
| | | UpdatePassEquipPageBtn(); |
| | | OnUpdateSltSkillInfo(); |
| | | UpdateEquipPassSkill(); |
| | | SetEquipHoleSelect(GetEquipHoleIndex(model.presentSltSkillID)); |
| | | DayRemind.Instance.SetDayRemind(DayRemind.PASS_SKILL_REDPOINT, true); |
| | | } |
| | | |
| | | protected override void OnActived() |
| | | { |
| | | base.OnActived(); |
| | | UpdatePageBtn(); |
| | | } |
| | | |
| | | protected override void OnAfterOpen() |
| | | { |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | Input.multiTouchEnabled = true; |
| | | PlayerSkillDatas.OnRefreshSkill -= OnRefreshSkill; |
| | | model.OnRefreshSltSkill -= OnRefreshSltSkill; |
| | | model.UpdatePassEquipSkillEvent -= UpdatePassEquipSkillEvent; |
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnRefreshPlayerInfo; |
| | | model.SetDayRemind(); |
| | | } |
| | | |
| | | protected override void OnAfterClose() |
| | | { |
| | | model.SendEquipPage(); |
| | | } |
| | | |
| | | protected override void LateUpdate() |
| | | { |
| | | base.LateUpdate(); |
| | | if (model.skillDraging) |
| | | { |
| | | flipScroll.locked = true; |
| | | if (!m_DragImg.gameObject.activeSelf) |
| | | { |
| | | m_DragImg.gameObject.SetActive(true); |
| | | SkillConfig cfg = ConfigManager.Instance.GetTemplate<SkillConfig>(model.skillDragId); |
| | | if (cfg != null) |
| | | { |
| | | m_DragSkillImg.SetSprite(cfg.IconName); |
| | | } |
| | | } |
| | | Vector2 _pos; |
| | | if (RectTransformUtility.ScreenPointToLocalPointInRectangle(this.transform as RectTransform, |
| | | Input.mousePosition, CameraManager.uiCamera, out _pos)) |
| | | { |
| | | m_DragImg.rectTransform.localPosition = _pos; |
| | | } |
| | | |
| | | if (Input.GetMouseButtonUp(0)) |
| | | { |
| | | model.skillDraging = false; |
| | | flipScroll.locked = false; |
| | | m_DragImg.gameObject.SetActive(false); |
| | | CheckReplaceEquipSkill(); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | private void OnRefreshSltSkill() |
| | | { |
| | | flipScroll.RefreshActive(); |
| | | var _equipIndex = GetEquipHoleIndex(model.presentSltSkillID); |
| | | SetEquipHoleSelect(_equipIndex); |
| | | m_GetWayBtn.gameObject.SetActive(CheckOpenGetWays(_equipIndex)); |
| | | OnUpdateSltSkillInfo(); |
| | | } |
| | | |
| | | private bool CheckOpenGetWays(int _index) |
| | | { |
| | | PassSkillLimit _limit; |
| | | if (model.TryGetPassSkillLimit(_index, out _limit)) |
| | | { |
| | | if (_limit.level > 0 && PlayerDatas.Instance.baseData.LV < _limit.level) |
| | | { |
| | | return true; |
| | | } |
| | | else if (_limit.vipLv > 0 && PlayerDatas.Instance.baseData.VIPLv < _limit.vipLv) |
| | | { |
| | | return true; |
| | | } |
| | | else if (_limit.MountLv > 0 && promoteModel.GetMountTotallv() < _limit.MountLv) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private void OnRefreshPlayerInfo(PlayerDataRefresh type) |
| | | { |
| | | switch (type) |
| | | { |
| | | case PlayerDataRefresh.LV: |
| | | case PlayerDataRefresh.LV2: |
| | | case PlayerDataRefresh.LVEx: |
| | | case PlayerDataRefresh.VIPLv: |
| | | UpdateEquipPassSkill(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void OnRefreshSkill() |
| | | { |
| | | flipScroll.RefreshActive(); |
| | | } |
| | | private void OnRefreshPassSkill(int page, RectTransform cell) |
| | | { |
| | | for (int i = 0; i < cell.childCount; i++) |
| | | { |
| | | Transform skillTran = cell.GetChild(i); |
| | | int index = page * SkillModel.PASS_SKILL_NUM + i; |
| | | if (index < skillListPass.Count) |
| | | { |
| | | skillTran.gameObject.SetActive(true); |
| | | skillTran.GetComponent<SkillCell>().Refresh(skillListPass[index]); |
| | | } |
| | | else |
| | | { |
| | | skillTran.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnTweenCompt() |
| | | { |
| | | UpdatePageBtn(); |
| | | } |
| | | |
| | | void UpdatePageBtn() |
| | | { |
| | | if (flipScroll.Page == 0) |
| | | { |
| | | m_LeftBtn.gameObject.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | m_LeftBtn.gameObject.SetActive(true); |
| | | } |
| | | if (flipScroll.Page == flipScroll.pageCnt - 1) |
| | | { |
| | | m_RightBtn.gameObject.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | m_RightBtn.gameObject.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | void OnUpdateSltSkillInfo() |
| | | { |
| | | SkillConfig _cfg = ConfigManager.Instance.GetTemplate<SkillConfig>(model.presentSltSkillID); |
| | | m_ContainerSkillDetails.gameObject.SetActive(_cfg != null); |
| | | m_ContainerUnselect.gameObject.SetActive(_cfg == null); |
| | | if (_cfg != null) |
| | | { |
| | | m_SkillNameTxt.text = _cfg.SkillName; |
| | | m_SkillSourceTxt.text = _cfg.Skillsource; |
| | | m_SkillDescTxt.text = UIHelper.ReplaceNewLine(_cfg.Description); |
| | | m_CoolDownTxt.text = _cfg.CoolDownTime == 0 ? string.Empty : Language.Get("L1065", _cfg.CoolDownTime / 1000); |
| | | } |
| | | } |
| | | |
| | | void GetSkillList() |
| | | { |
| | | Dictionary<int, List<SkillConfig>> dic = SkillConfig.GetSkillWithOccpyAndType((int)Mathf.Pow(2, PlayerDatas.Instance.baseData.Job), SkillModel.PASS_SKILL_TYPE); |
| | | Dictionary<int, PlayerSkillData> playerskills = PlayerDatas.Instance.skill.GetAllSkill(); |
| | | skillListPass.Clear(); |
| | | foreach (int key in dic.Keys) |
| | | { |
| | | SkillConfig lvCfg = dic[key][0]; |
| | | foreach (SkillConfig cfg in dic[key]) |
| | | { |
| | | if (PlayerDatas.Instance.skill.GetSKillById(cfg.SkillID) != null) { lvCfg = cfg; break; } |
| | | } |
| | | if (PlayerDatas.Instance.skill.GetFilterPlayerSkill(PlayerDatas.Instance.baseData.Job).Contains(lvCfg.SkillID)) continue; |
| | | skillListPass.Add(lvCfg); |
| | | } |
| | | if (skillListPass.Count < 1) return; |
| | | model.presentSltSkillID = skillListPass[0].SkillID; |
| | | flipScroll.pageCnt = Mathf.CeilToInt((float)skillListPass.Count / SkillModel.PASS_SKILL_NUM); |
| | | flipScroll.RefreshActive(); |
| | | } |
| | | |
| | | private void UpdatePassEquipSkillEvent() |
| | | { |
| | | UpdateEquipPassSkill(); |
| | | SetEquipHoleSelect(GetEquipHoleIndex(model.presentSltSkillID)); |
| | | } |
| | | |
| | | private void UpdateEquipPassSkill() |
| | | { |
| | | for (int i = 0; i < equipPassSkills.Count; i++) |
| | | { |
| | | PassSkillLimit limit; |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleUnLimitColor; |
| | | if (model.TryGetPassSkillLimit(i, out limit)) |
| | | { |
| | | if (limit.level > 0) |
| | | { |
| | | if (PlayerDatas.Instance.baseData.LV < limit.level) |
| | | { |
| | | SetEquipSkillDeActive(i); |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleLimitColor; |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = Language.Get("PassSkillHoleLimitLv", limit.level); |
| | | continue; |
| | | } |
| | | } |
| | | else if (limit.vipLv > 0) |
| | | { |
| | | if (PlayerDatas.Instance.baseData.VIPLv < limit.vipLv) |
| | | { |
| | | SetEquipSkillDeActive(i); |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleLimitColor; |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = Language.Get("PassSkillHoleLimitVip", limit.vipLv); |
| | | continue; |
| | | } |
| | | } |
| | | else if (limit.MountLv > 0) |
| | | { |
| | | if (promoteModel.GetMountTotallv() < limit.MountLv) |
| | | { |
| | | SetEquipSkillDeActive(i); |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleLimitColor; |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = Language.Get("PassSkillHoleLimitMount", limit.MountLv); |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | int _skillId = 0; |
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = string.Empty; |
| | | equipPassSkills[i].skillData.m_LockImg.gameObject.SetActive(false); |
| | | model.TryGetEquipPassSkills(model.presentSltPage, i, out _skillId); |
| | | equipPassSkills[i].skillData.SetSkillData(_skillId); |
| | | } |
| | | } |
| | | |
| | | private void CheckReplaceEquipSkill() |
| | | { |
| | | for (int i = 0; i < equipPassSkills.Count; i++) |
| | | { |
| | | var rect = equipPassSkills[i].transform as RectTransform; |
| | | var des = RectTransformUtility.CalculateRelativeRectTransformBounds(this.transform, rect); |
| | | var src = RectTransformUtility.CalculateRelativeRectTransformBounds(this.transform, m_DragImg.rectTransform); |
| | | var dis = Vector3.Distance(des.center, src.center); |
| | | if (dis < rect.rect.width / 2) |
| | | { |
| | | if (CheckOpenGetWays(i)) |
| | | { |
| | | //SoundPlayer.Instance.PlayUIAudio(2); |
| | | return; |
| | | } |
| | | model.SendEquipPassSkills(model.skillDragId, i); |
| | | if (model.passSkillHoleRedpoints[i].state == RedPointState.Simple) |
| | | { |
| | | model.SetDayRemind(); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void SetEquipSkillDeActive(int _hole) |
| | | { |
| | | equipPassSkills[_hole].skillData.m_LockImg.gameObject.SetActive(true); |
| | | equipPassSkills[_hole].skillData.SetSkillData(0); |
| | | } |
| | | |
| | | private void OnClickPage(int index) |
| | | { |
| | | if (index != model.presentSltPage) |
| | | { |
| | | model.SetDayRemind(); |
| | | } |
| | | model.presentSltPage = index; |
| | | UpdateEquipPassSkill(); |
| | | UpdatePassEquipPageBtn(); |
| | | var _equipIndex = GetEquipHoleIndex(model.presentSltSkillID); |
| | | SetEquipHoleSelect(_equipIndex); |
| | | m_GetWayBtn.gameObject.SetActive(CheckOpenGetWays(_equipIndex)); |
| | | } |
| | | |
| | | private void UpdatePassEquipPageBtn() |
| | | { |
| | | for (int i = 0; i < m_PageBtns.Count; i++) |
| | | { |
| | | m_PageBtns[i].image.SetSprite(model.presentSltPage == i ? "SkillRightbtn_A" : "Skillbtnbtn_A"); |
| | | } |
| | | } |
| | | |
| | | private void OnClickEquipHole(int index) |
| | | { |
| | | PassSkillLimit limit; |
| | | m_GetWayBtn.gameObject.SetActive(false); |
| | | SetEquipHoleSelect(index); |
| | | if (model.TryGetPassSkillLimit(index, out limit)) |
| | | { |
| | | if (limit.level > 0) |
| | | { |
| | | if (PlayerDatas.Instance.baseData.LV < limit.level) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("PassEquipLimitLevel", limit.level); |
| | | m_GetWayBtn.gameObject.SetActive(true); |
| | | } |
| | | } |
| | | else if (limit.vipLv > 0) |
| | | { |
| | | if (PlayerDatas.Instance.baseData.VIPLv < limit.vipLv) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("PassEquipLimitVip", limit.vipLv); |
| | | m_GetWayBtn.gameObject.SetActive(true); |
| | | return; |
| | | } |
| | | } |
| | | else if (limit.MountLv > 0) |
| | | { |
| | | if (promoteModel.GetMountTotallv() < limit.MountLv) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("PassEquipLimitMountLevel", limit.MountLv); |
| | | m_GetWayBtn.gameObject.SetActive(true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnRefreshCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | Text _text = cell.GetComponentInChildren<Text>(); |
| | | _text.text = model.passEquipGetWayTxts[cell.index]; |
| | | } |
| | | |
| | | private void OnGetWayBtn() |
| | | { |
| | | scrollerController.Refresh(); |
| | | if (model.passEquipGetWays.ContainsKey(presentSltEquipIndex)) |
| | | { |
| | | int[] intarray = model.passEquipGetWays[presentSltEquipIndex]; |
| | | foreach (var key in intarray) |
| | | { |
| | | scrollerController.AddCell(ScrollerDataType.Header, key, OnClickFunc); |
| | | } |
| | | } |
| | | scrollerController.Restart(); |
| | | m_ContainerGetWay.gameObject.SetActive(true); |
| | | } |
| | | |
| | | private void OnClickFunc(CellView cell) |
| | | { |
| | | WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)cell.index); |
| | | } |
| | | |
| | | private void SetEquipHoleSelect(int _index) |
| | | { |
| | | if (presentSltEquipIndex != -1) |
| | | { |
| | | equipPassSkills[presentSltEquipIndex].skillData.m_SelectImg.gameObject.SetActive(false); |
| | | } |
| | | presentSltEquipIndex = _index; |
| | | if (_index == -1) |
| | | { |
| | | return; |
| | | } |
| | | if (equipPassSkills[_index].skillData.skillId != 0) |
| | | { |
| | | equipPassSkills[_index].skillData.m_SelectImg.gameObject.SetActive(true); |
| | | model.presentSltSkillID = equipPassSkills[_index].skillData.skillId; |
| | | flipScroll.RefreshActive(); |
| | | OnUpdateSltSkillInfo(); |
| | | } |
| | | else |
| | | { |
| | | equipPassSkills[_index].skillData.m_SelectImg.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | private int GetEquipHoleIndex(int _skillId) |
| | | { |
| | | for (int i = 0; i < equipPassSkills.Count; i++) |
| | | { |
| | | if (equipPassSkills[i].skillData.skillId == _skillId) |
| | | { |
| | | return i; |
| | | } |
| | | } |
| | | return -1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Friday, November 10, 2017
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using TableConfig;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
|
| | | public class SkillPassWin : Window
|
| | | {
|
| | | [SerializeField] FlipScroll flipScroll;
|
| | | [SerializeField] RectTransform m_ContainerSkillDetails;
|
| | | [SerializeField] RectTransform m_ContainerUnselect;
|
| | | [SerializeField] Text m_SkillNameTxt;
|
| | | [SerializeField] Text m_SkillSourceTxt;
|
| | | [SerializeField] Text m_SkillDescTxt;
|
| | | [SerializeField] Text m_CoolDownTxt;
|
| | | [SerializeField] Button m_LeftBtn;
|
| | | [SerializeField] Button m_RightBtn;
|
| | | [SerializeField] List<SkillCell> equipPassSkills = new List<SkillCell>();
|
| | | [SerializeField] Image m_DragImg;
|
| | | [SerializeField] Image m_DragSkillImg;
|
| | | [SerializeField] List<Button> m_PageBtns = new List<Button>();
|
| | | [Header("GetWay")]
|
| | | [SerializeField]
|
| | | Button m_GetWayBtn;
|
| | | [SerializeField] ScrollerController scrollerController;
|
| | | [SerializeField] RectTransform m_ContainerGetWay;
|
| | | [SerializeField] ClickScreenOtherSpace clickOtherSpace;
|
| | | private List<SkillConfig> skillListPass = new List<SkillConfig>();
|
| | | private int presentSltEquipIndex = -1;
|
| | | SkillModel m_Model;
|
| | | SkillModel model
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<SkillModel>());
|
| | | }
|
| | | }
|
| | |
|
| | | RolePromoteModel m_PromoteModel;
|
| | | RolePromoteModel promoteModel
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_PromoteModel ?? (m_PromoteModel = ModelCenter.Instance.GetModel<RolePromoteModel>());
|
| | | }
|
| | | }
|
| | |
|
| | | VipModel m_VipModel;
|
| | | VipModel vipModel
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>());
|
| | | }
|
| | | }
|
| | |
|
| | | static readonly Color equipHoleLimitColor = new Color32(250, 3, 3, 255);
|
| | | static readonly Color equipHoleUnLimitColor = new Color32(51, 8, 0, 255);
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | flipScroll.OnRefreshData += OnRefreshPassSkill;
|
| | | flipScroll.OnTweenCompt += OnTweenCompt;
|
| | | m_LeftBtn.onClick.AddListener(flipScroll.FlipLeft);
|
| | | m_RightBtn.onClick.AddListener(flipScroll.FlipRight);
|
| | | for (int i = 0; i < m_PageBtns.Count; i++)
|
| | | {
|
| | | int index = i;
|
| | | m_PageBtns[i].onClick.AddListener(() =>
|
| | | {
|
| | | OnClickPage(index);
|
| | | });
|
| | | }
|
| | | for (int i = 0; i < equipPassSkills.Count; i++)
|
| | | {
|
| | | int index = i;
|
| | | equipPassSkills[i].skillData.m_SkillBtn.onClick.AddListener(() =>
|
| | | {
|
| | | OnClickEquipHole(index);
|
| | | });
|
| | | }
|
| | | scrollerController.OnRefreshCell += OnRefreshCell;
|
| | | m_GetWayBtn.onClick.AddListener(OnGetWayBtn);
|
| | | clickOtherSpace.AddListener(() =>
|
| | | {
|
| | | m_ContainerGetWay.gameObject.SetActive(false);
|
| | | });
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | m_DragImg.gameObject.SetActive(false);
|
| | | m_ContainerGetWay.gameObject.SetActive(false);
|
| | | m_GetWayBtn.gameObject.SetActive(false);
|
| | | flipScroll.locked = false;
|
| | | PlayerSkillDatas.OnRefreshSkill += OnRefreshSkill;
|
| | | model.OnRefreshSltSkill += OnRefreshSltSkill;
|
| | | model.UpdatePassEquipSkillEvent += UpdatePassEquipSkillEvent;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnRefreshPlayerInfo;
|
| | | model.presentSltPage = model.presentEquipPage;
|
| | | Input.multiTouchEnabled = false;
|
| | | GetSkillList();
|
| | | UpdatePassEquipPageBtn();
|
| | | OnUpdateSltSkillInfo();
|
| | | UpdateEquipPassSkill();
|
| | | SetEquipHoleSelect(GetEquipHoleIndex(model.presentSltSkillID));
|
| | | DayRemind.Instance.SetDayRemind(DayRemind.PASS_SKILL_REDPOINT, true);
|
| | | }
|
| | |
|
| | | protected override void OnActived()
|
| | | {
|
| | | base.OnActived();
|
| | | UpdatePageBtn();
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | Input.multiTouchEnabled = true;
|
| | | PlayerSkillDatas.OnRefreshSkill -= OnRefreshSkill;
|
| | | model.OnRefreshSltSkill -= OnRefreshSltSkill;
|
| | | model.UpdatePassEquipSkillEvent -= UpdatePassEquipSkillEvent;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnRefreshPlayerInfo;
|
| | | model.SetDayRemind();
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | model.SendEquipPage();
|
| | | }
|
| | |
|
| | | protected override void LateUpdate()
|
| | | {
|
| | | base.LateUpdate();
|
| | | if (model.skillDraging)
|
| | | {
|
| | | flipScroll.locked = true;
|
| | | if (!m_DragImg.gameObject.activeSelf)
|
| | | {
|
| | | m_DragImg.gameObject.SetActive(true);
|
| | | SkillConfig cfg = ConfigManager.Instance.GetTemplate<SkillConfig>(model.skillDragId);
|
| | | if (cfg != null)
|
| | | {
|
| | | m_DragSkillImg.SetSprite(cfg.IconName);
|
| | | }
|
| | | }
|
| | | Vector2 _pos;
|
| | | if (RectTransformUtility.ScreenPointToLocalPointInRectangle(this.transform as RectTransform,
|
| | | Input.mousePosition, CameraManager.uiCamera, out _pos))
|
| | | {
|
| | | m_DragImg.rectTransform.localPosition = _pos;
|
| | | }
|
| | |
|
| | | if (Input.GetMouseButtonUp(0))
|
| | | {
|
| | | model.skillDraging = false;
|
| | | flipScroll.locked = false;
|
| | | m_DragImg.gameObject.SetActive(false);
|
| | | CheckReplaceEquipSkill();
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | | private void OnRefreshSltSkill()
|
| | | {
|
| | | flipScroll.RefreshActive();
|
| | | var _equipIndex = GetEquipHoleIndex(model.presentSltSkillID);
|
| | | SetEquipHoleSelect(_equipIndex);
|
| | | m_GetWayBtn.gameObject.SetActive(CheckOpenGetWays(_equipIndex));
|
| | | OnUpdateSltSkillInfo();
|
| | | }
|
| | |
|
| | | private bool CheckOpenGetWays(int _index)
|
| | | {
|
| | | PassSkillLimit _limit;
|
| | | if (model.TryGetPassSkillLimit(_index, out _limit))
|
| | | {
|
| | | if (_limit.level > 0 && PlayerDatas.Instance.baseData.LV < _limit.level)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | else if (_limit.vipLv > 0 && PlayerDatas.Instance.baseData.VIPLv < _limit.vipLv)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | else if (_limit.MountLv > 0 && promoteModel.GetMountTotallv() < _limit.MountLv)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | private void OnRefreshPlayerInfo(PlayerDataRefresh type)
|
| | | {
|
| | | switch (type)
|
| | | {
|
| | | case PlayerDataRefresh.LV:
|
| | | case PlayerDataRefresh.LV2:
|
| | | case PlayerDataRefresh.LVEx:
|
| | | case PlayerDataRefresh.VIPLv:
|
| | | UpdateEquipPassSkill();
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnRefreshSkill()
|
| | | {
|
| | | flipScroll.RefreshActive();
|
| | | }
|
| | | private void OnRefreshPassSkill(int page, RectTransform cell)
|
| | | {
|
| | | for (int i = 0; i < cell.childCount; i++)
|
| | | {
|
| | | Transform skillTran = cell.GetChild(i);
|
| | | int index = page * SkillModel.PASS_SKILL_NUM + i;
|
| | | if (index < skillListPass.Count)
|
| | | {
|
| | | skillTran.gameObject.SetActive(true);
|
| | | skillTran.GetComponent<SkillCell>().Refresh(skillListPass[index]);
|
| | | }
|
| | | else
|
| | | {
|
| | | skillTran.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnTweenCompt()
|
| | | {
|
| | | UpdatePageBtn();
|
| | | }
|
| | |
|
| | | void UpdatePageBtn()
|
| | | {
|
| | | if (flipScroll.Page == 0)
|
| | | {
|
| | | m_LeftBtn.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_LeftBtn.gameObject.SetActive(true);
|
| | | }
|
| | | if (flipScroll.Page == flipScroll.pageCnt - 1)
|
| | | {
|
| | | m_RightBtn.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_RightBtn.gameObject.SetActive(true);
|
| | | }
|
| | | }
|
| | |
|
| | | void OnUpdateSltSkillInfo()
|
| | | {
|
| | | SkillConfig _cfg = ConfigManager.Instance.GetTemplate<SkillConfig>(model.presentSltSkillID);
|
| | | m_ContainerSkillDetails.gameObject.SetActive(_cfg != null);
|
| | | m_ContainerUnselect.gameObject.SetActive(_cfg == null);
|
| | | if (_cfg != null)
|
| | | {
|
| | | m_SkillNameTxt.text = _cfg.SkillName;
|
| | | m_SkillSourceTxt.text = _cfg.Skillsource;
|
| | | m_SkillDescTxt.text = UIHelper.ReplaceNewLine(_cfg.Description);
|
| | | m_CoolDownTxt.text = _cfg.CoolDownTime == 0 ? string.Empty : Language.Get("L1065", _cfg.CoolDownTime / 1000);
|
| | | }
|
| | | }
|
| | |
|
| | | void GetSkillList()
|
| | | {
|
| | | Dictionary<int, List<SkillConfig>> dic = SkillConfig.GetSkillWithOccpyAndType((int)Mathf.Pow(2, PlayerDatas.Instance.baseData.Job), SkillModel.PASS_SKILL_TYPE);
|
| | | Dictionary<int, PlayerSkillData> playerskills = PlayerDatas.Instance.skill.GetAllSkill();
|
| | | skillListPass.Clear();
|
| | | foreach (int key in dic.Keys)
|
| | | {
|
| | | SkillConfig lvCfg = dic[key][0];
|
| | | foreach (SkillConfig cfg in dic[key])
|
| | | {
|
| | | if (PlayerDatas.Instance.skill.GetSKillById(cfg.SkillID) != null) { lvCfg = cfg; break; }
|
| | | }
|
| | | if (PlayerDatas.Instance.skill.GetFilterPlayerSkill(PlayerDatas.Instance.baseData.Job).Contains(lvCfg.SkillID)) continue;
|
| | | skillListPass.Add(lvCfg);
|
| | | }
|
| | | if (skillListPass.Count < 1) return;
|
| | | model.presentSltSkillID = skillListPass[0].SkillID;
|
| | | flipScroll.pageCnt = Mathf.CeilToInt((float)skillListPass.Count / SkillModel.PASS_SKILL_NUM);
|
| | | flipScroll.RefreshActive();
|
| | | }
|
| | |
|
| | | private void UpdatePassEquipSkillEvent()
|
| | | {
|
| | | UpdateEquipPassSkill();
|
| | | SetEquipHoleSelect(GetEquipHoleIndex(model.presentSltSkillID));
|
| | | }
|
| | |
|
| | | private void UpdateEquipPassSkill()
|
| | | {
|
| | | for (int i = 0; i < equipPassSkills.Count; i++)
|
| | | {
|
| | | PassSkillLimit limit;
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleUnLimitColor;
|
| | | if (model.TryGetPassSkillLimit(i, out limit))
|
| | | {
|
| | | if (limit.level > 0)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.LV < limit.level)
|
| | | {
|
| | | SetEquipSkillDeActive(i);
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleLimitColor;
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = Language.Get("PassSkillHoleLimitLv", limit.level);
|
| | | continue;
|
| | | }
|
| | | }
|
| | | else if (limit.vipLv > 0)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.VIPLv < limit.vipLv)
|
| | | {
|
| | | SetEquipSkillDeActive(i);
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleLimitColor;
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = Language.Get("PassSkillHoleLimitVip", limit.vipLv);
|
| | | continue;
|
| | | }
|
| | | }
|
| | | else if (limit.MountLv > 0)
|
| | | {
|
| | | if (promoteModel.GetMountTotallv() < limit.MountLv)
|
| | | {
|
| | | SetEquipSkillDeActive(i);
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.color = equipHoleLimitColor;
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = Language.Get("PassSkillHoleLimitMount", limit.MountLv);
|
| | | continue;
|
| | | }
|
| | | }
|
| | | }
|
| | | int _skillId = 0;
|
| | | equipPassSkills[i].skillData.m_SkillNameTxt.text = string.Empty;
|
| | | equipPassSkills[i].skillData.m_LockImg.gameObject.SetActive(false);
|
| | | model.TryGetEquipPassSkills(model.presentSltPage, i, out _skillId);
|
| | | equipPassSkills[i].skillData.SetSkillData(_skillId);
|
| | | }
|
| | | }
|
| | |
|
| | | private void CheckReplaceEquipSkill()
|
| | | {
|
| | | for (int i = 0; i < equipPassSkills.Count; i++)
|
| | | {
|
| | | var rect = equipPassSkills[i].transform as RectTransform;
|
| | | var des = RectTransformUtility.CalculateRelativeRectTransformBounds(this.transform, rect);
|
| | | var src = RectTransformUtility.CalculateRelativeRectTransformBounds(this.transform, m_DragImg.rectTransform);
|
| | | var dis = Vector3.Distance(des.center, src.center);
|
| | | if (dis < rect.rect.width / 2)
|
| | | {
|
| | | if (CheckOpenGetWays(i))
|
| | | {
|
| | | //SoundPlayer.Instance.PlayUIAudio(2);
|
| | | return;
|
| | | }
|
| | | model.SendEquipPassSkills(model.skillDragId, i);
|
| | | if (model.passSkillHoleRedpoints[i].state == RedPointState.Simple)
|
| | | {
|
| | | model.SetDayRemind();
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void SetEquipSkillDeActive(int _hole)
|
| | | {
|
| | | equipPassSkills[_hole].skillData.m_LockImg.gameObject.SetActive(true);
|
| | | equipPassSkills[_hole].skillData.SetSkillData(0);
|
| | | }
|
| | |
|
| | | private void OnClickPage(int index)
|
| | | {
|
| | | if (index != model.presentSltPage)
|
| | | {
|
| | | model.SetDayRemind();
|
| | | }
|
| | | model.presentSltPage = index;
|
| | | UpdateEquipPassSkill();
|
| | | UpdatePassEquipPageBtn();
|
| | | var _equipIndex = GetEquipHoleIndex(model.presentSltSkillID);
|
| | | SetEquipHoleSelect(_equipIndex);
|
| | | m_GetWayBtn.gameObject.SetActive(CheckOpenGetWays(_equipIndex));
|
| | | }
|
| | |
|
| | | private void UpdatePassEquipPageBtn()
|
| | | {
|
| | | for (int i = 0; i < m_PageBtns.Count; i++)
|
| | | {
|
| | | m_PageBtns[i].image.SetSprite(model.presentSltPage == i ? "SkillRightbtn_A" : "Skillbtnbtn_A");
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnClickEquipHole(int index)
|
| | | {
|
| | | PassSkillLimit limit;
|
| | | m_GetWayBtn.gameObject.SetActive(false);
|
| | | SetEquipHoleSelect(index);
|
| | | if (model.TryGetPassSkillLimit(index, out limit))
|
| | | {
|
| | | if (limit.level > 0)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.LV < limit.level)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("PassEquipLimitLevel", limit.level);
|
| | | m_GetWayBtn.gameObject.SetActive(true);
|
| | | }
|
| | | }
|
| | | else if (limit.vipLv > 0)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.VIPLv < limit.vipLv)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("PassEquipLimitVip", limit.vipLv);
|
| | | m_GetWayBtn.gameObject.SetActive(true);
|
| | | return;
|
| | | }
|
| | | }
|
| | | else if (limit.MountLv > 0)
|
| | | {
|
| | | if (promoteModel.GetMountTotallv() < limit.MountLv)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("PassEquipLimitMountLevel", limit.MountLv);
|
| | | m_GetWayBtn.gameObject.SetActive(true);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | Text _text = cell.GetComponentInChildren<Text>();
|
| | | _text.text = model.passEquipGetWayTxts[cell.index];
|
| | | }
|
| | |
|
| | | private void OnGetWayBtn()
|
| | | {
|
| | | scrollerController.Refresh();
|
| | | if (model.passEquipGetWays.ContainsKey(presentSltEquipIndex))
|
| | | {
|
| | | int[] intarray = model.passEquipGetWays[presentSltEquipIndex];
|
| | | foreach (var key in intarray)
|
| | | {
|
| | | scrollerController.AddCell(ScrollerDataType.Header, key, OnClickFunc);
|
| | | }
|
| | | }
|
| | | scrollerController.Restart();
|
| | | m_ContainerGetWay.gameObject.SetActive(true);
|
| | | }
|
| | |
|
| | | private void OnClickFunc(CellView cell)
|
| | | {
|
| | | WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)cell.index);
|
| | | }
|
| | |
|
| | | private void SetEquipHoleSelect(int _index)
|
| | | {
|
| | | if (presentSltEquipIndex != -1)
|
| | | {
|
| | | equipPassSkills[presentSltEquipIndex].skillData.m_SelectImg.gameObject.SetActive(false);
|
| | | }
|
| | | presentSltEquipIndex = _index;
|
| | | if (_index == -1)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (equipPassSkills[_index].skillData.skillId != 0)
|
| | | {
|
| | | equipPassSkills[_index].skillData.m_SelectImg.gameObject.SetActive(true);
|
| | | model.presentSltSkillID = equipPassSkills[_index].skillData.skillId;
|
| | | flipScroll.RefreshActive();
|
| | | OnUpdateSltSkillInfo();
|
| | | }
|
| | | else
|
| | | {
|
| | | equipPassSkills[_index].skillData.m_SelectImg.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | | private int GetEquipHoleIndex(int _skillId)
|
| | | {
|
| | | for (int i = 0; i < equipPassSkills.Count; i++)
|
| | | {
|
| | | if (equipPassSkills[i].skillData.skillId == _skillId)
|
| | | {
|
| | | return i;
|
| | | }
|
| | | }
|
| | | return -1;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|