Пример #1
0
        //abuse
        public void OnJoinGame(NetworkConnection conn, JoinMessage Join)
        {
            NetPlayer NP = Instantiate(playerPrefab).GetComponent <NetPlayer>();

            NetworkServer.AddPlayerForConnection(conn, NP.gameObject);

            PlayerBrain PB = Instantiate(GamePlayer);

            NetworkServer.Spawn(PB.gameObject, conn);

            for (int i = 0; i < 25; i++)
            {
                ItemBox IB = Instantiate(ItemBox);
                NetworkServer.Spawn(IB.gameObject);
                IB.Randomize();
            }
            for (int i = 0; i < 5; i++)
            {
                PlatBrain PlB = Instantiate(PlatGuy);
                PlB.transform.position = new Vector3(300, 300, 0) * Random.insideUnitCircle;
                NetworkServer.Spawn(PlB.gameObject);
                PlB.Die();
            }

            //Players.Add(NP.netId, NP);
            //PlayerBrains.Add(NP.netId, PB);

            JoinedMessage joined = new JoinedMessage();

            //Debug.Log(NP.netId+"|"+PB.netId);
            joined.id     = NP.netId;
            joined.Player = PB.netId;
            NetworkServer.SendToAll(joined);
        }