コード例 #1
0
ファイル: Main.cs プロジェクト: FahadAhmad2001/ZeroG
        public void SendPlayerUpdate(Vector3 position, Quaternion rotation)
        {
            PlayerPosition packet = new PlayerPosition();

            packet.Generate(userName, ConvertCustomTypes.ConvertVectorSerializable(position), ConvertCustomTypes.ConvertQuaternionSerializable(rotation));
            ZeroGPacket mainPacket = PacketGenerator.Generate("PlayerPosition", packet);

            gClient.Send(mainPacket, LiteNetLib.DeliveryMethod.Unreliable);
        }
コード例 #2
0
        public static void Process(PlayerPosition packet)
        {
            Main clientInst = InstanceKeeper.GetMainClient();

            foreach (GameObject gameobject in clientInst.playerShips)
            {
                ZeroGPlayer playerName = gameobject.GetComponent <ZeroGPlayer>();
                try
                {
                    if (playerName.PlayerName == packet.PlayerName)
                    {
                        gameobject.GetComponentInChildren <PlayerObjectConfiguration>().GetShip().transform.position = ConvertCustomTypes.ConvertVectorOriginal(packet.Position);
                        gameobject.GetComponentInChildren <PlayerObjectConfiguration>().GetShip().transform.rotation = ConvertCustomTypes.ConvertQuaternionOriginal(packet.Rotation);
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.Error("Error while processing remote player movement: " + ex.Message + ex.StackTrace);
                }
            }
        }