private void RefillGames()
 {
     gamesQueue = games.ToList();
     for (int i = gamesQueue.Count - 1; i >= 0; i--)
     {
         int      j = Random.Range(0, gamesQueue.Count);
         Minigame m = gamesQueue[i];
         gamesQueue[i] = gamesQueue[j];
         gamesQueue[j] = m;
     }
 }
        public void StartGame()
        {
            if (currentGame)
            {
                currentGame.ForceEnd();
            }
            inGame            = true;
            gameWon           = false;
            playerScores      = new int[4];
            transitionStarted = false;
            scoreAdded        = false;

            respawnNodes = new List <RespawnNode>();
            goblets      = new List <Goblet>();
            gamesQueue   = new List <Minigame>();

            RespawnNode[] findNodes = FindObjectsOfType <RespawnNode>();
            for (int i = 0; i < findNodes.Length; i++)
            {
                respawnNodes.Add(findNodes[i]);
            }

            Goblet[] findGoblets = FindObjectsOfType <Goblet>();
            for (int i = 0; i < findGoblets.Length; i++)
            {
                goblets.Add(findGoblets[i]);
            }

            dialogHolder = GameObject.Find("DialogHolder");

            field = GameObject.Find("Field");

            RefillGames();
            currentGame = gamesQueue[0];
            gamesQueue.RemoveAt(0);

            for (int i = 0; i < controllers.Count; i++)
            {
                controllers[i].Enable();
                RespawnNode playerNode = respawnNodes.Find(x => x.ID.Equals(controllers[i].ID));
                controllers[i].transform.position = playerNode.transform.position;
                controllers[i].SetInitAttributes();
                controllers[i].RespawnAt(playerNode.transform.position);
            }

            currentGame.Init();
            veryFirstTimer = 4f;
            Camera.main.GetComponent <Animator>().SetTrigger("GodDemands");
            dialogHolder.GetComponent <SpriteRenderer>().sprite = currentGame.instructions;

            winningCharacterSprite = GameObject.Find("WinningCharacterSprite");
            winText = GameObject.Find("WinText");
        }
        void Update()
        {
			if(sleepTimer > 0) {
				sleepTimer -= Time.deltaTime;
			}
			if (paused || sleepTimer > 0) DeltaTime = 0;
			else DeltaTime = Time.deltaTime;

            if (inGame)
            {

                if (!currentGame.finished && !transitionStarted)
                {
					veryFirstTimer -= DeltaTime;
					if(veryFirstTimer <= 0) {
                    	currentGame.Run();
					}
					if(ControllerManager.instance.GetButtonDown(ControllerInputWrapper.Buttons.Start, PlayerID.One))
					{
						if (!paused)
						{
							PauseGame();
						}
						else
						{
							UnPauseGame();
						}
					}

                }
                else
                {

					if(!transitionStarted) {
						transitionStarted = true;
						if(IncrementPlayerScore(currentGame.Winners)) {
							inGame = false;
							gameWon = true;
							winTimer = 3f;
						}
						demandingTimer = 5f;
						transitionTimer2 = 15f;
                        if (gamesQueue.Count == 0) RefillGames();
						currentGame = gamesQueue[0];
                        gamesQueue.RemoveAt(0);
					} else {
						demandingTimer -= DeltaTime;

						if(demandingTimer <= 0) {
							transitionTimer2 = 5f;
							demandingTimer = 10f;
							Camera.main.GetComponent<Animator>().SetTrigger("GodDemands");
							SFXManager.instance.source.PlayOneShot(SFXManager.instance.RandomGodTalk());
							dialogHolder.GetComponent<SpriteRenderer>().sprite = currentGame.instructions;
						}

						transitionTimer2 -= DeltaTime;

						if(transitionTimer2 <= 0) {
							currentGame.Init();
							transitionStarted = false;
						}
					}
                }
				if(dialogHolder != null) dialogHolder.transform.localScale = Vector3.one*Mathf.Max(1.5f,(Mathf.Sin(Time.time*8f)+1));
			} else if(gameWon) {
                inGame = false;
				winTimer -= DeltaTime;
				if(winTimer <= 0) {
					gameWon = false;
                    Camera.main.GetComponent<EndGameUI>().enabled = true;
					Camera.main.GetComponent<Animator>().SetTrigger("GameEnd");
					for(int i = 0; i < controllers.Count; i++) {
						if(controllers[i].Character == winningCharacter) {
							winningCharacterSprite.GetComponent<Image>().sprite = controllers[i].Sprite.GetComponent<SpriteRenderer>().sprite;
							winText.GetComponent<Text>().text = "Congratulations! " + controllers[i].Character + " Was Sacrificed!";
                            //winText.GetComponent<Text>().color = Color.black;
                            EventSystem.current.SetSelectedGameObject(GameObject.Find("PlayAgain"));

                            break;
						}
					}
				}
			}
        }
        public void StartGame()
        {
            if (currentGame) currentGame.ForceEnd();
            inGame = true;
            gameWon = false;
            playerScores = new int[4];
            transitionStarted = false;
            scoreAdded = false;

            respawnNodes = new List<RespawnNode>();
            goblets = new List<Goblet>();
            gamesQueue = new List<Minigame>();

            RespawnNode[] findNodes = FindObjectsOfType<RespawnNode>();
            for (int i = 0; i < findNodes.Length; i++)
            {
                respawnNodes.Add(findNodes[i]);
            }

            Goblet[] findGoblets = FindObjectsOfType<Goblet>();
            for (int i = 0; i < findGoblets.Length; i++)
            {
                goblets.Add(findGoblets[i]);
            }

			dialogHolder = GameObject.Find("DialogHolder");

			field = GameObject.Find("Field");

            RefillGames();
            currentGame = gamesQueue[0];
            gamesQueue.RemoveAt(0);

            for (int i = 0; i < controllers.Count; i++)
            {
                controllers[i].Enable();
                RespawnNode playerNode = respawnNodes.Find(x => x.ID.Equals(controllers[i].ID));
                controllers[i].transform.position = playerNode.transform.position;
                controllers[i].SetInitAttributes();
                controllers[i].RespawnAt(playerNode.transform.position);
            }
                
			currentGame.Init();
			veryFirstTimer = 4f;
			Camera.main.GetComponent<Animator>().SetTrigger("GodDemands");
			dialogHolder.GetComponent<SpriteRenderer>().sprite = currentGame.instructions;

			winningCharacterSprite = GameObject.Find("WinningCharacterSprite");
			winText = GameObject.Find("WinText");

        }
        void Update()
        {
            if (sleepTimer > 0)
            {
                sleepTimer -= Time.deltaTime;
            }
            if (paused || sleepTimer > 0)
            {
                DeltaTime = 0;
            }
            else
            {
                DeltaTime = Time.deltaTime;
            }

            if (inGame)
            {
                if (!currentGame.finished && !transitionStarted)
                {
                    veryFirstTimer -= DeltaTime;
                    if (veryFirstTimer <= 0)
                    {
                        currentGame.Run();
                    }
                    if (ControllerManager.instance.GetButtonDown(ControllerInputWrapper.Buttons.Start, PlayerID.One))
                    {
                        if (!paused)
                        {
                            PauseGame();
                        }
                        else
                        {
                            UnPauseGame();
                        }
                    }
                }
                else
                {
                    if (!transitionStarted)
                    {
                        transitionStarted = true;
                        if (IncrementPlayerScore(currentGame.Winners))
                        {
                            inGame   = false;
                            gameWon  = true;
                            winTimer = 3f;
                        }
                        demandingTimer   = 5f;
                        transitionTimer2 = 15f;
                        if (gamesQueue.Count == 0)
                        {
                            RefillGames();
                        }
                        currentGame = gamesQueue[0];
                        gamesQueue.RemoveAt(0);
                    }
                    else
                    {
                        demandingTimer -= DeltaTime;

                        if (demandingTimer <= 0)
                        {
                            transitionTimer2 = 5f;
                            demandingTimer   = 10f;
                            Camera.main.GetComponent <Animator>().SetTrigger("GodDemands");
                            SFXManager.instance.source.PlayOneShot(SFXManager.instance.RandomGodTalk());
                            dialogHolder.GetComponent <SpriteRenderer>().sprite = currentGame.instructions;
                        }

                        transitionTimer2 -= DeltaTime;

                        if (transitionTimer2 <= 0)
                        {
                            currentGame.Init();
                            transitionStarted = false;
                        }
                    }
                }
                if (dialogHolder != null)
                {
                    dialogHolder.transform.localScale = Vector3.one * Mathf.Max(1.5f, (Mathf.Sin(Time.time * 8f) + 1));
                }
            }
            else if (gameWon)
            {
                inGame    = false;
                winTimer -= DeltaTime;
                if (winTimer <= 0)
                {
                    gameWon = false;
                    Camera.main.GetComponent <EndGameUI>().enabled = true;
                    Camera.main.GetComponent <Animator>().SetTrigger("GameEnd");
                    for (int i = 0; i < controllers.Count; i++)
                    {
                        if (controllers[i].Character == winningCharacter)
                        {
                            winningCharacterSprite.GetComponent <Image>().sprite = controllers[i].Sprite.GetComponent <SpriteRenderer>().sprite;
                            winText.GetComponent <Text>().text = "Congratulations! " + controllers[i].Character + " Was Sacrificed!";
                            //winText.GetComponent<Text>().color = Color.black;
                            EventSystem.current.SetSelectedGameObject(GameObject.Find("PlayAgain"));

                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void StartGame()
        {
            inGame = true;
            /*
            Controller[] findControllers = FindObjectsOfType<Controller>();
            for (int i = 0; i < findControllers.Length; i++)
            {
                controllers.Add(findControllers[i]);
            }
            */

            RespawnNode[] findNodes = FindObjectsOfType<RespawnNode>();
            for (int i = 0; i < findNodes.Length; i++)
            {
                respawnNodes.Add(findNodes[i]);
            }

            Goblet[] findGoblets = FindObjectsOfType<Goblet>();
            for (int i = 0; i < findGoblets.Length; i++)
            {
                goblets.Add(findGoblets[i]);
            }

			dialogHolder = GameObject.Find("DialogHolder");

			field = GameObject.Find("Field");

            currentGame = games[Random.Range(0, games.Count)];

            for (int i = 0; i < controllers.Count; i++)
            {
                controllers[i].Enable();
                RespawnNode playerNode = respawnNodes.Find(x => x.ID.Equals(controllers[i].ID));
                controllers[i].transform.position = playerNode.transform.position;
            }
                
			currentGame.Init();
			veryFirstTimer = 4f;
			Camera.main.GetComponent<Animator>().SetTrigger("GodDemands");
			dialogHolder.GetComponent<SpriteRenderer>().sprite = currentGame.instructions;

			winningCharacterSprite = GameObject.Find("WinningCharacterSprite");
			winText = GameObject.Find("WinText");

        }
Exemplo n.º 7
0
        void Update()
        {
            if (inGame)
            {
				if (!currentGame.finished && !transitionStarted)
                {
					veryFirstTimer -= Time.deltaTime;
					if(veryFirstTimer <= 0) {
                    	currentGame.Run();
					}

                }
                else
                {

					if(!transitionStarted) {
						transitionStarted = true;
						if(IncrementPlayerScore(currentGame.Winners)) {
							inGame = false;
							gameWon = true;
							winTimer = 3f;
						}
						demandingTimer = 5f;
						transitionTimer2 = 15f;
						currentGame = games[Random.Range(0, games.Count)];
//						Debug.Log("Next game chosen: " + currentGame.name);
					} else {
						demandingTimer -= Time.deltaTime;

						if(demandingTimer <= 0) {
							transitionTimer2 = 5f;
							demandingTimer = 10f;
							Camera.main.GetComponent<Animator>().SetTrigger("GodDemands");
							SFXManager.instance.source.PlayOneShot(SFXManager.instance.RandomGodTalk());
							dialogHolder.GetComponent<SpriteRenderer>().sprite = currentGame.instructions;
						}

						transitionTimer2 -= Time.deltaTime;

						if(transitionTimer2 <= 0) {
							currentGame.Init();
							transitionStarted = false;
						}
					}
                }
				dialogHolder.transform.localScale = Vector3.one*Mathf.Max(1.5f,(Mathf.Sin(Time.time*8f)+1));
			} else if(gameWon) {
				winTimer -= Time.deltaTime;
				if(winTimer <= 0) {
					gameWon = false;
					Camera.main.GetComponent<Animator>().SetTrigger("GameEnd");
					for(int i = 0; i < controllers.Count; i++) {
						if(controllers[i].Character == winningCharacter) {
							winningCharacterSprite.GetComponent<Image>().sprite = controllers[i].Sprite.GetComponent<SpriteRenderer>().sprite;
							winText.GetComponent<Text>().text = "Congratulations! " + controllers[i].Character + " Was Sacrificed!";
							break;
						}
					}
				}
			}
        }