public void QuitGame() { if (MsgBox.Confirm("Are you sure about that?")) { lcState = LCState.CloseApplication; fader.FadeOut(3); } }
// Update is called once per frame void Update() { if (gameTimer >= 0 && gameRunning && lcState != LCState.Nothing) { if (gameRunning) { // Game-ending checks gameTimer -= Time.deltaTime; // Timeover conditions if (gameTimer <= 0) { if (Mathf.Abs(score) <= TIE_THRESHOLD) { // game is tied! no one wins! splashAnim.SetInteger("WinState", 0); // sudden death? } else if (score > TIE_THRESHOLD) { // enemy wins! majority is happy! splashAnim.SetInteger("WinState", -1); } else if (score < TIE_THRESHOLD) { // player wins!!! majority is f****d! splashAnim.SetInteger("WinState", 1); } // endGame lcState = LCState.ShowGOMenu; splashAnim.SetTrigger("TimeSplash"); } } if (player.GetComponent <Character>().mood >= MAX_LOSE) { // game over! player has become happy lcState = LCState.ShowGOMenu; splashAnim.SetTrigger("DeathSplash"); } // control level // tally score int sum = 0; foreach (Character c in NPCs) { sum += c.mood; } score = sum / (float)NPCs.Count; } // game should be in transition mode otherwise // stats should be showing, player goven the opportunity // to play again, go to main menu, quit }
// Use this for initialization void Start() { lcState = defaultState; if (lcState == LCState.Nothing) { gameRunning = false; } fader = GameObject.FindObjectOfType <FadeController>(); SplashController splash = FindObjectOfType <SplashController>(); if (defaultState != LCState.Nothing) { splashAnim = splash.GetComponent <Animator>(); SpawnPoints = new List <GameObject>(); NPCs = new List <Character>(); attributes = Resources.LoadAll <Sprite>("Sprites/CoMA People"); player = GameObject.Find("Player"); player.GetComponent <PlayerMovement>().canMove = false; A_star = GetComponent <NavGrid>(); cubicle = Resources.Load <GameObject>("Prefabs/Cubicle"); SpawnCubicles(); if (A_star != null) { A_star.GenerateMap(); } bible = Resources.Load <GameObject>("Prefabs/Bible").GetComponent <Character>(); reference = Resources.Load <GameObject>("Prefabs/NPC").GetComponent <Character>(); if (reference != null) { SpawnPeople(); } gameTimer = LevelTime; } }
public void Notify() { switch (lcState) { case LCState.SwitchScene: // transition to next Scene SceneManager.LoadScene(nextLevel); break; case LCState.StartGame: splashAnim.SetTrigger("StartSplash"); break; case LCState.CloseApplication: Application.Quit(); break; case LCState.RestartGame: // reset all things foreach (Transform npc in GameObject.Find("NPCs").transform) { GameObject.Destroy(npc.gameObject); } Character player = GameObject.Find("Player").GetComponent <Character>(); player.mood = player.defaultMood = -Character.MOOD_RANGE; //reset cool downs A_star.ResetMap(); gameTimer = LevelTime; lcState = LCState.StartGame; fader.FadeIn(); break; } }
public void LoadScene(String scene) { lcState = LCState.SwitchScene; nextLevel = scene; fader.FadeOut(2); }
public void RestartGame() { lcState = LCState.RestartGame; fader.FadeOut(2); }