示例#1
0
    // Use Update() instead of Start() so that the spawn points can initialize
    void Update()
    {
        GameObject net_mgr = GameObject.Find("NetworkManager");

        if (!net_mgr)
        {
            Debug.LogError("Could not find global GameObject with name 'NetworkManager'.");
            return;
        }

        Toxic.NetworkManager nm = net_mgr.GetComponent <Toxic.NetworkManager>();
        Toxic.PlayerManager  pm = net_mgr.GetComponent <Toxic.PlayerManager>();

        if (!nm)
        {
            Debug.LogError("Could not find a 'Toxic.NetworkManager' on global GameObject 'NetworkManager'.");
            return;
        }

        if (!pm)
        {
            Debug.LogError("Could not find a 'Toxic.PlayerManager' on global GameObject 'NetworkManager'.");
            return;
        }

        if (nm.isServer)
        {
            GameObject[] objects = GameObject.FindGameObjectsWithTag("SpawnPoints");

            int spawner = 0;

            foreach (Toxic.PlayerManager.PlayerData pd in pm.playerData.Values)
            {
                Toxic.SpawnPoint sp     = objects[spawner].GetComponent <Toxic.SpawnPoint>();
                GameObject       player = sp.spawn();

                NetworkServer.ReplacePlayerForConnection(pd.network_connection, player, pd.player_controller_id);

                spawner = (spawner + 1) % objects.Length;
            }
        }

        enabled = false;
    }
示例#2
0
    public void Start()
    {
        GameObject net_mgr = GameObject.Find("NetworkManager");

        if (!net_mgr) {
            Debug.LogError("Could not find global GameObject with name 'NetworkManager'.");
            return;
        }

        _network_mgr = net_mgr.GetComponent<Toxic.NetworkManager>();
        _player_mgr = net_mgr.GetComponent<Toxic.PlayerManager>();

        if (!_network_mgr) {
            Debug.LogError("Could not find a 'Toxic.NetworkManager' on global GameObject 'NetworkManager'.");
        }

        if (!_player_mgr) {
            Debug.LogError("Could not find a 'PlayerManager' on global GameObject 'NetworkManager'.");
        }
    }
示例#3
0
    public void Start()
    {
        GameObject net_mgr = GameObject.Find("NetworkManager");

        if (!net_mgr)
        {
            Debug.LogError("Could not find global GameObject with name 'NetworkManager'.");
            return;
        }

        _network_mgr = net_mgr.GetComponent <Toxic.NetworkManager>();
        _player_mgr  = net_mgr.GetComponent <Toxic.PlayerManager>();

        if (!_network_mgr)
        {
            Debug.LogError("Could not find a 'Toxic.NetworkManager' on global GameObject 'NetworkManager'.");
        }

        if (!_player_mgr)
        {
            Debug.LogError("Could not find a 'PlayerManager' on global GameObject 'NetworkManager'.");
        }
    }