コード例 #1
0
        public static void Welcome(Packet _packet)
        {
            string _msg  = _packet.ReadString();
            int    _myId = _packet.ReadInt();

            Console.WriteLine($"Message from server: {_msg}");
            Client.myId = _myId;
            ClientSend.WelcomeReceived();

            Client.udp.Connect(((IPEndPoint)Client.tcp.socket.Client.LocalEndPoint).Port);
        }
コード例 #2
0
        public void Update()
        {
            string[] playerInfo =
            {
                "\"Player\"",
                "{",
                $"	\"Position\"	\"{position}\"",
                $"	\"Angles\"	\"{angles}\"",
                $"	\"Username\"	\"{username}\"",
                $"	\"IsLocal\"	\"{isLocal}\"",
                "}"
            };

            foreach (string file in Directory.GetFiles(Program.tempPath))
            {
                if (file.Contains("GameInfo"))
                {
                    continue;
                }

                string[] path     = file.Split((char)92);
                string   fileName = path[path.Length - 1];
                fileName = fileName.Split(".txt")[0];
                int player = int.Parse(fileName);
                if (player > GameManager.players.Count)
                {
                    File.Delete(file);
                }
            }

            Directory.CreateDirectory(Program.tempPath);
            File.WriteAllLines(Path.Combine(Program.tempPath, id.ToString() + ".txt"), playerInfo);

            if (isLocal)
            {
                ClientSend.PlayerMovement(position, angles);
            }
        }