public static void ShowLevelEndScreen(Outcome o)
    {
        singletonInstance.timeFinished = DateTime.Now;
        singletonInstance.timeElapsed  = singletonInstance.timeFinished.Subtract(singletonInstance.timeStart);
        string time = string.Format("{0:00}:{1:00}", singletonInstance.timeElapsed.Minutes, singletonInstance.timeElapsed.Seconds);

        string outcome = null;
        string option  = null;

        if (o == Outcome.Victory)
        {
            outcome = "Victory";
            option  = "Continue";
            singletonInstance.levelWon = true;
        }

        else if (o == Outcome.Defeat)
        {
            outcome = "Defeat";
            option  = "Replay";
            singletonInstance.levelWon = false;
        }

        singletonInstance.outcome.GetComponent <TextMeshProUGUI>().text        = outcome;
        singletonInstance.killValueText.GetComponent <TextMeshProUGUI>().text  = singletonInstance.kills.ToString();
        singletonInstance.timeValueText.GetComponent <TextMeshProUGUI>().text  = time;
        singletonInstance.livesValueText.GetComponent <TextMeshProUGUI>().text = LivesController.GetCurrentLives().ToString();
        singletonInstance.optionText.GetComponent <Text>().text = option;

        singletonInstance.StartCoroutine("BeginLevelEndAnimation");
    }
Beispiel #2
0
    private void WinGame()
    {
        DespawnBeds();

        if (nGreats == numberOfBeds)
        {
            if (GameMode.Mode == GameMode.GameModes.Minigame)
            {
                animator.SetTrigger("perfect");
                MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
                minigameModeController.OnMinigameFinished(true, "Preguiça");
                return;
            }

            LivesController.addVidas();
            animator.SetTrigger("perfect");
        }
        else
        {
            if (GameMode.Mode == GameMode.GameModes.Minigame)
            {
                animator.SetTrigger("win");
                MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
                minigameModeController.OnMinigameFinished(true, "Preguiça");
                return;
            }

            animator.SetTrigger("win");
        }
        GameObject.Find("Player").GetComponent <PlayerMovement>().StartDelaySobeCarinha();
        GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
    }
    public void Start()
    {
        myLocation = this.transform;
        startPos   = myLocation.position;

        livesController = GameObject.Find("lives").GetComponent <LivesController>();
    }
Beispiel #4
0
 public void SemFim()
 {
     HapticVibration();
     LivesController.InitVidas();
     GameMode.Mode = GameMode.GameModes.Endless;
     GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("MainEndless");
 }
Beispiel #5
0
    void Start()
    {
        body            = this.GetComponent <Rigidbody2D>();
        boxCollider     = this.GetComponent <BoxCollider2D>();
        livesController = GameObject.Find("LivesController");
        soundController = GameObject.Find("SoundController");
        greenArea       = GameObject.FindGameObjectWithTag("GreenArea");  //Reset Green Area

        if (livesController != null)
        {
            livesControllerScript = livesController.GetComponent <LivesController>();
        }
        if (greenArea != null)
        {
            greenAreaControllerScript = greenArea.GetComponent <GreenAreaController>();
        }
        if (soundController != null)
        {
            soundControllerScript = soundController.GetComponent <SoundController>();
        }

        checkPointPosition = new Vector2(this.transform.position.x, this.transform.position.y);

        if (livesController != null)
        {
            if (Application.loadedLevel == 1)
            {
                livesControllerScript.resetLives();                 // Reset lives so LevelOne starts with 0 lives due to CheckPoint Deaths PlayerPref
            }
        }
    }
Beispiel #6
0
    private void WinGame()
    {
        // Checa se o jogador ganhou de Perfect (ganhar em menos de 1 segundo)
        if (maxTime - timeLeft <= 1)
        {
            if (GameMode.Mode == GameMode.GameModes.Minigame)
            {
                canvas.GetComponent <Animator>().SetBool("Perfect", true);
                MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
                minigameModeController.OnMinigameFinished(true, "Ira");
                return;
            }

            LivesController.addVidas();
            canvas.GetComponent <Animator>().SetBool("Perfect", true);
            GameObject.Find("Player").GetComponent <PlayerMovement>().StartDelaySobeCarinha();
            GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
        }
        else
        {
            if (GameMode.Mode == GameMode.GameModes.Minigame)
            {
                canvas.GetComponent <Animator>().SetBool("Won", true);
                MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
                minigameModeController.OnMinigameFinished(true, "Ira");
                return;
            }

            canvas.GetComponent <Animator>().SetBool("Won", true);
            GameObject.Find("Player").GetComponent <PlayerMovement>().StartDelaySobeCarinha();
            GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
        }
    }
