From e660e02f44933f28dc0d42c541332aae66040ef8 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 28 十一月 2025 22:15:04 +0800
Subject: [PATCH] 0312 行商小人喊话
---
Main/System/InternalAffairs/FuncNPCManager.cs | 34 +++++++++++
Main/System/Sound/SoundPlayer.cs | 1
Main/System/Guild/GuildHawkerWin.cs | 10 +++
Main/System/Guild/GuildBaseWin.cs | 90 +++++++++++++++++++++++++++++
4 files changed, 131 insertions(+), 4 deletions(-)
diff --git a/Main/System/Guild/GuildBaseWin.cs b/Main/System/Guild/GuildBaseWin.cs
index f75ce64..8584a57 100644
--- a/Main/System/Guild/GuildBaseWin.cs
+++ b/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);
}
}
\ No newline at end of file
diff --git a/Main/System/Guild/GuildHawkerWin.cs b/Main/System/Guild/GuildHawkerWin.cs
index 0beb2df..89230f1 100644
--- a/Main/System/Guild/GuildHawkerWin.cs
+++ b/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;
diff --git a/Main/System/InternalAffairs/FuncNPCManager.cs b/Main/System/InternalAffairs/FuncNPCManager.cs
index dd8f9c9..6d482f2 100644
--- a/Main/System/InternalAffairs/FuncNPCManager.cs
+++ b/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鎵嶈兘鍙備笌鍠婅瘽锛涚Щ鍔ㄦ垨鑰呮秷澶遍兘涓篺alse
+
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;
+ }
}
diff --git a/Main/System/Sound/SoundPlayer.cs b/Main/System/Sound/SoundPlayer.cs
index 61ebe21..e91c270 100644
--- a/Main/System/Sound/SoundPlayer.cs
+++ b/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)
--
Gitblit v1.8.0