void HandlePlayerData(byte[] data) { int packetnum; KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); packetnum = buffer.ReadInteger(); int i = buffer.ReadInteger(); if (Globals.instance.MyIndex < 1) { Globals.instance.MyIndex = i; ClientSendData.instance._index = Globals.instance.MyIndex; } _LoginWindow.SetActive(false); Network.instanceP[i].index = i; General.instance.SetPlayerX(i, buffer.ReadFloat()); General.instance.SetPlayerY(i, buffer.ReadFloat()); General.instance.SetPlayerZ(i, buffer.ReadFloat()); Network.instanceP[i].Username = buffer.ReadString(); _playerPrefs = Instantiate(_playerPrefs, new Vector3(General.instance.GetPlayerX(i), General.instance.GetPlayerY(i), General.instance.GetPlayerZ(i)), Quaternion.identity); _playerPrefs.GetComponent <NetPlayer>().Index = i; _playerPrefs.name = "Player " + i + " : " + Network.instanceP[i].Username; }
public void SendDataTo(int index, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); Network.Clients[index].myStream.BeginWrite(buffer.ToArray(), 0, buffer.ToArray().Length, null, null); buffer = null; }
void HandleLogin(int index, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packetnum = buffer.ReadInteger(); string username = buffer.ReadString(); string password = buffer.ReadString(); if (!Globals.database.AccountExists(index, username)) { //SendUserDoesNotExist return; } if (!Globals.database.PasswordOK(index, username, password)) { // Send password not correct return; } Console.WriteLine("Player" + username + " logged in successfully!"); //Send Player into game //Load player Globals.database.LoadPlayer(index, username); Globals.tempPlayer[index].inGame = true; // Set tempPlayer.ingame = true; Globals.networkSendData.SendInGame(index); }
public void SendDataToServer(byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); network.myStream.Write(buffer.ToArray(), 0, buffer.ToArray().Length); buffer = null; }
void HandleLookingForMatch(int index, byte[] Data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(Data); int packet = buffer.ReadInteger(); RoomInstance.instance.JoinOrCreateRoom(index); }
void HandleRageBar(int packetNum, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packet = buffer.ReadInteger(); int ragebar = buffer.ReadInteger(); _rage.text = ragebar.ToString(); _ragebar.fillAmount = (float)(decimal)ragebar / 10; }
void HandleNewAccount(int index, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packetNum = buffer.ReadInteger(); string username = buffer.ReadString(); string password = buffer.ReadString(); Globals.database.AddAccount(username, password); }
void HandleAlertMsg(int packetNum, byte[] data) { int packetnum; KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); packetnum = buffer.ReadInteger(); string AlertMsg = buffer.ReadString(); Debug.Log(AlertMsg); }
void HandleDisconnect(int index, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packetnum = buffer.ReadInteger(); int connected = buffer.ReadInteger(); int Index = buffer.ReadInteger(); Globals.tempPlayer[index].inGame = false; // Set tempPlayer.ingame = true; Globals.networkSendData.SendDisconnect(Index, connected); }
public void HandleData(byte[] data) { int packetnum; KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); packetnum = buffer.ReadInteger(); buffer = null; if (packetnum == 0) { return; } HandleMessages(packetnum, data); }
void HandleIngame(int packetNum, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packetnum = buffer.ReadInteger(); Player.instance.Username = buffer.ReadString(); Player.instance.Password = buffer.ReadString(); Player.instance.Level = buffer.ReadInteger(); Player.instance.Access = buffer.ReadByte(); Player.instance.FirstTime = buffer.ReadByte(); buffer = null; _playerWelcome.text = "Welcome back, " + Player.instance.Username; MenuManager.instance._menu = MenuManager.Menu.Ingame; }
public void HandleData(int index, byte[] data) { int packetnum; Packet_ Packet; KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); packetnum = buffer.ReadInteger(); buffer = null; if (packetnum == 0) { return; } if (Packets.TryGetValue(packetnum, out Packet)) { Packet.Invoke(index, data); } }
void HandleMatchMaking(int packetNum, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packet = buffer.ReadInteger(); string player1 = buffer.ReadString(); string player2 = buffer.ReadString(); if (player1 == Player.instance.Username) { _opponent.text = player2; } else { _opponent.text = player1; } MenuManager.instance._menu = MenuManager.Menu.InMatch; }
void HandleNewAccount(int index, byte[] Data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(Data); int packet = buffer.ReadInteger(); string username = buffer.ReadString(); string password = buffer.ReadString(); if (Database.instance.AccountExist(username) == true) { //SendAlertMsg return; } Database.instance.AddAccount(index, username, password); ServerSendData.instance.SendIngame(index); }
void HandleMovement(int index, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packetnum = buffer.ReadInteger(); float posX = buffer.ReadFloat(); float posY = buffer.ReadFloat(); float posZ = buffer.ReadFloat(); float rotX = buffer.ReadFloat(); float rotY = buffer.ReadFloat(); float rotZ = buffer.ReadFloat(); float rotW = buffer.ReadFloat(); Globals.general.SetPlayerX(index, posX); Globals.general.SetPlayerY(index, posY); Globals.general.SetPlayerZ(index, posZ); // SendPlayer Movement Globals.networkSendData.SendPlayerMovement(index, posX, posY, posZ, rotX, rotY, rotZ, rotW); }
void HandleDisconnect(byte[] data) { int packetnum; KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); packetnum = buffer.ReadInteger(); int index = buffer.ReadInteger(); int connected = buffer.ReadInteger(); if (connected == 0) { for (int i = 1; i < Constants.MAX_PLAYERS; i++) { if (index != i) { Destroy(Network.instanceP[index]); } } } }
void HandleLogin(int index, byte[] Data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(Data); int packet = buffer.ReadInteger(); string username = buffer.ReadString(); string password = buffer.ReadString(); if (Database.instance.AccountExist(username) == false) { //SendAlertMsg user does not exist return; } if (Database.instance.PasswordOK(username, password) == false) { //SendAlertMsg password does not match return; } Database.instance.LoadPlayer(index, username); ServerSendData.instance.SendIngame(index); }
void HandleLogin(int index, byte[] data) { KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); buffer.WriteBytes(data); int packetNum = buffer.ReadInteger(); string username = buffer.ReadString(); string password = buffer.ReadString(); if (!Globals.database.AccountExist(index, username)) { //SendUserNotExists return; } if (!Globals.database.PasswordOK(index, username, password)) { //SendPasswordwasNotCorrect return; } Console.WriteLine("Player " + username + " logged in succesfully."); //SendPlayerIntoTheGame }
void HandleMovement(byte[] _data) { Debug.Log("Data is player movement."); int packetnum; KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames(); //buffer.WriteBytes(data); buffer.WriteBytes(_data); packetnum = buffer.ReadInteger(); // PLayer Info int index = buffer.ReadInteger(); // PLayer Position float x = buffer.ReadFloat(); float y = buffer.ReadFloat(); float z = buffer.ReadFloat(); // Player Rotation float rotX = buffer.ReadFloat(); float rotY = buffer.ReadFloat(); float rotZ = buffer.ReadFloat(); float rotW = buffer.ReadFloat(); GameObject _netPlayer; if (_netPlayer = GameObject.Find("Player " + index + " : " + Network.instanceP[index].Username)) { _netPlayer.GetComponent <Transform>().position = new Vector3(x, y, z); _netPlayer.GetComponent <Transform>().rotation = new Quaternion(rotX, rotY, rotZ, rotW); } else { } }