Add teams, make team spawns and do some reorganizing
This commit is contained in:
parent
5217a351d1
commit
0430badc00
@ -154,7 +154,7 @@ Transform:
|
|||||||
- {fileID: 1901268757}
|
- {fileID: 1901268757}
|
||||||
- {fileID: 315509112}
|
- {fileID: 315509112}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 8
|
m_RootOrder: 7
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &130756071
|
--- !u!1 &130756071
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -363,6 +363,36 @@ Transform:
|
|||||||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 4b9b55215c46317428803b7adeda89c3, type: 3}
|
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 4b9b55215c46317428803b7adeda89c3, type: 3}
|
||||||
m_PrefabInstance: {fileID: 315509111}
|
m_PrefabInstance: {fileID: 315509111}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &327191960
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 327191961}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: SunSpawn1
|
||||||
|
m_TagString: SunRespawn
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &327191961
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 327191960}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -31.92384, y: 1.3995848, z: 8.992973}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1280423821}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &332119780
|
--- !u!1 &332119780
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -782,6 +812,66 @@ Light:
|
|||||||
m_UseBoundingSphereOverride: 0
|
m_UseBoundingSphereOverride: 0
|
||||||
m_ShadowRadius: 0
|
m_ShadowRadius: 0
|
||||||
m_ShadowAngle: 0
|
m_ShadowAngle: 0
|
||||||
|
--- !u!1 &589581210
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 589581211}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: SunSpawn2
|
||||||
|
m_TagString: SunRespawn
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &589581211
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 589581210}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -37.75384, y: 3.6095848, z: 16.12297}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1280423821}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &596859584
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 596859585}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: MoonSpawn1
|
||||||
|
m_TagString: MoonRespawn
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &596859585
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 596859584}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -31.92384, y: 1.3995848, z: -8.992973}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1280423821}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &629769912
|
--- !u!1 &629769912
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1225,6 +1315,36 @@ Light:
|
|||||||
m_UseBoundingSphereOverride: 0
|
m_UseBoundingSphereOverride: 0
|
||||||
m_ShadowRadius: 0
|
m_ShadowRadius: 0
|
||||||
m_ShadowAngle: 0
|
m_ShadowAngle: 0
|
||||||
|
--- !u!1 &738586440
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 738586441}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: MoonSpawn2
|
||||||
|
m_TagString: MoonRespawn
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &738586441
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 738586440}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -37.75384, y: 3.6095848, z: -16.122972}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1280423821}
|
||||||
|
m_RootOrder: 1
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1001 &816236545
|
--- !u!1001 &816236545
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1946,8 +2066,8 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1280423821}
|
- component: {fileID: 1280423821}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: SpawnPoint
|
m_Name: SpawnPoints
|
||||||
m_TagString: Respawn
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@ -1959,12 +2079,17 @@ Transform:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1280423820}
|
m_GameObject: {fileID: 1280423820}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0.02, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children:
|
||||||
|
- {fileID: 596859585}
|
||||||
|
- {fileID: 738586441}
|
||||||
|
- {fileID: 327191961}
|
||||||
|
- {fileID: 589581211}
|
||||||
|
- {fileID: 1645654011}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 7
|
m_RootOrder: 9
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1326636135
|
--- !u!1 &1326636135
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -2182,6 +2307,36 @@ Light:
|
|||||||
m_UseBoundingSphereOverride: 0
|
m_UseBoundingSphereOverride: 0
|
||||||
m_ShadowRadius: 0
|
m_ShadowRadius: 0
|
||||||
m_ShadowAngle: 0
|
m_ShadowAngle: 0
|
||||||
|
--- !u!1 &1645654010
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1645654011}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: FFASpawn
|
||||||
|
m_TagString: Respawn
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1645654011
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1645654010}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0.38, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1280423821}
|
||||||
|
m_RootOrder: 4
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1734890295
|
--- !u!1 &1734890295
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -3165,7 +3320,7 @@ Transform:
|
|||||||
- {fileID: 2012327805}
|
- {fileID: 2012327805}
|
||||||
- {fileID: 665920420}
|
- {fileID: 665920420}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 9
|
m_RootOrder: 8
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &2084062065
|
--- !u!1 &2084062065
|
||||||
GameObject:
|
GameObject:
|
||||||
|
8
Assets/Scripts/Game.meta
Normal file
8
Assets/Scripts/Game.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bf03d5097c37ef34a97b36e834e39cde
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
67
Assets/Scripts/Game/GameMaster.cs
Normal file
67
Assets/Scripts/Game/GameMaster.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NeonTea.Quakeball.Networking.Instances;
|
||||||
|
using NeonTea.Quakeball.Networking;
|
||||||
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Game {
|
||||||
|
|
||||||
|
public class GameMaster {
|
||||||
|
private NetInstance Instance;
|
||||||
|
|
||||||
|
public GameMode GameMode;
|
||||||
|
public Dictionary<Team, List<ulong>> Players = new Dictionary<Team, List<ulong>>();
|
||||||
|
|
||||||
|
public GameMaster() {
|
||||||
|
Instance = Net.Singleton.Instance;
|
||||||
|
|
||||||
|
GameMode = GameMode.TeamPlay;
|
||||||
|
Players[Team.FreeForAll] = new List<ulong>();
|
||||||
|
Players[Team.Sun] = new List<ulong>();
|
||||||
|
Players[Team.Moon] = new List<ulong>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayerJoined(NetPlayer player) {
|
||||||
|
Team team = Team.FreeForAll;
|
||||||
|
if (GameMode == GameMode.TeamPlay) {
|
||||||
|
if (Players[Team.Sun].Count > Players[Team.Moon].Count) {
|
||||||
|
team = Team.Sun;
|
||||||
|
} else {
|
||||||
|
team = Team.Moon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Players[Team.Sun].Add(player.Id);
|
||||||
|
player.Team = team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayerLeft(NetPlayer player) {
|
||||||
|
Players[player.Team].Remove(player.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetSpawn(NetPlayer player) {
|
||||||
|
string Tag = "Respawn";
|
||||||
|
switch (player.Team) {
|
||||||
|
case Team.Sun:
|
||||||
|
Tag = "SunRespawn";
|
||||||
|
break;
|
||||||
|
case Team.Moon:
|
||||||
|
Tag = "MoonRespawn";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GameObject[] spawnPoints = GameObject.FindGameObjectsWithTag(Tag);
|
||||||
|
return spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GameMode {
|
||||||
|
TeamPlay = 0,
|
||||||
|
FreeForAll = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Team {
|
||||||
|
FreeForAll = 0,
|
||||||
|
Sun = 1,
|
||||||
|
Moon = 2,
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Game/GameMaster.cs.meta
Normal file
11
Assets/Scripts/Game/GameMaster.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ef14f81104861ca4c896fa03a5932554
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -20,6 +20,8 @@ namespace NeonTea.Quakeball.Networking {
|
|||||||
RegisterPacket(typeof(HelloPckt));
|
RegisterPacket(typeof(HelloPckt));
|
||||||
RegisterPacket(typeof(PingPckt));
|
RegisterPacket(typeof(PingPckt));
|
||||||
RegisterPacket(typeof(PingListPckt));
|
RegisterPacket(typeof(PingListPckt));
|
||||||
|
RegisterPacket(typeof(ReadyPckt));
|
||||||
|
RegisterPacket(typeof(PlayerInitPckt));
|
||||||
RegisterPacket(typeof(SpawnPckt));
|
RegisterPacket(typeof(SpawnPckt));
|
||||||
RegisterPacket(typeof(SelfIdentPckt));
|
RegisterPacket(typeof(SelfIdentPckt));
|
||||||
RegisterPacket(typeof(NicknamePckt));
|
RegisterPacket(typeof(NicknamePckt));
|
||||||
|
@ -83,37 +83,47 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
if (packet is SelfIdentPckt) {
|
if (packet is SelfIdentPckt) {
|
||||||
SelfIdentPckt ident = (SelfIdentPckt)packet;
|
SelfIdentPckt ident = (SelfIdentPckt)packet;
|
||||||
LocalPlayer.Id = ident.PlayerId;
|
LocalPlayer.Id = ident.PlayerId;
|
||||||
|
LocalPlayer.Team = ident.Team;
|
||||||
LocalPlayer.Controlled.NetId = LocalPlayer.Id;
|
LocalPlayer.Controlled.NetId = LocalPlayer.Id;
|
||||||
AddPlayer(LocalPlayer);
|
AddPlayer(LocalPlayer);
|
||||||
SelfIdentified = true;
|
SelfIdentified = true;
|
||||||
|
|
||||||
NicknamePckt nickpckt = new NicknamePckt(LocalPlayer.Nick);
|
NicknamePckt nickpckt = new NicknamePckt(LocalPlayer.Nick);
|
||||||
Peer.SendReliable(Server.uid, nickpckt);
|
Peer.SendReliableLater(Server.uid, nickpckt);
|
||||||
|
|
||||||
SpawnPckt spawn = new SpawnPckt(LocalPlayer.Controlled.transform.position);
|
ReadyPckt ready = new ReadyPckt();
|
||||||
Peer.SendReliableLater(Server.uid, spawn);
|
Peer.SendReliable(Server.uid, ready);
|
||||||
} else if (packet is NicknamePckt) {
|
} else if (packet is NicknamePckt) {
|
||||||
NicknamePckt nick = (NicknamePckt)packet;
|
NicknamePckt nick = (NicknamePckt)packet;
|
||||||
if (nick.PlayerId != LocalPlayer.Id) {
|
if (nick.PlayerId != LocalPlayer.Id) {
|
||||||
if (!Players.ContainsKey(nick.PlayerId)) {
|
|
||||||
NetPlayer player = new NetPlayer(nick.PlayerId);
|
|
||||||
AddPlayer(player);
|
|
||||||
}
|
|
||||||
Players[nick.PlayerId].Nick = nick.Nick;
|
Players[nick.PlayerId].Nick = nick.Nick;
|
||||||
}
|
}
|
||||||
} else if (packet is SpawnPckt) {
|
} else if (packet is SpawnPckt) {
|
||||||
SpawnPckt spawn = (SpawnPckt)packet;
|
SpawnPckt spawn = (SpawnPckt)packet;
|
||||||
if (spawn.PlayerId == LocalPlayer.Id && spawn.IsInitial) {
|
|
||||||
return; // Ignore, it's their own.
|
|
||||||
}
|
|
||||||
if (spawn.IsInitial) {
|
if (spawn.IsInitial) {
|
||||||
Player obj = Net.SpawnPlayer(spawn.Location).GetComponent<Player>();
|
Debug.Log("Got spawn!");
|
||||||
Players[spawn.PlayerId].Controlled = obj;
|
if (spawn.PlayerId == LocalPlayer.Id) {
|
||||||
|
HandlePlayerRespawn(spawn.PlayerId, spawn.Location);
|
||||||
|
} else {
|
||||||
|
Player obj = Net.SpawnPlayer(spawn.Location).GetComponent<Player>();
|
||||||
|
Players[spawn.PlayerId].Controlled = obj;
|
||||||
|
}
|
||||||
} else if (Players[spawn.PlayerId].Controlled.IsDead) {
|
} else if (Players[spawn.PlayerId].Controlled.IsDead) {
|
||||||
if (Players.ContainsKey(spawn.PlayerId)) {
|
if (Players.ContainsKey(spawn.PlayerId)) {
|
||||||
HandlePlayerRespawn(spawn.PlayerId, spawn.Location);
|
HandlePlayerRespawn(spawn.PlayerId, spawn.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (packet is PlayerInitPckt) {
|
||||||
|
PlayerInitPckt init = (PlayerInitPckt)packet;
|
||||||
|
if (Players.ContainsKey(conn.uid)) {
|
||||||
|
return; // Got the same init twice
|
||||||
|
}
|
||||||
|
NetPlayer player = new NetPlayer(init.PlayerId);
|
||||||
|
player.Nick = init.NicknamePckt.Nick;
|
||||||
|
player.Team = init.Team;
|
||||||
|
Player obj = Net.SpawnPlayer(init.SpawnPckt.Location).GetComponent<Player>();
|
||||||
|
player.Controlled = obj;
|
||||||
|
AddPlayer(player);
|
||||||
} else if (packet is DeadPckt) {
|
} else if (packet is DeadPckt) {
|
||||||
DeadPckt dead = (DeadPckt)packet;
|
DeadPckt dead = (DeadPckt)packet;
|
||||||
if (Players.ContainsKey(dead.DeadPlayerId)) {
|
if (Players.ContainsKey(dead.DeadPlayerId)) {
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using NeonTea.Quakeball.Networking.Packets;
|
using NeonTea.Quakeball.Networking.Packets;
|
||||||
using NeonTea.Quakeball.Players;
|
using NeonTea.Quakeball.Players;
|
||||||
|
using NeonTea.Quakeball.Game;
|
||||||
using NeonTea.Quakeball.Interface;
|
using NeonTea.Quakeball.Interface;
|
||||||
using NeonTea.Quakeball.TeaNet.Peers;
|
using NeonTea.Quakeball.TeaNet.Peers;
|
||||||
using NeonTea.Quakeball.TeaNet.Packets;
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
@ -18,6 +19,8 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
private float LastSentPing;
|
private float LastSentPing;
|
||||||
public static float PingInterval = 1;
|
public static float PingInterval = 1;
|
||||||
|
|
||||||
|
public GameMaster GameMaster;
|
||||||
|
|
||||||
public Server() {
|
public Server() {
|
||||||
LocalPlayer = new NetPlayer(ulong.MaxValue);
|
LocalPlayer = new NetPlayer(ulong.MaxValue);
|
||||||
}
|
}
|
||||||
@ -35,10 +38,14 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
|
|
||||||
Net = GameObject.FindGameObjectWithTag("Net").GetComponent<NetChaperone>();
|
Net = GameObject.FindGameObjectWithTag("Net").GetComponent<NetChaperone>();
|
||||||
|
|
||||||
|
GameMaster = new GameMaster();
|
||||||
|
|
||||||
Player obj = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
|
Player obj = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
|
||||||
LocalPlayer.Controlled = obj;
|
LocalPlayer.Controlled = obj;
|
||||||
LocalPlayer.Nick = nick;
|
LocalPlayer.Nick = nick;
|
||||||
AddPlayer(LocalPlayer);
|
AddPlayer(LocalPlayer);
|
||||||
|
|
||||||
|
PlayerJoined(LocalPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnStop() {
|
public override void OnStop() {
|
||||||
@ -59,42 +66,55 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
if (p.Controlled == null) { // Not yet initialized, sending later.
|
if (p.Controlled == null) { // Not yet initialized, sending later.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
NicknamePckt nick = new NicknamePckt(p.Nick, p.Id);
|
|
||||||
Peer.SendReliableLater(conn.uid, nick);
|
|
||||||
|
|
||||||
|
NicknamePckt nick = new NicknamePckt(p.Nick, p.Id);
|
||||||
SpawnPckt spawn = new SpawnPckt(p.Controlled.transform.position, p.Id);
|
SpawnPckt spawn = new SpawnPckt(p.Controlled.transform.position, p.Id);
|
||||||
Peer.SendReliableLater(conn.uid, spawn);
|
PlayerInitPckt init = new PlayerInitPckt(p.Id, p.Team, nick, spawn);
|
||||||
|
Peer.SendReliableLater(conn.uid, init);
|
||||||
}
|
}
|
||||||
NetPlayer RemotePlayer = new NetPlayer(PlayerIdCounter++);
|
NetPlayer RemotePlayer = new NetPlayer(PlayerIdCounter++);
|
||||||
|
GameMaster.PlayerJoined(RemotePlayer);
|
||||||
AddPlayer(RemotePlayer);
|
AddPlayer(RemotePlayer);
|
||||||
SelfIdentPckt ident = new SelfIdentPckt();
|
|
||||||
ident.PlayerId = RemotePlayer.Id;
|
SelfIdentPckt ident = new SelfIdentPckt(RemotePlayer.Id, RemotePlayer.Team);
|
||||||
Peer.SendReliable(conn.uid, ident);
|
Peer.SendReliable(conn.uid, ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Disconnected(Connection conn) {
|
public override void Disconnected(Connection conn) {
|
||||||
Terminal.Singleton.Println($"{conn.uid} Disconnected: {conn.ClosingReason}");
|
Terminal.Singleton.Println($"{conn.uid} Disconnected: {conn.ClosingReason}");
|
||||||
if (Players.ContainsKey(conn.uid)) {
|
if (Players.ContainsKey(conn.uid)) {
|
||||||
GameObject.Destroy(Players[conn.uid].Controlled.gameObject);
|
NetPlayer player = Players[conn.uid];
|
||||||
RemovePlayer(Players[conn.uid]);
|
GameMaster.PlayerLeft(player);
|
||||||
|
GameObject.Destroy(player.Controlled.gameObject);
|
||||||
|
RemovePlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PlayerJoined(NetPlayer player) {
|
||||||
|
NicknamePckt nick = new NicknamePckt(player.Nick, player.Id);
|
||||||
|
SpawnPckt spawn = new SpawnPckt(player.Controlled.transform.position, player.Id);
|
||||||
|
PlayerInitPckt init = new PlayerInitPckt(player.Id, player.Team, nick, spawn);
|
||||||
|
SendReliableToAll(init, except: spawn.PlayerId);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Handle(Connection conn, Packet packet) {
|
public override void Handle(Connection conn, Packet packet) {
|
||||||
if (packet is NicknamePckt) {
|
if (packet is ReadyPckt) {
|
||||||
|
Debug.Log("Got ready!");
|
||||||
|
if (Players[conn.uid].Controlled == null) {
|
||||||
|
NetPlayer player = Players[conn.uid];
|
||||||
|
Player obj = Net.SpawnPlayer(GameMaster.GetSpawn(player)).GetComponent<Player>();
|
||||||
|
player.Controlled = obj;
|
||||||
|
|
||||||
|
SpawnPckt spawn = new SpawnPckt(obj.transform.position, player.Id);
|
||||||
|
Peer.SendReliable(conn.uid, spawn);
|
||||||
|
|
||||||
|
PlayerJoined(player);
|
||||||
|
}
|
||||||
|
} else if (packet is NicknamePckt) {
|
||||||
NicknamePckt nick = (NicknamePckt)packet;
|
NicknamePckt nick = (NicknamePckt)packet;
|
||||||
Players[conn.uid].Nick = nick.Nick;
|
Players[conn.uid].Nick = nick.Nick;
|
||||||
nick.PlayerId = conn.uid;
|
nick.PlayerId = conn.uid;
|
||||||
SendReliableToAll(nick);
|
SendReliableToAll(nick);
|
||||||
} else if (packet is SpawnPckt) {
|
|
||||||
SpawnPckt spawn = (SpawnPckt)packet;
|
|
||||||
if (Players[conn.uid].Controlled == null && spawn.IsInitial) {
|
|
||||||
Player obj = Net.SpawnPlayer(spawn.Location).GetComponent<Player>();
|
|
||||||
Players[conn.uid].Controlled = obj;
|
|
||||||
|
|
||||||
spawn = new SpawnPckt(obj.transform.position, conn.uid);
|
|
||||||
SendReliableToAll(spawn, except: spawn.PlayerId);
|
|
||||||
}
|
|
||||||
} else if (packet is PlayerUpdatePckt) {
|
} else if (packet is PlayerUpdatePckt) {
|
||||||
PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet;
|
PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet;
|
||||||
HandleUpdatePckt(conn.uid, updatePckt);
|
HandleUpdatePckt(conn.uid, updatePckt);
|
||||||
@ -219,7 +239,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePlayerRespawn(ulong uid) {
|
public void HandlePlayerRespawn(ulong uid) {
|
||||||
Vector3 point = GameObject.FindGameObjectWithTag("Respawn").transform.position;
|
Vector3 point = GameMaster.GetSpawn(Players[uid]);
|
||||||
Players[uid].Controlled.Respawn(point);
|
Players[uid].Controlled.Respawn(point);
|
||||||
SpawnPckt spawn = new SpawnPckt(point, uid, false);
|
SpawnPckt spawn = new SpawnPckt(point, uid, false);
|
||||||
SendReliableToAll(spawn);
|
SendReliableToAll(spawn);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using NeonTea.Quakeball.Game;
|
||||||
using NeonTea.Quakeball.Players;
|
using NeonTea.Quakeball.Players;
|
||||||
|
|
||||||
namespace NeonTea.Quakeball.Networking {
|
namespace NeonTea.Quakeball.Networking {
|
||||||
@ -25,6 +26,7 @@ namespace NeonTea.Quakeball.Networking {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string Nick;
|
public string Nick;
|
||||||
|
public Team Team = Team.FreeForAll;
|
||||||
public bool Unsynced = false;
|
public bool Unsynced = false;
|
||||||
public float Ping = 0;
|
public float Ping = 0;
|
||||||
|
|
||||||
|
25
Assets/Scripts/Networking/Packets/DeadPckt.cs
Normal file
25
Assets/Scripts/Networking/Packets/DeadPckt.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Networking.Packets {
|
||||||
|
public class DeadPckt : Packet {
|
||||||
|
|
||||||
|
public ulong DeadPlayerId;
|
||||||
|
public ulong KillerPlayerId;
|
||||||
|
|
||||||
|
public DeadPckt() { }
|
||||||
|
public DeadPckt(ulong deadid, ulong killerid) {
|
||||||
|
DeadPlayerId = deadid;
|
||||||
|
KillerPlayerId = killerid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Read(ByteBuffer buffer) {
|
||||||
|
DeadPlayerId = buffer.ReadULong();
|
||||||
|
KillerPlayerId = buffer.ReadULong();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(ByteBuffer buffer) {
|
||||||
|
buffer.Write(DeadPlayerId);
|
||||||
|
buffer.Write(KillerPlayerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Networking/Packets/DeadPckt.cs.meta
Normal file
11
Assets/Scripts/Networking/Packets/DeadPckt.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5d18c60df716294fb89cdd1548901a9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,17 +1,27 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using NeonTea.Quakeball.Game;
|
||||||
using NeonTea.Quakeball.TeaNet.Packets;
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
|
|
||||||
namespace NeonTea.Quakeball.Networking.Packets {
|
namespace NeonTea.Quakeball.Networking.Packets {
|
||||||
|
|
||||||
public class SelfIdentPckt : Packet {
|
public class SelfIdentPckt : Packet {
|
||||||
public ulong PlayerId;
|
public ulong PlayerId;
|
||||||
|
public Team Team;
|
||||||
|
|
||||||
|
public SelfIdentPckt() { }
|
||||||
|
public SelfIdentPckt(ulong id, Team team) {
|
||||||
|
PlayerId = id;
|
||||||
|
Team = team;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Read(ByteBuffer buffer) {
|
public override void Read(ByteBuffer buffer) {
|
||||||
PlayerId = buffer.ReadULong();
|
PlayerId = buffer.ReadULong();
|
||||||
|
Team = (Team)buffer.Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(ByteBuffer buffer) {
|
public override void Write(ByteBuffer buffer) {
|
||||||
buffer.Write(PlayerId);
|
buffer.Write(PlayerId);
|
||||||
|
buffer.Write((byte)Team);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,39 +36,4 @@ namespace NeonTea.Quakeball.Networking.Packets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MultipleSyncsPckt : Packet {
|
|
||||||
|
|
||||||
public List<PlayerSyncPacket> Syncs = new List<PlayerSyncPacket>();
|
|
||||||
|
|
||||||
public MultipleSyncsPckt() { }
|
|
||||||
|
|
||||||
public MultipleSyncsPckt(List<NetPlayer> players) {
|
|
||||||
foreach (NetPlayer p in players) {
|
|
||||||
if (p.Controlled == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
PlayerSyncPacket pckt = p.Controlled.CreateSyncPacket(p.Id, p.Unsynced);
|
|
||||||
p.Unsynced = false;
|
|
||||||
Syncs.Add(pckt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Read(ByteBuffer buffer) {
|
|
||||||
Syncs.Clear();
|
|
||||||
int count = buffer.ReadInt();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
PlayerSyncPacket pckt = new PlayerSyncPacket();
|
|
||||||
pckt.Read(buffer);
|
|
||||||
Syncs.Add(pckt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(ByteBuffer buffer) {
|
|
||||||
buffer.Write(Syncs.Count);
|
|
||||||
foreach (PlayerSyncPacket p in Syncs) {
|
|
||||||
p.Write(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
40
Assets/Scripts/Networking/Packets/MultipleSyncsPckt.cs
Normal file
40
Assets/Scripts/Networking/Packets/MultipleSyncsPckt.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Networking.Packets {
|
||||||
|
public class MultipleSyncsPckt : Packet {
|
||||||
|
|
||||||
|
public List<PlayerSyncPacket> Syncs = new List<PlayerSyncPacket>();
|
||||||
|
|
||||||
|
public MultipleSyncsPckt() { }
|
||||||
|
|
||||||
|
public MultipleSyncsPckt(List<NetPlayer> players) {
|
||||||
|
foreach (NetPlayer p in players) {
|
||||||
|
if (p.Controlled == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PlayerSyncPacket pckt = p.Controlled.CreateSyncPacket(p.Id, p.Unsynced);
|
||||||
|
p.Unsynced = false;
|
||||||
|
Syncs.Add(pckt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Read(ByteBuffer buffer) {
|
||||||
|
Syncs.Clear();
|
||||||
|
int count = buffer.ReadInt();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
PlayerSyncPacket pckt = new PlayerSyncPacket();
|
||||||
|
pckt.Read(buffer);
|
||||||
|
Syncs.Add(pckt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(ByteBuffer buffer) {
|
||||||
|
buffer.Write(Syncs.Count);
|
||||||
|
foreach (PlayerSyncPacket p in Syncs) {
|
||||||
|
p.Write(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Networking/Packets/MultipleSyncsPckt.cs.meta
Normal file
11
Assets/Scripts/Networking/Packets/MultipleSyncsPckt.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3814a13ee189018459b9f5d591715dc8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
43
Assets/Scripts/Networking/Packets/PlayerInitPckt.cs
Normal file
43
Assets/Scripts/Networking/Packets/PlayerInitPckt.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
using NeonTea.Quakeball.Game;
|
||||||
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Networking.Packets {
|
||||||
|
public class PlayerInitPckt : Packet {
|
||||||
|
|
||||||
|
public ulong PlayerId;
|
||||||
|
public Team Team;
|
||||||
|
public SpawnPckt SpawnPckt;
|
||||||
|
public NicknamePckt NicknamePckt;
|
||||||
|
|
||||||
|
public PlayerInitPckt() { }
|
||||||
|
public PlayerInitPckt(ulong id, Team team, NicknamePckt nickname, SpawnPckt spawn) {
|
||||||
|
PlayerId = id;
|
||||||
|
Team = team;
|
||||||
|
NicknamePckt = nickname;
|
||||||
|
SpawnPckt = spawn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void Read(ByteBuffer buffer) {
|
||||||
|
PlayerId = buffer.ReadULong();
|
||||||
|
Team = (Team)buffer.Read();
|
||||||
|
SpawnPckt = new SpawnPckt();
|
||||||
|
SpawnPckt.Read(buffer);
|
||||||
|
NicknamePckt = new NicknamePckt();
|
||||||
|
NicknamePckt.Read(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(ByteBuffer buffer) {
|
||||||
|
buffer.Write(PlayerId);
|
||||||
|
buffer.Write((byte)Team);
|
||||||
|
SpawnPckt.Write(buffer);
|
||||||
|
NicknamePckt.Write(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReadyPckt : Packet {
|
||||||
|
public override void Read(ByteBuffer buffer) { }
|
||||||
|
public override void Write(ByteBuffer buffer) { }
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Networking/Packets/PlayerInitPckt.cs.meta
Normal file
11
Assets/Scripts/Networking/Packets/PlayerInitPckt.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ad1f5a63b881dc84b8fb98abbbd26073
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
34
Assets/Scripts/Networking/Packets/PlayerSyncPacket.cs
Normal file
34
Assets/Scripts/Networking/Packets/PlayerSyncPacket.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using NeonTea.Quakeball.TeaNet.Packets;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Networking.Packets {
|
||||||
|
public class PlayerSyncPacket : Packet {
|
||||||
|
public ulong PlayerId;
|
||||||
|
public bool Unsynced;
|
||||||
|
|
||||||
|
public Vector3 Location;
|
||||||
|
public Vector3 GroundVelocity;
|
||||||
|
|
||||||
|
public PlayerSyncPacket() { }
|
||||||
|
public PlayerSyncPacket(ulong id, bool unsynced, Vector3 location, Vector3 groundVelocity) {
|
||||||
|
PlayerId = id;
|
||||||
|
Unsynced = unsynced;
|
||||||
|
Location = location;
|
||||||
|
GroundVelocity = groundVelocity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Read(ByteBuffer buffer) {
|
||||||
|
PlayerId = buffer.ReadULong();
|
||||||
|
Unsynced = buffer.ReadBool();
|
||||||
|
Location = buffer.ReadVector3();
|
||||||
|
GroundVelocity = buffer.ReadVector3();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(ByteBuffer buffer) {
|
||||||
|
buffer.Write(PlayerId);
|
||||||
|
buffer.Write(Unsynced);
|
||||||
|
buffer.Write(Location);
|
||||||
|
buffer.Write(GroundVelocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Networking/Packets/PlayerSyncPacket.cs.meta
Normal file
11
Assets/Scripts/Networking/Packets/PlayerSyncPacket.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9142bdd9611dcb44ad5fedeccf38892
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -37,34 +37,4 @@ namespace NeonTea.Quakeball.Networking.Packets {
|
|||||||
buffer.Write(Yaw);
|
buffer.Write(Yaw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerSyncPacket : Packet {
|
|
||||||
public ulong PlayerId;
|
|
||||||
public bool Unsynced;
|
|
||||||
|
|
||||||
public Vector3 Location;
|
|
||||||
public Vector3 GroundVelocity;
|
|
||||||
|
|
||||||
public PlayerSyncPacket() { }
|
|
||||||
public PlayerSyncPacket(ulong id, bool unsynced, Vector3 location, Vector3 groundVelocity) {
|
|
||||||
PlayerId = id;
|
|
||||||
Unsynced = unsynced;
|
|
||||||
Location = location;
|
|
||||||
GroundVelocity = groundVelocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Read(ByteBuffer buffer) {
|
|
||||||
PlayerId = buffer.ReadULong();
|
|
||||||
Unsynced = buffer.ReadBool();
|
|
||||||
Location = buffer.ReadVector3();
|
|
||||||
GroundVelocity = buffer.ReadVector3();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(ByteBuffer buffer) {
|
|
||||||
buffer.Write(PlayerId);
|
|
||||||
buffer.Write(Unsynced);
|
|
||||||
buffer.Write(Location);
|
|
||||||
buffer.Write(GroundVelocity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,26 +28,4 @@ namespace NeonTea.Quakeball.Networking.Packets {
|
|||||||
buffer.Write(IsInitial);
|
buffer.Write(IsInitial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeadPckt : Packet {
|
|
||||||
|
|
||||||
public ulong DeadPlayerId;
|
|
||||||
public ulong KillerPlayerId;
|
|
||||||
|
|
||||||
public DeadPckt() { }
|
|
||||||
public DeadPckt(ulong deadid, ulong killerid) {
|
|
||||||
DeadPlayerId = deadid;
|
|
||||||
KillerPlayerId = killerid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Read(ByteBuffer buffer) {
|
|
||||||
DeadPlayerId = buffer.ReadULong();
|
|
||||||
KillerPlayerId = buffer.ReadULong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(ByteBuffer buffer) {
|
|
||||||
buffer.Write(DeadPlayerId);
|
|
||||||
buffer.Write(KillerPlayerId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,6 +8,8 @@ TagManager:
|
|||||||
- RemotePlayer
|
- RemotePlayer
|
||||||
- Net
|
- Net
|
||||||
- DeadScreen
|
- DeadScreen
|
||||||
|
- MoonRespawn
|
||||||
|
- SunRespawn
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
Loading…
Reference in New Issue
Block a user