void Start() { maxHP = HP; gameOverCanvas.enabled = false; playerUIHandler = FindObjectOfType <PlayerUIHandler>(); fpsController = GetComponentInParent <RigidbodyFirstPersonController>(); }
private void Start() { _renderer = GetComponentInChildren <SpriteRenderer>(); handler = GetComponent <PlayerUIHandler>(); color = _renderer.material.GetColor("GlowColor"); UpdateCharge(); }
private void Start() { handler = FindObjectOfType <PlayerUIHandler>(); anim = GetComponent <Animator>(); controller = GetComponent <PlayerController>(); handler.UpdateHealth(totalHealth); }
void Start() { spawnPoints = GetComponentsInChildren <EnemySpawnPoint>(); playerUIHandler = FindObjectOfType <PlayerUIHandler>(); pickupManager = FindObjectOfType <PickupManager>(); waveNum = 1; StartCoroutine(StartNextWave()); }
private void AssignUI(CharController charController, int currPlayer) { //Debug.Log("Inside AssignUI for " + currPlayer); PlayerUIHandler pu = charController.gameObject.AddComponent <PlayerUIHandler>(); pu.SetUp(healthBars[currPlayer - 1], abilityCDsX[currPlayer - 1], abilityCDsY[currPlayer - 1], abilityCDsA[currPlayer - 1], abilityCDsB[currPlayer - 1], charController); charController.pui = pu; }
void Start() { FPSCamera = Camera.main; ammo = GetComponentInParent <Ammo>(); animator = GetComponent <Animator>(); playerUIHandler = FindObjectOfType <PlayerUIHandler>(); UpdateWeaponUI(); previousAmmo = ammo.GetAmmoAmount(ammoType); }
public void Initialize(GameHandler gameHandler) { menuUIHandler = GetComponentInChildren <MenuUIHandler>(); menuUIHandler.Initialize(gameHandler); gameOverviewUIHandler = GetComponentInChildren <GameOverviewUIHandler>(); gameOverviewUIHandler.Initialize(); playerUIHandler = GetComponentInChildren <PlayerUIHandler>(); playerUIHandler.Initialize(gameHandler); }
private void Start() { GameConstants.Instance.PlayerObject = gameObject; mPlayerMovementScript = GetComponent <PlayerMovement>(); mPlayerParticleHandlerScript = GetComponent <PlayerParticleHandler>(); mPlayerUIHandler = mPlayerUICanvas.GetComponent <PlayerUIHandler>(); mMainSystemScript = mMainSystem.GetComponent <MainSystem>(); }
private void Start() { mPlayerHandler = mPlayerObject.GetComponent <PlayerHandler>(); mPlayerUIHandler = mPlayerUICanvas.GetComponent <PlayerUIHandler>(); }
IEnumerator Flow() { TitleScreen.alpha = 0.0f; Announcements.alpha = 0.0f; while (true) { GameUI.alpha = 0.0f; MusicSource.clip = IntroClip; MusicSource.Play(); // Title screen fade if (!FastSpawn) { float time = Time.time; while ((Time.time - time) < 3) { yield return(null); } while ((Time.time - time) < 4) { TitleScreen.alpha = (Time.time - time) - 3.0f; yield return(null); } } // Show title screen TitleScreen.alpha = 1.0f; while (BackToTitle) { yield return(null); } MusicSource.Stop(); MusicSource.clip = IngameClip; MusicSource.Play(); if (!FastSpawn) { float time = Time.time; while ((Time.time - time) < 1) { TitleScreen.alpha = 1.0f - (Time.time - time); yield return(null); } } // Hide title screen TitleScreen.alpha = 0.0f; GameUI.alpha = 1.0f; TeamLeftScore = 0; TeamRightScore = 0; while (true) { ResetGame = false; if (PlayerCount < 2 && PlayerCount > 4) { Debug.Break(); } if (players != null) { foreach (PlayerController p in players) { if (p != null) { Destroy(p.gameObject); } } } foreach (GameObject j in junkList) { Destroy(j); } junkList.Clear(); if (cameraManager != null) { cameraManager.Destroy(); Destroy(cameraManager.gameObject); } if (BackToTitle) { break; } // CREATE INITIAL JUNK int totalJunk = 0; int[] freqAccum = new int[JunkPrefabs.Length]; for (int i = 0; i < JunkPrefabs.Length; i++) { totalJunk += JunkPrefabs[i].freq; freqAccum[i] = totalJunk; } UnityEngine.Random rand = new UnityEngine.Random(); for (int i = 0; i < InitialJunkCount; i++) { int sel = 0; int val = UnityEngine.Random.Range(0, totalJunk); for (; sel < freqAccum.Length && val > freqAccum[sel]; sel++) { ; } GameObject junk = Instantiate(JunkPrefabs[sel].prefab); junk.name = string.Format("Junk{0}({1})", i, JunkPrefabs[sel].prefab.name); junkList.Add(junk); float pos = (float)(Math.Round(UnityEngine.Random.Range(0.0f, 1.0f)) * 2.0f - 1.0f) * 75.0f; junk.transform.position = new Vector3(pos, 1.0f, 0.0f); junk.transform.rotation *= Quaternion.Euler(0, 0, UnityEngine.Random.Range(0, 2 * Mathf.PI)); if (!FastSpawn || i % 10 == 0) { yield return(null); } } // WAIT 5 SECS if (!FastSpawn) { float time = Time.time; while ((Time.time - time) < 2.5f) { yield return(null); } } // CREATE PLAYERS players = new PlayerController[PlayerCount]; Camera CameraTemplate = transform.Find("CameraTemplate")?.GetComponent <Camera>(); if (CameraTemplate == null) { Debug.Break(); } PlayerController PlayerTemplate = transform.Find("PlayerTemplate")?.GetComponent <PlayerController>(); if (PlayerTemplate == null) { Debug.Break(); } if (GameUI == null) { Debug.Break(); } PlayerUIHandler PlayerUITemplate = GameUI.transform.Find("PlayerUITemplate")?.GetComponent <PlayerUIHandler>(); if (PlayerUITemplate == null) { Debug.Break(); } for (int i = 0; i < PlayerCount; i++) { // Create player players[i] = Instantiate(PlayerTemplate); players[i].gameObject.SetActive(true); players[i].gameObject.name = string.Format("Player{0}", i + 1); players[i].Init(i); float side = ((i % 2) * 2) - 1.0f; float team = ((i / 2) * 2) - 1.0f; players[i].transform.position = new Vector3(50.0f * side + 3.0f * team, 0, 0); foreach (MeshRenderer plRender in players[i].ColorRenderers) { if (plRender && PlayerMaterials != null && i < PlayerMaterials.Length) { plRender.material = PlayerMaterials[i]; } } } if (true || PlayerCount == 2) { var camDirectorObj = new GameObject(); camDirectorObj.name = "CameraDirector"; cameraManager = camDirectorObj.AddComponent <CameraDirector>(); cameraManager.Setup(CameraTemplate, players, GameUI, PlayerUITemplate); } else { var camDirectorObj = new GameObject(); camDirectorObj.name = "CameraSplit"; cameraManager = camDirectorObj.AddComponent <CameraSplit>(); cameraManager.Setup(CameraTemplate, players, GameUI, PlayerUITemplate); } for (int i = 0; i < PlayerCount; i++) { var healthMeter = cameraManager.GameUIs[i].transform.Find("HealthMeter")?.GetComponent <UnityEngine.UI.Text>(); if (healthMeter != null) { healthMeter.color = Color.Lerp(Color.black, PlayerMaterials[i].color, 0.8f); } } // Check if someone won bool leftWon = false; while (true) { // Check if int teamLeftAlive = 0; int teamRightAlive = 0; for (int i = 0; i < players.Length; i++) { bool left = (i % 2) == 0; bool dead = players[i].health <= 0; int healthUI = (int)Math.Round(players[i].health); if (healthUI < 0) { healthUI = 0; } cameraManager.GameUIs[i].HealthMeter.text = string.Format("Health: {0}%", healthUI); if (left) { teamLeftAlive += dead ? 0 : 1; } else { teamRightAlive += dead ? 0 : 1; } } if (ResetGame || BackToTitle) { continue; } if (teamLeftAlive == 0) { leftWon = false; break; } if (teamRightAlive == 0) { leftWon = true; break; } yield return(null); } UnityEngine.UI.Text annText = Announcements.GetComponent <UnityEngine.UI.Text>(); if (annText != null) { if (leftWon) { annText.text = "Team left\n WINS"; } else { annText.text = "Team right\n WINS"; } } // FADE IN if (!FastSpawn) { float time = Time.time; while ((Time.time - time) < 1) { Announcements.alpha = Time.time - time; yield return(null); } } Announcements.alpha = 1.0f; { float time = Time.time; while ((Time.time - time) < 5) { yield return(null); } } // FADE OUT if (!FastSpawn) { float time = Time.time; while ((Time.time - time) < 1) { Announcements.alpha = 1.0f - (Time.time - time); yield return(null); } } Announcements.alpha = 0.0f; } } }
public override void Setup(Camera CameraTemplate, PlayerController[] ToFollow, CanvasGroup UI, PlayerUIHandler PlayerUITemplate) { Destroy(); base.Setup(CameraTemplate, ToFollow, UI, PlayerUITemplate); follow = new PlayerController[ToFollow.Length]; for (int i = 0; i < ToFollow.Length; i++) { follow[i] = ToFollow[i]; } cameras = new Camera[follow.Length]; smoothPos = new Vector2[follow.Length]; for (int i = 0; i < cameras.Length; i++) { cameras[i] = Instantiate(CameraTemplate); cameras[i].gameObject.SetActive(true); cameras[i].gameObject.name = string.Format("Camera{0}", i + 1); cameras[i].transform.SetParent(transform, false); smoothPos[i] = follow[i].ToFollow.position; } if (CameraTemplate.orthographic) { orthographicSize = CameraTemplate.orthographicSize; } else { double dst = Math.Abs(CameraTemplate.transform.position.z); double tan = Math.Tan(CameraTemplate.fieldOfView); double size = (dst * tan) / CameraTemplate.aspect; orthographicSize = (float)(size * 0.5); } }
public override void Setup(Camera CameraTemplate, PlayerController[] ToFollow, CanvasGroup UI, PlayerUIHandler PlayerUITemplate) { Destroy(); base.Setup(CameraTemplate, ToFollow, UI, PlayerUITemplate); follow = new PlayerController[ToFollow.Length]; for (int i = 0; i < ToFollow.Length; i++) { follow[i] = ToFollow[i]; } cameras = new Camera[follow.Length]; for (int i = 0; i < cameras.Length; i++) { cameras[i] = Instantiate(CameraTemplate); cameras[i].gameObject.SetActive(true); cameras[i].gameObject.name = string.Format("Camera{0}", i + 1); cameras[i].transform.SetParent(transform, false); Rect rect = cameras[i].rect; rect.x = (i % 2) * 0.5f; rect.width = 0.5f; if (ToFollow.Length > 2) { rect.height = 0.5f; if ((i / 2) < 1) { rect.y = 0.5f; } } cameras[i].rect = rect; CameraPlayer cp = cameras[i].GetComponent <CameraPlayer>(); if (cp == null) { cp = cameras[i].gameObject.AddComponent <CameraPlayer>(); } cp.Follow = follow[i]; } orthographicSize = CameraTemplate.orthographicSize; }
public virtual void Setup(Camera CameraTemplate, PlayerController[] ToFollow, CanvasGroup UI, PlayerUIHandler PlayerUITemplate) { GameUIs = new PlayerUIHandler[ToFollow.Length]; for (int i = 0; i < GameUIs.Length; i++) { GameUIs[i] = Instantiate(PlayerUITemplate); GameUIs[i].gameObject.SetActive(true); GameUIs[i].gameObject.name = string.Format("PlayerUI{0}", i + 1); GameUIs[i].transform.SetParent(UI.transform, false); } }