This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
project-undercover/Project Undercover/Assets/Scripts/Lobby/GameManager.cs

72 lines
2 KiB
C#
Raw Normal View History

using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameManager : Photon.PunBehaviour {
public GuardCameraController guardCamera;
public GameObject spyPrefab, NPCPrefab, cameraRigPrefab;
public int numNpcs = 9;
public override void OnLeftRoom()
{
SceneManager.LoadScene("Launcher");
}
public override void OnPhotonPlayerConnected(PhotonPlayer other)
{
Debug.Log("OnPhotonPlayerConnected() " + other.NickName); // not seen if you're the player connecting
}
public override void OnPhotonPlayerDisconnected(PhotonPlayer other)
{
Debug.Log("OnPhotonPlayerDisconnected() " + other.NickName); // seen when other disconnects
LeaveRoom();
}
public void LeaveRoom()
{
PhotonNetwork.LeaveRoom();
}
2017-09-26 16:44:11 -05:00
void Start()
{
if (PersistantPlayerSettings.character == PersistantPlayerSettings.Character.Guard)
{
guardCamera.SetCameraEnabled(guardCamera, true);
2017-10-03 04:15:13 -05:00
//guardPanel.SetActive(true);
}
else
{
guardCamera.GetComponent<GuardCamera>().spotLight.enabled = true;
Vector3 randPos = StateController.GetRandomLocation();
var spy = PhotonNetwork.Instantiate(spyPrefab.name, randPos, Quaternion.identity, 0);
2017-10-03 04:15:13 -05:00
GameObject cameraRig = Instantiate(cameraRigPrefab, Vector3.zero, Quaternion.identity);
cameraRig.GetComponentInChildren<ThirdPersonCameraController>().SetTarget(spy.transform);
//spyPanel.SetActive(true);
}
2017-09-26 16:07:13 -05:00
if (PhotonNetwork.isMasterClient)
{
for (int i = 0; i < numNpcs; i++)
{
Vector3 randPos = StateController.GetRandomLocation();
PhotonNetwork.Instantiate(NPCPrefab.name, randPos, Quaternion.identity, 0);
}
2017-09-26 16:07:13 -05:00
}
}
[PunRPC]
void SpawnNPC(Vector3 pos)
{
Instantiate(NPCPrefab, pos, Quaternion.identity);
}
}