//Navigating to the campaign menu void GotoMissionSelection() { UISelectionAudio(); currentMenu = activeMenu.MissionSelection; ShowAndHideCanvas(); GetComponent <AudioSource>().clip = UImusic[4]; GetComponent <AudioSource>().Play(); Dpad(); }
//Navigating to the selection menu void GoToCharSelection() { if (currentMenu == activeMenu.Highscore) { GetComponent <AudioSource>().clip = UImusic[2]; GetComponent <AudioSource>().Play(); } currentMenu = activeMenu.CharSelection; ShowAndHideCanvas(); UISelectionAudio(); }
void Update() { if (Input.GetKey(KeyCode.I)) { InstaWin(); } if (currentMenu == activeMenu.None) { //Count players alive if (CountPlayersAlive() == 0 && (!objectiveComplete || bossSpawned)) { Debug.Log("GameOver"); currentMenu = activeMenu.Highscore; StartCoroutine(ShowHighScore()); } if (missionMode == missionObjectives.escortAndDefend) { GameObject[] escortPlaneCount = GameObject.FindGameObjectsWithTag("Escort"); if (escortPlaneCount.Length == 0 && !objectiveComplete && !bossSpawned && currentMenu != activeMenu.Highscore) { Debug.Log("GameOver"); currentMenu = activeMenu.Highscore; StartCoroutine(ShowHighScore()); } } UpdateIngameUI(); } else { MenuNavigation(); } //Back to MainMenu if (currentMenu != activeMenu.None && (GamePad.GetButton(GamePad.Button.Y, GamePad.Index.Any) || Input.GetKey(KeyCode.Y)) && !pressedButton && fadeFinished) { pressedButton = true; GotoMainMenu(); } }
//Navigating to the main menu void GotoMainMenu() { currentMenu = activeMenu.ModeSelection; currentMainMenuSelection = 0; //Default is 1 -> Misson ShowAndHideCanvas(); UISelectionAudio(); //Reset menu colorization for (int i = 0; i < mainMenuGuiText.Count; i++) { mainMenuGuiText[i].color = new Color(255f, 255f, 255f, 255f); string tempString = mainMenuGuiText[i].text; tempString = tempString.Replace("✠", " "); mainMenuGuiText[i].text = tempString; } mainMenuGuiText[currentMainMenuSelection].color = new Color(255f, 0f, 0f, 255f); mainMenuGuiText[currentMainMenuSelection].text = mainMenuGuiText[currentMainMenuSelection].text.Remove(0, 1); mainMenuGuiText[currentMainMenuSelection].text = mainMenuGuiText[currentMainMenuSelection].text.Remove(mainMenuGuiText[currentMainMenuSelection].text.Length - 1, 1); mainMenuGuiText[currentMainMenuSelection].text = mainMenuGuiText[currentMainMenuSelection].text.Insert(0, "✠"); mainMenuGuiText[currentMainMenuSelection].text = mainMenuGuiText[currentMainMenuSelection].text.Insert(mainMenuGuiText[currentMainMenuSelection].text.Length, "✠"); }
public IEnumerator ShowHighScore() { if (gameMode == selectedGameMode.survive) { objectiveComplete = true; } gameOver.SetActive(!objectiveComplete); fadeDirection = 1; StartCoroutine("Fade"); yield return(new WaitForSeconds(1)); currentMenu = activeMenu.Highscore; ShowAndHideCanvas(); if (objectiveComplete) { //Update missionProgress if (gameMode == selectedGameMode.campaign) { Missions[currentMissionSelected].GetComponent <Mission>().status = 2; //Save progress to saveFile SaveFile.current.campaignMissionStatus[currentMissionSelected] = 2; //unlock next misson if (currentMissionSelected < Missions.Count - 1) { if (Missions[currentMissionSelected + 1].GetComponent <Mission>().status == 0) { Missions[currentMissionSelected + 1].GetComponent <Mission>().status = 1; SaveFile.current.campaignMissionStatus[currentMissionSelected + 1] = 1; } } //Autoselect next Mission do { if (currentMissionSelected < Missions.Count - 1) { currentMissionSelected++; } else { currentMissionSelected = 0; } }while (Missions[currentMissionSelected].GetComponent <Mission>().status < 1); Dpad(); Save(); for (int i = 0; i < Missions.Count; i++) { Missions[i].GetComponent <SpriteRenderer>().sprite = MissionSprites[Missions[i].GetComponent <Mission>().status]; } } GetComponent <AudioSource>().clip = UImusic[5]; GetComponent <AudioSource>().Play(); } else { GetComponent <AudioSource>().clip = UImusic[6]; GetComponent <AudioSource>().Play(); } StopSpawnCoroutines();//Stop spawning props and units StopCoroutine("CountDown"); //Remove all gamePlayAssets from Scene CleanScene("Player"); CleanScene("Enemy"); CleanScene("Props"); CleanScene("Island"); CleanScene("Escort"); CleanScene("Bullet"); CleanScene("Level"); CleanScene("PowerUp"); int highestScore = 0; int highestPlayer = 0; float pos = 256, posY = 0.64f; for (int j = 0; j < playerCount; j++) { //highScoreGUIText[j].transform.localPosition = new Vector3((0 - pos * (playerCount - 1)) + j * (pos * 2), posY, 0f); } for (int i = 0; i < 4; i++) { if (playerActive[i]) { highScoreGUIText[i].text = " Spieler " + (i + 1) + " \n Punkte: \n" + playerScore[i]; } else { highScoreGUIText[i].text = ""; } highScoreGUIText[highestPlayer].transform.GetChild(0).gameObject.SetActive(false); if (playerScore[i] > highestScore) { highestScore = playerScore[i]; highestPlayer = i; } highScoreGUIText[i].transform.position = new Vector3((0 - pos * (playerCount - 1)) + i * (pos * 2), posY, 0f); } highScoreGUIText[highestPlayer].transform.GetChild(0).gameObject.SetActive(true); resetScore(); ShowAndHideCanvas(); fadeDirection = -1; StartCoroutine("Fade"); }
void GameStart() { objectiveComplete = false; fadeDirection = -1; StartCoroutine("Fade"); //Spawn the playerPlanes for (int i = 0; i < playerCount; i++) { if (playerActive[i]) { player[i] = (GameObject)Instantiate(PlayableCharacters[Mathf.Abs(chosenCharacterIndex[i])], new Vector2((1 - playerCount) + (i * 2), -4f), PlayableCharacters[Mathf.Abs(chosenCharacterIndex[i])].transform.rotation); player[i].SendMessage("SetPlayer", (i + 1)); player[i].SendMessage("SetPlaneValue", (playerCount)); } } objectiveComplete = false; //activeMenu.None check will be used to check inside of Update() if all players are alive, so it needs to be set AFTER the players are spawned currentMenu = activeMenu.None; ShowAndHideCanvas(); if (gameMode == selectedGameMode.campaign) { Background.GetComponent <MeshRenderer>().material = BackgroundMaterials[currentMissionSelected / 5]; //Spawn level if assigned if (missionObjects[currentMissionSelected] != null) { Instantiate(missionObjects[currentMissionSelected], missionObjects[currentMissionSelected].transform.position, missionObjects[currentMissionSelected].transform.rotation); } if (currentMissionSelected == 0) { requiredObjectivesToKill = 4; missionMode = missionObjectives.killObjective; ObjectiveIntroText.text = "Zerstöre alle Bunker"; } if (currentMissionSelected == 1) { missionMode = missionObjectives.escortAndDefend; ObjectiveIntroText.text = "Eskortiere das Schiff"; StartCoroutine("CountDown"); Instantiate(escortShip, escortShip.transform.position = new Vector2(0f, -3f), escortShip.transform.rotation); } if (currentMissionSelected == 2) { requiredObjectivesToKill = 1; missionMode = missionObjectives.killObjective; ObjectiveIntroText.text = "Zerstöre die Bohrinsel"; } if (currentMissionSelected == 3) { missionMode = missionObjectives.killAll; ObjectiveIntroText.text = "Zerstöre genug Schiffe"; } if (currentMissionSelected == 4) { missionMode = missionObjectives.reachAndSurvive; ObjectiveIntroText.text = "Erreiche das Ziel"; StartCoroutine("CountDown"); } if (currentMissionSelected == 5) { missionMode = missionObjectives.escortAndDefend; ObjectiveIntroText.text = "Eskortiere die Flugzeuge"; StartCoroutine("CountDown"); Instantiate(escortPlane, escortPlane.transform.position = new Vector2(-3f, -3f), escortPlane.transform.rotation); Instantiate(escortPlane, escortPlane.transform.position = new Vector2(3f, -3f), escortPlane.transform.rotation); } if (currentMissionSelected == 6) { missionMode = missionObjectives.reachAndSurvive; ObjectiveIntroText.text = "Überlebe bis zum Ende"; StartCoroutine("CountDown"); } if (currentMissionSelected == 7) { missionMode = missionObjectives.killAll; ObjectiveIntroText.text = "Zerstöre die Gegner"; } if (currentMissionSelected == 8) { requiredObjectivesToKill = 3; missionMode = missionObjectives.killObjective; ObjectiveIntroText.text = "Zerstöre alle Transporter"; } if (currentMissionSelected == 9) { missionMode = missionObjectives.reachAndSurvive; ObjectiveIntroText.text = "Erreiche das Ziel"; StartCoroutine("CountDown"); } UpdateIngameUI(); StartCoroutine("ShowQuest"); } if (gameMode == selectedGameMode.survive) { Background.GetComponent <MeshRenderer>().material = BackgroundMaterials[0]; missionText.text = ""; objectiveText.text = ""; missionMode = missionObjectives.none; } GetComponent <AudioSource>().clip = BattleMusic[Random.Range(1, BattleMusic.Length)]; GetComponent <AudioSource>().Play(); StartCoroutine("VolumeOn"); StartSpawnCoroutines(); }
public static void initializeGamePlay() { shaders.deathAlpha = 0.1f; sounds.musicSoundBank.PlayCue("game_music"); camera.v_pos = new Vector2(150, 50); LvlFunc.populateItems(10); LvlFunc.setActiveLevelTo("Anderson St. NE"); UI.initializePDA(); //item temp = world.items[0]; //temp.B_base.v_position = new Vector2(250, 500); //temp.B_base.f_Position_Z = 20; //itemFunc.createItem(world.items[1], new Vector2(370, 500), 100); //itemFunc.createItem(world.items[2], new Vector2(380, 500), 100); CharFunc.addActor(new Vector2(250, 500), 0, CharType.survivor, ControlType.player_current, "SPECOPS", false); world.levels[world.i_currentLvl].char_living[0].Inventory = itemFunc.createItem_INVEN(world.levels[world.i_currentLvl].char_living[0].Inventory, world.items[20], Vector2.Zero, 0); world.levels[world.i_currentLvl].char_living[0].Primary_weap = world.weapons[6]; world.levels[world.i_currentLvl].char_living[0].Primary_weap.clipCurrent = 6; world.levels[world.i_currentLvl].char_living[0].current_weap = world.levels[world.i_currentLvl].char_living[0].Primary_weap; for (int i = 0; i != 5; i++) { CharFunc.addActor(LvlFunc.randomPositon(), 0, CharType.zombie, ControlType.NPC, "", false); //CharFunc.addActor(LvlFunc.randomPositon(), 0, CharType.soldier, ControlType.NPC, "HAZMAT", false); //CharFunc.addActor(LvlFunc.randomPositon(), 0, CharType.zombie, ControlType.NPC, "BROWN", false); } LvlFunc.populateChar(10); //world.levels[world.i_currentLvl].char_living[world.levels[world.i_currentLvl].char_living.Length - 1].current_weap = world.levels[world.i_currentLvl].char_living[0].Primary_weap; Game1.currentMenu = Game1.activeMenu.game; }
private void GameDraw(Texture2D tex1) { spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); if (!CharFunc.thisPlayerLiving || AIfunc.livingZombies == 0) { shaders.deathBegin(); spriteBatch.Draw(tex1, Vector2.Zero, Color.White); shaders.deathEnd(); } else { shaders.bloomBegin(0.4f); spriteBatch.Draw(tex1, Vector2.Zero, Color.White); shaders.bloomEnd(); } spriteBatch.End(); if (world.levels[world.i_currentLvl].indoor && CharFunc.thisPlayerLiving) { graphics.GraphicsDevice.SetRenderTarget(null); Texture2D tex2 = rt; spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); shaders.lightFlickerBegin(); spriteBatch.Draw(tex2, Vector2.Zero, Color.White); shaders.lightFlickerEnd(); spriteBatch.End(); } scoreFunc.drawScore(spriteBatch); UI.draw(spriteBatch); UI.drawMessages(spriteBatch); if (!CharFunc.thisPlayerLiving || AIfunc.livingZombies==0) { spriteBatch.Begin(); if (!CharFunc.thisPlayerLiving) { spriteBatch.Draw(deathOverlay, new Rectangle(0, 0, (int)v_resolution.X, (int)v_resolution.Y), new Color(255, 255, 255, (byte)(120 * shaders.deathAlpha))); } else { spriteBatch.Draw(winOverlay, new Rectangle(0, 0, (int)v_resolution.X/2, (int)v_resolution.Y/2), new Color(255, 255, 255, (byte)(120 * shaders.deathAlpha))); } if (shaders.deathAlpha >= 1) { //character p = world.levels[world.i_currentLvl].char_living[CharFunc.ThisPlayerTag]; spriteBatch.Draw(mainMenu, Game1.v_resolution / 2, null, Color.White, 0, new Vector2(mainMenu.Width, mainMenu.Height) / 2, 1, SpriteEffects.None, 0); spriteBatch.DrawString(UI.pump_font, "Kills: " + CharFunc.ThisPlayerKills, (Game1.v_resolution / 2) + new Vector2(0, 60), Color.White); } spriteBatch.End(); if (shaders.deathAlpha >= 1) { //spriteBatch.Draw(mainMenu, Game1.v_resolution / 2, null, Color.White, 0, new Vector2(mainMenu.Width, mainMenu.Height) / 2, 1, SpriteEffects.None, 0); if (Controller.is_a(PlayerIndex.One)) { currentMenu = activeMenu.main; for (int i = 0; i != world.levels.Length; i++) { if (world.levels[i].name != "mainmenu") { world.levels[i].char_living = null; world.levels[i].items = null; world.levels[i].debris_current = null; } } LvlFunc.setActiveLevelTo("mainmenu"); } } } }