| | |
| | |
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using UnityEngine;
|
| | |
|
| | | public class OfficialRankManager : GameSystemManager<OfficialRankManager>
|
| | | {
|
| | | bool redpointDirty = false;
|
| | |
|
| | | #region 官职任务
|
| | | //当前官职的任务状态
|
| | | int taskAwardState;
|
| | | Dictionary<int, int> taskValues = new Dictionary<int, int>();
|
| | | public Dictionary<int, int[]> realMissionGuides = new Dictionary<int, int[]>();
|
| | | public event Action RealmMissionRefreshEvent;
|
| | |
|
| | | public Dictionary<int, int> mainLevelDict = new Dictionary<int, int>(); //id:索引 用于判断还需多少关
|
| | | public override void Init()
|
| | | {
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
|
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent += UpdateRedpoint;
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitialize;
|
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += UpdateRedpoint;
|
| | |
|
| | |
|
| | | var levelList = MainLevelConfig.GetKeys().ToList();
|
| | | levelList.Sort();
|
| | | for (int i = 0; i < levelList.Count; i++)
|
| | | { |
| | | mainLevelDict[levelList[i]] = i;
|
| | | }
|
| | | }
|
| | |
|
| | | public override void Release()
|
| | | {
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh;
|
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent -= UpdateRedpoint;
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerDataInitialize;
|
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= UpdateRedpoint;
|
| | | }
|
| | |
|
| | | void BeforePlayerDataInitialize()
|
| | | {
|
| | | taskValues.Clear();
|
| | | taskAwardState = 0;
|
| | | }
|
| | |
|
| | |
|
| | | void PlayerDataRefresh(PlayerDataType type)
|
| | | {
|
| | | if (type == PlayerDataType.LV ||
|
| | | type == PlayerDataType.ExAttr1
|
| | | )
|
| | | {
|
| | | //等级 通关
|
| | | UpdateRedpoint();
|
| | | }
|
| | | else if (type == PlayerDataType.RealmLevel)
|
| | | {
|
| | | if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin)
|
| | | return;
|
| | | //升级成功表现
|
| | | if (!UIManager.Instance.IsOpened<OfficialLVUPSuccessWin>())
|
| | | {
|
| | | UIManager.Instance.OpenWindow<OfficialLVUPSuccessWin>();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 返回服务端的记录任务奖励状态 0未领取 1已领取
|
| | | public int GetMissionAwardState(int id)
|
| | |
| | | return (taskAwardState & (int)Math.Pow(2, id)) != 0 ? 1 : 0;
|
| | | }
|
| | |
|
| | | //任务类型 任务说明 所需值
|
| | | // 1 等级达到x级 x级
|
| | | // 2 通关x地图x层 地图ID|层 |
| | | // 3 消耗战锤 x个
|
| | |
|
| | | // 2 通过主线关卡 关卡ID |
| | | // 3 消耗战锤 x个 (仅通知这个)
|
| | | // 4 祝福树 等级 |
| | | //客户端显示的任务状态 0 代表进行中 1 代表可领取 2 代表已领取
|
| | | public int GetMissionState(int realm, int missionID)
|
| | | {
|
| | | var id = RealmLVUPTaskConfig.GetID(realm, missionID);
|
| | | var config = RealmLVUPTaskConfig.Get(id);
|
| | | var config = RealmLVUPTaskConfig.GetID(realm, missionID);
|
| | | var type = config.TaskType;
|
| | |
|
| | | if (GetMissionAwardState(missionID) == 1)
|
| | |
| | | case 1:
|
| | | return PlayerDatas.Instance.baseData.LV >= config.NeedValueList[0] ? 1 : 0;
|
| | | case 2:
|
| | | if (config.NeedValueList[0] == 0)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | return 0;
|
| | | //策划配置关卡ID为201,即 过关2-1(0/1) ,使用 ExAttr1 值判断,如ExAttr1值为20103代表当前已经过了第2章第1关第3波,包含了波,需要击败该关卡boss后才算该关过关
|
| | | return PlayerDatas.Instance.baseData.ExAttr1 / 100 > config.NeedValueList[0] ? 1 : 0;
|
| | | case 3:
|
| | | return taskValues.ContainsKey(missionID) && taskValues[missionID] >= config.NeedValueList[0] ? 1 : 0;
|
| | | |
| | | |
| | | case 4:
|
| | | return BlessLVManager.Instance.m_TreeLV >= config.NeedValueList[0] ? 1 : 0;
|
| | |
|
| | | default:
|
| | | return 0;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public int GetMissionProcess(int id)
|
| | | public void GetMissionProcess(int id, out int process, out int total)
|
| | | {
|
| | | if (taskValues.ContainsKey(id))
|
| | | var config = RealmLVUPTaskConfig.GetID(PlayerDatas.Instance.baseData.realmLevel, id);
|
| | | var type = config.TaskType;
|
| | | process = 1;
|
| | | total = 1;
|
| | | switch (type)
|
| | | {
|
| | | return taskValues[id];
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | //type: 1等级 2通关 3消耗战锤
|
| | |
|
| | | public void RealMissionGuide(int type, int id = 0)
|
| | | {
|
| | | if (realMissionGuides.ContainsKey(type))
|
| | | {
|
| | | |
| | | int guideIndex = 0;
|
| | | if (type == 1)
|
| | | {
|
| | | |
| | | }
|
| | | else if (type == 2)
|
| | | {
|
| | | if (!FuncOpen.Instance.IsFuncOpen(164, true))
|
| | | {
|
| | | return;
|
| | | }
|
| | | }
|
| | | else if (type == 3)
|
| | | {
|
| | | if (FuncOpen.Instance.IsFuncOpen(108))
|
| | | {
|
| | | guideIndex = 1;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | //NewBieCenter.Instance.StartNewBieGuideEx(guideID);
|
| | | case 1:
|
| | | process = PlayerDatas.Instance.baseData.LV;
|
| | | total = config.NeedValueList[0];
|
| | | break;
|
| | | case 2:
|
| | | process = PlayerDatas.Instance.baseData.ExAttr1 / 100 > config.NeedValueList[0] ? 1 : 0;
|
| | | total = 1;
|
| | | break;
|
| | | case 3:
|
| | | process = taskValues.ContainsKey(id) ? taskValues[id] : 0;
|
| | | total = config.NeedValueList[0];
|
| | | break;
|
| | | case 4:
|
| | | process = BlessLVManager.Instance.m_TreeLV;
|
| | | total = config.NeedValueList[0];
|
| | | break;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | public void RequestAllAwards()
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | RealmMissionRefreshEvent?.Invoke();
|
| | | redpointDirty = true;
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | Redpoint redpoint = new Redpoint(MainRedDot.RedPoint_OfficialKey);
|
| | | void UpdateRedpoint()
|
| | | {
|
| | | redpoint.state = RedPointState.None;
|
| | |
|
| | | var ids = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel);
|
| | | bool finish = true;
|
| | | foreach (var id in ids)
|
| | | {
|
| | | if (GetMissionAwardState(id) != 1)
|
| | | {
|
| | | if (GetMissionState(PlayerDatas.Instance.baseData.realmLevel, id) == 1)
|
| | | {
|
| | | redpoint.state = RedPointState.Simple;
|
| | | }
|
| | |
|
| | | finish = false;
|
| | | }
|
| | | }
|
| | | |
| | | if (finish)
|
| | | redpoint.state = RedPointState.Simple;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | public Color GetOfficialRankColor(int quality)
|
| | | {
|
| | |
|
| | | switch (quality)
|
| | | {
|
| | | case 1:
|
| | | // bbbbbb
|
| | | return new Color32(187, 187, 187, 255);
|
| | | case 2:
|
| | | // ffffff
|
| | | return new Color32(255, 255, 255, 255);
|
| | | case 3:
|
| | | // bbd5ff
|
| | | return new Color32(187, 213, 255, 255);
|
| | | case 4:
|
| | | // e4bbfe
|
| | | return new Color32(228, 187, 254, 255);
|
| | | case 5:
|
| | | // f7eba4
|
| | | return new Color32(247, 235, 164, 255);
|
| | | case 6:
|
| | | // ffc096
|
| | | return new Color32(255, 192, 150, 255);
|
| | | case 7:
|
| | | // fe9896
|
| | | return new Color32(254, 152, 150, 255);
|
| | | case 8:
|
| | | // ffaffe
|
| | | return new Color32(255, 174, 254, 255);
|
| | | case 9:
|
| | | // ffefcl
|
| | | return new Color32(255, 239, 203, 255);
|
| | | case 10:
|
| | | // e9fffa
|
| | | return new Color32(233, 255, 250, 255);
|
| | | case 11:
|
| | | // f5ddff
|
| | | return new Color32(245, 221, 255, 255);
|
| | | case 12:
|
| | | // b3fcfe
|
| | | return new Color32(179, 252, 254, 255);
|
| | | case 13:
|
| | | // ffd0f7
|
| | | return new Color32(255, 208, 247, 255);
|
| | | }
|
| | | return Color.white;
|
| | | }
|
| | |
|
| | | }
|