26 lines
783 B
C#
26 lines
783 B
C#
using Mirror;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class RtsNetworkManager : NetworkManager
|
|
{
|
|
[SerializeField] private GameObject _unitSpawnerPrefab;
|
|
|
|
public override void OnServerAddPlayer(NetworkConnectionToClient conn)
|
|
{
|
|
base.OnServerAddPlayer(conn);
|
|
|
|
RTSPlayer player = conn.identity.GetComponent<RTSPlayer>();
|
|
player.SetDisplayName($"Player {numPlayers.ToString()}");
|
|
player.SetPlayerColor(ColorManipulation.GetRandomColor());
|
|
|
|
Transform playerStartPosition = conn.identity.transform;
|
|
|
|
GameObject unitSpawner = Instantiate(
|
|
_unitSpawnerPrefab,
|
|
playerStartPosition.position,
|
|
playerStartPosition.rotation);
|
|
|
|
NetworkServer.Spawn(unitSpawner, conn);
|
|
}
|
|
} |