Exemplo n.º 1
0
    private IEnumerator CountdownThenSpawn()
    {
        currentPhaseOfLevel = PhaseOfLevel.TRAVEL_FLOW;
        countdownStarted    = true;
        int timer = countdownToStartGame;

        if (countdownStartGame.activeInHierarchy == false)
        {
            uiMenuScript.PutInFrontOfCamera(countdownStartGame);
            countdownStartGame.SetActive(true);
        }

        while (timer >= 0)
        {
            if (timer == 5)
            {
                WebClientSender.instance.ResetLedDolphin(); //Some of these commands are redundant due to the fact sometimes they are not executed because of connection unstable
            }
            yield return(new WaitForSeconds(1f));

            timer--;
            labelCountdownTextMesh.text = timer.ToString();
        }

        WebClientSender.instance.OpenEyesDolphin();
        WebClientSender.instance.ResetLedDolphin();


        countdownStartGame.SetActive(false);
        labelCountdownTextMesh.text = countdownToStartGame.ToString();


        if (gameModeSelected == GameMode.TUTORIAL)
        {
            StartCoroutine(SpawnWavesTutorial());
        }
        else if (gameModeSelected == GameMode.TUTORIAL_BASIC)
        {
            StartCoroutine(SpawnWavesTutorialBasic());
        }
        else
        {
            StartCoroutine(SpawnWavesRandom()); //spawnWavesRandomCoroutine = StartCoroutine(SpawnWavesRandom()); If we want to later stop coroutine (not recommended with this complex one)
        }
        countdownStarted = false;
    }
Exemplo n.º 2
0
    public void NextLevel()
    {
        //Calculations at the end of the level


        DataController.instance.printCurrentMatchData();
        currentLevel++;
        DataController.instance.currentMatch.levels.Add(new LevelData());

        //In the pretravel phase we activate the aura

        currentPhaseOfLevel = PhaseOfLevel.PRE_TRAVEL_FLOW;
        areaPlayer.GetComponent <PlayerArea>().AuraActive              = true;
        areaPlayer.GetComponent <PlayerArea>().auraEntered             = false;
        areaPlayer.GetComponent <PlayerArea>().AuraFound               = false;
        areaPlayer.GetComponent <PlayerArea>().auraSoundSource.enabled = true;


        areaPlayer.GetComponent <PlayerArea>().SetActiveGoIntoAuraMessage(true);
        //areaPlayer.GetComponent<PlayerArea>().SetActiveIndicatorToAura(true);
        areaPlayer.GetComponent <PlayerArea>().SetActiveParticlesAura(true);
    }
Exemplo n.º 3
0
    private void TreasureHunt()
    {
        timeStartTreasureHunt = System.DateTime.Now;
        bool randomically    = true;
        bool nonRandomically = false;

        areaPlayer.GetComponent <PlayerArea>().SetActiveParticlesAura(false);
        currentPhaseOfLevel = PhaseOfLevel.TREASURE_HUNT;

        if (currentLevel == 3)
        {
            DecorationsSpawnerManager.Instance.SpawnWallsDecorationObjects(DecorationsSpawnerManager.Instance.paintingsWallsDecorationObjectPrefabs, randomically);
        }
        else
        {
            DecorationsSpawnerManager.Instance.SpawnWallsDecorationObjects(DecorationsSpawnerManager.Instance.gifWallsDecorationObjectPrefabs, randomically);
        }

        DecorationsSpawnerManager.Instance.CleanFloorObjects();

        StartCoroutine(DecorationsSpawnerManager.Instance.SpawnFloorDecorationObjects(levelsParams[currentLevel].treasureHuntObjects, nonRandomically));
    }
Exemplo n.º 4
0
    public IEnumerator EndGameLose()
    {
        GameObject[] elementsLeft = GameObject.FindGameObjectsWithTag("ElementFlow");
        if (elementsLeft.Length != 0)
        {
            foreach (GameObject elementToDeactivate in elementsLeft)
            {
                elementToDeactivate.SetActive(false);
            }
        }

        startedGame = false;
        uiGameScript.SetActiveLowEnergySound(false);
        SoundManager.instance.PlaySoundtrackLoseDeath(0.4f, 2f, false);

        spawnWavesIsActive = false;

        currentPhaseOfLevel = PhaseOfLevel.END;
        gameModeSelected    = GameMode.IDLE;

        WebClientSender.instance.MoveMouthAndEyesDolphinTogether();


        AuraAndGeneratorsDeactivation();


        uiMenuScript.PutInFrontOfCamera(loseMessage);
        loseMessage.SetActive(true);
        yield return(new WaitForSeconds(10f));

        loseMessage.SetActive(false);
        WebClientSender.instance.ResetLedDolphin();

        DataController.instance.printCurrentMatchData();
        uiMenuScript.ShowInsertPlayerNameMenu();
    }
