hch
2025-11-28 e660e02f44933f28dc0d42c541332aae66040ef8
0312 行商小人喊话
4个文件已修改
135 ■■■■■ 已修改文件
Main/System/Guild/GuildBaseWin.cs 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildHawkerWin.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/FuncNPCManager.cs 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Sound/SoundPlayer.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Guild/GuildBaseWin.cs
@@ -1,5 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
@@ -21,6 +23,19 @@
    [SerializeField] Button requestBtn;
    //NPC对话相关
    [Header("行商必须放第一个")]
    [SerializeField] HeroSkinModel[] funcNPCs;
    [SerializeField] Transform[] talkRects;
    [SerializeField] Text[] talkTexts;
    //行商特殊处理
    [SerializeField] Transform hawkerRect;
    [SerializeField] Transform pos1;
    [SerializeField] Transform pos2;
    [SerializeField] UIHeroController hawkerModel;
    protected override void InitComponent()
    {
        guildBtn.AddListener(() =>
@@ -39,6 +54,7 @@
            StoreModel.Instance.selectStoreFuncType = StoreFunc.Guild;
            UIManager.Instance.OpenWindow<StoreBaseWin>();
        });
        InitHawker();
    }
@@ -47,6 +63,7 @@
        if (PlayerDatas.Instance.fairyData.fairy == null)
            return;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        GlobalTimeEvent.Instance.fiveSecondEvent += OnFiveSecondEvent;
        Display();
    }
@@ -54,6 +71,7 @@
    protected override void OnPreClose()
    {
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        GlobalTimeEvent.Instance.fiveSecondEvent -= OnFiveSecondEvent;
    }
@@ -65,7 +83,7 @@
    void OnSecondEvent()
    {
        ShowHawkerTime();
        ShowHawkerTime(true);
    }
    void ShowGuildInfo()
@@ -86,7 +104,7 @@
        UIManager.Instance.OpenWindow<GuildHawkerWin>();
    }
    void ShowHawkerTime()
    void ShowHawkerTime(bool modelPlay = false)
    {
        var toTenSeconds = TimeUtility.GetToTheHourSeconds();
        if (toTenSeconds > 0)
@@ -95,12 +113,80 @@
            guildHawkerInfo.SetActive(true);
            var addStr = new string('.', (int)Time.time % 4);
            guildHawkerInfo.text = Language.Get("Guild_72") + addStr;
            if (modelPlay)
                HawkerMove(false);
        }
        else
        {
            guildHawkerTimeText.text = TimeUtility.SecondsToHMS((int)(TimeUtility.GetTodayEndTime() - TimeUtility.ServerNow).TotalSeconds);
            guildHawkerInfo.SetActive(false);
            if (modelPlay)
                HawkerMove(true);
        }
    }
    void InitHawker()
    {
        if (FuncNPCManager.Instance.isHawkerStandBy)
        {
            hawkerRect.localPosition = pos1.localPosition;
        }
        else
        {
            hawkerRect.localPosition = pos2.localPosition;
        }
        hawkerModel.PlayAnimation("idle", true);
    }
    //isShow true走出来,false走出去
    void HawkerMove(bool isShow)
    {
        if (isShow == FuncNPCManager.Instance.isHawkerShowNow)
        {
            return;
        }
        FuncNPCManager.Instance.isHawkerShowNow = isShow;
        hawkerModel.PlayAnimation("zoulu", true);
        FuncNPCManager.Instance.isHawkerStandBy = false;
        hawkerModel.transform.localScale = new Vector3(isShow ? hawkerModel.transform.localScale.x : -hawkerModel.transform.localScale.x, hawkerModel.transform.localScale.y, hawkerModel.transform.localScale.z);
        hawkerRect.DOLocalMove(isShow ? pos1.localPosition : pos2.localPosition, 1f).onComplete = () =>
        {
            hawkerModel.PlayAnimation("idle", true);
            FuncNPCManager.Instance.isHawkerStandBy = isShow;
        };
    }
    //NPC对话相关
    void OnFiveSecondEvent()
    {
        var index = FuncNPCManager.Instance.GetRandomGuildNpcTalk();
        if (index == -1)
        {
            return;
        }
        var talk = FuncNPCManager.Instance.GetGuildTalk(funcNPCs[index].heroSkinID);
        if (talk != null)
        {
            talkTexts[index].text = Language.Get(talk);
            talkRects[index].SetActive(true);
        }
        var npc = funcNPCs[index].GetModel();
        npc.PlayAnimation("hanhua", true);
        Talk(index).Forget();
    }
    async UniTask Talk(int index)
    {
        await UniTask.Delay(5000);
        talkRects[index].SetActive(false);
        var npc = funcNPCs[index].GetModel();
        npc.PlayAnimation("idle", true);
    }
}
Main/System/Guild/GuildHawkerWin.cs
@@ -17,7 +17,7 @@
    [SerializeField] Button cutBtn;
    [SerializeField] Text cutText;
    [SerializeField] Text timeText;
    [SerializeField] UIHeroController heroController;
