From 094f1d4f485f80bfbb7558c67faf43ba486676b0 Mon Sep 17 00:00:00 2001 From: azw Date: Sat, 18 May 2024 16:20:42 +0800 Subject: [PATCH] 1 --- F6/MetaTable.cs | 117 ++++++++++++++++++++++++++++++++++++++++++ Managers/BattleMgr.cs | 52 +++++++++++++++++-- Mt/Equip.cs | 12 +++++ Mtb/Equip.cs | 13 +++++ 4 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 F6/MetaTable.cs create mode 100644 Mt/Equip.cs create mode 100644 Mtb/Equip.cs diff --git a/F6/MetaTable.cs b/F6/MetaTable.cs new file mode 100644 index 0000000..be23f64 --- /dev/null +++ b/F6/MetaTable.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Collections; +using System.Collections.Generic; + +namespace F6 +{ + public delegate bool TraverseCb(T ele); + + public interface IMetaTable + { + bool IsNoLoad() + { + return false; + } + + void Load() + { + + } + + void PreInit1() + { + + } + + void ElementsInit(int round) + { + + } + + void PostInit1() + { + + } + + } + + public class RawMetaTable: IMetaTable + { + + + protected string fileName; + protected string primKey; + protected bool noLoad; + protected List rawList = new List(); + + public void Traverse(TraverseCb cb) + { + foreach(var item in this.rawList) + { + if (!cb(item)) + { + break; + } + } + } + + public T RandElement() + { + if (this.rawList.Count > 0) + { + + return this.rawList[new Random().Next(0, this.rawList.Count)]; + } + return default(T); + } + + public virtual void Load() + { + + } + + protected virtual void LoadPost() + { + + } + } + + public class IdMetaTable: RawMetaTable + { + protected Dictionary idHash = new Dictionary (); + + public T GetById(Int64 id) + { + T v = default(T); + this.idHash.TryGetValue(id, out v); + return v; + } + + protected override void LoadPost() + { + base.LoadPost(); + } + } + + public class NameMetaTable: RawMetaTable + { + protected Dictionary nameHash = new Dictionary(); + + public T GetByName(string key) + { + T v = default(T); + this.nameHash.TryGetValue(key, out v); + return v; + } + + protected override void LoadPost() + { + base.LoadPost(); + } + } + +} diff --git a/Managers/BattleMgr.cs b/Managers/BattleMgr.cs index 96ff029..d6529ce 100644 --- a/Managers/BattleMgr.cs +++ b/Managers/BattleMgr.cs @@ -1,13 +1,40 @@ using UnityEngine; using LuaFramework; +using BestHTTP; +using BestHTTP.WebSocket; +using System; +using Newtonsoft; +using System.Collections.Generic; + +public class Test +{ + //[Newtonsoft.Json.JsonConverter(typeof(string))] + public string id; + [Newtonsoft.Json.JsonProperty("Name")] + public string name; + public int age; +} public class BattleMgr { + public static void StartBattle(JoinInfo join_info) { //CUILoading.OpenLoading(); //CUILoading.SetLoading(0); + string path = Application.dataPath; + try + { + var test = Newtonsoft.Json.JsonConvert.DeserializeObject>("{\"id\":123423.45454, \"Name\":\"Test\", \"age\":38.4344}"); + int i = 2; + var t1 = new Test(); + + }catch(Exception e) + { + int i = 0; + } + GameObject fightRootObject = new GameObject("fight"); { fightRootObject.transform.parent = LuaHelper.GetGameManager().m_pGameMap.transform; @@ -21,17 +48,32 @@ public class BattleMgr TransformExtension.localScale(mapObj.transform, 1, 1, 1); } var mapBase = LuaHelper.GetResManager().LoadPrefab("map16", "Data/model/mapterrain/", "model/mapterrain"); + var t = CUtil.AddChild(mapObj, mapBase, true); { - var t = CUtil.AddChild(mapObj, mapBase, true); TransformExtension.localEulerAngles(t.transform, 0, 0, 0); TransformExtension.localPosition(t.transform, 0, 0, 0); } { - var terrainName = "1_" + "map16"; - var terrainObj = LuaHelper.GetResManager().LoadPrefab(terrainName, "Data/model/mapterrain/", "model/mapterrain"); - terrainObj.localEulerAngle(terrainObj.tanasform, 0, 0, 0); - terrainObj.localPosition(terrainObj.transfrom, 0, 0, 0); + var terrainName = "l_" + "map16"; + var terrainObj = LuaHelper.GetResManager().LoadPrefab( + terrainName, "Data/model/mapterrain/", "model/mapterrain"); + CUtil.AddChild(t, terrainObj, true); + TransformExtension.localEulerAngles(terrainObj.transform, 0, 0, 0); + TransformExtension.localPosition(terrainObj.transform, 0, 0, 0); } } + + public static void StartNet(JoinInfo join_info) + { + /* + var m_webSocket = new WebSocket(new Uri("192.168.100.21")); + m_webSocket.OnOpen += BattleMgr.OnOpen; + m_webSocket.OnBinary += BattleMgr.OnBinaryReceived; + m_webSocket.OnError += BattleMgr.OnError; + m_webSocket.OnClosed += BattleMgr.OnClosed; + m_webSocket.Open();*/ + + } + } diff --git a/Mt/Equip.cs b/Mt/Equip.cs new file mode 100644 index 0000000..da9e4d4 --- /dev/null +++ b/Mt/Equip.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace cfclient.Mt +{ + class Equip + { + } +} diff --git a/Mtb/Equip.cs b/Mtb/Equip.cs new file mode 100644 index 0000000..938775b --- /dev/null +++ b/Mtb/Equip.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace cfclient.Mtb +{ + class Equip + { + public int id { get; } + } +}