Skip to content

Commit 7bdad84

Browse files
committed
add instance sharing test case files
1 parent 99debd3 commit 7bdad84

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

Assets/ColyseusClient.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public Button
6464
protected Client client;
6565
protected Room<State> room;
6666

67+
protected Room<IndexedDictionary<string, object>> roomFossilDelta;
68+
protected Room<object> roomNoneSerializer;
69+
6770
protected IndexedDictionary<Entity, GameObject> entities = new IndexedDictionary<Entity, GameObject>();
6871

6972
// Use this for initialization
@@ -106,6 +109,8 @@ async void ConnectToServer ()
106109
public async void CreateRoom()
107110
{
108111
room = await client.Create<State>(roomName, new Dictionary<string, object>() { });
112+
//roomNoneSerializer = await client.Create("no_state", new Dictionary<string, object>() { });
113+
//roomFossilDelta = await client.Create<IndexedDictionary<string, object>>("fossildelta", new Dictionary<string, object>() { });
109114
RegisterRoomHandlers();
110115
}
111116

@@ -117,7 +122,7 @@ public async void JoinOrCreateRoom()
117122

118123
public async void JoinRoom ()
119124
{
120-
room = await client.Join<State>(roomName, new Dictionary<string, object>() {});
125+
room = await client.Join<State>(roomName, new Dictionary<string, object>() { });
121126
RegisterRoomHandlers();
122127
}
123128

@@ -143,7 +148,6 @@ public void RegisterRoomHandlers()
143148

144149
room.State.entities.OnAdd += OnEntityAdd;
145150
room.State.entities.OnRemove += OnEntityRemove;
146-
//room.State.entities.OnChange += OnEntityMove;
147151
room.State.TriggerAll();
148152

149153
PlayerPrefs.SetString("roomId", room.Id);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// THIS FILE HAS BEEN GENERATED AUTOMATICALLY
3+
// DO NOT CHANGE IT MANUALLY UNLESS YOU KNOW WHAT YOU'RE DOING
4+
//
5+
// GENERATED USING @colyseus/schema 1.0.0-alpha.46
6+
//
7+
8+
using Colyseus.Schema;
9+
10+
namespace SchemaTest.InstanceSharing {
11+
public class Player : Schema {
12+
[Type(0, "ref", typeof(Position))]
13+
public Position position = new Position();
14+
}
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// THIS FILE HAS BEEN GENERATED AUTOMATICALLY
3+
// DO NOT CHANGE IT MANUALLY UNLESS YOU KNOW WHAT YOU'RE DOING
4+
//
5+
// GENERATED USING @colyseus/schema 1.0.0-alpha.46
6+
//
7+
8+
using Colyseus.Schema;
9+
10+
namespace SchemaTest.InstanceSharing {
11+
public class Position : Schema {
12+
[Type(0, "number")]
13+
public float x = default(float);
14+
15+
[Type(1, "number")]
16+
public float y = default(float);
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// THIS FILE HAS BEEN GENERATED AUTOMATICALLY
3+
// DO NOT CHANGE IT MANUALLY UNLESS YOU KNOW WHAT YOU'RE DOING
4+
//
5+
// GENERATED USING @colyseus/schema 1.0.0-alpha.46
6+
//
7+
8+
using Colyseus.Schema;
9+
10+
namespace SchemaTest.InstanceSharing {
11+
public class State : Schema {
12+
[Type(0, "ref", typeof(Player))]
13+
public Player player1 = new Player();
14+
15+
[Type(1, "ref", typeof(Player))]
16+
public Player player2 = new Player();
17+
18+
[Type(2, "array", typeof(ArraySchema<Player>))]
19+
public ArraySchema<Player> arrayOfPlayers = new ArraySchema<Player>();
20+
21+
[Type(3, "map", typeof(MapSchema<Player>))]
22+
public MapSchema<Player> mapOfPlayers = new MapSchema<Player>();
23+
}
24+
}

Assets/ExampleScene.unity

-312 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)