public static void ReceiveGamedata(string body) //!GAMEDATA { GameData payload = JsonConvert.DeserializeObject <GameData>(body); GameMain.map = new Map(payload.mapName); GameMain.mainPlayer = new MainPlayer(payload.clientId, "Bernie", new Vector2(payload.spawnX, payload.spawnY)); ClientSenderV2.ContinueSync(); }
public static void StartConnection(string body) //.WELCOME { var payloadDef = new { version = "" }; var payload = JsonConvert.DeserializeAnonymousType(body, payloadDef); if (payload.version != Assembly.GetExecutingAssembly().GetName().Version.ToString()) //Version mismatch { Menu.OpenModal("The server is running a different version (" + payload.version + ")", "Error"); Engine.networkClient.disconnect(); } ClientSenderV2.ContinueSync(); }
public static void ReceiveEntities(string body) //!ENTITIES { EntitiesData payload = JsonConvert.DeserializeObject <EntitiesData>(body); payload.players.ForEach((it) => { GameMain.players.Add(new Player(it.data.id, it.name, it.data.position, it.hp)); }); payload.items.ForEach((it) => { var item = EntityStore.GetItemWithId(it.id); item.uid = it.uid; item.position = it.position; GameMain.map.items.Add(item); }); ClientSenderV2.ContinueSync(); }