2025-04-18 19:18:15 +08:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using TEngine;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using GameConfig.giftConfig;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Cysharp.Threading.Tasks;
|
2025-04-24 16:50:21 +08:00
|
|
|
using TMPro;
|
2025-05-07 15:16:19 +08:00
|
|
|
using Coffee.UIExtensions;
|
2025-05-17 15:34:51 +08:00
|
|
|
using UnityEngine.Video;
|
2025-06-03 22:26:10 +08:00
|
|
|
using System.Xml.Linq;
|
2025-04-18 19:18:15 +08:00
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
{
|
2025-04-24 16:50:21 +08:00
|
|
|
[Window(UILayer.UI)]
|
|
|
|
class UIGameBattle : UIWindow
|
|
|
|
{
|
|
|
|
#region 脚本工具生成的代码
|
2025-06-04 20:39:11 +08:00
|
|
|
private RectTransform m_rectTopFx;
|
2025-05-19 17:28:34 +08:00
|
|
|
private RectTransform m_rectSdx;
|
|
|
|
private RectTransform m_rectSceneFx;
|
|
|
|
private RectTransform m_rectSpeed;
|
2025-05-09 16:29:30 +08:00
|
|
|
private RectTransform m_rectBgList;
|
2025-05-09 16:53:47 +08:00
|
|
|
private Image m_img_BT;
|
2025-04-24 16:50:21 +08:00
|
|
|
private TextMeshProUGUI m_tmpTimer;
|
|
|
|
private TextMeshProUGUI m_tmpWinPoint;
|
|
|
|
private TextMeshProUGUI m_tmpScoreAll;
|
|
|
|
private Button m_btnSetting;
|
|
|
|
private Button m_btnRank;
|
|
|
|
private RectTransform m_rectHPanel;
|
2025-04-24 17:46:30 +08:00
|
|
|
private GameObject m_itemActorHItem;
|
2025-05-08 23:23:31 +08:00
|
|
|
private RectTransform m_rect_GiftPanel;
|
2025-05-09 16:29:30 +08:00
|
|
|
private RawImage m_rimgHeadIcon;
|
|
|
|
private TextMeshProUGUI m_tmpPlayName;
|
|
|
|
private TextMeshProUGUI m_tmpTeamName;
|
|
|
|
private TextMeshProUGUI m_tmpGiftMsg;
|
|
|
|
private Image m_imgGiftImg;
|
|
|
|
private TextMeshProUGUI m_tmpCount;
|
2025-05-17 15:34:51 +08:00
|
|
|
private RawImage m_rimg_ViewTexture;
|
|
|
|
private VideoPlayer m_video_Video;
|
2025-06-04 06:20:22 +08:00
|
|
|
private RectTransform m_rect_Dz;
|
2025-06-04 20:39:11 +08:00
|
|
|
private TextMeshProUGUI m_tmp_PlayerName;
|
2025-06-04 05:06:28 +08:00
|
|
|
private RectTransform m_rectGjsk;
|
2025-06-03 22:26:10 +08:00
|
|
|
private Image m_img_HuangJinShiDai;
|
2025-06-04 21:03:24 +08:00
|
|
|
private VideoPlayer m_video_SjVideo;
|
|
|
|
private RawImage m_rimg_ViewSjTexture;
|
2025-06-03 22:26:10 +08:00
|
|
|
private Text m_textHuangJinInfo;
|
2025-05-26 23:23:18 +08:00
|
|
|
private Button m_btn_StartBtn;
|
2025-06-03 22:26:10 +08:00
|
|
|
private RectTransform m_rect_ShiJian;
|
|
|
|
private Image m_img_JinDu;
|
|
|
|
private TextMeshProUGUI m_tmp_ShiJian;
|
|
|
|
private TextMeshProUGUI m_tmp_ShiJianValue;
|
|
|
|
private Image m_imgShiJianSign;
|
2025-04-24 16:50:21 +08:00
|
|
|
protected override void ScriptGenerator()
|
|
|
|
{
|
2025-06-04 20:39:11 +08:00
|
|
|
m_rectTopFx = FindChildComponent<RectTransform>("Bg/m_rectTopFx");
|
2025-05-19 17:28:34 +08:00
|
|
|
m_rectSdx = FindChildComponent<RectTransform>("Bg/m_rectSdx");
|
|
|
|
m_rectSceneFx = FindChildComponent<RectTransform>("Bg/m_rectSceneFx");
|
|
|
|
m_rectSpeed = FindChildComponent<RectTransform>("Bg/m_rectSpeed");
|
2025-05-09 16:29:30 +08:00
|
|
|
m_rectBgList = FindChildComponent<RectTransform>("Bg/m_rectBgList");
|
2025-05-09 16:53:47 +08:00
|
|
|
m_img_BT = FindChildComponent<Image>("Bg/Top/m_img_BT");
|
|
|
|
m_tmpTimer = FindChildComponent<TextMeshProUGUI>("Bg/Top/m_img_BT/m_tmpTimer");
|
|
|
|
m_tmpWinPoint = FindChildComponent<TextMeshProUGUI>("Bg/Top/m_img_BT/m_tmpWinPoint");
|
|
|
|
m_tmpScoreAll = FindChildComponent<TextMeshProUGUI>("Bg/Top/m_img_BT/m_tmpScoreAll");
|
2025-04-24 16:50:21 +08:00
|
|
|
m_btnSetting = FindChildComponent<Button>("Bg/Top/m_btnSetting");
|
|
|
|
m_btnRank = FindChildComponent<Button>("Bg/Top/m_btnRank");
|
|
|
|
m_rectHPanel = FindChildComponent<RectTransform>("Bg/Main/m_rectHPanel");
|
2025-04-24 17:46:30 +08:00
|
|
|
m_itemActorHItem = FindChild("Bg/Main/m_rectHPanel/m_itemActorHItem").gameObject;
|
2025-05-08 23:23:31 +08:00
|
|
|
m_rect_GiftPanel = FindChildComponent<RectTransform>("Bg/m_rect_GiftPanel");
|
2025-05-09 16:29:30 +08:00
|
|
|
m_rimgHeadIcon = FindChildComponent<RawImage>("Bg/m_rect_GiftPanel/GiftItem/Item/Mask/m_rimgHeadIcon");
|
|
|
|
m_tmpPlayName = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_GiftPanel/GiftItem/Item/m_tmpPlayName");
|
|
|
|
m_tmpTeamName = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_GiftPanel/GiftItem/Item/m_tmpTeamName");
|
|
|
|
m_tmpGiftMsg = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_GiftPanel/GiftItem/Item/m_tmpGiftMsg");
|
|
|
|
m_imgGiftImg = FindChildComponent<Image>("Bg/m_rect_GiftPanel/GiftItem/Item/m_imgGiftImg");
|
|
|
|
m_tmpCount = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_GiftPanel/GiftItem/Item/m_tmpCount");
|
2025-05-17 15:34:51 +08:00
|
|
|
m_rimg_ViewTexture = FindChildComponent<RawImage>("Bg/BattleBg/m_rimg_ViewTexture");
|
|
|
|
m_video_Video = FindChildComponent<VideoPlayer>("Bg/BattleBg/m_video_Video");
|
2025-06-04 06:20:22 +08:00
|
|
|
m_rect_Dz = FindChildComponent<RectTransform>("Bg/m_rect_Dz");
|
2025-06-04 20:39:11 +08:00
|
|
|
m_tmp_PlayerName = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_Dz/Icon/m_tmp_PlayerName");
|
2025-06-04 05:06:28 +08:00
|
|
|
m_rectGjsk = FindChildComponent<RectTransform>("Bg/m_rectGjsk");
|
2025-06-03 22:26:10 +08:00
|
|
|
m_img_HuangJinShiDai = FindChildComponent<Image>("Bg/m_img_HuangJinShiDai");
|
2025-06-04 21:03:24 +08:00
|
|
|
m_video_SjVideo = FindChildComponent<VideoPlayer>("Bg/m_img_HuangJinShiDai/m_video_SjVideo");
|
|
|
|
m_rimg_ViewSjTexture = FindChildComponent<RawImage>("Bg/m_img_HuangJinShiDai/m_rimg_ViewSjTexture");
|
2025-06-03 22:26:10 +08:00
|
|
|
m_textHuangJinInfo = FindChildComponent<Text>("Bg/m_img_HuangJinShiDai/m_textHuangJinInfo");
|
2025-05-26 23:23:18 +08:00
|
|
|
m_btn_StartBtn = FindChildComponent<Button>("Bg/m_btn_StartBtn");
|
2025-06-03 22:26:10 +08:00
|
|
|
m_rect_ShiJian = FindChildComponent<RectTransform>("Bg/m_rect_ShiJian");
|
|
|
|
m_img_JinDu = FindChildComponent<Image>("Bg/m_rect_ShiJian/m_img_JinDu");
|
|
|
|
m_tmp_ShiJian = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_ShiJian/Image/m_tmp_ShiJian");
|
|
|
|
m_tmp_ShiJianValue = FindChildComponent<TextMeshProUGUI>("Bg/m_rect_ShiJian/Image/m_tmp_ShiJianValue");
|
|
|
|
m_imgShiJianSign = FindChildComponent<Image>("Bg/m_rect_ShiJian/m_imgShiJianSign");
|
2025-04-24 16:50:21 +08:00
|
|
|
m_btnSetting.onClick.AddListener(OnClickSettingBtn);
|
|
|
|
m_btnRank.onClick.AddListener(OnClickRankBtn);
|
2025-05-26 23:23:18 +08:00
|
|
|
m_btn_StartBtn.onClick.AddListener(OnClick_StartBtnBtn);
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 事件
|
2025-05-26 23:23:18 +08:00
|
|
|
private void OnClick_StartBtnBtn()
|
|
|
|
{
|
|
|
|
// 游戏状态
|
|
|
|
DataGameSceneManager.Instance.SetGameState(true);
|
|
|
|
m_btn_StartBtn.gameObject.SetActive(false);
|
|
|
|
}
|
2025-04-24 16:50:21 +08:00
|
|
|
private void OnClickSettingBtn()
|
|
|
|
{
|
|
|
|
GameModule.UI.ShowUI<UISettingForm>();
|
|
|
|
}
|
|
|
|
private async void OnClickRankBtn()
|
|
|
|
{
|
2025-05-19 17:28:34 +08:00
|
|
|
GameModule.UI.ShowUI<UIGameWorldRankForm>();
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
private Dictionary<RectTransform, Vector2> targetPositions = new Dictionary<RectTransform, Vector2>();
|
|
|
|
private float animationSpeed = 150f; // Adjust this value to control the speed of the animation
|
|
|
|
protected override void OnCreate()
|
|
|
|
{
|
|
|
|
base.OnCreate();
|
|
|
|
|
2025-05-26 23:23:18 +08:00
|
|
|
// 游戏状态
|
|
|
|
//DataGameSceneManager.Instance.SetGameState(true);
|
2025-04-24 16:50:21 +08:00
|
|
|
|
2025-06-04 14:06:41 +08:00
|
|
|
// 清除视频上的targetTexture残像
|
|
|
|
m_video_Video.targetTexture.Release();
|
|
|
|
|
2025-04-24 21:04:43 +08:00
|
|
|
// 刷新
|
|
|
|
UpdateGameTiemr();
|
|
|
|
UpdateGameScoreValue();
|
2025-04-24 16:50:21 +08:00
|
|
|
//RestHItemFunc();
|
|
|
|
|
2025-05-26 23:27:19 +08:00
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
// 创建横板列表
|
2025-04-24 17:46:30 +08:00
|
|
|
for (int i = 0; i < DataGameSceneManager.Instance.m_Strs.Count; i++)
|
|
|
|
{
|
|
|
|
ActorHItem actorHItem = CreateWidgetByPrefab<ActorHItem>(m_itemActorHItem, m_rectHPanel);
|
2025-04-24 21:04:43 +08:00
|
|
|
var r = actorHItem.gameObject.GetComponent<RectTransform>();
|
|
|
|
// 计算位置
|
|
|
|
r.anchorMin = new Vector2(0.5f, 0.5f);
|
|
|
|
r.anchorMax = new Vector2(0.5f, 0.5f);
|
2025-06-04 11:13:41 +08:00
|
|
|
r.anchoredPosition = new Vector2(127, 435 - 65 - i * (109 - 5f));
|
2025-04-24 21:04:43 +08:00
|
|
|
r.localPosition = new Vector3(r.localPosition.x, r.localPosition.y, 0);
|
|
|
|
actorHItem.OnInit(i);
|
2025-04-25 14:37:15 +08:00
|
|
|
DataGameSceneManager.Instance.m_DicTeamList.Add((i + 1).ToString(), actorHItem);
|
2025-04-24 17:46:30 +08:00
|
|
|
DataGameSceneManager.Instance.m_TeamSortList.Add(actorHItem);
|
|
|
|
}
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
2025-06-04 14:06:41 +08:00
|
|
|
protected override void Close()
|
|
|
|
{
|
|
|
|
base.Close();
|
|
|
|
|
|
|
|
// 清除视频上的targetTexture残像
|
|
|
|
m_video_Video.targetTexture.Release();
|
|
|
|
}
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
protected override void OnUpdate()
|
|
|
|
{
|
|
|
|
base.OnUpdate();
|
|
|
|
|
2025-05-26 23:23:18 +08:00
|
|
|
if (!DataGameSceneManager.Instance.GetGameState())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2025-04-24 16:50:21 +08:00
|
|
|
|
|
|
|
UpdateGameTiemr();
|
|
|
|
UpdateGameScoreValue();
|
|
|
|
UpdateHItem();
|
|
|
|
|
|
|
|
// Move each HItemActor towards its target position
|
|
|
|
foreach (var kvp in targetPositions)
|
|
|
|
{
|
|
|
|
if (kvp.Key == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
var rectTransform = kvp.Key;
|
|
|
|
var targetPosition = kvp.Value;
|
|
|
|
float distance = Vector2.Distance(rectTransform.localPosition, targetPosition);
|
|
|
|
float speed = distance / 0.2f; // Calculate speed to ensure movement completes in 1 second
|
|
|
|
rectTransform.localPosition = Vector2.MoveTowards(rectTransform.localPosition, targetPosition, speed * Time.deltaTime);
|
|
|
|
}
|
2025-04-28 15:07:13 +08:00
|
|
|
|
|
|
|
DataGameSceneManager.Instance.m_TeamSortList.Sort((a, b) =>
|
|
|
|
{
|
|
|
|
if (a.GetAllPower() > b.GetAllPower())
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2025-05-04 21:26:33 +08:00
|
|
|
|
2025-06-03 22:26:10 +08:00
|
|
|
// 黄金事件相关逻辑处理
|
|
|
|
if (DataGameSceneManager.Instance.isLiShiShiJian)
|
|
|
|
{
|
|
|
|
// 更新界面逻辑
|
|
|
|
// 目前固定两百个点赞逻辑。
|
|
|
|
m_tmp_ShiJianValue.text = string.Format("{0}/200", DataGameSceneManager.Instance.m_LiShiShiJianLikeCount);
|
2025-06-04 21:47:43 +08:00
|
|
|
|
2025-06-04 03:43:13 +08:00
|
|
|
m_img_JinDu.fillAmount = (float)(DataGameSceneManager.Instance.m_LiShiShiJianLikeCount / (float)DataGameSceneManager.Instance.m_LiShiShiJianLikeCountMax);
|
|
|
|
|
2025-06-04 03:08:23 +08:00
|
|
|
|
2025-06-03 22:26:10 +08:00
|
|
|
|
|
|
|
// 奖励也是固定死的
|
|
|
|
if (DataGameSceneManager.Instance.m_LiShiShiJianLikeCount >= DataGameSceneManager.Instance.m_LiShiShiJianLikeCountMax)
|
|
|
|
{
|
|
|
|
|
2025-06-04 03:08:23 +08:00
|
|
|
Log.Debug("历史事件成功。。。");
|
|
|
|
|
2025-06-03 22:26:10 +08:00
|
|
|
DataGameSceneManager.Instance.isLiShiShiJian = false; // 重置
|
|
|
|
|
|
|
|
// 触发历史事件条件
|
|
|
|
m_img_HuangJinShiDai.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
// 设置用户信息显示
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Sort((a, b) =>
|
|
|
|
{
|
|
|
|
if (a.count > b.count)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2025-06-04 03:29:21 +08:00
|
|
|
|
|
|
|
var config = ConfigSystem.Instance.Tables.TbTeamConfig.Get(
|
|
|
|
DataGameSceneManager.Instance.m_TeamId);
|
|
|
|
|
2025-06-03 22:26:10 +08:00
|
|
|
// 设置用户信息
|
|
|
|
m_textHuangJinInfo.text = string.Format(
|
2025-06-04 03:43:13 +08:00
|
|
|
config.TextInfo,
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Count > 0 && DataGameSceneManager.Instance.sjDatas[0] != null ? DataGameSceneManager.Instance.sjDatas[0].name : "暂无",
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Count > 1 && DataGameSceneManager.Instance.sjDatas[1] != null ? DataGameSceneManager.Instance.sjDatas[1].name : "暂无",
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Count > 2 && DataGameSceneManager.Instance.sjDatas[2] != null ? DataGameSceneManager.Instance.sjDatas[2].name : "暂无"
|
|
|
|
);
|
2025-06-03 22:26:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
// 设置图片从透明到不透明
|
2025-06-04 21:03:24 +08:00
|
|
|
//m_img_HuangJinShiDai.sprite = GameModule.Resource.LoadAsset<Sprite>(config.ImgName);
|
2025-06-03 22:26:10 +08:00
|
|
|
|
2025-06-04 21:03:24 +08:00
|
|
|
int teamId = DataGameSceneManager.Instance.m_TeamId;
|
2025-06-03 22:32:01 +08:00
|
|
|
|
2025-06-04 21:03:24 +08:00
|
|
|
Log.Debug("当前黄金时代id" + teamId);
|
|
|
|
|
|
|
|
// 先播放视频
|
|
|
|
string videoName = ConfigSystem.Instance.Tables.TbTeamConfig.Get(teamId).ImgName;
|
2025-06-03 22:32:01 +08:00
|
|
|
|
2025-06-04 21:03:24 +08:00
|
|
|
m_video_Video.loopPointReached += (v) =>
|
2025-06-03 22:26:10 +08:00
|
|
|
{
|
2025-06-04 03:29:21 +08:00
|
|
|
|
2025-06-03 22:26:10 +08:00
|
|
|
m_img_HuangJinShiDai.gameObject.SetActive(false);
|
2025-06-04 03:29:21 +08:00
|
|
|
m_rect_ShiJian.gameObject.SetActive(false);
|
2025-06-04 03:43:13 +08:00
|
|
|
DataGameSceneManager.Instance.m_LiShiShiJianLikeCount = 0;
|
2025-06-04 21:03:24 +08:00
|
|
|
m_video_Video.targetTexture.DiscardContents();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
var videoClip = GameModule.Resource.LoadAsset<VideoClip>(videoName);
|
|
|
|
m_video_SjVideo.clip = videoClip;
|
|
|
|
m_video_SjVideo.Play();
|
2025-06-04 21:03:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Clear(); // 清空数据
|
2025-06-04 03:43:13 +08:00
|
|
|
|
2025-06-03 22:26:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void RegisterEvent()
|
2025-06-04 03:08:23 +08:00
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
{
|
|
|
|
base.RegisterEvent();
|
|
|
|
GameEvent.AddEventListener(EventConts.RestGameBattle, RestGameBattleFunc);
|
2025-05-07 15:16:19 +08:00
|
|
|
GameEvent.AddEventListener<GiftConfig>(EventConts.TtqEffectCreate, TtqEffectCreateFunc);
|
2025-04-24 16:50:21 +08:00
|
|
|
GameEvent.AddEventListener<UnitPlayerData>(EventConts.AddPlayer, AddPlayerFunc);
|
2025-05-09 16:29:30 +08:00
|
|
|
GameEvent.AddEventListener(EventConts.SwitchTeamId, SwitchTeamIdFunc);
|
2025-06-03 21:54:52 +08:00
|
|
|
GameEvent.AddEventListener(EventConts.HuangJinGameEnd, HuangJinGameEndFunc);
|
2025-06-04 05:06:28 +08:00
|
|
|
GameEvent.AddEventListener(EventConts.GuanJunShiKe, GuanJunShiKeFunc);
|
2025-06-04 06:20:22 +08:00
|
|
|
GameEvent.AddEventListener<string>(EventConts.UIDianZan, UIDianZanFunc);
|
2025-04-24 16:50:21 +08:00
|
|
|
GameEvent.AddEventListener<UnitPlayerData, GiftConfig, int>(EventConts.AddGiftMessage, AddGiftMessageFunc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
{
|
|
|
|
base.OnDestroy();
|
|
|
|
GameEvent.RemoveEventListener(EventConts.RestGameBattle, RestGameBattleFunc);
|
2025-05-07 15:16:19 +08:00
|
|
|
GameEvent.RemoveEventListener<GiftConfig>(EventConts.TtqEffectCreate, TtqEffectCreateFunc);
|
2025-04-24 16:50:21 +08:00
|
|
|
GameEvent.RemoveEventListener<UnitPlayerData>(EventConts.AddPlayer, AddPlayerFunc);
|
2025-05-09 16:29:30 +08:00
|
|
|
GameEvent.RemoveEventListener(EventConts.SwitchTeamId, SwitchTeamIdFunc);
|
2025-06-03 21:54:52 +08:00
|
|
|
GameEvent.RemoveEventListener(EventConts.HuangJinGameEnd, HuangJinGameEndFunc);
|
2025-06-04 05:06:28 +08:00
|
|
|
GameEvent.RemoveEventListener(EventConts.GuanJunShiKe, GuanJunShiKeFunc);
|
2025-06-04 06:20:22 +08:00
|
|
|
GameEvent.RemoveEventListener<string>(EventConts.UIDianZan, UIDianZanFunc);
|
2025-04-24 16:50:21 +08:00
|
|
|
GameEvent.RemoveEventListener<UnitPlayerData, GiftConfig, int>(EventConts.AddGiftMessage, AddGiftMessageFunc);
|
|
|
|
}
|
|
|
|
|
2025-06-04 06:20:22 +08:00
|
|
|
private void UIDianZanFunc(string nickName)
|
|
|
|
{
|
|
|
|
CreateWidgetByPrefab<UIDianZanItem>(m_rect_Dz.gameObject).OnInit(nickName);
|
|
|
|
}
|
2025-06-03 21:54:52 +08:00
|
|
|
|
2025-06-04 05:06:28 +08:00
|
|
|
private void GuanJunShiKeFunc()
|
|
|
|
{
|
|
|
|
m_rectGjsk.gameObject.SetActive(true);
|
|
|
|
}
|
|
|
|
|
2025-06-04 03:08:23 +08:00
|
|
|
private int m_LishiId = -1;
|
2025-06-03 21:54:52 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 黄金时代结束
|
|
|
|
/// </summary>
|
|
|
|
private void HuangJinGameEndFunc()
|
|
|
|
{
|
|
|
|
|
|
|
|
int teamId = DataGameSceneManager.Instance.m_TeamId;
|
|
|
|
|
2025-06-04 19:11:29 +08:00
|
|
|
Log.Debug("当前黄金时代id" + teamId);
|
|
|
|
|
2025-06-03 21:54:52 +08:00
|
|
|
// 先播放视频
|
|
|
|
string videoName = ConfigSystem.Instance.Tables.TbTeamConfig.Get(teamId).VideoName;
|
|
|
|
|
|
|
|
m_video_Video.loopPointReached += (v) =>
|
|
|
|
{
|
|
|
|
// 弹个UI窗口
|
2025-06-03 22:26:10 +08:00
|
|
|
m_rect_ShiJian.gameObject.SetActive(true);
|
2025-06-03 21:54:52 +08:00
|
|
|
|
|
|
|
// 创建itme 实时更新进度条显示
|
2025-06-03 22:26:10 +08:00
|
|
|
DataGameSceneManager.Instance.isLiShiShiJian = true;
|
|
|
|
|
2025-06-03 21:54:52 +08:00
|
|
|
};
|
2025-06-04 03:08:23 +08:00
|
|
|
|
2025-06-04 03:16:46 +08:00
|
|
|
var videoClip = GameModule.Resource.LoadAsset<VideoClip>(videoName);
|
|
|
|
m_video_Video.clip = videoClip;
|
|
|
|
m_video_Video.Play();
|
|
|
|
|
2025-06-04 03:08:23 +08:00
|
|
|
// 历史事件时间周期
|
|
|
|
if (m_LishiId != -1)
|
|
|
|
{
|
|
|
|
GameModule.Timer.RemoveTimer(m_LishiId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 历史事件维持时间周期
|
|
|
|
m_LishiId = GameModule.Timer.AddTimer((e) =>
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Debug("历史事件失败。。。");
|
|
|
|
|
|
|
|
DataGameSceneManager.Instance.isLiShiShiJian = false;
|
|
|
|
|
|
|
|
// 告知关闭历史事件了
|
|
|
|
// 设置用户信息显示
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Sort((a, b) =>
|
|
|
|
{
|
|
|
|
if (a.count > b.count)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2025-06-04 03:29:21 +08:00
|
|
|
m_img_HuangJinShiDai.gameObject.SetActive(true);
|
|
|
|
var config = ConfigSystem.Instance.Tables.TbTeamConfig.Get(teamId);
|
|
|
|
|
2025-06-04 03:08:23 +08:00
|
|
|
// 设置用户信息
|
|
|
|
m_textHuangJinInfo.text = ConfigSystem.Instance.Tables.TbTeamConfig.Get(teamId).LoswerInfo;
|
|
|
|
|
|
|
|
// 设置图片从透明到不透明
|
2025-06-04 21:03:24 +08:00
|
|
|
//m_img_HuangJinShiDai.sprite = GameModule.Resource.LoadAsset<Sprite>(config.ImgName);
|
2025-06-04 03:43:13 +08:00
|
|
|
|
2025-06-04 21:03:24 +08:00
|
|
|
// 先播放视频
|
|
|
|
string videoName = ConfigSystem.Instance.Tables.TbTeamConfig.Get(teamId).ImgName;
|
2025-06-04 03:08:23 +08:00
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
m_video_SjVideo.loopPointReached += (v) =>
|
2025-06-04 03:08:23 +08:00
|
|
|
{
|
2025-06-04 21:03:24 +08:00
|
|
|
|
2025-06-04 03:08:23 +08:00
|
|
|
m_img_HuangJinShiDai.gameObject.SetActive(false);
|
2025-06-04 03:29:21 +08:00
|
|
|
m_rect_ShiJian.gameObject.SetActive(false);
|
2025-06-04 21:03:24 +08:00
|
|
|
DataGameSceneManager.Instance.m_LiShiShiJianLikeCount = 0;
|
2025-06-04 21:47:43 +08:00
|
|
|
m_video_SjVideo.targetTexture.DiscardContents();
|
2025-06-04 21:03:24 +08:00
|
|
|
|
|
|
|
};
|
2025-06-04 21:47:43 +08:00
|
|
|
var videoClip = GameModule.Resource.LoadAsset<VideoClip>(videoName);
|
|
|
|
m_video_SjVideo.clip = videoClip;
|
|
|
|
m_video_SjVideo.Play();
|
|
|
|
|
2025-06-04 21:03:24 +08:00
|
|
|
|
|
|
|
DataGameSceneManager.Instance.sjDatas.Clear(); // 清空数据
|
|
|
|
DataGameSceneManager.Instance.m_LiShiShiJianLikeCount = 0;
|
2025-06-04 03:08:23 +08:00
|
|
|
|
|
|
|
|
2025-06-04 03:29:21 +08:00
|
|
|
}, EventConts.LiShiShiJianEnd);
|
2025-06-04 03:08:23 +08:00
|
|
|
|
2025-06-03 21:54:52 +08:00
|
|
|
}
|
|
|
|
|
2025-05-09 16:29:30 +08:00
|
|
|
private void SwitchTeamIdFunc()
|
|
|
|
{
|
2025-05-17 15:34:51 +08:00
|
|
|
|
2025-05-09 16:29:30 +08:00
|
|
|
int teamId = DataGameSceneManager.Instance.m_TeamId;
|
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
Log.Debug("触发切换朝代:" + teamId);
|
2025-05-17 15:34:51 +08:00
|
|
|
|
2025-05-20 02:11:32 +08:00
|
|
|
if (teamId != 1)
|
|
|
|
{
|
|
|
|
// 先播放视频
|
2025-06-04 21:03:24 +08:00
|
|
|
string videoName = "Scene_" + (teamId);
|
2025-05-20 02:11:32 +08:00
|
|
|
|
|
|
|
m_video_Video.loopPointReached += (v) =>
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_rectBgList.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectBgList.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < m_rectSdx.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectSdx.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < m_rectSceneFx.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectSceneFx.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < m_rectSpeed.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectSpeed.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
2025-06-04 21:07:59 +08:00
|
|
|
for (int i = 0; i < m_rectTopFx.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectTopFx.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
2025-05-20 02:11:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (teamId > m_rectBgList.childCount)
|
|
|
|
{
|
|
|
|
Log.Error("背景Id错误" + teamId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_rectBgList.GetChild(teamId).gameObject.SetActive(true);
|
|
|
|
m_rectSdx.GetChild(teamId).gameObject.SetActive(true);
|
|
|
|
m_rectSceneFx.GetChild(teamId).gameObject.SetActive(true);
|
|
|
|
m_rectSpeed.GetChild(teamId).gameObject.SetActive(true);
|
2025-06-04 21:07:59 +08:00
|
|
|
m_rectTopFx.GetChild(teamId).gameObject.SetActive(true);
|
2025-05-20 02:11:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
// 替换UI图
|
|
|
|
SwitchUIResource();
|
2025-06-04 03:16:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
// 清除视频上的targetTexture残像
|
|
|
|
m_video_Video.targetTexture.Release();
|
2025-05-20 02:11:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// 播放音频
|
|
|
|
var videoAudioName = "csm_audios";
|
2025-06-04 21:47:43 +08:00
|
|
|
GameModule.Audio.Play(TEngine.AudioType.UISound, videoAudioName, false, 0.5f, true);
|
2025-05-20 02:11:32 +08:00
|
|
|
|
|
|
|
var videoClip = GameModule.Resource.LoadAsset<VideoClip>(videoName);
|
|
|
|
m_video_Video.clip = videoClip;
|
|
|
|
m_video_Video.Play();
|
2025-06-04 21:47:43 +08:00
|
|
|
|
2025-05-17 15:34:51 +08:00
|
|
|
for (int i = 0; i < m_rectBgList.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectBgList.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
2025-05-17 15:55:08 +08:00
|
|
|
for (int i = 0; i < m_rectSdx.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectSdx.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < m_rectSceneFx.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectSceneFx.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < m_rectSpeed.childCount; i++)
|
|
|
|
{
|
|
|
|
m_rectSpeed.GetChild(i).gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
for (int i = 0; i < m_rectSpeed.childCount; i++)
|
2025-05-17 15:34:51 +08:00
|
|
|
{
|
2025-06-04 21:47:43 +08:00
|
|
|
m_rectTopFx.GetChild(i).gameObject.SetActive(false);
|
2025-05-17 15:34:51 +08:00
|
|
|
}
|
2025-06-04 21:47:43 +08:00
|
|
|
}
|
2025-05-17 15:55:08 +08:00
|
|
|
|
2025-05-17 15:34:51 +08:00
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
if (teamId > m_rectBgList.childCount)
|
|
|
|
{
|
|
|
|
Log.Error("背景Id错误" + teamId);
|
|
|
|
return;
|
2025-05-20 02:11:32 +08:00
|
|
|
}
|
2025-05-17 15:34:51 +08:00
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
m_rectBgList.GetChild(teamId - 1).gameObject.SetActive(true);
|
|
|
|
m_rectSdx.GetChild(teamId - 1).gameObject.SetActive(true);
|
|
|
|
m_rectSceneFx.GetChild(teamId - 1).gameObject.SetActive(true);
|
|
|
|
m_rectSpeed.GetChild(teamId - 1).gameObject.SetActive(true);
|
|
|
|
m_rectTopFx.GetChild(teamId - 1).gameObject.SetActive(true);
|
2025-05-17 16:10:26 +08:00
|
|
|
|
2025-05-09 16:29:30 +08:00
|
|
|
|
2025-06-04 21:47:43 +08:00
|
|
|
// 替换UI图
|
|
|
|
SwitchUIResource();
|
|
|
|
|
2025-05-09 16:41:00 +08:00
|
|
|
|
2025-05-09 16:29:30 +08:00
|
|
|
}
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
private void AddPlayerFunc(UnitPlayerData unitPlayerData)
|
|
|
|
{
|
2025-05-09 00:35:25 +08:00
|
|
|
|
|
|
|
// 显示加入UI
|
|
|
|
var jiaRuItem = GameObject.Instantiate(m_rect_GiftPanel.transform.GetChild(1));
|
|
|
|
jiaRuItem.transform.SetParent(m_rect_GiftPanel);
|
2025-05-09 16:29:30 +08:00
|
|
|
jiaRuItem.transform.localScale = Vector3.one;
|
2025-06-04 21:47:43 +08:00
|
|
|
jiaRuItem.transform.localPosition = new Vector3(350, 0, 0);
|
2025-05-09 00:35:25 +08:00
|
|
|
jiaRuItem.gameObject.SetActive(true);
|
|
|
|
jiaRuItem.GetComponent<UIJiaRuItem>().OnInit(unitPlayerData);
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
2025-05-30 17:11:34 +08:00
|
|
|
|
|
|
|
public GameObject m_TestEgo = null;
|
2025-05-07 15:16:19 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 甜甜圈特效
|
|
|
|
/// </summary>
|
2025-05-27 20:31:55 +08:00
|
|
|
private async void TtqEffectCreateFunc(GiftConfig giftConfig)
|
2025-05-07 15:16:19 +08:00
|
|
|
{
|
2025-05-27 20:31:55 +08:00
|
|
|
|
2025-06-04 18:09:15 +08:00
|
|
|
//// 判断场景是否存在这个资源
|
|
|
|
//if (m_TestEgo != null)
|
|
|
|
//{
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// var m_Ego = GameModule.Resource.LoadGameObject("TTQ01");
|
|
|
|
// m_TestEgo = m_Ego;
|
|
|
|
// m_Ego.transform.SetParent(this.transform);
|
|
|
|
// m_Ego.transform.localPosition = Vector3.zero;
|
|
|
|
// m_Ego.transform.localScale = Vector3.one;
|
|
|
|
|
|
|
|
// // 设置时间消失
|
|
|
|
// await UniTask.Delay(giftConfig.TimerLen * 1000);
|
|
|
|
// GameObject.Destroy(m_Ego);
|
|
|
|
// m_TestEgo = null;
|
|
|
|
//}
|
2025-05-27 20:31:55 +08:00
|
|
|
|
2025-05-07 15:16:19 +08:00
|
|
|
}
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
private async void AddGiftMessageFunc(UnitPlayerData unitPlayerData, GiftConfig giftConfig, int num)
|
|
|
|
{
|
2025-05-08 23:23:31 +08:00
|
|
|
var giftItem = GameObject.Instantiate(m_rect_GiftPanel.transform.GetChild(0));
|
|
|
|
giftItem.transform.SetParent(m_rect_GiftPanel);
|
|
|
|
giftItem.transform.localScale = Vector3.one;
|
|
|
|
giftItem.transform.localPosition = Vector3.zero;
|
|
|
|
giftItem.gameObject.SetActive(true);
|
|
|
|
giftItem.GetComponent<UIGiftItem>().OnInit(unitPlayerData, giftConfig, num);
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 收到游戏重开的消息
|
|
|
|
/// </summary>
|
|
|
|
private void RestGameBattleFunc()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2025-05-09 16:53:47 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 基于朝代切换资源
|
|
|
|
/// </summary>
|
|
|
|
private void SwitchUIResource()
|
|
|
|
{
|
2025-06-04 05:46:20 +08:00
|
|
|
//m_img_BT.sprite = GameModule.Resource.LoadAsset<Sprite>(string.Format("zjm_{0}_BT", DataGameSceneManager.Instance.m_TeamId + 1));
|
|
|
|
//m_img_BT.SetNativeSize();
|
|
|
|
m_img_BT.material = GameModule.Resource.LoadAsset<Material>(string.Format("Main_UI_Top{0}", DataGameSceneManager.Instance.m_TeamId + 1));
|
2025-05-09 16:53:47 +08:00
|
|
|
}
|
2025-04-24 16:50:21 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 更新游戏时间
|
|
|
|
/// </summary>
|
|
|
|
private void UpdateGameTiemr()
|
|
|
|
{
|
|
|
|
|
|
|
|
// 计算分钟和剩余秒数
|
|
|
|
int minutes = (int)DataGameSceneManager.Instance.m_GameTimerLen / 60;
|
|
|
|
int remainingSeconds = (int)DataGameSceneManager.Instance.m_GameTimerLen % 60;
|
|
|
|
|
|
|
|
// 返回格式化的字符串
|
|
|
|
m_tmpTimer.text = $"{minutes}:{remainingSeconds:D2}";
|
2025-06-04 03:48:59 +08:00
|
|
|
|
2025-06-04 21:06:05 +08:00
|
|
|
if (DataGameSceneManager.Instance.m_GameTimerLen <= 0)
|
|
|
|
{
|
|
|
|
m_rectGjsk.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
2025-06-04 03:48:59 +08:00
|
|
|
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 更新游戏公用数据
|
|
|
|
/// </summary>
|
|
|
|
private void UpdateGameScoreValue()
|
|
|
|
{
|
|
|
|
// 积分池更新
|
|
|
|
m_tmpScoreAll.text = UITool.ConvertToString(DataGameSceneManager.Instance.ScoreAllValue);
|
|
|
|
|
|
|
|
// 胜点池
|
|
|
|
m_tmpWinPoint.text = UITool.ConvertToString(DataGameSceneManager.Instance.WinAllValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 更新横版排版移动
|
|
|
|
/// </summary>
|
|
|
|
private void UpdateHItem()
|
|
|
|
{
|
2025-04-24 21:04:43 +08:00
|
|
|
// Create a list to hold the HItemActors and their scores
|
2025-05-07 20:54:39 +08:00
|
|
|
List<(ActorHItem actor, double score)> hItemActors = new List<(ActorHItem, double)>();
|
2025-04-24 16:50:21 +08:00
|
|
|
|
2025-04-24 21:04:43 +08:00
|
|
|
// Populate the list with HItemActors and their scores
|
|
|
|
for (int i = 0; i < m_rectHPanel.childCount; i++)
|
|
|
|
{
|
|
|
|
if (i < DataGameSceneManager.Instance.m_TeamSortList.Count)
|
|
|
|
{
|
2025-04-28 15:07:13 +08:00
|
|
|
var hItemActor = DataGameSceneManager.Instance.m_DicTeamList[(i + 1).ToString()];
|
2025-05-07 20:54:39 +08:00
|
|
|
double score = hItemActor.GetAllPower(); // Assume GetScore() returns the score of the actor
|
2025-04-24 21:04:43 +08:00
|
|
|
hItemActors.Add((hItemActor, score));
|
|
|
|
}
|
|
|
|
}
|
2025-04-24 16:50:21 +08:00
|
|
|
|
2025-04-24 21:04:43 +08:00
|
|
|
// Sort the list based on scores in descending order
|
|
|
|
hItemActors.Sort((a, b) => b.score.CompareTo(a.score));
|
|
|
|
|
|
|
|
// Set the target positions for the HItemActors based on their new order
|
|
|
|
for (int i = 0; i < hItemActors.Count; i++)
|
|
|
|
{
|
2025-05-27 20:31:55 +08:00
|
|
|
var hItemActor = hItemActors[i].actor;
|
2025-05-28 23:08:14 +08:00
|
|
|
//hItemActor.m_Index = i;
|
2025-04-24 21:04:43 +08:00
|
|
|
var rectTransform = hItemActor.gameObject.GetComponent<RectTransform>();
|
2025-06-04 11:13:41 +08:00
|
|
|
Vector2 targetPosition = new Vector2(127, 435 - i * (109 - 5f));
|
2025-04-24 21:04:43 +08:00
|
|
|
targetPositions[rectTransform] = targetPosition;
|
|
|
|
}
|
|
|
|
|
2025-04-24 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2025-04-18 19:18:15 +08:00
|
|
|
}
|
2025-06-04 21:47:43 +08:00
|
|
|
|