Exemplo n.º 5
0
    private IEnumerator SpawnWavesTutorialBasic()
    {
        spawnWavesIsActive = true;

        yield return(new WaitForSeconds(levelsParams[currentLevel].startWait));

        labelGenericMessage.text = "TUTORIAL BASIC";
        textGenericMessage.text  = "Girati verso il generatore\ne centra gli anelli che\nverranno verso di te!";
        uiMenuScript.PutInFrontOfCamera(genericMessage);
        genericMessage.SetActive(true);
        yield return(new WaitForSeconds(5f));

        genericMessage.SetActive(false);

        CounterCaughtRingsTutorial = 0;
        GeneratorOrbitAroundCenter generatorOrbitAroundCenter = rotatingSpawnGenerator.GetComponent <GeneratorOrbitAroundCenter>();
        string    newElementName  = torusBubble.name;
        Coroutine movingCoroutine = null;

        GeneratorIsMoving = false;

        while (CounterCaughtRingsTutorial <= 9)
        {
            if (!startedGame)
            {
                yield break; //Kill the coroutine if the game ended (most cases, when player loses)
            }
            GameObject newElement = ObjectPoolingManager.Instance.GetObject(newElementName);

            newElement.transform.position = rotatingSpawnGenerator.transform.position;
            newElement.transform.rotation = rotatingSpawnGenerator.transform.rotation;
            newElement.GetComponent <Rigidbody>().velocity = newElement.transform.up * levelsParams[currentLevel].speedElements;


            //yield return new WaitForSeconds(levelsParams[currentLevel].spawnWait);
            yield return(new WaitForSeconds(7.5f));



            if (GeneratorMoveRight && !GeneratorIsMoving)
            {
                GeneratorIsMoving = true;
                yield return(new WaitForSeconds(5f));

                movingCoroutine = StartCoroutine(generatorOrbitAroundCenter.OrbitRightUntilPosDegrees(45));
                yield return(movingCoroutine); //yield return new WaitForSeconds(5f); //This could be removed to make the game more challenging, rings would be fired when moving

                GeneratorIsMoving  = false;
                GeneratorMoveRight = false;
            }
            else if (GeneratorMoveLeft && !GeneratorIsMoving)
            {
                GeneratorIsMoving = true;
                yield return(new WaitForSeconds(5f));

                movingCoroutine = StartCoroutine(generatorOrbitAroundCenter.OrbitLeftUntilNegDegrees(-45));
                yield return(movingCoroutine); //yield return new WaitForSeconds(10f);

                GeneratorIsMoving = false;
                GeneratorMoveLeft = false;
            }
            else if (GeneratorMoveCenterAndDown && !GeneratorIsMoving)
            {
                GeneratorIsMoving = true;
                yield return(new WaitForSeconds(5f));

                movingCoroutine = StartCoroutine(generatorOrbitAroundCenter.OrbitUntilCenter());
                yield return(movingCoroutine);

                movingCoroutine = StartCoroutine(generatorOrbitAroundCenter.GoSitDown());
                yield return(movingCoroutine);

                GeneratorIsMoving          = false;
                GeneratorMoveCenterAndDown = false;
            }
            else if (GeneratorMovementComplete && !GeneratorIsMoving)
            {
                //yield return new WaitForSeconds(5f);
                //StartCoroutine(generatorOrbitAroundCenter.ReturnUpToParentCenter());
                //yield return new WaitForSeconds(5f);
                GeneratorMovementComplete = false;
                break;
            }
        }

        CounterCaughtRingsTutorial = 0;
        GeneratorIsMoving          = false;
        GeneratorMoveRight         = false;
        GeneratorMoveLeft          = false;
        GeneratorMoveCenterAndDown = false;
        GeneratorMovementComplete  = false;

        yield return(new WaitForSeconds(10f)); //Wait until the last elements flow, if there are

        generatorOrbitAroundCenter.ResetPositionGeneratorRotating();

        spawnWavesIsActive = false;

        AuraAndGeneratorsDeactivation();

        areaPlayer.GetComponent <PlayerArea>().goIntoAuraMessage.GetComponentInChildren <TextMesh>().text = "Prendi il delfino\ne vai dentro\nl'aura!";

        UiMenuHandler.instance.DeactivateArrowCameraIfVuforiaDisabled();

        if (!startedGame)
        {
            yield break;
        }

        startedGame         = false;
        gameModeSelected    = GameMode.IDLE;
        currentPhaseOfLevel = PhaseOfLevel.END;

        WebClientSender.instance.MoveMouthAndEyesDolphinTogether();
        labelGenericMessage.text = "FINE TUTORIAL";
        textGenericMessage.text  = "Tutorial completato!";
        uiMenuScript.PutInFrontOfCamera(genericMessage);
        genericMessage.SetActive(true);
        yield return(new WaitForSeconds(3f));

        genericMessage.SetActive(false);

        uiMenuScript.ShowMainMenu();
    }
