SHARE
TWEET

Untitled

a guest Feb 28th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SpawnManager : MonoBehaviour
  6. {
  7.     Transform mySpawn;
  8.     public string roomName = "Room";
  9.  
  10.     public enum Teams { Blue, Neutral, Red };
  11.     public Teams mySelectedTeam;
  12.  
  13.     void Start()
  14.     {
  15.         PhotonNetwork.ConnectUsingSettings("V 1.0");
  16.     }
  17.  
  18.     void OnJoinedLobby()
  19.     {
  20.         RoomOptions myRoomOptions = new RoomOptions () { isVisible = true,maxPlayers = 6 };
  21.         PhotonNetwork.JoinOrCreateRoom(roomName, myRoomOptions, TypedLobby.Default);
  22.     }
  23.  
  24.     void OnJoinedRoom()
  25.     {
  26.         Debug.Log("Du bist im Raum " + PhotonNetwork.room.Name);
  27.         SpawnPlayer();
  28.     }
  29.  
  30.     void SpawnPlayer()
  31.     {
  32.         SpawnSpot[] availableSpawn = FindObjectsOfType<SpawnSpot>();
  33.  
  34.         foreach(SpawnSpot s in availableSpawn)
  35.         {
  36.             if(s.GetComponent<SpawnSpot>().myTeam.ToString() ==  mySelectedTeam || s.GetComponent<SpawnSpot>().myTeam.ToString() == Teams.Neutral.ToString())
  37.             {
  38.            
  39.             }
  40.         }
  41.  
  42.         int spawnIndex = Random.Range(0, availableSpawn.Length);
  43.         mySpawn = availableSpawn[spawnIndex].transform;
  44.         GameObject EGoPlayer = PhotonNetwork.Instantiate("EGoPlayer", mySpawn.position, Quaternion.identity, 0);
  45.  
  46.         EGoPlayer.GetComponent<MovementController>().enabled = true;
  47.         EGoPlayer.GetComponent<MouseLook>().enabled = true;
  48.         EGoPlayer.GetComponentInChildren<Camera>().enabled = true;
  49.         EGoPlayer.GetComponentInChildren<FlareLayer>().enabled = true;
  50.         EGoPlayer.GetComponentInChildren<AudioListener>().enabled = true;
  51.         EGoPlayer.GetComponentInChildren<GUILayer>().enabled = true;
  52.  
  53.         if (mySpawn == null)
  54.         {
  55.             Debug.Log("Es wurden kein Spawn gefunden");
  56.         }
  57.  
  58.     }
  59.  
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top