Beispiel #7
0
 public void Classico()
 {
     HapticVibration();
     LivesController.InitVidas();
     GameMode.Mode = GameMode.GameModes.Classic;
     GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
 }
Beispiel #8
0
 // Use this for initialization
 void Start()
 {
     anim = GetComponent <Animator> ();
     sp   = GetComponent <SpriteRenderer> ();
     tf   = this.transform;
     rb   = GetComponent <Rigidbody2D> ();
     lc   = GameObject.Find("Lives").GetComponent <LivesController> ();
 }
    //Increase lives
    private IEnumerator LivesUp()
    {
        LivesController lives = FindObjectOfType <LivesController>();

        lives.IncreaseLives(1);
        playerRender.color = new Color(1f, 0, 1f);
        yield return(new WaitForSeconds(1.5f));

        playerRender.color = initalPlayerColor;
    }
Beispiel #10
0
    // Ativa animacao de warning na tela

    public IEnumerator WarnPlayer()
    {
        yield return(new WaitForSeconds(3));

        yield return(new WaitUntil(() => LivesController.GetVidas() == 1));

        CanvasHud.SetBool("Warning", true);
        yield return(new WaitUntil(() => CanvasHud.GetCurrentAnimatorStateInfo(0).IsTag("piscando")));

        CanvasHud.SetBool("Warning", false);
    }
Beispiel #11
0
        void Start()
        {
            livesController = GameHandler.Instance.lives;

            liveIcons = new Image[livesController.MaxLives];
            for (int i = 0; i < livesController.MaxLives; ++i)
            {
                liveIcons[i] = Instantiate(liveIconPrefab, livesContainer);
            }

            livesController.OnChanged += LivesChanged;
        }
Beispiel #12
0
    void Start()
    {
        otherCharacters = new List <GameObject>();

        if (this.gameObject.tag == "Player")
        {
            this.enabled = false;
        }

        player = GameObject.FindGameObjectWithTag("Player");

        allCharactersOnBoard = new List <GameObject>();

        if (GameState.P1 != null)
        {
            allCharactersOnBoard.Add(GameState.P1);
        }

        if (GameState.P2 != null)
        {
            allCharactersOnBoard.Add(GameState.P2);
        }

        foreach (GameObject character in allCharactersOnBoard)
        {
            if (character != gameObject && character != null)
            {
                otherCharacters.Add(character);
            }
        }

        try
        {
            target = otherCharacters[UnityEngine.Random.Range(0, otherCharacters.Count)];
        }
        catch (Exception e) { }

        livesController = Camera.main.gameObject.GetComponent <LivesController>();

        if (livesController != null)
        {
            livesController.RemoveCharacterFromAIList += HandleRemoveCharacterFromList;
        }

        spawnCharacterController = Camera.main.gameObject.GetComponent <SpawnCharacterController>();

        if (spawnCharacterController != null)
        {
            spawnCharacterController.MakeAIJump += HandleJumpOffOfRespawnPlatform;
        }
    }
Beispiel #13
0
 void Start()
 {
     livesController = GameObject.Find("LivesController");
     if (livesController != null)
     {
         livesControllerScript = livesController.GetComponent <LivesController> ();
     }
     else
     {
         Debug.Log("HUDController: Lives Controller is Null.");
     }
     heartTextureWidth  = hearts.width;
     heartTextureHeight = hearts.height;
 }
Beispiel #14
0
    void Start()
    {
        livesController = GameObject.Find("LivesController");

        if (livesController != null)
        {
            livesControllerScript = livesController.GetComponent <LivesController>();
        }

        if (PlayerPrefs.HasKey("CheckPointLevel"))
        {
            checkPointLevel = PlayerPrefs.GetInt("CheckPointLevel");
        }
    }
