This commit is contained in:
azw 2024-05-23 08:55:13 +08:00
parent 3c8df7a0f0
commit d94a18c827
7 changed files with 108 additions and 31 deletions

View File

@ -84,7 +84,7 @@ namespace F6
if (this.handlerHash.TryGetValue(msgId, out handler))
{
var msg = handler.createMsg();
msg.Descriptor.Parser.ParseFrom(data, offset, length);
msg = msg.Descriptor.Parser.ParseFrom(data, offset, length);
foreach (var h in handler.handlers)
{
h(msg);

View File

@ -5,11 +5,16 @@ using System.Text;
using System.Threading.Tasks;
using Google.Protobuf;
using UnityEngine;
using LuaFramework;
class Battle
{
private JoinInfo joinInfo;
private Net.ClientNet conn;
private int netMapId = 0;
private int netMyselfUniId = 0;
private string netRoomUuid;
private Mt.Map mapMeta;
public Battle(JoinInfo joinInfo)
{
@ -29,8 +34,55 @@ class Battle
this.conn.Open();
this.conn.msgHandler.RegisterHandler((battle.cs.SMJoinedNotify msg) =>
{
int i = 0;
});
this.conn.msgHandler.RegisterHandler((battle.cs.SMMapInfo msg) =>
{
this.SMMapInfo(msg);
});
this.conn.msgHandler.RegisterHandler((battle.cs.SMUpdate msg) =>
{
this.SMUpdate(msg);
});
}
private void SMMapInfo(battle.cs.SMMapInfo msg)
{
this.netMapId = msg.MapId;
this.netMyselfUniId = msg.PlayerId;
this.netRoomUuid = msg.RoomUuid;
this.mapMeta = Mt.Table.Map.GetById(this.netMapId);
GameObject fightRootObject = new GameObject("fight");
{
fightRootObject.transform.parent = LuaHelper.GetGameManager().m_pGameMap.transform;
fightRootObject.layer = CUtil.WorldMapLayer_0_31;
}
GameObject mapObj = new GameObject("map");
{
mapObj.transform.parent = fightRootObject.transform;
mapObj.layer = CUtil.WorldMapLayer_0_31;
TransformExtension.localPosition(mapObj.transform, 0, 0, 0);
TransformExtension.localScale(mapObj.transform, 1, 1, 1);
}
var mapBase = LuaHelper.GetResManager().LoadPrefab<GameObject>(this.mapMeta.asset_name, "Data/model/mapterrain/", "model/mapterrain");
var t = CUtil.AddChild(mapObj, mapBase, true);
{
TransformExtension.localEulerAngles(t.transform, 0, 0, 0);
TransformExtension.localPosition(t.transform, 0, 0, 0);
}
{
var terrainName = "l_" + this.mapMeta.asset_name;
var terrainObj = LuaHelper.GetResManager().LoadPrefab<GameObject>(
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);
}
}
private void SMUpdate(battle.cs.SMUpdate msg)
{
}
}

View File

@ -14,35 +14,7 @@ public class BattleMgr
//CUILoading.OpenLoading();
//CUILoading.SetLoading(0);
Mt.Table.Load();
GameObject fightRootObject = new GameObject("fight");
{
fightRootObject.transform.parent = LuaHelper.GetGameManager().m_pGameMap.transform;
fightRootObject.layer = CUtil.WorldMapLayer_0_31;
}
GameObject mapObj = new GameObject("map");
{
mapObj.transform.parent = fightRootObject.transform;
mapObj.layer = CUtil.WorldMapLayer_0_31;
TransformExtension.localPosition(mapObj.transform, 0, 0, 0);
TransformExtension.localScale(mapObj.transform, 1, 1, 1);
}
var mapBase = LuaHelper.GetResManager().LoadPrefab<GameObject>("map16", "Data/model/mapterrain/", "model/mapterrain");
var t = CUtil.AddChild(mapObj, mapBase, true);
{
TransformExtension.localEulerAngles(t.transform, 0, 0, 0);
TransformExtension.localPosition(t.transform, 0, 0, 0);
}
{
var terrainName = "l_" + "map16";
var terrainObj = LuaHelper.GetResManager().LoadPrefab<GameObject>(
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);
}
{
var b = new Battle(join_info);
}
var b = new Battle(join_info);
}
}

13
Objects/Actor.cs Normal file
View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cfclient.Objects
{
class Actor : WorldObject
{
}
}

12
Objects/Car.cs Normal file
View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cfclient.Objects
{
class Car : Actor
{
}
}

12
Objects/Player.cs Normal file
View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cfclient.Objects
{
class Player : Actor
{
}
}

16
Objects/WorldObject.cs Normal file
View File

@ -0,0 +1,16 @@
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cfclient.Objects
{
class WorldObject
{
private int uniid;
private Vector3 serverPos = new Vector3();
private GameObject gameObject;
}
}