diff --git a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll index 2dcbc66e36..3d7d6fdd65 100644 Binary files a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll and b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll differ diff --git a/Assets/PerfectWorld/Scripts/Common/AutoInitializer.cs b/Assets/PerfectWorld/Scripts/Common/AutoInitializer.cs index ff057fee5a..948e25d22c 100644 --- a/Assets/PerfectWorld/Scripts/Common/AutoInitializer.cs +++ b/Assets/PerfectWorld/Scripts/Common/AutoInitializer.cs @@ -94,7 +94,7 @@ namespace BrewMonster } catch (Exception ex) { - Debug.LogError($"AutoInitializer: Failed to initialize {type.FullName}: {ex}"); + Debug.LogError($"AutoInitializer: Failed to initialize {type.FullName}: {ex} {ex.StackTrace}"); } } } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem.cs index 7029fbe58a..430fac1ee8 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem.cs @@ -36,7 +36,8 @@ namespace PerfectWorld.Scripts.Managers var edm = ElementDataManProvider.GetElementDataMan(); if (edm == null) return CacheAndReturn(templateId, ""); uint id = unchecked((uint)templateId); - object data = edm.get_data_ptr(id, ID_SPACE.ID_SPACE_ESSENCE); + DATA_TYPE dATA_TYPE = default; + object data = edm.get_data_ptr(id, ID_SPACE.ID_SPACE_ESSENCE,ref dATA_TYPE); string name = ExtractNameFromElement(data); if (string.IsNullOrEmpty(name)) { diff --git a/Assets/Resources.meta b/Assets/Resources.meta new file mode 100644 index 0000000000..65f71ffd89 --- /dev/null +++ b/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0ee9b2b0487546348a46b02d6183bfd2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/actions_player.txt b/Assets/Resources/actions_player.txt new file mode 100644 index 0000000000..ec3b0d6f32 --- /dev/null +++ b/Assets/Resources/actions_player.txt @@ -0,0 +1,132 @@ +#_begin + +// 0 +站立 +战斗站立 +行走 +奔跑 +起跳 + +// 5 +起跳空中循环 +跳跃落地 +游动 +漂浮 +翅膀起飞 + +// 10 +翅膀悬停 +翅膀前进 +翅膀高空下降 +翅膀低空下降 +翅膀落地 + +// 15 +飞剑起飞 +飞剑悬停 +飞剑前进 +飞剑高空下降 +飞剑低空下降 + +// 20 +飞剑落地 +打坐 +打坐循环 +打坐站起 +受伤 + +// 25 +陆地死亡 +死亡地面循环 +水中死亡 +死亡水中循环 +空中死亡 + +// 30 +空中死亡下落循环 +空中死亡落地 +死亡落地循环 +复活 +长休闲动作头 + +// 35 +被击退 +被击倒 +被击倒倒地循环 +被击倒站起 +采摘 + +// 40 +采摘植物循环 +采摘站起 +捡东西 +伸懒腰 +四处张望 + +// 45 +转动兵器 +招手 +点头 +摇头 +耸肩膀 + +// 50 +大笑 +生气 +晕倒 +沮丧 +飞吻 + +// 55 +害羞 +抱拳 +坐下 +坐下循环 +坐下站起 + +// 60 +冲锋 +思考 +挑衅 +胜利 +亲吻 + +// 65 +亲吻循环 +亲吻结束 +普攻1 +普攻2 +普攻3 + +// 70 +普攻4 +放暗器 +花招跑 +花招跳 +翅膀滑翔 + +// 75 +飞剑滑翔 +战斗 +攻击1 +攻击2 +攻击3 + +// 80 +攻击4 +防御 +摔倒 +倒地 +张望 + +// 85 +舞蹈 +时装武器 +使用物品 +使用物品循环 +双人亲吻 + +// 90 +使用道具 +移动攻击漂浮 +新烟花 \ No newline at end of file diff --git a/Assets/Resources/actions_player.txt.meta b/Assets/Resources/actions_player.txt.meta new file mode 100644 index 0000000000..add7256e5f --- /dev/null +++ b/Assets/Resources/actions_player.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 51f9ac299dd9beb40bde3afc767036bf +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index f9f0ccf0d0..b4f74fda00 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -17,7 +17,7 @@ using static UnityEngine.InputManagerEntry; using Unity.VisualScripting; using PerfectWorld.Scripts.Managers; -public class CECHostPlayer : MonoBehaviour +public class CECHostPlayer : EC_Player { [SerializeField] private TextMeshPro txtName; [SerializeField] private CharacterController controller; @@ -59,6 +59,7 @@ public class CECHostPlayer : MonoBehaviour private void Awake() { + base.Awake(); _moveState = new PlayerMoveState(this); _idleState = new PlayerIdleState(this); _playerStateMachine = new PlayerStateMachine(); diff --git a/Assets/Scripts/CECStringTab.cs b/Assets/Scripts/CECStringTab.cs new file mode 100644 index 0000000000..a283c163f9 --- /dev/null +++ b/Assets/Scripts/CECStringTab.cs @@ -0,0 +1,190 @@ +锘縰sing ModelRenderer.Scripts.Common; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using UnityEngine; // th锚m 膽峄 d霉ng Resources & TextAsset + +public class CECStringTab +{ + private readonly Dictionary m_AStrTab = new Dictionary(); + private readonly Dictionary m_WStrTab = new Dictionary(); + + private bool m_bInit = false; + private bool m_bUnicode = false; + + public CECStringTab() { } + ~CECStringTab() { Release(); } + + public bool Init(string szFile, bool bUnicode) + { + Release(); + m_bUnicode = bUnicode; + + try + { + bool ok = bUnicode ? LoadWideStrings(szFile) : LoadANSIStrings(szFile); + m_bInit = ok; + foreach(var str in m_AStrTab.Values) + { + BrewMonster.Logger.Log("HoangDev: m_AStrTab.Values" + str); + } + return ok; + } + catch (Exception e) + { + Debug.LogError($"[CECStringTab] Init failed: {e}"); + Release(); + return false; + } + } + + public void Release() + { + m_AStrTab.Clear(); + m_WStrTab.Clear(); + m_bInit = false; + m_bUnicode = false; + } + + public string GetANSIString(int n) => m_AStrTab.TryGetValue(n, out var s) ? s : null; + public string GetWideString(int n) => m_WStrTab.TryGetValue(n, out var s) ? s : null; + public string GetWideStringObject(int n) => GetWideString(n); + public bool IsInitialized() => m_bInit; + + // ==== 膼峄峜 t峄 Resources thay v矛 膽瓢峄漬g d岷玭 ==== + + protected bool LoadANSIStrings(string resourceName) + { + TextAsset textAsset = Resources.Load(resourceName); + if (textAsset == null) + { + Debug.LogError($"[CECStringTab] Resource not found: {resourceName}"); + return false; + } + + // Gi岷 m茫 bytes -> string (ANSI: d霉ng Encoding.Default) + string content = ByteToStringUtils.ByteArrayToCP936String(textAsset.bytes); + using var sr = new StringReader(content); + return ParseIntoDict(sr, isWide: false); + } + + protected bool LoadWideStrings(string resourceName) + { + TextAsset textAsset = Resources.Load(resourceName); + if (textAsset == null) + { + Debug.LogError($"[CECStringTab] Resource not found: {resourceName}"); + return false; + } + + // Unity TextAsset m岷穋 膽峄媙h 膽茫 decode text UTF8 -> textAsset.text + // nh瓢ng 膽峄 ch岷痗 ch岷痭 BOM/Unicode th矛 膽峄峜 t峄 bytes + string content; + content = ByteToStringUtils.ByteArrayToUnicodeString(textAsset.bytes); + + using var sr = new StringReader(content); + return ParseIntoDict(sr, isWide: true); + } + + private static Encoding DetectEncoding(byte[] bom) + { + if (bom.Length >= 3 && bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF) return Encoding.UTF8; + if (bom.Length >= 2 && bom[0] == 0xFF && bom[1] == 0xFE) return Encoding.Unicode; + if (bom.Length >= 2 && bom[0] == 0xFE && bom[1] == 0xFF) return Encoding.BigEndianUnicode; + return null; + } + + private bool ParseIntoDict(StringReader sr, bool isWide) + { + bool bIndexMode = false; + bool bBegan = false; + int autoIndex = 0; + + var allLines = new List(); + string line; + while ((line = sr.ReadLine()) != null) + { + allLines.Add(line); + } + + for (int i = 0; i < allLines.Count; i++) + { + var ln = allLines[i].Trim(); + if (ln.Length == 0) continue; + + if (ln.Equals("#_index", StringComparison.OrdinalIgnoreCase)) + { + bIndexMode = true; + } + else if (ln.Equals("#_begin", StringComparison.OrdinalIgnoreCase)) + { + bBegan = true; + + for (int j = i + 1; j < allLines.Count; j++) + { + var payload = allLines[j].Trim(); + if (payload.Length == 0) continue; + if (payload.StartsWith("#")) continue; + + if (bIndexMode) + { + if (!TrySplitIndexAndText(payload, out int idx, out string text)) + continue; + PutString(idx, text, isWide); + } + else + { + PutString(autoIndex++, payload, isWide); + } + } + break; + } + } + + return bBegan; + } + + private static bool TrySplitIndexAndText(string line, out int index, out string text) + { + index = 0; text = null; + + int eq = line.IndexOf('='); + if (eq >= 0) + { + var left = line.Substring(0, eq).Trim(); + var right = line.Substring(eq + 1); + if (int.TryParse(left, out index)) + { + text = right; + return true; + } + return false; + } + + int sp = FirstWhiteSpaceIndex(line); + if (sp <= 0) return false; + + var left2 = line.Substring(0, sp).Trim(); + var right2 = line.Substring(sp).TrimStart(); + if (int.TryParse(left2, out index)) + { + text = right2; + return true; + } + return false; + } + + private static int FirstWhiteSpaceIndex(string s) + { + for (int i = 0; i < s.Length; i++) + if (char.IsWhiteSpace(s[i])) return i; + return -1; + } + + private void PutString(int id, string value, bool isWide) + { + if (isWide) m_WStrTab[id] = value; + else m_AStrTab[id] = value; + } +} diff --git a/Assets/Scripts/CECStringTab.cs.meta b/Assets/Scripts/CECStringTab.cs.meta new file mode 100644 index 0000000000..1f7e39d767 --- /dev/null +++ b/Assets/Scripts/CECStringTab.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: db8df7318b3376c4fb57c2cce332cf85 \ No newline at end of file diff --git a/Assets/Scripts/EC_Utility.cs b/Assets/Scripts/EC_Utility.cs index 9acaef124a..c73501799b 100644 --- a/Assets/Scripts/EC_Utility.cs +++ b/Assets/Scripts/EC_Utility.cs @@ -1,5 +1,8 @@ -锘縰sing System; +锘縰sing BrewMonster; +using System; +using System.Collections; using UnityEngine; +using static EC_Player; public static class EC_Utility { @@ -30,8 +33,22 @@ public static class EC_Utility { return new System.Numerics.Vector3(v.x, v.y, v.z); } - public static float MagnitudeH(this Vector3 v) + public static float MagnitudeH(this Vector3 v) { return Mathf.Sqrt(v.x * v.x + v.z * v.z); } + public static string BuildActionName(PLAYER_ACTION action, int weaponType) + { + string prefix = action.data.ActionPrefix ?? string.Empty; + string suffix = string.Empty; + + if (action.data.action_weapon_suffix != null + && weaponType >= 0 + && weaponType < action.data.action_weapon_suffix.Length) + { + suffix = action.data.action_weapon_suffix[weaponType].Suffix ?? string.Empty; + } + + return $"{prefix}_{suffix}"; + } } diff --git a/Assets/Scripts/EventBus.cs b/Assets/Scripts/EventBus.cs deleted file mode 100644 index a140341591..0000000000 --- a/Assets/Scripts/EventBus.cs +++ /dev/null @@ -1,261 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Timers; -using UnityEngine; - -public static class EventBus -{ - private static readonly Dictionary globalListeners = new(); - private static readonly Dictionary globalClassListeners = new(); - - private static readonly Dictionary> channelListeners = new(); - private static readonly Dictionary> channelClassListeners = new(); - - private static Timer cleanupTimer; - - public static bool DebugEnabled = false; - - private static void DebugLog(string message) - { - if (DebugEnabled) - Console.WriteLine($"[EventBus] {message}"); - } - - // ===== GLOBAL STRUCT EVENTS ===== - public static void Subscribe(Action listener) where T : struct - { - var type = typeof(T); - - if (!globalListeners.ContainsKey(typeof(T))) - globalListeners[type] = null; - - globalListeners[type] = (Action)globalListeners[type] + listener; - } - - public static void Unsubscribe(Action listener) where T : struct - { - var type = typeof(T); - if (globalListeners.ContainsKey(typeof(T))) - { - globalListeners[type] = (Action)globalListeners[type] - listener; - if (globalListeners[type] == null) - globalListeners.Remove(type); - } - } - - public static void Publish(T eventData) where T : struct - { - var type = typeof(T); - if (globalListeners.TryGetValue(type, out var del) && del is Action action) - { - DebugLog($"Publish Global Struct Event: {typeof(T).Name}"); - action.Invoke(eventData); - } - } - - // ===== GLOBAL CLASS EVENTS ===== - public static void SubscribeClass(Action listener) where T : class - { - var type = typeof(T); - if (!globalClassListeners.ContainsKey(type)) - globalClassListeners[type] = null; - - globalClassListeners[type] = (Action)globalClassListeners[type] + listener; - } - - public static void UnsubscribeClass(Action listener) where T : class - { - var type = typeof(T); - if (globalClassListeners.ContainsKey(type)) - { - globalClassListeners[type] = (Action)globalClassListeners[type] - listener; - if (globalClassListeners[type] == null) - globalClassListeners.Remove(type); - } - } - - public static void PublishClass(T eventData) where T : class - { - var type = typeof(T); - if (globalClassListeners.TryGetValue(type, out var del) && del is Action action) - { - DebugLog($"Publish Global Class Event: {typeof(T).Name}"); - action.Invoke(eventData); - } - } - - // ===== CHANNEL STRUCT EVENTS ===== - public static void SubscribeChannel(int channelId, Action listener) where T : struct - { - var type = typeof(T); - - if (!channelListeners.ContainsKey(channelId)) - channelListeners[channelId] = new Dictionary(); - - if (!channelListeners[channelId].ContainsKey(type)) - channelListeners[channelId][type] = null; - - channelListeners[channelId][type] = (Action)channelListeners[channelId][type] + listener; - } - - public static void UnsubscribeChannel(int channelId, Action listener) where T : struct - { - var type = typeof(T); - if (channelListeners.ContainsKey(channelId) && channelListeners[channelId].ContainsKey(type)) - { - channelListeners[channelId][type] = (Action)channelListeners[channelId][type] - listener; - if (channelListeners[channelId][type] == null) - channelListeners[channelId].Remove(type); - if (channelListeners[channelId].Count == 0) - channelListeners.Remove(channelId); - } - } - - public static void PublishChannel(int channelId, T eventData) where T : struct - { - var type = typeof(T); - if (channelListeners.TryGetValue(channelId, out var listeners) && - listeners.TryGetValue(type, out var del) && - del is Action action) - { - DebugLog($"Publish Channel Struct Event: {type.Name} to channel '{channelId}'"); - action.Invoke(eventData); - } - } - - // ===== CHANNEL CLASS EVENTS ===== - public static void SubscribeChannelClass(int channelId, Action listener) where T : class - { - var type = typeof(T); - if (!channelClassListeners.ContainsKey(channelId)) - channelClassListeners[channelId] = new Dictionary(); - - if (!channelClassListeners[channelId].ContainsKey(type)) - channelClassListeners[channelId][type] = null; - - channelClassListeners[channelId][type] = (Action)channelClassListeners[channelId][type] + listener; - } - - public static void UnsubscribeChannelClass(int channelId, Action listener) where T : class - { - var type = typeof(T); - if (channelClassListeners.ContainsKey(channelId) && channelClassListeners[channelId].ContainsKey(type)) - { - channelClassListeners[channelId][type] = (Action)channelClassListeners[channelId][type] - listener; - if (channelClassListeners[channelId][type] == null) - channelClassListeners[channelId].Remove(type); - if (channelClassListeners[channelId].Count == 0) - channelClassListeners.Remove(channelId); - } - } - - public static void PublishChannelClass(int channelId, T eventData) where T : class - { - var type = typeof(T); - if (channelClassListeners.TryGetValue(channelId, out var listeners) && - listeners.TryGetValue(type, out var del) && - del is Action action) - { - DebugLog($"Publish Channel Class Event: {type.Name} to channel '{channelId}'"); - action.Invoke(eventData); - } - } - - // ===== ONE-TIME SUBSCRIBE ===== - public static void SubscribeOnce(Action listener) where T : struct - { - Action wrapper = null; - wrapper = (data) => - { - listener(data); - Unsubscribe(wrapper); - }; - Subscribe(wrapper); - } - - public static void SubscribeOnceClass(Action listener) where T : class - { - Action wrapper = null; - wrapper = (data) => - { - listener(data); - UnsubscribeClass(wrapper); - }; - SubscribeClass(wrapper); - } - - public static void SubscribeOnceChannel(int channelId, Action listener) where T : struct - { - Action wrapper = null; - wrapper = (data) => - { - listener(data); - UnsubscribeChannel(channelId, wrapper); - }; - SubscribeChannel(channelId, wrapper); - } - - public static void SubscribeOnceChannelClass(int channelId, Action listener) where T : class - { - Action wrapper = null; - wrapper = (data) => - { - listener(data); - UnsubscribeChannelClass(channelId, wrapper); - }; - SubscribeChannelClass(channelId, wrapper); - } - - // ===== CHANNEL UTILITIES ===== - public static bool ChannelExists(int channelId) - { - return channelListeners.ContainsKey(channelId) || channelClassListeners.ContainsKey(channelId); - } - - public static void EnableAutoCleanup(float delaySeconds = 5f) - { - cleanupTimer = new Timer(delaySeconds * 1000); - cleanupTimer.Elapsed += (sender, e) => - { - var emptyStructChannels = channelListeners - .Where(pair => pair.Value.Values.All(d => d == null)) - .Select(pair => pair.Key) - .ToList(); - - foreach (var id in emptyStructChannels) - { - channelListeners.Remove(id); - DebugLog($"Removed empty struct channel: {id}"); - } - - var emptyClassChannels = channelClassListeners - .Where(pair => pair.Value.Values.All(d => d == null)) - .Select(pair => pair.Key) - .ToList(); - - foreach (var id in emptyClassChannels) - { - channelClassListeners.Remove(id); - DebugLog($"Removed empty class channel: {id}"); - } - }; - cleanupTimer.AutoReset = true; - cleanupTimer.Start(); - } -#if UNITY_EDITOR - public static void LogAllActiveListeners() - { - foreach (var kv in globalListeners) - { - var methods = kv.Value?.GetInvocationList(); - if (methods != null && methods.Length > 0) - { - Debug.LogWarning($"[EventBus Leak] {kv.Key.Name} still has {methods.Length} listeners:"); - foreach (var m in methods) - Debug.LogWarning($" - Target: {m.Target}, Method: {m.Method}"); - } - } - } -#endif -} diff --git a/Assets/Scripts/EventBus.cs.meta b/Assets/Scripts/EventBus.cs.meta deleted file mode 100644 index bde522192d..0000000000 --- a/Assets/Scripts/EventBus.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: f24ba7881ac213b4e905d525121d0a95 \ No newline at end of file diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index ace92d1263..31ed432380 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -57,6 +57,7 @@ public class GameController : MonoBehaviour Debug.LogError("null prefab"); return; } + EC_Player.InitStaticRes(); hostPlayer = Instantiate(characterPrefab, transform); hostPlayer.InitCharacter(info); //Vector3 pos = new Vector3(info.pos.x, info.pos.y, info.pos.z); diff --git a/Assets/Scripts/InitializePlayer.cs b/Assets/Scripts/InitializePlayer.cs new file mode 100644 index 0000000000..74f9de84a2 --- /dev/null +++ b/Assets/Scripts/InitializePlayer.cs @@ -0,0 +1,15 @@ +using BrewMonster; +using UnityEngine; + +public class InitializePlayer /*: IAutoInitialize*/ +{ + public void Dispose() + { + EC_Player.Dispose(); + } + + public void Initialize() + { + EC_Player.InitStaticRes(); + } +} diff --git a/Assets/Scripts/InitializePlayer.cs.meta b/Assets/Scripts/InitializePlayer.cs.meta new file mode 100644 index 0000000000..4d7598a16b --- /dev/null +++ b/Assets/Scripts/InitializePlayer.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d693d80f20d058a4786bf8234eeb0ce3 \ No newline at end of file diff --git a/Assets/Scripts/Move/EC_Player.cs b/Assets/Scripts/Move/EC_Player.cs index 052a19326b..e2b6fd176c 100644 --- a/Assets/Scripts/Move/EC_Player.cs +++ b/Assets/Scripts/Move/EC_Player.cs @@ -1,6 +1,267 @@ +锘縰sing BrewMonster; +using ModelRenderer.Scripts.GameData; +using Mono.Cecil; +using System.Collections.Generic; using UnityEngine; -public class EC_Player +public class EC_Player : MonoBehaviour { - public Bounds m_aabbServer; + private static PLAYER_ACTION[] _default_actions; + private static PLAYER_ACTION[] _turning_actions; + PLAYER_ACTION[] m_PlayerActions; + + protected void Awake() + { + m_PlayerActions = _default_actions; + BrewMonster.Logger.Log("m_PlayerActions " + m_PlayerActions.Length); + } + + public static void InitStaticRes() + { + BuildActionList(); + } + private static void BuildActionList() + { + if (_default_actions == null) + { + // thay cho hashtab trong C++ + Dictionary actionMap = + new Dictionary(100); + + Dictionary skillActionMap = + new Dictionary(100); + + elementdataman dataman = ElementDataManProvider.GetElementDataMan(); + PLAYER_ACTION_INFO_CONFIG data; + + int count = dataman.get_data_num(ID_SPACE.ID_SPACE_CONFIG); + + DATA_TYPE dt = default; + uint id = 0; + + for (int i = 0; i < count; ++i) + { + id = dataman.get_data_id(ID_SPACE.ID_SPACE_CONFIG, i, ref dt); + if (dt != DATA_TYPE.DT_PLAYER_ACTION_INFO_CONFIG) + continue; + + data = (PLAYER_ACTION_INFO_CONFIG)dataman.get_data_ptr(id, ID_SPACE.ID_SPACE_CONFIG, ref dt); + if (!string.IsNullOrEmpty(data.ActionName) && data.ActionName[0] != '0') + { + if (!actionMap.TryAdd(data.ActionName, data)) + { + + } + } + } + + CECStringTab actionNames = new CECStringTab(); + actionNames.Init("actions_player", false); + + _default_actions = new PLAYER_ACTION[(int)PLAYER_ACTION_TYPE.ACT_MAX]; + + for (int i = 0; i < _default_actions.Length; i++) + { + _default_actions[i].type = (PLAYER_ACTION_TYPE)i; + + string szName = actionNames.GetANSIString(i); + BrewMonster.Logger.Log("HoangDev: szName " + szName); + + if (!string.IsNullOrEmpty(szName)) + { + if (actionMap.TryGetValue(szName, out var it)) + { + + _default_actions[i].data = it; + } + } + } + } + } + public bool PlayAction(int iAction, bool bRestart/* true */, int iTransTime/* 200 */, bool bQueue/* false */) + { + return PlayActionWithConfig(iAction, 0, bRestart, iTransTime, bQueue); + } + public bool PlayActionWithConfig(int iAction, int actionConfigID, bool bRestart/* =true */, int iTransTime/* =200 */, bool bQueue/* =false */) + { + if (iAction < 0 || iAction >= (int)PLAYER_ACTION_TYPE.ACT_MAX) + { + return false; + } + if (actionConfigID > 0) + { + DATA_TYPE dt = DATA_TYPE.DT_INVALID; + var p = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)actionConfigID, ID_SPACE. ID_SPACE_CONFIG, ref dt); + if (dt == DATA_TYPE.DT_PLAYER_ACTION_INFO_CONFIG) + { + PLAYER_ACTION actionConfig; + actionConfig.type = (PLAYER_ACTION_TYPE)iAction; + actionConfig.data = (PLAYER_ACTION_INFO_CONFIG) p; + return PlayActionWithConfig(iAction, actionConfig, bRestart, iTransTime, bQueue); + } + else + { + BrewMonster.Logger.LogError($"CECPlayer::PlayActionWithConfig, invalid action config ID({actionConfigID})"); + } + } + return PlayActionWithConfig(iAction, m_PlayerActions[iAction], bRestart, iTransTime, bQueue); + } + public bool PlayActionWithConfig(int iAction, in PLAYER_ACTION actionConfig, + bool bRestart = true, int iTransTime = 200, bool bQueue = false) + { + PLAYER_ACTION action = actionConfig; + + var szAct = EC_Utility.BuildActionName(action, 10); + + BrewMonster.Logger.Log("HoangDev : szActszAct " + szAct); + return true; + } + public static void Dispose() + { + _default_actions = null; + _turning_actions = null; + } + + + public struct PLAYER_ACTION + { + public PLAYER_ACTION_TYPE type; + public PLAYER_ACTION_INFO_CONFIG data; + }; + public enum PLAYER_ACTION_TYPE + { + // 0 + ACT_STAND = 0, // 膼峄﹏g + ACT_FIGHTSTAND, // 膼峄﹏g chi岷縩 膽岷 + ACT_WALK, // 膼i b峄 + ACT_RUN, // Ch岷 + ACT_JUMP_START, // B岷痶 膽岷 nh岷 + + // 5 + ACT_JUMP_LOOP, // Nh岷 tr锚n kh么ng l岷穚 l岷 + ACT_JUMP_LAND, // Nh岷 ti岷縫 膽岷 + ACT_SWIM, // B啤i + ACT_HANGINWATER, // L啤 l峄璶g trong n瓢峄沜 + ACT_TAKEOFF, // C岷 c谩nh (should be ACT_TAKEOFF_WING) + + // 10 + ACT_HANGINAIR, // Treo tr锚n kh么ng (should be ACT_HANGINAIR_WING) + ACT_FLY, // Bay (should be ACT_FLY_WING) + ACT_FLYDOWN, // Bay xu峄憂g cao (should be ACT_FLYDOWN_WING_HIGH) + ACT_FLYDOWN_WING_LOW, // Bay xu峄憂g th岷 (should be ACT_FLYDOWN_WING_LOW) + ACT_LANDON, // H岷 c谩nh (should be ACT_LAND_WING) + + // 15 + ACT_TAKEOFF_SWORD, // Ki岷縨 bay - c岷 c谩nh + ACT_HANGINAIR_SWORD, // Ki岷縨 bay - treo kh么ng trung + ACT_FLY_SWORD, // Ki岷縨 bay - ti岷縩 t峄沬 + ACT_FLYDOWN_SWORD_HIGH, // Ki岷縨 bay - r啤i cao + ACT_FLYDOWN_SWORD_LOW, // Ki岷縨 bay - r啤i th岷 + + // 20 + ACT_LANDON_SWORD, // Ki岷縨 bay - h岷 c谩nh + ACT_SITDOWN, // Ng峄搃 + ACT_SITDOWN_LOOP, // Ng峄搃 l岷穚 l岷 + ACT_STANDUP, // 膼峄﹏g d岷瓂 + ACT_WOUNDED, // B峄 th瓢啤ng + + // 25 + ACT_GROUNDDIE, // Ch岷縯 tr锚n m岷穞 膽岷 + ACT_GROUNDDIE_LOOP, // Ch岷縯 tr锚n 膽岷 (loop) + ACT_WATERDIE, // Ch岷縯 trong n瓢峄沜 + ACT_WATERDIE_LOOP, // Ch岷縯 trong n瓢峄沜 (loop) + ACT_AIRDIE_ST, // Ch岷縯 tr锚n kh么ng (b岷痶 膽岷) + + // 30 + ACT_AIRDIE, // Ch岷縯 tr锚n kh么ng (loop r啤i) + ACT_AIRDIE_ED, // Ch岷縯 tr锚n kh么ng (ch岷 膽岷) + ACT_AIRDIE_LAND_LOOP, // Ch岷縯 r啤i 膽岷 (loop) + ACT_REVIVE, // H峄搃 sinh + ACT_CUSTOMIZE, // 膼峄檔g t谩c t霉y ch峄塶h + + // 35 + ACT_STRIKEBACK, // B峄 膽谩nh l霉i + ACT_STRIKEDOWN, // B峄 膽谩nh ng茫 + ACT_STRIKEDOWN_LOOP, // B峄 膽谩nh ng茫 (loop) + ACT_STRIKEDOWN_STANDUP, // B峄 膽谩nh ng茫 r峄搃 膽峄﹏g d岷瓂 + ACT_PICKUP, // Nh岷穞 膽峄 + + // 40 + ACT_PICKUP_LOOP, // Nh岷穞 膽峄 (loop) + ACT_PICKUP_STANDUP, // Nh岷穞 膽峄 膽峄﹏g d岷瓂 + ACT_PICKUP_MATTER, // Nh岷穞 v岷璽 th峄 + ACT_GAPE, // H谩 mi峄噉g + ACT_LOOKAROUND, // Nh矛n quanh + + // 45 + ACT_PLAYWEAPON, // Vung v农 kh铆 + ACT_EXP_WAVE, // V岷珁 tay + ACT_EXP_NOD, // G岷璽 膽岷 + ACT_EXP_SHAKEHEAD, // L岷痗 膽岷 + ACT_EXP_SHRUG, // Nh煤n vai + + // 50 + ACT_EXP_LAUGH, // C瓢峄漣 l峄沶 + ACT_EXP_ANGRY, // T峄ヽ gi岷璶 + ACT_EXP_STUN, // Cho谩ng + ACT_EXP_DEPRESSED, // Bu峄搉 b茫 + ACT_EXP_KISSHAND, // H么n tay + + // 55 + ACT_EXP_SHY, // Ng岷 ng霉ng + ACT_EXP_SALUTE, // Ch脿o + ACT_EXP_SITDOWN, // Ng峄搃 xu峄憂g + ACT_EXP_SITDOWN_LOOP, // Ng峄搃 xu峄憂g (loop) + ACT_EXP_SITDOWN_STANDUP, // Ng峄搃 xu峄憂g r峄搃 膽峄﹏g d岷瓂 + + // 60 + ACT_EXP_ASSAULT, // T岷 c么ng + ACT_EXP_THINK, // Suy ngh末 + ACT_EXP_DEFIANCE, // Th谩ch th峄ヽ + ACT_EXP_VICTORY, // Chi岷縩 th岷痭g + ACT_EXP_KISS, // H么n + + // 65 + ACT_EXP_KISS_LOOP, // H么n (loop) + ACT_EXP_KISS_END, // K岷縯 th煤c h么n + ACT_ATTACK_1, // T岷 c么ng 1 + ACT_ATTACK_2, // T岷 c么ng 2 + ACT_ATTACK_3, // T岷 c么ng 3 + + // 70 + ACT_ATTACK_4, // T岷 c么ng 4 + ACT_ATTACK_TOSS, // N茅m v农 kh铆 + ACT_TRICK_RUN, // Chi锚u khi ch岷 + ACT_TRICK_JUMP, // Chi锚u khi nh岷 + ACT_FLY_GLIDE, // L瓢峄 + + // 75 + ACT_FLY_GLIDE_SWORD, // Ki岷縨 bay - l瓢峄 + ACT_EXP_FIGHT, // T瓢 th岷 chi岷縩 膽岷 + ACT_EXP_ATTACK1, // T岷 c么ng di峄卬 xu岷 1 + ACT_EXP_ATTACK2, // T岷 c么ng di峄卬 xu岷 2 + ACT_EXP_ATTACK3, // T岷 c么ng di峄卬 xu岷 3 + + // 80 + ACT_EXP_ATTACK4, // T岷 c么ng di峄卬 xu岷 4 + ACT_EXP_DEFENCE, // Ph貌ng th峄 + ACT_EXP_FALL, // T茅 ng茫 + ACT_EXP_FALLONGROUND, // Ng茫 xu峄憂g 膽岷 + ACT_EXP_LOOKAROUND, // Nh矛n quanh + + // 85 + ACT_EXP_DANCE, // Nh岷 m煤a + ACT_EXP_FASHIONWEAPON, // 膼峄檔g t谩c v农 kh铆 th峄漣 trang + ACT_USEITEM, // D霉ng item + ACT_USEITMELOOP, // D霉ng item (loop) + ACT_TWO_KISS, // H么n 膽么i + + // 90 + ACT_USING_TARGET_ITEM, // D霉ng 膽岷 c峄 + ACT_SWIM_FOR_MOVESKILL, // B啤i trong l煤c d霉ng skill di chuy峄僴 + + ACT_MAX, + ACT_CASTSKILL // Ch峄 l脿 placeholder cho skill actions + } + } diff --git a/Assets/Scripts/PlayerState/PlayerMoveState.cs b/Assets/Scripts/PlayerState/PlayerMoveState.cs index d884b4cce0..e82e7f53a4 100644 --- a/Assets/Scripts/PlayerState/PlayerMoveState.cs +++ b/Assets/Scripts/PlayerState/PlayerMoveState.cs @@ -1,4 +1,5 @@ using UnityEngine; +using static EC_Player; public class PlayerMoveState : PlayerState { @@ -8,7 +9,7 @@ public class PlayerMoveState : PlayerState public override void Enter() { - + _characterCtrl.PlayAction((int)PLAYER_ACTION_TYPE.ACT_WALK,true,1,false); } public override void Exit() diff --git a/Assets/Scripts/PlayerStateMachine.cs b/Assets/Scripts/PlayerStateMachine.cs index 855db49398..787af10b2d 100644 --- a/Assets/Scripts/PlayerStateMachine.cs +++ b/Assets/Scripts/PlayerStateMachine.cs @@ -13,6 +13,7 @@ public class PlayerStateMachine return; } _state = state; + _state.Enter(); } public void ChangeState(PlayerState state) diff --git a/Assets/Scripts/SelecScreenCharacter.cs b/Assets/Scripts/SelecScreenCharacter.cs index 86d5c7c227..1af673c7f3 100644 --- a/Assets/Scripts/SelecScreenCharacter.cs +++ b/Assets/Scripts/SelecScreenCharacter.cs @@ -13,10 +13,8 @@ namespace BrewMonster.UI public void InitScreen(List roleInfos, Action OnClickItemChar) { - Logger.Log($"InitScreen {roleInfos.Count}"); foreach(RoleInfo info in roleInfos) { - Logger.Log($"Role Name {info.roleid}"); CharacterItemUI item = Instantiate(characterItemPrefab, parentItems).GetComponent(); item.InitItem(info, OnClickItemChar); } diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index aa5a1c3e31..3bb036aaa3 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -36,10 +36,8 @@ GraphicsSettings: - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_PreloadShadersBatchTimeLimit: -1 - m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, - type: 0} - m_CustomRenderPipeline: {fileID: 11400000, guid: 4b83569d67af61e458304325a23e5dfd, - type: 2} + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_CustomRenderPipeline: {fileID: 11400000, guid: 4b83569d67af61e458304325a23e5dfd, type: 2} m_TransparencySortMode: 0 m_TransparencySortAxis: {x: 0, y: 0, z: 1} m_DefaultRenderingPath: 1 @@ -60,9 +58,8 @@ GraphicsSettings: m_FogKeepExp2: 1 m_AlbedoSwatchInfos: [] m_RenderPipelineGlobalSettingsMap: - UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 18dc0cd2c080841dea60987a38ce93fa, - type: 2} - m_LightsUseLinearIntensity: 1 + UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 18dc0cd2c080841dea60987a38ce93fa, type: 2} + m_LightsUseLinearIntensity: 0 m_LightsUseColorTemperature: 1 m_LogWhenShaderIsCompiled: 0 m_LightProbeOutsideHullStrategy: 0