1
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Spine.Unity;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -18,6 +19,9 @@ public enum TurretControlMode
|
||||
|
||||
public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
public GameObject spineObj;//他的子对象child0带SkeletonGraphic
|
||||
public GameObject ziObj;//他的子对象child0带textmeshprougui
|
||||
|
||||
public Button btn_SelectPaoBei; //点击打开关闭选择面板
|
||||
public GameObject selectPaoBeiPanel; //他的出现效果是从上往下滑动的动画效果 关闭是从下往上滑动的动画效果 所称height变成0和还原那种的时间0.5s
|
||||
public GameObject paobeiItemPrefab;//自己的gameobject上面有image组件和button组件 选择后直接关闭 然后他的getchild0上有个textmeshprougui 5000以下的炮倍是蓝色的 5000-10000是紫色 10000以上是红色的 黄色是选中状态的
|
||||
@@ -795,6 +799,70 @@ public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
transform.GetChild(1).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
#region 表情包显示(spineObj / ziObj)
|
||||
|
||||
/// <summary>表情显示时长(秒),超时自动隐藏</summary>
|
||||
public float biaoQingDuration = 3f;
|
||||
/// <summary>正在运行的表情隐藏协程(新表情顶掉旧表情)</summary>
|
||||
private Coroutine _biaoQingCoroutine;
|
||||
|
||||
/// <summary>
|
||||
/// 显示 Spine 动画表情:spineObj 的 child0(SkeletonGraphic)换骨骼资源并播放动画,
|
||||
/// biaoQingDuration 秒后自动隐藏。与文字表情互斥(同时只显示一种)。
|
||||
/// </summary>
|
||||
/// <param name="asset">spine 骨骼资源</param>
|
||||
/// <param name="animName">动画名</param>
|
||||
public void ShowBiaoQingSpine(SkeletonDataAsset asset, string animName)
|
||||
{
|
||||
if (spineObj == null || asset == null || string.IsNullOrEmpty(animName)) return;
|
||||
// child0 = SkeletonGraphic
|
||||
var sg = spineObj.transform.childCount > 0
|
||||
? spineObj.transform.GetChild(0).GetComponent<SkeletonGraphic>()
|
||||
: null;
|
||||
if (sg == null) return;
|
||||
|
||||
if (ziObj != null) ziObj.SetActive(false);
|
||||
if (_biaoQingCoroutine != null) { StopCoroutine(_biaoQingCoroutine); _biaoQingCoroutine = null; }
|
||||
|
||||
sg.skeletonDataAsset = asset;
|
||||
sg.Initialize(false);
|
||||
sg.AnimationState.SetAnimation(0, animName, true);
|
||||
spineObj.SetActive(true);
|
||||
_biaoQingCoroutine = StartCoroutine(HideBiaoQingAfter(spineObj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示文字表情:ziObj 的 child0(TextMeshProUGUI)设置文字,
|
||||
/// biaoQingDuration 秒后自动隐藏。与 spine 表情互斥(同时只显示一种)。
|
||||
/// </summary>
|
||||
/// <param name="text">文字内容</param>
|
||||
public void ShowBiaoQingZi(string text)
|
||||
{
|
||||
if (ziObj == null || string.IsNullOrEmpty(text)) return;
|
||||
// child0 = TextMeshProUGUI
|
||||
var tmp = ziObj.transform.childCount > 0
|
||||
? ziObj.transform.GetChild(0).GetComponent<TextMeshProUGUI>()
|
||||
: null;
|
||||
if (tmp == null) return;
|
||||
|
||||
if (spineObj != null) spineObj.SetActive(false);
|
||||
if (_biaoQingCoroutine != null) { StopCoroutine(_biaoQingCoroutine); _biaoQingCoroutine = null; }
|
||||
|
||||
tmp.text = text;
|
||||
ziObj.SetActive(true);
|
||||
_biaoQingCoroutine = StartCoroutine(HideBiaoQingAfter(ziObj));
|
||||
}
|
||||
|
||||
/// <summary>表情显示 biaoQingDuration 秒后自动隐藏</summary>
|
||||
private IEnumerator HideBiaoQingAfter(GameObject obj)
|
||||
{
|
||||
yield return new WaitForSeconds(biaoQingDuration);
|
||||
if (obj != null) obj.SetActive(false);
|
||||
_biaoQingCoroutine = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>房主退出后,将房主身份转移给第一个活跃的非人机玩家</summary>
|
||||
/// <remarks>鱼创建已由服务端 OnFishSpawn 统一下发,此处仅维护 roomOwnerSit 标识(用于 bot 控制/AFK 等场景)。</remarks>
|
||||
public static void TransferRoomOwner()
|
||||
@@ -870,8 +938,9 @@ public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
/// </summary>
|
||||
private void LoadTurretNormal(int turretNumber)
|
||||
{
|
||||
// ⭐ 炮台/战神显示二选一:切回普通炮台时清除战神并恢复 turretParent 显示
|
||||
ClearZhanShen();
|
||||
// ⭐ 装备战神时切炮台不顶掉战神:战神保持显示并继续接管开火状态机,
|
||||
// 新炮台照常加载到 turretParent(战神装备中它是隐藏的),卸下战神(ClearZhanShen)后自动显示新炮台
|
||||
bool zhanShenActive = currentZhanShenData != null;
|
||||
|
||||
// ⭐ 换炮台时只清活跃子弹(清屏),保留池缓存(同 prefab 能复用)
|
||||
// 用 ClearActive 而非 ClearAll:ClearAll 会清池导致永远不复用
|
||||
@@ -915,13 +984,18 @@ public class SitPosData : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
// 缓存旋转节点:优先用 TurretData.tra_RotationPivot,否则回退父节点
|
||||
tra_CurrTurret = GetTurretRotationPivot(currentTurret);
|
||||
|
||||
// 绑定状态机入口
|
||||
OnStateChange = currentTurret.ChangeState;
|
||||
// 绑定状态机入口:战神装备中不抢(保持战神接管开火),无战神时才交给炮台
|
||||
if (!zhanShenActive)
|
||||
OnStateChange = currentTurret.ChangeState;
|
||||
|
||||
// 无战神时确保炮台可见;战神装备中保持 turretParent 隐藏(卸下时由 ClearZhanShen 恢复显示)
|
||||
if (turretParent != null && !zhanShenActive)
|
||||
turretParent.gameObject.SetActive(true);
|
||||
|
||||
// ⭐ 缓存炮台在世界坐标(Z=0平面)的位置,bot AI/锁定检测距离时用
|
||||
UpdateTurretWorldPos();
|
||||
|
||||
Debug.Log($"[SitPosData] 炮台已加载(Normal): #{turretNumber}");
|
||||
Debug.Log($"[SitPosData] 炮台已加载(Normal): #{turretNumber}" + (zhanShenActive ? "(战神装备中,炮台待命)" : ""));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user