This commit is contained in:
2026-07-24 01:37:11 +08:00
parent c91dbde7cb
commit d5c7ad40e3
12 changed files with 889 additions and 845 deletions
+49 -49
View File
@@ -1510,19 +1510,19 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 132536, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_IsActive
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22400762, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.0000076293945
value: -0.0000038146973
objectReference: {fileID: 0}
- target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.x
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 0.78070176
objectReference: {fileID: 0}
- target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMin.y
@@ -1530,51 +1530,51 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 165.4
objectReference: {fileID: 0}
- target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 720.3
objectReference: {fileID: 0}
- target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 165.4
objectReference: {fileID: 0}
- target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 885.7
objectReference: {fileID: 0}
- target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_Pivot.x
@@ -1658,147 +1658,147 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 165.4
objectReference: {fileID: 0}
- target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 1216.5
objectReference: {fileID: 0}
- target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 22485076, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.x
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22485076, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22485076, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: -28
objectReference: {fileID: 0}
- target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 165.4
objectReference: {fileID: 0}
- target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 248.09999
objectReference: {fileID: 0}
- target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 165.4
objectReference: {fileID: 0}
- target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 1051.1
objectReference: {fileID: 0}
- target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 306.8
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 484.19998
objectReference: {fileID: 0}
- target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
value: 165.4
objectReference: {fileID: 0}
- target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
value: 36
objectReference: {fileID: 0}
- target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: 82.7
objectReference: {fileID: 0}
- target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -18
objectReference: {fileID: 0}
- target: {fileID: 958269219681220773, guid: 67117722a812a2e46ab8cb8eafbf5f5e,
type: 3}
@@ -652,17 +652,17 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
//bossTimer = 3f;
if (!fishTypeConfig.TryGetValue(FishTypeEnum.Boss鱼, out var bossList) || bossList.Count == 0)
return;
//foreach (var item in bossList)
//{
// if (item.fishNumber == "11030")
// item.isCreate = 2;
foreach (var item in bossList)
{
if (item.fishNumber == "11030")
item.isCreate = 2;
// if (item.fishNumber == "11027")
// item.isCreate = 2;
// // if (item.fishNumber == "11030")
// // item.isCreate = 2;
if (item.fishNumber == "11027")
item.isCreate = 2;
// if (item.fishNumber == "11030")
// item.isCreate = 2;
//}
}
StartCoroutine(buchongfu(bossList, bossCount, fishDatas_hashCodekey_Boss, bossRecentList, bossRecentMax));
+25 -25
View File
@@ -348,33 +348,33 @@ public class GameManager : MonoSingleton<GameManager>
}
#endif
// FPS 统计
fpsFrameCount++;
fpsTimer += Time.unscaledDeltaTime;
if (fpsTimer >= 0.5f)
{
fps = Mathf.RoundToInt(fpsFrameCount / fpsTimer);
fpsFrameCount = 0;
fpsTimer = 0f;
}
//// FPS 统计
//fpsFrameCount++;
//fpsTimer += Time.unscaledDeltaTime;
//if (fpsTimer >= 0.5f)
//{
// fps = Mathf.RoundToInt(fpsFrameCount / fpsTimer);
// fpsFrameCount = 0;
// fpsTimer = 0f;
//}
}
//// ===== FPS 显示 =====
//private int fpsFrameCount;
//private float fpsTimer;
//private int fps;
// ===== FPS 显示 =====
private int fpsFrameCount;
private float fpsTimer;
private int fps;
void OnGUI()
{
// 左上角显示帧数
GUIStyle style = new GUIStyle(GUI.skin.label)
{
fontSize = 28,
fontStyle = FontStyle.Bold
};
style.normal.textColor = fps >= 50 ? Color.green : (fps >= 30 ? Color.yellow : Color.red);
GUI.Label(new Rect(10, 10, 200, 40), "FPS: " + fps, style);
}
//void OnGUI()
//{
// // 左上角显示帧数
// GUIStyle style = new GUIStyle(GUI.skin.label)
// {
// fontSize = 28,
// fontStyle = FontStyle.Bold
// };
// style.normal.textColor = fps >= 50 ? Color.green : (fps >= 30 ? Color.yellow : Color.red);
// GUI.Label(new Rect(10, 10, 200, 40), "FPS: " + fps, style);
//}
public void Logout(Action onDone = null)
{
+4 -4
View File
@@ -17,16 +17,16 @@ namespace Assets.MyGame.Scripts.Net
public static Dictionary<APIType, string> dic_API = new Dictionary<APIType, string>();
//public const string baseURL = "http://game5241.wzaxr.top";
#if UNITY_EDITOR
public const string baseURL = "http://8.137.163.153";
//public const string baseURL = "http://8.137.8.46";
//public const string baseURL = "http://8.137.163.153";
public const string baseURL = "http://47.109.34.50";
#else
//public const string baseURL = "http://8.137.8.46";
public const string baseURL = "http://8.137.163.153";
public const string baseURL = "http://47.109.34.50";
#endif
public static string token;
public static string token;
static APIManager()
{
@@ -195,13 +195,6 @@ namespace Assets.MyGame.Scripts.Net.APIRequest.Params
public int taskType = -1; // -1=全部
}
/// <summary>领取 Vip 每日礼包(GET)参数:当前 vip 等级,领取 V1~vipLevel 所有每日礼包</summary>
[Serializable]
public class GetVipDayGiftParam : RequestParamBase
{
public int vipLevel;
}
/// <summary>发送全服广播(GET)</summary>
[Serializable]
public class SendBroadcastParam : RequestParamBase
@@ -164,13 +164,11 @@ namespace Assets.MyGame.Scripts.Net
/// <summary>
/// 领取 Vip 每日礼包(GET)
/// 参数:当前 vip 等级(领取 V1~vipLevel 所有每日礼包)
/// 返回:GiftInfo(礼包信息)
/// </summary>
public static void GetVipDayGift(int vipLevel, Action<GiftInfo> callback)
public static void GetVipDayGift(Action<GiftInfo> callback)
{
APIManager.Response<GiftInfo>(APIType.Hall_GetVipDayGift,
new GetVipDayGiftParam { vipLevel = vipLevel }, callback);
APIManager.Response<GiftInfo>(APIType.Hall_GetVipDayGift, callback);
}
/// <summary>
+10 -3
View File
@@ -32,12 +32,12 @@ namespace Assets.MyGame.Scripts.Net
//private const string baseUrl = "ws://game5241.wzaxr.top";
#if UNITY_EDITOR
private const string baseUrl = "ws://8.137.163.153";
//private const string baseUrl = "ws://8.137.8.46";
//private const string baseUrl = "ws://8.137.163.153";
private const string baseUrl = "ws://47.109.34.50";
#else
//private const string baseUrl = "ws://8.137.8.46";
private const string baseUrl = "ws://8.137.163.153";
private const string baseUrl = "ws://47.109.34.50";
#endif
public bool isGame = false;
@@ -117,6 +117,13 @@ namespace Assets.MyGame.Scripts.Net
socketUrls[type] = url;
handshakeActions[type] = action;
var ws = new WebSocket(new Uri(url));
// Best.WebSockets 1.22.3 bug:服务器返回 3xx 重定向时,InternalRequest_OnBeforeRedirection
// 会再次调用 StartOpen(),但实例已 open 过,抛 "Open already called!"。
// 这里禁用内部 HTTP 请求的重定向跟随来规避。
ws.OnInternalRequestCreated += (socket, req) =>
{
req.RedirectSettings.MaxRedirects = 0;
};
sockets[type] = ws;
// 事件绑定
ws.OnOpen += (web) =>
@@ -644,10 +644,13 @@ namespace Assets.MyGame.Scripts.Net
var data = JsonConvert.DeserializeObject<WebSocketResponseBase<Dictionary<string, object>>>(msg).arguments[0];
if (data != null)
{
int seatType = data.TryGetValue("type", out var t) ? Convert.ToInt32(t) : 0;
// 注意:JSON 字段可能是 long/double/string/bool 等任意类型,
// 直接 Convert.ToInt32(object) 对字符串会走 int.Parse 抛 FormatException。
// 这里统一通过 ToString() + TryParse 容错。
int seatType = data.TryGetValue("type", out var t) && int.TryParse(t?.ToString(), out var st) ? st : 0;
string userId = data.TryGetValue("userId", out var u) ? u?.ToString() : "";
int position = data.TryGetValue("position", out var p) ? Convert.ToInt32(p) : -1;
bool showWaiting = data.TryGetValue("showWaiting", out var sw) && Convert.ToBoolean(sw);
int position = data.TryGetValue("position", out var p) && int.TryParse(p?.ToString(), out var pos) ? pos : -1;
bool showWaiting = data.TryGetValue("showWaiting", out var sw) && (sw is bool b ? b : (sw != null && bool.TryParse(sw.ToString(), out var bv) && bv));
Debug.Log($"[FishGameHub] 座位变更: type={seatType}, userId={userId}, position={position}, showWaiting={showWaiting}");
WebSocketReponseList.SeatChange(seatType, userId, position, showWaiting);
}
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Spine.Unity;
using System;
using System.Collections;
@@ -122,32 +122,48 @@ public class FishResourcesData
Debug.Log($"Prefab 加载完成,共 {fishPrefabDic.Count} 个");
// ---------------- 3. 加载死亡 Spine 动效 ----------------
var dieKeys = new List<string> { dieSpine_AALabel, GameManager.Instance.gameData.currGameType.ToString() };
var dieHandle = Addressables.LoadAssetsAsync<SkeletonDataAsset>(dieKeys, data =>
// 注意:某些游戏类型下 Addressables 中 "DieSpine"+"游戏类型" 两个 label 可能没有交集资源,
// 会抛 InvalidKeyException。这里用 try-catch 容错,避免单个资源类型加载失败阻塞整体流程。
try
{
if (FishResourcesSpineDieDic.TryGetValue(data.name, out int id))
var dieKeys = new List<string> { dieSpine_AALabel, GameManager.Instance.gameData.currGameType.ToString() };
var dieHandle = Addressables.LoadAssetsAsync<SkeletonDataAsset>(dieKeys, data =>
{
diePrefabDic[id] = data;
}
}, MergeMode.Intersection);
if (FishResourcesSpineDieDic.TryGetValue(data.name, out int id))
{
diePrefabDic[id] = data;
}
}, MergeMode.Intersection);
await dieHandle.Task;
Addressables.Release(dieHandle);
Debug.Log($"死亡 Spine 加载完成,共 {diePrefabDic.Count} 个");
await dieHandle.Task;
Addressables.Release(dieHandle);
Debug.Log($"死亡 Spine 加载完成,共 {diePrefabDic.Count} 个");
}
catch (Exception e)
{
Debug.LogWarning($"[FishResourcesData] 死亡 Spine 加载失败(游戏类型={GameManager.Instance.gameData.currGameType}),跳过此项: {e.Message}");
}
// ---------------- 4. 加载鱼 Sprite ----------------
var spriteKeys = new List<string> { Sprite_AALabel, GameManager.Instance.gameData.currGameType.ToString() };
var spriteHandle = Addressables.LoadAssetsAsync<Sprite>(spriteKeys, data =>
try
{
if (FishResourcesSpriteDic.TryGetValue(data.name, out int id))
var spriteKeys = new List<string> { Sprite_AALabel, GameManager.Instance.gameData.currGameType.ToString() };
var spriteHandle = Addressables.LoadAssetsAsync<Sprite>(spriteKeys, data =>
{
fishResourcesSpritesDic[id] = data;
}
}, MergeMode.Intersection);
if (FishResourcesSpriteDic.TryGetValue(data.name, out int id))
{
fishResourcesSpritesDic[id] = data;
}
}, MergeMode.Intersection);
await spriteHandle.Task;
Addressables.Release(spriteHandle);
Debug.Log($"Sprite 加载完成,共 {fishResourcesSpritesDic.Count} 个");
await spriteHandle.Task;
Addressables.Release(spriteHandle);
Debug.Log($"Sprite 加载完成,共 {fishResourcesSpritesDic.Count} 个");
}
catch (Exception e)
{
Debug.LogWarning($"[FishResourcesData] Sprite 加载失败(游戏类型={GameManager.Instance.gameData.currGameType}),跳过此项: {e.Message}");
}
Debug.Log("所有鱼资源加载完毕!");
}
File diff suppressed because it is too large Load Diff
@@ -1522,7 +1522,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1641643194739858, guid: d82e692e41cc85e4e86f6899f58f771d, type: 3}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1641643194739858, guid: d82e692e41cc85e4e86f6899f58f771d, type: 3}
propertyPath: m_TagString
@@ -7473,12 +7473,6 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 98071442387624804}
m_PrefabAsset: {fileID: 0}
--- !u!1 &97162546455774594 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1508148588832486, guid: d82e692e41cc85e4e86f6899f58f771d,
type: 3}
m_PrefabInstance: {fileID: 98071442387624804}
m_PrefabAsset: {fileID: 0}
--- !u!1 &97318211613593590 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1641643194739858, guid: d82e692e41cc85e4e86f6899f58f771d,
@@ -7499,16 +7493,28 @@ MonoBehaviour:
m_EditorClassIdentifier:
beilv: 0
guid:
lastMoveLineId:
monsterData:
die_Score: 0
isDie: 0
fishTypeConfig:
fishNumber:
fishName:
fishBrief:
fishType: 0
fishScore: 0
killWeight: 0
pathList:
fishImage:
fishMultipleDesc:
moveLine:
bezierCurveData:
name:
start: {x: 0, y: 0}
controlPoints: []
end: {x: 0, y: 0}
moveTime: 0
moveSpeed: 0
skeleton: {fileID: 0}
isSpine: 1
fishTypeID: 11030
@@ -7538,7 +7544,7 @@ MonoBehaviour:
- {fileID: 93477760682605764}
- {fileID: 95139269106097999}
lockPoint: {fileID: 93793445555571887}
bingDongEffect: {fileID: 97162546455774594}
bingDongEffect: {fileID: 0}
rotationPY: 60
isRotate: 0
isNot1: 0
@@ -7555,4 +7561,6 @@ MonoBehaviour:
isDieFish: 0
dieTime: 3
v3: {x: 0, y: 0, z: 0}
isLocalCoin: 0
killerSitPos: -1
animator: {fileID: 4384588345448661}
@@ -167,39 +167,31 @@ public class UIHome_BY_VIPPanel : SubUIBase
txt_VIPNFreeGift.text = $"贵族{level}免费礼包";
ShowGiftItems(config.dailyGift, btn_AwardItemParent_Bottom);
// 按钮状态
if (level > vipLevel)
{
btn_Award_Get.gameObject.SetActive(false);
btn_Award_GetEnd.SetActive(false);
btn_Award_NotUnlock.SetActive(true);
}
else
// 按钮状态:只在当前 vip 等级显示领取/已领取按钮,其他等级都不显示
if (level == vipLevel)
{
btn_Award_NotUnlock.SetActive(false);
// 按等级独立判断:vipGift 为未领取的 Vip 礼包等级集合,包含当前等级则可领取
bool canReceive = assets?.vipGift != null && System.Array.IndexOf(assets.vipGift, level) >= 0;
btn_Award_Get.gameObject.SetActive(canReceive);
btn_Award_GetEnd.SetActive(!canReceive);
bool isDayGiftReceived = assets != null && assets.isVipDayGift;
btn_Award_Get.gameObject.SetActive(!isDayGiftReceived);
btn_Award_GetEnd.SetActive(isDayGiftReceived);
if (canReceive)
if (!isDayGiftReceived)
{
btn_Award_Get.onClick.RemoveAllListeners();
btn_Award_Get.onClick.AddListener(() =>
{
// 传入当前查看的等级,领取该等级的每日礼包
APIRequestList.GetVipDayGift(level, result =>
APIRequestList.GetVipDayGift(result =>
{
if (result != null)
{
UIManager.Instance.ShowBoardError("领取成功");
// 拉取服务器最新 UserToken(含更新后的 vipGift),触发 OnUserDataChanged 刷新 UI
APIRequestList.GetUser(user =>
// 手动设置每日礼包已领取状态,并刷新 UI
if (GameManager.Instance.user.assets != null)
{
if (user != null)
GameManager.Instance.UpdataUserData(user);
});
GameManager.Instance.user.assets.isVipDayGift = true;
UpdateVIPPanel(currentDisplayLevel);
}
}
else
{
@@ -209,6 +201,19 @@ public class UIHome_BY_VIPPanel : SubUIBase
});
}
}
else if (level > vipLevel)
{
btn_Award_Get.gameObject.SetActive(false);
btn_Award_GetEnd.SetActive(false);
btn_Award_NotUnlock.SetActive(true);
}
else
{
// 已解锁但非当前等级:不显示任何按钮
btn_Award_Get.gameObject.SetActive(false);
btn_Award_GetEnd.SetActive(false);
btn_Award_NotUnlock.SetActive(false);
}
}
private int GetVIPBGIndex(int level)