示例#1
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        Vector3 pos = Vector3.zero;

        pos.y += (conn.connectionId % 8) * 2;
        pos.x += ((conn.connectionId / 4) * 4);

        GameObject thePlayer = (GameObject)Instantiate(base.playerPrefab, pos, Quaternion.identity);
        TankCombat tc        = thePlayer.GetComponent <TankCombat>();

        tc.InitializeFromTankType(TankTypeManager.Random());

        NetworkServer.AddPlayerForConnection(conn, thePlayer, playerControllerId);
    }
示例#2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (isServer)
            {
                NetworkManager.singleton.StopHost();
            }
            else
            {
                NetworkManager.singleton.client.Disconnect();
                Application.LoadLevel("title");
            }
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            // spawn heavy tank
            GameObject tank = (GameObject)Instantiate(NetworkManager.singleton.playerPrefab, Vector3.zero, Quaternion.identity);
            TankCombat tc   = tank.GetComponent <TankCombat>();
            tc.InitializeFromTankType(TankTypeManager.Random());
            NetworkServer.Spawn(tank);
        }
    }