Skip to content

Commit

Permalink
feat: ✨ .
Browse files Browse the repository at this point in the history
  • Loading branch information
hhzzff committed Apr 26, 2024
1 parent 2212b2f commit 8942193
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 57 deletions.
39 changes: 30 additions & 9 deletions interface/interface_live/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,36 @@ MonoBehaviour:
- p:
- {fileID: 1304984658260562521, guid: 693d92e1c7f9c6e4597faf934cdb42c0, type: 3}
- {fileID: 2191818354525212035, guid: 4ad9c437da4f8d1468ea72a9be373c8b, type: 3}
- p: []
- p: []
- p: []
- p: []
- p: []
- p: []
shiplist: []
bulletList: []
constructionList: []
- p:
- {fileID: 6520599987196359259, guid: acca4bed1be3e314191cd041b6718c5a, type: 3}
- p:
- {fileID: 73901610976941151, guid: c7b49a90d8bef8d46a4bce231bbd4bbc, type: 3}
- {fileID: 2076829689532050399, guid: 22ca1ac7000005944a2fb85b1ddb6e7f, type: 3}
- {fileID: 889495328777635882, guid: d7a44630d1355954f85ba41057cccb41, type: 3}
- p:
- {fileID: 2817536373982564735, guid: d43c88f52cfe70248899ea9ef8cfe8a2, type: 3}
- {fileID: 6689915564642265873, guid: 904adecf3b36a41439687b01ef339180, type: 3}
- {fileID: 667973134933400006, guid: 8787298c21a136d48a2b6956ab9c2277, type: 3}
- p:
- {fileID: 4461932328840788347, guid: df385eaebb177c244a8f6aa2fc2d05f2, type: 3}
- p:
- {fileID: 3284573290373744302, guid: 690965b65f8667d4299c13f7cb4dc444, type: 3}
- p:
- {fileID: 2487624789702488523, guid: 9ba3f57fff0f3f240aad67b489d717f2, type: 3}
shiplist:
- {fileID: 7171601645716739352, guid: 689388b1ed32205428711466f3794748, type: 3}
- {fileID: 1718981553063819522, guid: a69b4f22edee38141902bab64373c73d, type: 3}
- {fileID: 8427987949455047532, guid: 57d8c0b08e0f19f48a227b34b8b70a0b, type: 3}
bulletList:
- {fileID: 5236724725662676995, guid: ad4363c14d065c040bac11009ace5dc4, type: 3}
- {fileID: 7049118564761611801, guid: e0c55c5797964e045ad780dd1868169b, type: 3}
- {fileID: 5671706578558220722, guid: 9347cf63de3b0c242bac7ee29562d5dd, type: 3}
- {fileID: 6742644745694519620, guid: a2185ad8f0eb43249b555bda1913c662, type: 3}
- {fileID: 5671706578558220722, guid: afe69842439154b428512871bfc3db8a, type: 3}
constructionList:
- {fileID: 6257076823173944538, guid: f0f5b7271131c0f4b97b109570925eb9, type: 3}
- {fileID: 6520154078847335470, guid: 3ca3df56b82e8484ca02de1e96d8cef9, type: 3}
- {fileID: 8302654837601584078, guid: ab06c719504fda3449d4df06ab5693cc, type: 3}
mapfa: {fileID: 0}
--- !u!114 &689954760
MonoBehaviour:
Expand Down
83 changes: 41 additions & 42 deletions interface/interface_live/Assets/Scripts/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,50 @@ public class Debugger : SingletonMono<Debugger>

