yyl
2025-12-01 ea185afc20a915d15eae8adb07d0acd837f3c210
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);
    }
}