예제 #1
0
        static void SendInitialData(NetConnection receiver)
        {
            Console.WriteLine("Sending initial data");
            Random  random          = new Random();
            Vector3 initialPosition = new Vector3(100, 70, 100);
            Int16   model           = (Int16)random.Next(0, 4);
            //model = 2;
            int a = FindOpenSlot(openSlots);

            if (a >= 0)
            {
                openSlots[a] = false;
            }
            OtherPlayer        player = new OtherPlayer(initialPosition.X, initialPosition.Y, initialPosition.Z, a, 0, 0, false);
            NetOutgoingMessage om     = server.CreateMessage();

            Console.WriteLine("Random val: " + model.ToString());
            player.model = model;
            om.Write(Constants.NewConnection);
            Package.PlayerToOm(om, player);
            server.SendMessage(om, receiver, NetDeliveryMethod.Unreliable);
            Console.WriteLine(String.Format("Player {0} connected", player.IdToString()));
            players[a] = player;
        }