void Start()
{
// messageOfShip = new MessageOfShip()
// {
// X = 1145,
// Y = 1919,
// Speed = 0,
// Hp = 0,
// Armor = 0,
// Shield = 0,
// TeamId = 0,
// PlayerId = 0,
// Guid = 0,
// ShipState = 0,
// ShipType = 0,
// ViewRange = 0,
// ProducerType = 0,
// ConstructorType = 0,
// ArmorType = 0,
// ShieldType = 0,
// WeaponType = 0,
// FacingDirection = 0.0
// };
messageOfShip = new MessageOfShip()
{
X = 1145,
Y = 1919,
Speed = 0,
Hp = 0,
Armor = 0,
Shield = 0,
TeamId = 0,
PlayerId = 1,
Guid = 0,
ShipState = 0,
ShipType = 0,
ViewRange = 0,
ProducerType = 0,
ConstructorType = 0,
ArmorType = 0,
ShieldType = 0,
WeaponType = 0,
FacingDirection = 0.0
};

// messageOfObj = new MessageOfObj()
// {
// ShipMessage = messageOfShip,
// };
messageOfObj = new MessageOfObj()
{
ShipMessage = messageOfShip,
};

// messageToClient = new MessageToClient();
// messageOfAll = new MessageOfAll()
// {
messageToClient = new MessageToClient();
messageOfAll = new MessageOfAll()
{

// GameTime = 1,
// RedTeamScore = 2,
// BlueTeamScore = 3,
// RedTeamEnergy = 4,
// BlueTeamEnergy = 5,
// RedHomeHp = 6,
// BlueHomeHp = 7,
// };
// messageToClient.ObjMessage.Add(messageOfObj);
// messageToClient.GameState = GameState.GameRunning;
// messageToClient.AllMessage = messageOfAll;
// info = JsonConvert.SerializeObject(messageToClient);
// UpdateManager.GetInstance().UpdateMessageByJson(info);
// info = System.IO.File.ReadAllText(@"D:\SoftwareDepartment\THUAI7\THUAI7\interface\interface_live\Assets\frame.json");
GameTime = 1,
RedTeamScore = 2,
BlueTeamScore = 3,
RedTeamEnergy = 4,
BlueTeamEnergy = 5,
RedHomeHp = 6,
BlueHomeHp = 7,
};
messageToClient.ObjMessage.Add(messageOfObj);
messageToClient.GameState = GameState.GameRunning;
messageToClient.AllMessage = messageOfAll;
info = JsonConvert.SerializeObject(messageToClient);
UpdateManager.GetInstance().UpdateMessageByJson(info);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ public T GetValue(int index)
return valQueue[(tail + maxSize - index) % maxSize];
}
};
public static FrameQueue<MessageToClient> frameQueue;
public static FrameQueue<MessageToClient> frameQueue = new FrameQueue<MessageToClient>();
public static MessageOfMap map;
public static Dictionary<Tuple<int, int>, MessageOfResource> resources;
public static MessageOfHome[] homes = new MessageOfHome[2];
public static MessageOfTeam[] teams = new MessageOfTeam[2];
public static MessageOfShip[] ships = new MessageOfShip[8];
public static GameObject[] shipsG = new GameObject[8];
public static Dictionary<long, MessageOfBullet> bullets;
public static Dictionary<long, MessageOfBombedBullet> bombedBullets;
public static List<MessageOfFactory> factories;
public static List<MessageOfCommunity> communities;
public static List<MessageOfFort> forts;
public static bool initialized;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void UpdateMessageByJson(string jsonInfo)
{
// Debugger.GetInstance().text.text = jsonInfo;
CoreParam.frameQueue.Add(JsonConvert.DeserializeObject<MessageToClient>(jsonInfo, jSetting));
Debug.Log(CoreParam.frameQueue.GetValue(0));
}
// Start is called before the first frame update
void Start()
Expand Down
30 changes: 25 additions & 5 deletions interface/interface_live/Assets/Scripts/Render/RenderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,28 @@ void Start()
// Update is called once per frame
void Update()
{

DealFrame(CoreParam.frameQueue.GetValue(0));
ShowFrame();
}
void ShowFrame(MessageToClient info)
void DealFrame(MessageToClient info)
{
if (info.GameState == GameState.GameRunning)
{
foreach (MessageOfObj obj in info.ObjMessage)
{
ShowObj(obj);
DealObj(obj);
}
}
}
void ShowObj(MessageOfObj obj)
void DealObj(MessageOfObj obj)
{
switch (obj.MessageOfObjCase)
{
case MessageOfObj.MessageOfObjOneofCase.MapMessage:
CoreParam.map = obj.MapMessage;
break;
case MessageOfObj.MessageOfObjOneofCase.ShipMessage:
Debug.Log("receive shipmessage" + obj.ShipMessage);
CoreParam.ships[obj.ShipMessage.TeamId * 4 + obj.ShipMessage.PlayerId] = obj.ShipMessage;
break;
case MessageOfObj.MessageOfObjOneofCase.BulletMessage:
Expand Down Expand Up @@ -65,6 +67,15 @@ void ShowObj(MessageOfObj obj)
break;
}
}
void ShowFrame()
{
if (!CoreParam.initialized)
{
ShowShip(CoreParam.ships);
ShowMap(CoreParam.map);
CoreParam.initialized = true;
}
}
void ShowMap(MessageOfMap map)
{
for (int row = 1; row <= map.Height; row++)
Expand Down Expand Up @@ -96,7 +107,16 @@ void ShowMap(MessageOfMap map)
}
}
}
void ShowShip(MessageOfShip ship)
void ShowShip(MessageOfShip[] ships)
{
foreach (MessageOfShip ship in ships)
{
Debug.Log(ship);
if (!CoreParam.shipsG[ship.TeamId * 4 + ship.PlayerId])
{
CoreParam.shipsG[ship.TeamId * 4 + ship.PlayerId] = ObjCreater.GetInstance().CreateObj(ship.ShipType, new Vector2(ship.X, ship.Y));

}
}
}
}

0 comments on commit 8942193

Please sign in to comment.