lcy
2026-01-28 db03acba6290a09418bcc0a05392a662cc39743e
441 公会相关界面 公会日志
3个文件已修改
6个文件已添加
316 ■■■■■ 已修改文件
Main/System/Guild/GuildManager.cs 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildNoteHeaderCell.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildNoteHeaderCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildNoteNormalCell.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildNoteNormalCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildNoteWin.cs 227 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildNoteWin.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildOPWin.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/PlayerFairyData.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildManager.cs
@@ -180,7 +180,7 @@
    public int zbgOrgPriceValue;
    public int zbgChangFamilyCD;
    public List<int> cutCntListForTalk = new List<int>();
    public int familyRecordMaxCount;
    void ParseConfig()
    {
@@ -219,6 +219,9 @@
        zbgOrgPriceValue = int.Parse(config.Numerical2);
        zbgChangFamilyCD = int.Parse(config.Numerical3);
        cutCntListForTalk = JsonMapper.ToObject<List<int>>(config.Numerical4);
        config = FuncConfigConfig.Get("FamilyNote");
        familyRecordMaxCount = int.Parse(config.Numerical1);
    }
@@ -865,7 +868,7 @@
            return false;
        }
        bool restart = false;
        for (int i = 0; i < vNetData.FamilyActionList.Length; i++)
        {
            int playerID = (int)vNetData.FamilyActionList[i].Value1;
Main/System/Guild/GuildNoteHeaderCell.cs
New file
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using UnityEngine;
public class GuildNoteHeaderCell : MonoBehaviour
{
    [SerializeField] TextEx date;
    public void Display(int index, List<GuildNoteData> datas)
    {
        if (datas.IsNullOrEmpty() || index < 0 || index >= datas.Count)
            return;
        date.text = datas[index].Info;
    }
}
Main/System/Guild/GuildNoteHeaderCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c3a277ed730042a4987a4cc292e794a5
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/Guild/GuildNoteNormalCell.cs
New file
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class GuildNoteNormalCell : MonoBehaviour
{
    [SerializeField] TextEx time;
    [SerializeField] TextEx content;
    public void Display(int index, List<GuildNoteData> datas)
    {
        if (datas.IsNullOrEmpty() || index < 0 || index >= datas.Count)
            return;
        DateTime currentTime = TimeUtility.GetTime(datas[index].Time);
        time.text = currentTime.ToString("HH:mm");
        content.text = datas[index].Info;
    }
    public float GetHeight(string info)
    {
        float height = 0f;
        if (string.IsNullOrEmpty(info))
            return height;
        content.text = info;
        height = content.preferredHeight;
        return height;
    }
}
Main/System/Guild/GuildNoteNormalCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e8536aad1963a3244986aedefefbcd5c
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/Guild/GuildNoteWin.cs
New file
@@ -0,0 +1,227 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Cysharp.Threading.Tasks;
using UnityEngine;
/// <summary>
/// 公会日志界面
/// </summary>
public class GuildNoteWin : UIBase
{
    [SerializeField] Color32 nameColor;
    [SerializeField] Transform noNote;
    [SerializeField] Transform hasNote;
    [SerializeField] GuildNoteNormalCell guildNoteNormalCell;
    [SerializeField] ScrollerController scroller;
    [SerializeField] TextEx maxCount;
    protected override void OnPreOpen()
    {
        GuildManager.Instance.EnterOrQuitGuildEvent += OnEnterOrQuitGuildEvent;
        GuildManager.Instance.FamilyActionInfoEvent += OnFamilyActionInfoEvent;
        scroller.OnGetDynamicSize += OnGetChatDynamicSize;
        scroller.OnRefreshCell += OnRefreshCell;
        maxCount.text = Language.Get("Guild_82", GuildManager.Instance.familyRecordMaxCount);
        GuildManager.Instance.QueryFamilyAction(PlayerDatas.Instance.fairyData.fairy.FamilyID, GuildManager.MemberChangeActionType);
    }
    protected override void OnPreClose()
    {
        GuildManager.Instance.EnterOrQuitGuildEvent -= OnEnterOrQuitGuildEvent;
        GuildManager.Instance.FamilyActionInfoEvent -= OnFamilyActionInfoEvent;
        scroller.OnGetDynamicSize -= OnGetChatDynamicSize;
        scroller.OnRefreshCell -= OnRefreshCell;
    }
    private void OnEnterOrQuitGuildEvent(bool isEnter)
    {
        DelayCloseWindow().Forget();
    }
    private bool OnGetChatDynamicSize(ScrollerDataType type, int index, out float height)
    {
        height = 0;
        if (list.IsNullOrEmpty() || index < 0 || index >= list.Count)
            return false;
        var data = list[index];
        switch (type)
        {
            case ScrollerDataType.Header:
                height = 19;
                return true;
            case ScrollerDataType.Normal:
                height = guildNoteNormalCell.GetHeight(data.Info);
                return true;
        }
        return true;
    }
    private void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        if (type == ScrollerDataType.Header)
        {
            var _cell = cell.GetComponent<GuildNoteHeaderCell>();
            _cell?.Display(cell.index, list);
        }
        else
        {
            var _cell = cell.GetComponent<GuildNoteNormalCell>();
            _cell?.Display(cell.index, list);
        }
    }
    private void OnFamilyActionInfoEvent(int familyID, int actionType)
    {
        if (familyID != PlayerDatas.Instance.fairyData.fairy.FamilyID)
            return;
        if (actionType != GuildManager.MemberChangeActionType)
            return;
        Display();
    }
    List<GuildNoteData> list;
    private void Display()
    {
        if (!GuildManager.Instance.TryGetFamilyActions(GuildManager.MemberChangeActionType, out var actions))
        {
            hasNote.SetActive(false);
            noNote.SetActive(true);
            return;
        }
        list = GetShowGuildNoteDataList(actions);
        bool isNullOrEmpty = list.IsNullOrEmpty();
        if (isNullOrEmpty)
        {
            hasNote.SetActive(false);
            noNote.SetActive(true);
            return;
        }
        scroller.Refresh();
        if (!isNullOrEmpty)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ShowType == 0)
                {
                    scroller.AddCell(ScrollerDataType.Header, i);
                }
                else
                {
                    scroller.AddCell(ScrollerDataType.Normal, i);
                }
            }
        }
        scroller.Restart();
        noNote.SetActive(isNullOrEmpty);
        hasNote.SetActive(!isNullOrEmpty);
    }
    private List<GuildNoteData> GetShowGuildNoteDataList(HA513_tagMCFamilyActionInfo.tagMCFamilyAction[] actions)
    {
        List<GuildNoteData> list = GetGuildNoteDataList(actions);
        if (list.IsNullOrEmpty())
            return null;
        var result = new List<GuildNoteData>();
        int lastDay = -1;
        foreach (var noteData in list)
        {
            // 获取当前条目所属日期
            DateTime currentTime = TimeUtility.GetTime(noteData.Time);
            int currentDay = TimeUtility.GetPassDays((int)noteData.Time);
            // 检查是否需要插入日期标题
            if (lastDay == -1 || currentDay != lastDay)
            {
                // 获取目标天的凌晨时间戳
                DateTime dayStartTime = TimeUtility.GetDayStartTime(currentTime.Year, currentTime.Month, currentTime.Day);
                int dayStartSeconds = (int)(dayStartTime - TimeUtility.OriginalTime).TotalSeconds;
                result.Add(new GuildNoteData
                {
                    ShowType = 0, // 标题类型
                    Time = (uint)dayStartSeconds,
                    Info = currentTime.ToString("yyyy-MM-dd"),
                });
            }
            result.Add(noteData);
            lastDay = currentDay;
        }
        return result;
    }
    private List<GuildNoteData> GetGuildNoteDataList(HA513_tagMCFamilyActionInfo.tagMCFamilyAction[] actions)
    {
        if (actions.IsNullOrEmpty())
            return null;
        var result = new List<GuildNoteData>();
        int maxCount = GuildManager.Instance.familyRecordMaxCount;
        // 倒序遍历actions,并限制数量
        int count = 0;
        for (int i = actions.Length - 1; i >= 0 && count < maxCount; i--)
        {
            var action = actions[i];
            string info = GetInfo(action);
            result.Add(new GuildNoteData
            {
                ShowType = 1, // 内容类型
                Time = action.Time,
                Info = info,
            });
            count++;
        }
        return result.OrderBy(a => a.Time).ToList();
    }
    private string GetInfo(HA513_tagMCFamilyActionInfo.tagMCFamilyAction data)
    {
        if (data == null || data.Value1 != 2)
            return string.Empty;
        switch (data.Value2)
        {
            case 0:
                return Language.Get("Guild_52", GetColorStr(data.Name));
            case 1:
                return Language.Get("Guild_53", GetColorStr(data.Name));
            case 2:
                return Language.Get("Guild_55", GetColorStr(data.Name));
            case 4:
                if (data.Value3 > data.Value4)
                {
                    return Language.Get("Guild_54", GetColorStr(data.Name), GetColorStr(RichTextMsgReplaceConfig.GetRichReplace("FAMILY", (int)data.Value3)));
                }
                else
                {
                    return Language.Get("Guild_83", GetColorStr(data.Name), GetColorStr(RichTextMsgReplaceConfig.GetRichReplace("FAMILY", (int)data.Value3)));
                }
            case 3:
            default:
                return string.Empty;
        }
    }
    private string GetColorStr(string name)
    {
        return UIHelper.AppendColor(nameColor, name);
    }
}
public class GuildNoteData
{
    public uint Time;          //时间戳
    public int ShowType;       //显示用途类型 0-标题(年-月-日) 1-内容
    public string Info;        //信息
}
Main/System/Guild/GuildNoteWin.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0e090843a250514f8fabb9b8713e625
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/Guild/GuildOPWin.cs
@@ -43,7 +43,7 @@
        
        noteBtn.AddListener(() =>
        {
            // UIManager.Instance.OpenWindow<GuildNoteWin>();
            UIManager.Instance.OpenWindow<GuildNoteWin>();
        });
        
    }
Main/System/Guild/PlayerFairyData.cs
@@ -29,6 +29,7 @@
    // 0-成员,1-精英,2-副盟主,3-盟主
    public int leaderID;
    public string leaderName;
    // // 精英
    public List<int> elitePlayerIDList = new List<int>();
    // // 副盟主
@@ -102,6 +103,7 @@
            if (member.FmLV == 3)
            {
                leaderID = (int)member.PlayerID;
                leaderName = member.Name;
            }
        }
@@ -142,6 +144,7 @@
        memberDic.Clear();
        memberIDList.Clear();
        leaderID = 0;
        leaderName = string.Empty;
    }
    int SortMember(int id1, int id2)