Exemplo n.º 6
0
    private IEnumerator SpawnWavesTutorial()
    {
        spawnWavesIsActive = true;

        yield return(new WaitForSeconds(levelsParams[currentLevel].startWait));

        labelGenericMessage.text = "TUTORIAL";
        textGenericMessage.text  = "Rimani nell'aura o\ndopo 10 secondi perderai vita!\nVerranno verso di te\ndegli anelli,\nimpara a centrarli\ncon la giusta angolazione!";
        uiMenuScript.PutInFrontOfCamera(genericMessage);
        genericMessage.SetActive(true);
        yield return(new WaitForSeconds(10f));

        genericMessage.SetActive(false);

        CounterCaughtRingsTutorial = 0;

        while (CounterCaughtRingsTutorial < 9)
        {
            if (!startedGame)
            {
                yield break;                                  //Kill the coroutine if the game ended (most cases, when player loses)
            }
            Transform extractedSpawnGen = spawnGenerators[0]; //Random.range excludes the right number from the range

            string newElementName = torusBubble.name;

            GameObject newElement = ObjectPoolingManager.Instance.GetObject(newElementName);

            newElement.transform.position = extractedSpawnGen.transform.position;
            newElement.transform.rotation = extractedSpawnGen.transform.rotation;
            newElement.GetComponent <Rigidbody>().velocity = newElement.transform.up * levelsParams[currentLevel].speedElements;

            if (CounterCaughtRingsTutorial < 3)
            {
                newElement.transform.localEulerAngles += new Vector3(0f, 0f, 0f);
            }
            else if (CounterCaughtRingsTutorial >= 3 && CounterCaughtRingsTutorial < 6)
            {
                newElement.transform.localEulerAngles += new Vector3(0f, +20f, 0f);
            }
            else if (CounterCaughtRingsTutorial >= 6 && CounterCaughtRingsTutorial < 9)
            {
                newElement.transform.localEulerAngles += new Vector3(0f, -20f, 0f);
            }

            yield return(new WaitForSeconds(levelsParams[currentLevel].spawnWait));
        }

        CounterCaughtRingsTutorial = 0;


        yield return(new WaitForSeconds(8f)); //Wait until the last elements flow

        spawnWavesIsActive = false;
        AuraAndGeneratorsDeactivation();
        areaPlayer.GetComponent <PlayerArea>().goIntoAuraMessage.GetComponentInChildren <TextMesh>().text = "Prendi il delfino\ne vai dentro\nl'aura!";

        UiMenuHandler.instance.DeactivateArrowCameraIfVuforiaDisabled();

        if (!startedGame)
        {
            yield break;
        }

        startedGame         = false;
        gameModeSelected    = GameMode.IDLE;
        currentPhaseOfLevel = PhaseOfLevel.END;

        WebClientSender.instance.MoveMouthAndEyesDolphinTogether();
        labelGenericMessage.text = "FINE TUTORIAL";
        textGenericMessage.text  = "Tutorial completato!\nOra sei pronto per\ngiocare una vera partita!";
        uiMenuScript.PutInFrontOfCamera(genericMessage);
        genericMessage.SetActive(true);
        yield return(new WaitForSeconds(5f));

        textGenericMessage.text = "Ricorda: mentre giochi potresti\nincontrare anche:\n*Piccoli polpi (ricaricano l'energia!)\n*Ostacoli da evitare!";
        yield return(new WaitForSeconds(8f));

        genericMessage.SetActive(false);

        uiMenuScript.ShowMainMenu();
    }