/* void OnGUI() { GUILayout.BeginHorizontal("box"); GUILayout.Label("Player Count: "); for (int i = 0; i < 4; i++) if (GUILayout.Button(i + 1 + "")) SetPlayerCount(i + 1); GUILayout.EndHorizontal(); } */ void Awake() { gameOver = false; lava = GameObject.FindGameObjectWithTag("Lava").GetComponent<LavaController>(); playerList.Add(GameObject.FindGameObjectWithTag("Player")); spawnPoints = GameObject.FindGameObjectWithTag("Respawn").transform; //if (playerControllerIDs == null) playerControllerIDs = new int[] { -1, 1, 2, 3 }; //else playerList[0].GetComponent<PlayerController>().controllerID = playerControllerIDs[0]; SetPlayerCount(playerCount); AudioController.LoopSound(gameMusic, AudioChannel.UI); }
private void Start() { sharedInput = ReInput.players.GetPlayer("Shared"); menuController = GetComponent <MenuController>(); gemsCounter = GameObject.Find("Canvas/GemsCounterText").GetComponent <TextMeshProUGUI>(); countdownText = GameObject.Find("Canvas/CountdownText").GetComponent <TextMeshProUGUI>(); skullsManager = GameObject.Find("SkullsManager").GetComponent <SkullsManager>(); backdrop = GameObject.Find("Canvas/Backdrop"); gameOverMenu = GameObject.Find("Canvas/GameOverMenuPanel"); gameWinMenu = GameObject.Find("Canvas/GameWinMenuPanel"); winScreenDifficulty = gameWinMenu.transform.Find("DifficultyText").GetComponent <TextMeshProUGUI>(); winScreenTotalGems = gameWinMenu.transform.Find("TotalGemsText").GetComponent <TextMeshProUGUI>(); winScreenRedGems = gameWinMenu.transform.Find("RedGemsText").GetComponent <TextMeshProUGUI>(); winScreenBlueGems = gameWinMenu.transform.Find("BlueGemsText").GetComponent <TextMeshProUGUI>(); EnableGameOverMenu(false); EnableGameWinMenu(false); lavaController = GameObject.Find("Grid/Lava").GetComponent <LavaController>(); cameraController = GameObject.Find("Main Camera").GetComponent <CameraController>(); var players = GameObject.FindGameObjectsWithTag("Player"); playerControllers = new List <PlayerController>(); foreach (var player in players) { playerControllers.Add(player.GetComponent <PlayerController>()); } skullsManager.SpawnSkulls(); SetDifficulty(); UpdateUI(); StartCoroutine(StartCountdown(countdownSeconds)); StartCoroutine(RumbleInSeconds(countdownSeconds)); StartCoroutine(MoveLavaInSeconds(countdownSeconds + rumblingSeconds)); StartCoroutine(RandomRumbler(15, 30)); musicAudioSource.Play(); Cursor.visible = false; }
private void StartGame() { //Remove lava drops so they don't hit players on a new game List <GameObject> lavaDrops = new List <GameObject>(GameObject.FindGameObjectsWithTag("LavaDrop")); for (int i = 0; i < lavaDrops.Count; i++) { if (lavaDrops[i] != null) { Destroy(lavaDrops[i]); } } //Reset game values score = 0; currLevel = 1; coinTotal = 0; timeBonus = 30; bonusTracker = 1f; //Spawn new map and start at level one Spawn updateMap = (Spawn)tileMap.transform.Find("Spawner").GetComponent(typeof(Spawn)); updateMap.StartGame(); //Reset projectile frequency LavaController updateLavaArray = (LavaController)tileMap.transform.Find("LavaController").GetComponent(typeof(LavaController)); updateLavaArray.SetFrequency(currLevel); //Set game running value gameRunning = true; paused = false; //Display UI Changes for Starting Game //REFACTOR magic numbers Score.GetComponent <Text>().color = new Color(.84f, .89f, .98f, .75f); Level.GetComponent <Text>().color = new Color(.84f, .89f, .98f, 1f); LevelContainer.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f); ScoreIcon.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f); StartLine.GetComponent <StartLine>().showStart = false; TitleCard.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0f); GameOver.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0f); Ctrls.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, .25f); FinalScore.HideScore(); }
public void EndGame(bool winCheck) { //Display UI Changes for Ending Game Score.GetComponent <Text>().color = new Color(1f, 1f, 1f, 0f); Level.GetComponent <Text>().color = new Color(1f, 1f, 1f, 0f); LevelContainer.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0f); ScoreIcon.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0f); StartLine.GetComponent <StartLine>().showStart = true; GameOver.GetComponent <Animator>().SetBool("Win", winCheck); GameOver.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f); FinalScore.ShowScore(score); //Remove projectiles after game has ended LavaController updateLavaArray = (LavaController)tileMap.transform.Find("LavaController").GetComponent(typeof(LavaController)); updateLavaArray.SetFrequency(0); //Set game running value gameRunning = false; }
//If coin count hits 3, start next level and add time and score bonus private void CheckLevel() { levelCoins = coinTotal % 3; if (levelCoins == 0) { GameObject player = GameObject.FindWithTag("Player"); //Display level up animation if (player != null) { GameObject levelUp = Instantiate(addScorePrefab, player.transform.position, new Quaternion(0f, 0f, 0f, 0f)); levelUp.GetComponent <AddScore>().SetAnimation(1); } //Update values score += 50 + timeBonus; timeBonus = 30; bonusTracker = 1f; currLevel++; //End game if level hits 50 if (currLevel > 50) { if (player != null) { Destroy(player); } EndGame(true); return; } //Start a new map for next level Spawn updateMap = (Spawn)tileMap.transform.Find("Spawner").GetComponent(typeof(Spawn)); updateMap.SpawnNewMap(currLevel); //Make projectiles faster LavaController updateLavaArray = (LavaController)tileMap.transform.Find("LavaController").GetComponent(typeof(LavaController)); updateLavaArray.SetFrequency(currLevel); } }