Beispiel #15
0
 private void Lose()
 {
     if (GameMode.Mode == GameMode.GameModes.Minigame)
     {
         GetComponent <Animator>().SetTrigger("Lose");
         MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
         minigameModeController.OnMinigameFinished(false, "Orgulho");
     }
     else
     {
         GetComponent <Animator>().SetTrigger("Lose");
         LivesController.RemVidas();
         GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        DontDestroyOnLoad(gameObject);
        if (inst == null)
        {
            inst = this;
        }
        else
        {
            Destroy(this);
        }

        lives = livesMax;
        UpdateLifeBar();
    }
 //object type established
 private void Start()
 {
     if (gameObject.GetComponent <PlayerControl>())
     {
         lives = FindObjectOfType <LivesController>();
     }
     else if (gameObject.GetComponent <DestructibleBarrier>())
     {
         barrier = gameObject.GetComponent <DestructibleBarrier>();
     }
     else if (gameObject.GetComponent <PowerUp>())
     {
         powerUp = gameObject.GetComponent <PowerUp>();
     }
 }
Beispiel #18
0
 public void LoadGame()
 {
     LivesController.InitVidas();
     if (GameMode.Mode == GameMode.GameModes.Classic)
     {
         GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
     }
     else if (GameMode.Mode == GameMode.GameModes.Minigame)
     {
         GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("ModoMinigame_Transição");
     }
     else if (GameMode.Mode == GameMode.GameModes.Endless)
     {
         GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("MainEndless");
     }
 }
Beispiel #19
0
 private void Perfect()
 {
     if (GameMode.Mode == GameMode.GameModes.Minigame)
     {
         GetComponent <Animator>().SetTrigger("Perfect");
         MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
         minigameModeController.OnMinigameFinished(true, "Orgulho");
     }
     else
     {
         GetComponent <Animator>().SetTrigger("Perfect");
         LivesController.addVidas();
         GameObject.Find("Player").GetComponent <PlayerMovement>().StartDelaySobeCarinha();
         GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
     }
 }
Beispiel #20
0
    protected override void ExecutePowerUp()
    {
        GameObject managerObject = GameObject.FindGameObjectWithTag("GameManager");

        gameManager = managerObject.GetComponent <GameManager>();

        if (!gameManager.endless && !gameManager.survival)
        {
            GameObject lives = GameObject.FindGameObjectWithTag("Lives");
            livesController = lives.GetComponent <LivesController>();

            livesController.AddLife();
            EndPowerUp();
        }
        Destroy(gameObject);
    }
Beispiel #21
0
    public void RostoErrado()
    {
        faceClick = true;
        GameObject[] certos = GameObject.FindGameObjectsWithTag("Certo");
        foreach (GameObject certo in certos)
        {
            certo.gameObject.transform.GetChild(0).gameObject.SetActive(true);
        }
        LivesController.RemVidas();

        foreach (GameObject botao in listaDeBotoesInstanciados)
        {
            botao.GetComponent <Button>().enabled = false;
        }

        GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
    }
Beispiel #22
0
    void Start()
    {
        animator        = this.GetComponent <Animator>();
        pS              = PoolingSystem.Instance;
        livesController = GameObject.Find("LivesController");
        if (livesController != null)
        {
            livesControllerScript = livesController.GetComponent <LivesController>();
        }
        else
        {
            Debug.Log("HUDController: Lives Controller is Null.");
        }

        if (pS == null)
        {
            Debug.Log("PlayedController: PoolingSystem is Null.");
        }

        if (fireballButton != null)
        {
            fireballButtonImage = fireballButton.GetComponent <Image>();
        }
        else
        {
            if (Application.loadedLevelName == "TutorialOne")
            {
                //No FireBall Button in that Level
            }
            else if (Application.loadedLevelName == "TutorialTwo")
            {
                //No FireBall Button in that Level
            }
            else if (Application.loadedLevelName == "TutorialThree")
            {
                //No FireBall Button in that Level
            }
            else
            {
                Debug.Log("PlayerController: FireballButton is null.");
            }
        }

        fireBallInventory = 5;
        startingPoint     = new Vector3(this.transform.position.x, this.transform.position.y, 0f);
    }
Beispiel #23
0
 private void LoseGame()
 {
     if (GameMode.Mode == GameMode.GameModes.Minigame)
     {
         lost = true;
         canvas.GetComponent <Animator>().SetBool("Lost", true);
         MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
         minigameModeController.OnMinigameFinished(false, "Ira");
     }
     else
     {
         lost = true;
         LivesController.RemVidas();
         canvas.GetComponent <Animator>().SetBool("Lost", true);
         GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
     }
 }
Beispiel #24
0
    void Start()
    {
        levelController = GameObject.Find("LevelController");
        livesController = GameObject.Find("LivesController");

        if (levelController != null)
        {
            levelControllerScript = levelController.GetComponent <LevelController>();
            levelControllerScript.setCheckPointLevel(checkPointNumber);
        }

        if (livesController != null)
        {
            livesControllerScript = livesController.GetComponent <LivesController>();
            livesControllerScript.saveDeaths();            //Save Deaths
        }
    }
Beispiel #25
0
    /*void Awake(){
     *      DontDestroyOnLoad (transform.gameObject);
     *
     *      if (FindObjectsOfType (GetType ()).Length > 1) {// Prevent Duplicated of this GameObject due to DontDestroyOnLoad
     *              Destroy (gameObject);
     *      }
     * }*/

    void Start()
    {
        livesController = GameObject.Find("LivesController");
        if (livesController != null)
        {
            livesControllerScript = livesController.GetComponent <LivesController>();
        }
        levelController = GameObject.Find("LevelController");
        if (levelController != null)
        {
            levelControllerScript = levelController.GetComponent <LevelController>();
        }
        coinController = GameObject.Find("CoinController");
        if (coinController != null)
        {
            coinControllerScript = coinController.GetComponent <CoinController>();
        }
    }
Beispiel #26
0
    //Will load back to menu screen and grab all data from the current scene before transitioning if not tutorial
    public void LoadMenu(MenuState state)
    {
        float wait = 6f;

        if (isGame)
        {
            currentLevel += 1;
            ScoreController score = FindObjectOfType <ScoreController>();
            LivesController lives = FindObjectOfType <LivesController>();
            currentScore = score.GetScore();
            currentLives = lives.GetLives();
            wait         = 3f;
        }
        isGame      = false;
        sceneLoader = FindObjectOfType <SceneLoader>();
        currentMenu = state;
        sceneLoader.LoadMenu(wait);
    }
Beispiel #27
0
    public void Perdeu(string callerScene)
    {
        if (GameMode.Mode == GameMode.GameModes.Minigame)
        {
            MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
            minigameModeController.OnMinigameFinished(false, callerScene);
        }
        else
        {
            Screen.orientation = ScreenOrientation.AutoRotation;
            GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
            LivesController.RemVidas();
#if UNITY_ANDROID
            Screen.orientation = ScreenOrientation.Landscape;
            Screen.orientation = ScreenOrientation.AutoRotation;
#endif
        }
    }
Beispiel #28
0
    public void Perfect()
    {
        if (GameMode.Mode == GameMode.GameModes.Minigame)
        {
            MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
            minigameModeController.OnMinigameFinished(true, "Ganancia");
        }
        else
        {
            LivesController.addVidas();
            GameObject.Find("Player").GetComponent <PlayerMovement>().StartDelaySobeCarinha();
            Screen.orientation = ScreenOrientation.AutoRotation;
            GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
#if UNITY_ANDROID
            Screen.orientation = ScreenOrientation.Landscape;
            Screen.orientation = ScreenOrientation.AutoRotation;
#endif
        }
    }
    public void RostoCerto()
    {
        if (!faceClick)
        {
            if (GetComponent <CountdownScriptInveja>().TempoContagem > 10 - difficulty - 1)
            {
                if (GameMode.Mode == GameMode.GameModes.Minigame)
                {
                    perfect.gameObject.SetActive(true);
                    MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
                    minigameModeController.OnMinigameFinished(true, "Inveja");
                }

                perfect.gameObject.SetActive(true);
                LivesController.addVidas();
            }
            else
            {
                if (GameMode.Mode == GameMode.GameModes.Minigame)
                {
                    ganhou.gameObject.SetActive(true);
                    MinigameModeController minigameModeController = FindObjectOfType <MinigameModeController>();
                    minigameModeController.OnMinigameFinished(true, "Inveja");
                }

                ganhou.gameObject.SetActive(true);
            }

            foreach (GameObject errado in listaErrado)
            {
                errado.GetComponent <Animator>().SetBool("FadeOut", true);
                errado.GetComponent <Button>().enabled = false;
            }
            faceClick = true;

            if (GameMode.Mode != GameMode.GameModes.Minigame)
            {
                GameObject.Find("Player").GetComponent <PlayerMovement>().StartDelaySobeCarinha();
                GameObject.Find("FadeImage").GetComponent <FadeController>().CallFading("Main");
            }
        }
    }
Beispiel #30
0
    void Start()
    {
        livesController = GameObject.Find("LivesController");
        soundController = GameObject.Find("SoundController");

        if (livesController != null)
        {
            livesControllerScript = livesController.GetComponent <LivesController>();
        }

        if (soundController != null)
        {
            soundControllerScript = soundController.GetComponent <SoundController>();
        }

        guiStyle                  = new GUIStyle();
        guiStyle.fontSize         = 18;
        guiStyle.normal.textColor = Color.white;
        currentLevelNumber        = Application.loadedLevel;
    }