|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class GuildEmblemModel : GameSystemManager<GuildEmblemModel> | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public readonly int MaxItemRowCount = 6;    // 一行展示x个徽章 | 
|---|
|  |  |  | public readonly int FamilyActionsType = 15;     // 徽章类型15 | 
|---|
|  |  |  | public readonly int FuncId = 237; | 
|---|
|  |  |  | public int defaultFamilyEmblemId;           // 默认徽章ID | 
|---|
|  |  |  | public readonly int FamilyActionsType = 15;     // 公会记录徽章类型15 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool isSendA408Pack = false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private int m_NowChooseEmblemId; | 
|---|
|  |  |  | public event Action ChooseEmblemIdChangeEvent;      //切换徽章 | 
|---|
|  |  |  | public int nowChooseEmblemId | 
|---|
|  |  |  | { | 
|---|
|  |  |  | get { return m_NowChooseEmblemId; } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public event Action ChooseEmblemIdChangeEvent;      //切换标签页 | 
|---|
|  |  |  | //创建公会时,选择的徽章 | 
|---|
|  |  |  | int m_CreateSelectEmblemId; | 
|---|
|  |  |  | public event Action CreateSelectEmblemIdChangeEvent; | 
|---|
|  |  |  | public int createSelectEmblemId | 
|---|
|  |  |  | { | 
|---|
|  |  |  | get { return m_CreateSelectEmblemId; } | 
|---|
|  |  |  | set | 
|---|
|  |  |  | { | 
|---|
|  |  |  | m_CreateSelectEmblemId = value; | 
|---|
|  |  |  | CreateSelectEmblemIdChangeEvent?.Invoke(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public string createEmblemWord = ""; //创建公会时,输入的旗号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Redpoint entranceRedPoint = new Redpoint(10702, MainRedDot.FairyEmbleManageRepoint); //仙盟管理面板入口红点 | 
|---|
|  |  |  | // 旧的显示列表,用于判断是否有变化, 对比红点显示 | 
|---|
|  |  |  | public List<int> oldShowActiveList = new List<int>();   // 旧的激活列表,点击新的徽章时会更新,或者关闭的时候更新 | 
|---|
|  |  |  | public List<int> showList = new List<int>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override void Init() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PlayerDatas.Instance.fairyData.OnRefreshFairyInfo += OnRefreshFairyInfo; | 
|---|
|  |  |  | defaultFamilyEmblemId = int.Parse(FuncConfigConfig.Get("FairyEmblem").Numerical1); | 
|---|
|  |  |  | GuildManager.Instance.FamilyActionInfoEvent += OnFamilyActionInfoEvent; | 
|---|
|  |  |  | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override void Release() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PlayerDatas.Instance.fairyData.OnRefreshFairyInfo -= OnRefreshFairyInfo; | 
|---|
|  |  |  | GuildManager.Instance.FamilyActionInfoEvent -= OnFamilyActionInfoEvent; | 
|---|
|  |  |  | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void OnBeforePlayerDataInitialize() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | m_NowChooseEmblemId = 0; | 
|---|
|  |  |  | m_CreateSelectEmblemId = 0; | 
|---|
|  |  |  | createEmblemWord = ""; | 
|---|
|  |  |  | oldShowActiveList.Clear(); | 
|---|
|  |  |  | showList.Clear(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void OnRefreshFairyInfo() | 
|---|
|  |  |  | 
|---|
|  |  |  | // 仅盟主能看到 | 
|---|
|  |  |  | if (!IsCaptain()) | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | // 仙盟2级出现 | 
|---|
|  |  |  | if (PlayerDatas.Instance.fairyData == null || PlayerDatas.Instance.fairyData.fairy.FamilyLV != 2) | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | // 只出现一次 | 
|---|
|  |  |  | if (GetRedPointShow()) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!GetRedPointShow()) | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | entranceRedPoint.state = RedPointState.Simple; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string localStr = "FairyEmblemEntranceRedPoint_"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 新旧列表对比显示红点 | 
|---|
|  |  |  | public bool GetRedPointShow() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return LocalSave.GetBool(localStr + PlayerDatas.Instance.PlayerId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (oldShowActiveList.IsNullOrEmpty()) | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void SetRedPointShow() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | LocalSave.SetBool(localStr + PlayerDatas.Instance.PlayerId, true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool TryGetNowEmblemID(out int nowID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | nowID = 0; | 
|---|
|  |  |  | int emblemID = (int)PlayerDatas.Instance.fairyData.fairy.EmblemID; | 
|---|
|  |  |  | if (FamilyEmblemConfig.HasKey(emblemID) && IsUnLock(emblemID)) | 
|---|
|  |  |  | for (int i = 0; i < showList.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | nowID = (int)emblemID; | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (FamilyEmblemConfig.HasKey(defaultFamilyEmblemId)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | nowID = defaultFamilyEmblemId; | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | nowID = 0; | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 展示指定徽章 表中找不到徽章就显示默认的 | 
|---|
|  |  |  | public void ShowEmblem(int emblemID, ImageEx imgTitle, float scale = 1.0f) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | int nowEmblemID = emblemID; | 
|---|
|  |  |  | if (!FamilyEmblemConfig.HasKey(nowEmblemID)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | nowEmblemID = defaultFamilyEmblemId; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | FamilyEmblemConfig config = FamilyEmblemConfig.Get(nowEmblemID); | 
|---|
|  |  |  | UIFrame frame = imgTitle.GetComponent<UIFrame>(); | 
|---|
|  |  |  | if (UIFrameMgr.Inst.ContainsDynamicImage(config.Image)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (frame == null) | 
|---|
|  |  |  | frame = imgTitle.gameObject.AddComponent<UIFrame>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<UnityEngine.Sprite> spriteList = UIFrameMgr.Inst.GetDynamicImage(config.Image); | 
|---|
|  |  |  | if (!spriteList.IsNullOrEmpty()) | 
|---|
|  |  |  | //已解锁的 | 
|---|
|  |  |  | if (!oldShowActiveList.Contains(showList[i]) && IsUnLock(showList[i])) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | imgTitle.rectTransform.sizeDelta = new Vector2(spriteList[0].rect.width, spriteList[0].rect.height); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | imgTitle.raycastTarget = false; | 
|---|
|  |  |  | frame.ResetFrame(config.Image); | 
|---|
|  |  |  | frame.enabled = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (frame != null) | 
|---|
|  |  |  | frame.enabled = false; | 
|---|
|  |  |  | imgTitle.SetSprite(config.Image); | 
|---|
|  |  |  | imgTitle.SetNativeSize(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | imgTitle.rectTransform.localScale = new Vector3(scale, scale, scale); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<int> GetShowList() | 
|---|
|  |  |  | public List<int> SortShowList() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<int> showList = new List<int>(); | 
|---|
|  |  |  | List<int> keys = FamilyEmblemConfig.GetKeys(); | 
|---|
|  |  |  | for (int i = 0; i < keys.Count; i++) | 
|---|
|  |  |  | if (showList.IsNullOrEmpty()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | showList.Add(keys[i]); | 
|---|
|  |  |  | List<int> keys = FamilyEmblemConfig.GetKeys(); | 
|---|
|  |  |  | for (int i = 0; i < keys.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | showList.Add(keys[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | showList.Sort(Cmp); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (oldShowActiveList.IsNullOrEmpty()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // 初始化时,刷新旧的激活列表 | 
|---|
|  |  |  | RefreshOldShowActiveList(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return showList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 刷新旧的激活列表,用于对比红点显示 | 
|---|
|  |  |  | public void RefreshOldShowActiveList() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | for (int i = 0; i < showList.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //已解锁的 | 
|---|
|  |  |  | if (IsUnLock(showList[i])) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!oldShowActiveList.Contains(showList[i])) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oldShowActiveList.Add(showList[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 已激活>未激活 | 
|---|
|  |  |  | private int Cmp(int a, int b) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return a.CompareTo(b); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int GetSortNum(int emblemID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!FamilyEmblemConfig.HasKey(emblemID)) | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | return FamilyEmblemConfig.Get(emblemID).SortNum; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return config.UnlockFamilyLV > 0 ? FairyEmblemUnlockMethodType.LV : FairyEmblemUnlockMethodType.Active; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 指定的徽章解锁了吗 | 
|---|
|  |  |  | // 徽章是否解锁,未加入公会的也可以调用判断 | 
|---|
|  |  |  | public bool IsUnLock(int emblemId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | FamilyEmblemConfig config = FamilyEmblemConfig.Get(emblemId); | 
|---|
|  |  |  | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | case FairyEmblemUnlockMethodType.LV: | 
|---|
|  |  |  | int lv = 1; //没有公会的情况 | 
|---|
|  |  |  | if (PlayerDatas.Instance.fairyData.fairy != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | lv = PlayerDatas.Instance.fairyData.fairy.FamilyLV; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //所在仙盟等级小于徽章要求等级 未解锁 | 
|---|
|  |  |  | if (PlayerDatas.Instance.fairyData.fairy.FamilyLV < config.UnlockFamilyLV) | 
|---|
|  |  |  | if (lv < config.UnlockFamilyLV) | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool IsUsing(int emblemId) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void OnFamilyActionInfoEvent(int familyId, int actionType) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!TryGetNowEmblemID(out int Id)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return emblemId == Id; | 
|---|
|  |  |  | UpdateRedPoint(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool IsLimitTime(int emblemId, out HA513_tagMCFamilyActionInfo.tagMCFamilyAction familyAction) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public bool IsCaptain() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return (int)PlayerDatas.Instance.fairyData.mine.FmLV == 3; | 
|---|
|  |  |  | return PlayerDatas.Instance.fairyData.mine.FmLV == 3; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 尝试从封包中得到指定的徽章时效信息(活动途径获取的徽章,定制徽章) | 
|---|
|  |  |  | // 获得徽章记录信息信息(活动途径获取的徽章,定制徽章),value1是徽章ID,value2是徽章到期时间 | 
|---|
|  |  |  | private bool TryGetfamilyAction(int emblemId, out HA513_tagMCFamilyActionInfo.tagMCFamilyAction familyAction) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | familyAction = new HA513_tagMCFamilyActionInfo.tagMCFamilyAction(); | 
|---|
|  |  |  | 
|---|
|  |  |  | public bool TryGetEffectID(int emblemId, out int effectID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | effectID = 0; | 
|---|
|  |  |  | if (!FamilyEmblemConfig.HasKey(emblemId)) | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | FamilyEmblemConfig config = FamilyEmblemConfig.Get(emblemId); | 
|---|
|  |  |  | if (!EffectConfig.HasKey(config.EffectID)) | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class EmblemModel | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public int emblemID { get; private set; } | 
|---|
|  |  |  | public int emblemUIEffectID { get; private set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public EmblemModel(int emblemID, int emblemUIEffectID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | this.emblemID = emblemID; | 
|---|
|  |  |  | this.emblemUIEffectID = emblemUIEffectID; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|