void SpawnMyPlayer() { // AddChatMessage("Spawning player: " + PhotonNetwork.player.name); if (spawnSpots == null) { Debug.LogError("Broken"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject) PhotonNetwork.Instantiate("Player", mySpawnSpot.transform.position, transform.rotation, 0); myPlayerGO.GetComponent <NetworkCharacterMovement>().enabled = true; myPlayerGO.GetComponent <MouseMovement>().enabled = true; myPlayerGO.GetComponent <ChatManager>().enabled = true; myPlayerGO.GetComponent <PlayerMovement>().enabled = true; cameras = myPlayerGO.GetComponentsInChildren <Camera>(); foreach (Camera child in cameras) { child.enabled = true; } myPlayerGO.GetComponent <PlayerShoot>().enabled = true; myPlayerGO.GetComponent <FiringWeapons>().enabled = true; //myPlayerGO.GetComponent<PlayerSpotlight>().enabled = true; // myPlayerGO.GetComponent<UIController>().enabled = true; //myPlayerGO.GetComponentInChildren<> ().enabled = true; }
void SpawnMyPlayer(int teamID) { this.teamID = teamID; hasPickedTeam = true; //Instantiate (PlayerPrefs); only on my computer //SpawnSpot[] spots = GameObject.FindObjectsOfType<SpawnSpot> (); настройка спавнов для конкретной цели AddChatMessage("Spawning player : " + PhotonNetwork.player.name); Cursor.lockState = CursorLockMode.Locked; if (spawnSpots == null) { Debug.LogError("WTF!?!?!?"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.SetActive(false); //((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController") ).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerMovement")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true; myPlayerGO.GetComponent <PhotonView> ().RPC("SetTeamID", PhotonTargets.AllBuffered, teamID); myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true); }
void SpawnMyPlayer() { AddChatMessage("Spawning Player: " + PhotonNetwork.player.name); if (spawnSpots == null) { Debug.LogError("WTF?!?!?"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("playercontroller", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.SetActive(false); //((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController")).enabled = true; //((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerMovement")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("myCharacterMovement")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("ActivateAction")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("TrackingAction")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("ActivateActionFire")).enabled = true; myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true); }
void spawnMyPlayer() { if (spawnSpots == null) { Debug.LogError("spawn crash"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; // Spawn player GameObject player = (GameObject)PhotonNetwork.Instantiate(playerPrefab.name, (mySpawnSpot.transform.position + Vector3.up), mySpawnSpot.transform.rotation, 0); if (player != null) { AddChatMessage(PhotonNetwork.player.name + " has spawned"); //disable overlook cam standbyCamera.SetActive(false); //enable player scrips /*player.GetComponent<PlayerController>().enabled = true; * player.GetComponent<GunController>().enabled = true; * player.transform.FindChild("PlayerCamera").gameObject.SetActive(true); */ player.GetComponent <Enabler>().enable(player); Screen.lockCursor = true; locked = true; } }
public void playerSetup(SpawnSpot thisSpawn) { GameObject p = null; int playerID = PhotonNetwork.player.ID; if (currLevel.spawnStructure != null) { GameObject g = Instantiate(currLevel.spawnStructure, thisSpawn.getSpawnPoint(), thisSpawn.transform.rotation, currLevel.StructuresTransform); g.name = "PlayerSpawn: " + Persistent.thisPersist.Username + playerID; PlayerStructure s = g.GetComponent <PlayerStructure>(); if (s != null) { s.isLocal = true; currLevel.structures.Add(s); p = PhotonNetwork.Instantiate(playerInstantiate.name, s.spawnPosition.position, s.spawnPosition.rotation, 0, null); myPlayer = p.GetComponent <player>(); view.RPC("setStructure", PhotonTargets.Others, s.GenerateJSON().ToString()); myPlayer.spwanRoom = s; myPlayer.spwanPos = s.spawnPosition; } else { Debug.Log("The currLevel spawnStructure does not have a player sturcture comp. attached"); return; } } else { p = PhotonNetwork.Instantiate(playerInstantiate.name, thisSpawn.transform.position, thisSpawn.transform.rotation, 0, null); myPlayer = p.GetComponent <player>(); myPlayer.spwanPos = thisSpawn.transform; } myPlayer.playerID = playerID; myPlayer.name = PhotonNetwork.player.NickName = Persistent.thisPersist.Username; // myPlayer.transform.FindChild ("Graphics").GetComponent<Renderer> ().material.color = player.getPlayerColour (playerID); p.layer = LayerMask.NameToLayer(PlayerLayer); myPlayer.animModel.layer = LayerMask.NameToLayer(GhostLayer); p.GetComponent <Rigidbody>().isKinematic = false; PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { "Kills", 0 }, { "Placed", 0 }, { "NewItemsPicked", 0 }, { "Destroyed", 0 }, { "Deaths", 0 } }); if (doObjectives) { ObjectivesManeger.thisM.Initialize(); } NetworkEnable(); view.RPC("updatePlayers", PhotonTargets.AllBuffered, myPlayer.thisView.viewID, myPlayer.name, myPlayer.playerID); }
private void SpawnPowerup(IPowerup powerup) { SpawnSpot spawnSpot = SpawnSpotController.randomSpawn; IPowerup newPowerup = Instantiate(powerup.gameObject, spawnSpot.spawnTransform.position, Quaternion.identity).GetComponent <IPowerup>(); spawnSpot.hostedPowerup = newPowerup; }
void SpawnMyPlayer(int teamID) { this.teamId = teamID; hasPickedTeam = true; if (spawnSpots == null) { Debug.LogError("WTF?!?!?"); return; } players = GameObject.FindGameObjectsWithTag("Player"); if (players.Length > 0) { foreach (SpawnSpot spawn in spawnSpots) { spawnSpotsList.Add(spawn); foreach (GameObject player in players) { if (Vector3.Distance(player.transform.position, spawn.transform.position) < 30) { spawnSpotsList.Remove(spawn); } } } mySpawnSpot = spawnSpotsList[Random.Range(0, spawnSpotsList.Count)]; } else { mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; Debug.Log("random"); } GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); PhotonPlayer photonPlayer = PhotonPlayer.Find(myPlayerGO.GetComponent <PhotonView>().owner.ID); ExitGames.Client.Photon.Hashtable playerStats = photonPlayer.customProperties; playerStats["TeamId"] = this.teamId; playerStats["hasPickedTeam"] = true; photonPlayer.SetCustomProperties(playerStats); standbyCamera.SetActive(false); spawnSpotsList.Clear(); ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true; myPlayerGO.GetComponent <FPSInputController>().enabled = true; myPlayerGO.GetComponent <CharacterMotor>().enabled = true; myPlayerGO.GetComponent <PhotonView>().RPC("SetTeamID", PhotonTargets.AllBuffered, teamID); Debug.Log("Picked"); myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true); myPlayerGO.transform.FindChild("Sniper").gameObject.SetActive(false); }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.LogError("WTF?!?!?!!?"); return; } SpawnSpot mySpawnSpot = spawnSpots [Random.Range(0, spawnSpots.Length)]; PhotonNetwork.Instantiate("FPSController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.enabled = false; }
void Start() { if (dungeoneerPrefab == null || dMPrefab == null) { Debug.LogError("<Color=Red><a>Missing</a></Color> playerPrefab Reference. Please set it up in GameObject 'Game Manager'", this); } else { if (Player.LocalPlayerInstance == null) { Debug.Log("We are Instantiating LocalPlayer from " + Application.loadedLevelName); GameObject player; if (PhotonNetwork.player.isMasterClient) { player = PhotonNetwork.Instantiate(this.dMPrefab.name, new Vector3(77, 100, 0), Quaternion.Euler(90f, 0f, 0f), 0); } else { spawnSpots = GameObject.FindObjectsOfType <SpawnSpot>(); if (spawnSpots == null) { Debug.LogError("Nope."); return; } SpawnSpot mySpawnSpot = spawnSpots[UnityEngine.Random.Range(0, spawnSpots.Length)]; // we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate //SpawnSpot mySpawnSpot = spawnSpots[PhotonNetwork.countOfPlayers]; player = PhotonNetwork.Instantiate(this.dungeoneerPrefab.name, mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); //GUI.enabled = false; } GameObject MainCamera = GameObject.FindGameObjectWithTag("MainCamera"); if (MainCamera != null) { CameraWork cameraScript = MainCamera.GetComponent <CameraWork>(); if (cameraScript != null) { if (player.name == "2D_Player(Clone)") { MainCamera.transform.position = new Vector3(MainCamera.transform.position.x, MainCamera.transform.position.y - 0.2f, MainCamera.transform.position.z); } cameraScript.target = player; ui.SetActive(true); } } Playercount += 1; } else { Debug.Log("Ignoring scene load for " + Application.loadedLevelName); } } }
void SpawnMyPlayer() { SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayer = (GameObject)PhotonNetwork.Instantiate("First Person Controller", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); //((MonoBehaviour)myPlayer.GetComponent("FPSInputController")).enabled = true; ((MonoBehaviour)myPlayer.GetComponent("MouseLook")).enabled = true; ((MonoBehaviour)myPlayer.GetComponent("PlayerMovement")).enabled = true; ((MonoBehaviour)myPlayer.GetComponent("NetworkCharacter")).enabled = true; ((MonoBehaviour)myPlayer.GetComponent("PlayerShooting")).enabled = true; myPlayer.gameObject.transform.Find("Main Camera").gameObject.SetActive(true); StandbyCamera.SetActive(false); }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.LogError("YO MY DUDE THERE'S NO SPAWNS WHAT THE F**K AAAAAA"); } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); loadingCam.SetActive(false); myPlayerGO.GetComponent <PlayerMotor> ().enabled = true; myPlayerGO.transform.Find("CameraRoot").gameObject.SetActive(true); }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.Log("There are no spawn spots"); return; } SpawnSpot mySpawnSpot = spawnSpots [Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("Player", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); //end number sets it for groups (n/a in photon cloud) myPlayerGO.transform.Find("FirstPersonController").gameObject.SetActive(true); myPlayerGO.transform.FindChild("FirstPersonCharacter").gameObject.SetActive(true); }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.Log("No spawnpoint found"); return; } SpawnSpot mySpawnSpot = spawnSpots [Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGo = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standByCamera.enabled = false; ((MonoBehaviour)myPlayerGo.GetComponent("PlayerController")).enabled = true; ((MonoBehaviour)myPlayerGo.GetComponent("Entity")).enabled = true; }
public void OnJoinedRoom() { //pos.x = (float)-1.77; //pos.y = (float)-4.75; //pos.z = (float)-10.31; /*pos.x = (float)27.19; * pos.y = (float)4.6; * pos.z = (float)-33.07; */ SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; Debug.Log("OnJoinedRoom() called by PUN. Now this client is in a room. From here on, your game would be running. For reference, all callbacks are listed in enum: PhotonNetworkingMessage"); GameObject go = PhotonNetwork.Instantiate(avatarPrefab.name, mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.LogError("no spawnspots"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); myPlayerGO.GetComponent <FP_Controller> ().enabled = true; myPlayerGO.GetComponent <FP_Shooter> ().enabled = true; myPlayerGO.transform.Find("Main Camera").gameObject.SetActive(true); standbyCamera.SetActive(false); }
IEnumerator Respawner(GameObject monster) // 몬스터 리스폰 함수. { float time = monster.GetComponent <IMonsterStatusInterface>().RespawnTime; while (time > 0f) { time -= Time.deltaTime; yield return(null); } SpawnSpot spot = monster.transform.parent.GetComponent <SpawnSpot>(); int ran = Random.Range(0, spot.monsters.Count); spot.monsters[ran].transform.localPosition = Vector3.zero; spot.monsters[ran].SetActive(true); }
public void SpawnUser() { if (!spawned) { StandByCam.SetActive(false); if (mySpectator != null) { mySpectator.SetActive(false); } if (spawnSpots == null) { Debug.LogError("No spawn locations found."); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerCharacter", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); (myPlayerGO.GetComponent("FirstPersonController") as MonoBehaviour).enabled = true; Transform PlayerCamera = myPlayerGO.transform.Find("FirstPersonCharacter"); ((Camera)PlayerCamera.GetComponent("Camera")).enabled = true; ((AudioListener)PlayerCamera.GetComponent("AudioListener")).enabled = true; myPlayerGO.transform.Find("FirstPersonCharacter").gameObject.SetActive(true); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; spawned = true; // Set our timer var (Would move the script to the UIHandler script but I already made it here so this is quicker and easier for me) UIHandler uiHandler = (UIHandler)PlayerUI.GetComponent(typeof(UIHandler)); Timing = uiHandler.TimerText; uiHandler.player = myPlayerGO; uiHandler.toggleTimer(true); uiHandler.UpdateHealth(); uiHandler.toggleWeapons(true); } }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.LogError("No spawnSpots available.."); return; } OverviewCam.enabled = false; SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayer = (GameObject)PhotonNetwork.Instantiate("FPSController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); myPlayer.GetComponentInChildren <Camera>().enabled = true; myPlayer.GetComponent <CharacterController>().enabled = true; myPlayer.GetComponentInChildren <Shooting>().enabled = true; myPlayer.GetComponentInChildren <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().enabled = true; myPlayer.GetComponentInChildren <AudioListener>().enabled = true; }
void SpawnMyPlayer() { GameControl.control.TotalMatches++; GameControl.control.WriteStats(); if (spawnSpots == null) { Debug.LogError("WTF?!?!?"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; myPlayerGO = (GameObject)PhotonNetwork.Instantiate("TheDrone", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.SetActive(false); Debug.Log("Spawned"); enableSpawnedPlayerComponents(); }
void SpawnMyPlayer() { if (spawnSpots == null) { Debug.LogError("WTF?!?!?"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.enabled = false; ((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true; myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true); }
//Handles the instantiation of the player prefab void SpawnMyPlayer() { //If there are no spawnSpots if (spawnSpots.Length == 0) { Debug.Log("There are no spawnspots in the scene"); //Initialize myPlayer to a new instantiated player prefab PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, 0, 0), new Quaternion(), 0); } else { //Choose a random SpawnSpot SpawnSpot mySpawnSpot = spawnSpots [Random.Range(0, spawnSpots.Length)]; //Initialize myPlayer to a new instantiated player prefab PhotonNetwork.Instantiate(playerPrefab.name, mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); } }
void SpawnMyPlayer(int teamID) { this.teamID = teamID; hasPickedTeam = true; AddChatMessage("Spawning player: " + PhotonNetwork.player.name); if (spawnSpots == null) { Debug.LogError("WTF?!?!?"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.SetActive(false); ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerMovement")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("Health")).enabled = true; myPlayerGO.GetComponent <PhotonView>().RPC("setTeamID", PhotonTargets.AllBuffered, teamID); crosshair.guiTexture.enabled = true; myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true); UpdateSettings(); //enable chat when spawning Chat chat = GameObject.FindObjectOfType <Chat>(); chat.chatActive = true; //disable menu when spawning Menu menu = GameObject.FindObjectOfType <Menu>(); if (menu.showMenu == true) { menu.showMenu = false; } UnFreeze(); }
void SpawnMyPlayer(int _teamID) { teamID = _teamID; hasPickedTeam = true; AddChatMessage("Spawning player: " + PhotonNetwork.player.name); //SpawnSpot spot = spawnSpots[Random.Range(0, spawnSpots.Length)]; SpawnSpot spot = spawnSpots[0]; GameObject go = PhotonNetwork.Instantiate("PlayerController", spot.transform.position, spot.transform.rotation, 0); standbyCamera.SetActive(false); go.transform.FindChild("FirstPersonCharacter").gameObject.SetActive(true); go.GetComponent <PlayerController>().enabled = true; go.GetComponent <CharacterController>().enabled = true; go.GetComponent <LegacyMouseLook>().enabled = true; go.GetComponent <PhotonView>().RPC("SetTeamID", PhotonTargets.AllBuffered, teamID); // Test code - add a bot GameObject bot = PhotonNetwork.Instantiate("BotController", botSpawnPoint.transform.position, Quaternion.identity, 0); }
void SpawnMyPlayer() { AddChatMessages("Spawning player: " + PhotonNetwork.player.name); if (spawnSpots == null) { Debug.LogError("WTF?!?!"); return; } SpawnSpot mySpawnSpot = spawnSpots [Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("CharacterGirl", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); /* * myPlayerGO.layer = 9; * myPlayerGO.GetComponentInChildren<LayerChange> ().enabled = true; * myPlayerGO.GetComponentInChildren<NewLayerChange> ().enabled = true; * myPlayerGO.GetComponentInChildren<LayerChanger1> ().enabled = true; * myPlayerGO.GetComponentInChildren<LayerChanger2> ().enabled = true; * myPlayerGO.GetComponentInChildren<LayerChanger3> ().enabled = true; * myPlayerGO.GetComponentInChildren<LayerChanger4> ().enabled = true; * myPlayerGO.GetComponentInChildren<LayerChanger5> ().enabled = true; * myPlayerGO.transform.FindChild ("Hitboxes").gameObject.SetActive (false); */ myPlayerGO.GetComponentInChildren <Camera> ().enabled = true; //GameObject myGrudva = (GameObject)PhotonNetwork.Instantiate ("grudva", myPlayerGO.transform.position + myPlayerGO.transform.forward, myPlayerGO.transform.rotation, 0); standByCamera.SetActive(false); menuModel.SetActive(false); standByLight.SetActive(false); myPlayerGO.GetComponent <PlayerMovement> ().enabled = true; myPlayerGO.GetComponent <FirstPersonController> ().enabled = true; //myPlayerGO.GetComponent<CharacterController> ().enabled = true; myPlayerGO.GetComponent <BacanjeGrudve> ().enabled = true; myPlayerGO.GetComponent <Health> ().enabled = true; //myPlayerGO.GetComponent<Grudva> ().enabled = true; //myGrudva.GetComponent<GlassBreaker> ().enabled = true; myPlayerGO.GetComponentInChildren <AudioListener>().enabled = true; myPlayerGO.GetComponentInChildren <Chrosshair>().enabled = true; myPlayerGO.tag = "MyPlayer"; }
void Start() { spawnSpots = GameObject.FindObjectsOfType <SpawnSpot> (); if (spawnSpots == null) { Debug.LogError("Nope."); return; } SpawnSpot mySpawnSpot = spawnSpots [Random.Range(0, spawnSpots.Length)]; //standbyCamera.enabled = false; GameObject player = PhotonNetwork.Instantiate("Dungeoneer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); player.transform.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController> ().enabled = true; player.GetComponent <CharacterController>().enabled = true; player.transform.FindChild("FirstPersonCharacter").gameObject.SetActive(true); }
public void SpawnMyPlayer(PlayerClass teamId) { if (_spawnSpots == null) { Debug.Log("_spawnSpots is null, no where to spawn"); return; } SpawnSpot[] teamSpots = _spawnSpots.Where(t => t.ClassID == teamId).ToArray(); SpawnSpot mySpawnSpot = teamSpots[Random.Range(0, teamSpots.Length)]; GameObject player; switch (teamId) { case PlayerClass.Rock: player = PhotonNetwork.Instantiate("RockPlayer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); break; case PlayerClass.Paper: player = PhotonNetwork.Instantiate("PaperPlayer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); break; case PlayerClass.Scissors: player = PhotonNetwork.Instantiate("ScissorsPlayer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); break; default: player = PhotonNetwork.Instantiate("RockPlayer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); break; } StandbyCamera.SetActive(false); player.transform.Find("Main Camera").gameObject.SetActive(true); player.transform.Find("Graphics").gameObject.SetActive(false); player.GetComponent <FirstPersonController>().enabled = true; _uiManager.DisplayHUD(teamId); }
void AddMonster() // 스팟의 몬스터 정보대로 몬스터 생성 { for (int i = 0; i < spots.Count; i++) // 스팟 개수만큼 { SpawnSpot spot = spots[i].GetComponent <SpawnSpot>(); for (int index = 0; index < maxMonsterType; index++) // 스팟 별 생성 가능 몬스터 종류 만큼 (최대 3) { int.TryParse(spawnData[spots[i].id - 1]["Monster_ID_" + (index + 1)].ToString(), out int id); // 몬스터 아이디 if (DataManager.Instance.monsterMap.TryGetValue(id, out MonsterInfo value)) // 몬스터 딕셔너리에서 몬스터 정보 꺼내오기 { GameObject monster = Instantiate(ResourceManager.Instance.GetObj(value.monsterName), spots[i].transform); // 몬스터 정보 (이름)으로 리소스 검색 후 생성 IMonsterStatusInterface i_status = monster.GetComponent <IMonsterStatusInterface>(); // 몬스터 정보 인터페이스 i_status.SetInfo(value); // 리소스에 몬스터 정보 Set monster.transform.localPosition = Vector3.zero; spot.monsters.Add(monster); monster.SetActive(false); } } } }
void SpawnMyPlayer() { AddChatMessage("Spawning player: " + PhotonNetwork.player.name); if (spawnSpots == null) { Debug.LogError("No spawns"); return; } SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)]; GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("NetworkPlayer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0); standbyCamera.SetActive(false); ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerMovement")).enabled = true; ((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true; myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true); myPlayer = myPlayerGO; ((MonoBehaviour)GetComponent <GameManager>().GetComponent <PauseMenu>()).enabled = true; }
public void ReSpawn() { //重生 //CANNOT SEEN BY OTHERS AND CANNOT PUT THE BOMB; foreach (Transform child in transform) { /*if (child.gameObject.GetComponent<MeshRenderer> () != null) * child.gameObject.GetComponent<MeshRenderer> ().enabled = false; * if (child.gameObject.GetComponent<SkinnedMeshRenderer> () != null) * child.gameObject.GetComponent<SkinnedMeshRenderer> ().enabled = false;*/ if (child.name != "Camera") { child.gameObject.SetActive(false); } } gameObject.GetComponent <PowerUpManager> ().enabled = false; spawnSpots = GameObject.FindObjectsOfType <SpawnSpot>(); SpawnSpot newSpawn = spawnSpots [Random.Range(0, spawnSpots.Length)]; transform.position = newSpawn.transform.position; transform.rotation = newSpawn.transform.rotation; }
void AddSpotInScene() // 씬의 모든 스폰 스팟(구역 아이디 포함) { for (int i = 0; i < spawnData.Count; i++) { int mapID = (int)spawnData[i]["Map_ID"]; if (areas.Contains(mapID)) { float x = float.Parse(spawnData[i]["X"].ToString()); float y = float.Parse(spawnData[i]["Y"].ToString()); float z = float.Parse(spawnData[i]["Z"].ToString()); float rot_Y = float.Parse(spawnData[i]["Rotation_Y"].ToString()); Vector3 pos = new Vector3(x, y, z); Quaternion rot = Quaternion.AngleAxis(rot_Y, Vector3.up); GameObject spotClone = Instantiate(spot, pos, rot, spawner.transform); spotClone.name = "spot" + i; SpawnSpot spawn = spotClone.GetComponent <SpawnSpot>(); spawn.id = (int)spawnData[i]["ID"]; spots.Add(spawn); } } }