@@ -38,6 +38,7 @@
        scroller.OnRefreshCell += OnRefreshCell;
        GuildManager.Instance.UpdateZhenbaogeEvent += OnPlayerZBGEvent;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        GlobalTimeEvent.Instance.fiveSecondEvent += OnFiveSecondEvent;
        
        Display();
        CreateScroller();
@@ -55,6 +56,7 @@
        scroller.OnRefreshCell -= OnRefreshCell;
        GuildManager.Instance.UpdateZhenbaogeEvent -= OnPlayerZBGEvent;
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        GlobalTimeEvent.Instance.fiveSecondEvent -= OnFiveSecondEvent;
    }
    void OnSecondEvent()
@@ -62,6 +64,12 @@
        timeText.text = Language.Get("Guild_74", TimeUtility.SecondsToShortDHMS((int)(TimeUtility.GetTodayEndTime() - TimeUtility.ServerNow).TotalSeconds));
    }
    int index = 0;
    void OnFiveSecondEvent()
    {
        index++;
        heroController.PlayAnimation(index % 2 == 0 ? "idle" : "hanhua", true);
    }
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as GuildHawkerCutCell;
Main/System/InternalAffairs/FuncNPCManager.cs
@@ -17,6 +17,10 @@
    public float lastGuildTalkTime;
    public int lastGuildRandomIndex;
    //行商特殊处理
    public bool isHawkerShowNow = false; //行商状态,true 行商走出来和站岗中,false 行商走出去和外出中
    public bool isHawkerStandBy = false; //行商状态,true 行商站岗中,只有true才能参与喊话;移动或者消失都为false
    public override void Init()
    {
@@ -69,9 +73,28 @@
    public int GetRandomGuildNpcTalk()
    {
        int index = Random.Range(0, guildTalkIndexList.Count);
        //行商特殊处理,行商非站岗中不参与喊话
        int index;
        if (isHawkerStandBy)
        {
            index = Random.Range(0, guildTalkIndexList.Count);
        }
        else
        {
            if (guildTalkIndexList.Count == 1)
            {
                return -1;
            }
            index = Random.Range(1, guildTalkIndexList.Count);
        }
        if (index == lastGuildRandomIndex)
        {
            if (guildTalkIndexList.Count == 1)
            {
                //只有一个的情况
                lastGuildRandomIndex = -1;
                return -1;
            }
            index = (index + 1) % guildTalkIndexList.Count;
        }
        lastGuildRandomIndex = index;
@@ -87,5 +110,14 @@
        }
        return null;
    }
    public string GetGuildTalk(int skinID)
    {
        if (guildNpcTalkDic.ContainsKey(skinID))
        {
            return guildNpcTalkDic[skinID][Random.Range(0, guildNpcTalkDic[skinID].Length)];
        }
        return null;
    }
}
Main/System/Sound/SoundPlayer.cs
@@ -89,6 +89,7 @@
        m_Instance.name = "SoundPlayer";
        m_Instance.SetActive(true);
        DontDestroyOnLoad(gameObject);
        Debug.Log("CreateSoundPlayer");
    }
    public void PlayBackGroundMusic(int _audioId)