void Awake() { if (!i) { i = this; DontDestroyOnLoad(gameObject); version = GameObject.Find("Launcher").GetComponent <Launcher>().gameVersion; versiontxt.text = version; } else { Destroy(gameObject); } }
private void Start() { //Get references. localSettings = GameObject.Find("LocalSettings").GetComponent <LocalSettings>(); foreach (PhotonPlayer player in PhotonNetwork.playerList) { if (player.GetTeam() == PunTeams.Team.red) { teamRedCount++; teamRed.Add(player); Debug.Log(teamRedCount); } else { teamBlueCount++; teamBlue.Add(player); Debug.Log(teamBlueCount); } } if (PlayerMovement.localPlayerInstance == null) { if (PhotonNetwork.player.GetTeam() == PunTeams.Team.red) { spawn = spawnPointRed.transform.position; } else { spawn = spawnPointBlue.transform.position; } PhotonNetwork.Instantiate(playerPrefab.name, spawn, Quaternion.identity, 0); analytics = GameObject.FindGameObjectWithTag("Analytics").GetComponent <SendAnalyticInfo>(); } //Handle adding bots into the game. if (PhotonNetwork.isMasterClient && localSettings.addBots == true) { for (int i = teamRedCount; i < 5; i++) { Debug.Log("adding red bot"); // spawn bot GameObject bot = PhotonNetwork.Instantiate(botPrefab.name, new Vector3(0, 1000, 0), Quaternion.identity, 0) as GameObject; Text botNameText = (Text)bot.GetComponentInChildren(typeof(Text)); BOT_Profile bOT_Profile = (BOT_Profile)bot.GetComponent(typeof(BOT_Profile)); botNameText.color = Color.red; bOT_Profile.GetAndSetBotName(); botNameText.text = "[BOT]" + bOT_Profile.botName; bot.GetComponent <BOT_Profile>().red = true; if (bot.GetComponent <BOT_Profile>().red&& !bot.GetComponent <NavMeshAgent>().isOnNavMesh) { bot.GetComponent <NavMeshAgent>().Warp(spawnPointRed.transform.position); } else { bot.GetComponent <NavMeshAgent>().Warp(spawnPointBlue.transform.position); } teamRedCount++; } for (int i = teamBlueCount; i < 5; i++) { Debug.Log("adding blue bot"); // spawn bot GameObject bot = PhotonNetwork.Instantiate(botPrefab.name, new Vector3(0, 1000, 0), Quaternion.identity, 0) as GameObject; // Text botNameText = (Text)bot.GetComponentInChildren(typeof(Text)); BOT_Profile bOT_Profile = (BOT_Profile)bot.GetComponent(typeof(BOT_Profile)); botNameText.color = Color.blue; bOT_Profile.GetAndSetBotName(); botNameText.text = "[BOT]" + bOT_Profile.botName; bot.GetComponent <BOT_Profile>().blue = true; if (bot.GetComponent <BOT_Profile>().red&& !bot.GetComponent <NavMeshAgent>().isOnNavMesh) { bot.GetComponent <NavMeshAgent>().Warp(spawnPointRed.transform.position); } else { bot.GetComponent <NavMeshAgent>().Warp(spawnPointBlue.transform.position); } teamBlueCount++; } } }
// Use this for initialization void Start() { if (photonView.isMine) { //Get references. localSettings = GameObject.Find("LocalSettings").GetComponent <LocalSettings>(); roundWinPanel = GameObject.Find("RoundWinTeamPanel"); roundWinPanel.SetActive(false); movement = GetComponent <PlayerMovement> (); cameraLook = GetComponent <CameraLook> (); roundTimerText = GameObject.Find("RoundTimerText").GetComponent <Text>(); timeLeft = roundLengthInSecs; playerStats = GetComponent <PlayerStatsHandler>(); coundownFromEnd = roundFinishCooldown; analytics = GameObject.FindGameObjectWithTag("Analytics").GetComponent <SendAnalyticInfo>(); analytics.inMatch = true; gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); playerShoot = GetComponent <PlayerShoot>(); // 1st round roundCounter = GameObject.Find("RoundCounterText").GetComponent <Text>(); roundTimerText.text = Mathf.CeilToInt(timeLeft).ToString(); playerShoot.enabled = false; movement.enabled = false; cameraLook.enabled = false; startCountdown = true; didYouWin = GameObject.Find("DidYouWin"); didYouWin.SetActive(false); PunTeams.Team team = PhotonNetwork.player.GetTeam(); GameObject teamTextThing = GameObject.Find("TeamDefineText"); string teamS = ""; if (team == PunTeams.Team.blue) { teamS = "blue"; teamTextThing.GetComponent <Text> ().color = Color.blue; } else if (team == PunTeams.Team.red) { teamS = "red"; teamTextThing.GetComponent <Text> ().color = Color.red; } teamTextThing.GetComponent <Text> ().text = "You are on " + teamS + " team."; } if (PhotonNetwork.isMasterClient) { roundTimerText = GameObject.Find("RoundTimerText").GetComponent <Text>(); sync = syncEverySecs; timeLeft = roundLengthInSecs; roundTimerText.text = Mathf.CeilToInt(timeLeft).ToString(); coundownFromEnd = roundFinishCooldown; } playerHealth = GetComponent <PlayerHealth>(); }