Exemplo n.º 1
0
    void Spawn(int count, NetworkPlayer player)
    {
        Squad newSq = GameObject.Instantiate(squadPrefab, squadSpawns[sqSpawnInd].transform.position, squadPrefab.transform.rotation)
                      .GetComponent <Squad>();

        sqSpawnInd++;
        if (sqSpawnInd == squadSpawns.Length)
        {
            sqSpawnInd = 0;
        }

        for (int i = 0; i < count; i++)
        {
            int ind;

            if (spawnPositions.Length == 1)
            {
                ind = 0;
            }
            else
            {
                ind = (int)Mathf.Repeat(i, spawnPositions.Length - 1);
            }

            GameObject obj = GameObject.Instantiate(unitPrefab, spawnPositions[ind].transform.position, spawnPositions[ind].transform.rotation);

            FPControl newFp = obj.GetComponent <FPControl>();
            newFp.Init(team);
            newFp.Assign(newSq);

            //NetworkServer.SpawnWithClientAuthority(obj,  player.ipAddress/*connectionToClient*/);
        }
    }
Exemplo n.º 2
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        spawnPositions = GameObject.FindGameObjectsWithTag("Spawn Unit " + connTeams[conn]);
        squadSpawns    = GameObject.FindGameObjectsWithTag("Spawn Squad " + connTeams[conn]);

        GameObject obj   = GameObject.Instantiate(unitPrefab, spawnPositions[0].transform.position, spawnPositions[0].transform.rotation);
        FPControl  newFp = obj.GetComponent <FPControl>();

        newFp.Init(connTeams[conn] /*connNum*/);

        NetworkServer.AddPlayerForConnection(conn, obj, playerControllerId);
        //newFp.GetComponent<NetworkIdentity>().AssignClientAuthority(conn);
    }