Example #1
0
    // Use this for initialization
    void Start()
    {
        TimerScript.matchTime = MATCH_TIME;
        time_left             = MATCH_TIME;
        ScoreP1Script.scoreP1 = 0;
        ScoreP2Script.scoreP2 = 0;
        //state = stateOfMatch.notStarted;
        state = stateOfMatch.cinematic;

        point  = pointOfStart.player1;
        velLev = velocityLevel.level1;
        bc     = GetComponent <BoxCollider>();

        P1.transform.position = P1initialPosition.position;
        P2.transform.position = P2initialPosition.position;


        fadeValue = minValue;
        for (int i = 0; i < P2Materials.Length; i++)
        {
            P1Materials[i].SetFloat("Vector1_68C5C62B", fadeValue);
        }

        for (int i = 0; i < P1Materials.Length; i++)
        {
            P2Materials[i].SetFloat("Vector1_68C5C62B", fadeValue);
        }
    }
Example #2
0
 public void EndCinematic()
 {
     state = stateOfMatch.notStarted;
     PM.StartParticlesP1();
     GameObject.FindObjectOfType <AudioManager>().PlayRandomPitch("EnergyConcentration");
     match_started = true;
     GameObject.FindObjectOfType <AudioManager>().PlayRandomPitch("AirHorn");
 }
Example #3
0
    private void HotBallLogic()
    {
        timerBallTime += Time.deltaTime;
        if (timerBallTime >= ballTime)
        {
            timerBallTime = 0;

            PM.HitPlayerParticles(ball.transform);
            state         = stateOfMatch.endPoint;
            timerBallTime = 0;
            if (currentSideOfBall == 1)
            {
                P1.GetComponent <PlayerMovement>().defeated = true;

                P1.GetComponent <PlayerMovement>().HittedFront();
                DissolveManagerP1();
                point = pointOfStart.player2;
                PM.StartBurningGroundP1();
                FindObjectOfType <AudioManager>().PlayRandomPitch("ExplosionSound");

                ScoreP2Script.scoreP2++;
            }
            else
            {
                P2.GetComponent <PlayerMovement>().defeated = true;

                P2.GetComponent <PlayerMovement>().HittedFront();
                DissolveManagerP2();
                point = pointOfStart.player1;
                PM.StartBurningGroundP2();
                FindObjectOfType <AudioManager>().PlayRandomPitch("ExplosionSound");

                ScoreP1Script.scoreP1++;
            }
        }

        if (timerBallTime >= ballTime - timeInFlames)
        {
            PM.StartFireTrail();
        }
        else
        {
            PM.EndFireTrail();
        }
    }
Example #4
0
    private void GameOverManager()
    {
        if (time_left <= 0)
        {
            GameObject.FindObjectOfType <AudioManager>().PlayRandomPitch("AirHorn");
            ball.GetComponent <BallScript>().ballStopped = true;
            ball.GetComponent <BallScript>().hitted      = false;
            RestartTimerBall();
            PM.EndFireTrail();
            match_started           = false;                    //para que no corra el tiempo
            ball.transform.position = new Vector3(-10000, ball.transform.position.y, ball.transform.position.z);
            if (ScoreP1Script.scoreP1 == ScoreP2Script.scoreP2) //Draw
            {
                //completar empate
                GameObject.FindObjectOfType <LevelChanger>().FadeToNextLevel();
            }
            else
            {
                RestartDissolve();
                if (ScoreP1Script.scoreP1 > ScoreP2Script.scoreP2)   //win P1
                {
                    WINNER = 1;
                    GameObject.FindObjectOfType <CameraHolderScript>().MoveToP1();
                    P1initialPosition = WinPointP1;
                    P1.GetComponent <PlayerMovement>().defeated = true;
                    //P1.GetComponent<PlayerMovement>().isOnGround = true;

                    DissolveManagerP1();
                }
                else  //win P2
                {
                    WINNER = 2;
                    GameObject.FindObjectOfType <CameraHolderScript>().MoveToP2();
                    P2initialPosition = WinPointP2;
                    P2.GetComponent <PlayerMovement>().defeated = true;
                    DissolveManagerP2();
                }
                StartCoroutine(WaitBetweenRounds());
            }
            state = stateOfMatch.endGame;
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        if (match_started)
        {
            GameOverManager();
        }


        CheckPositionOfBall();
        CheckWallsOpen();

        RainManager();
        PostProcessingManager();
        if (match_started)
        {
            time_left            -= Time.deltaTime;
            TimerScript.matchTime = time_left;
            EnvironmentChanger();
        }


        switch (state)
        {
        case stateOfMatch.notStarted:

            ball.transform.position = startPointP1.position;
            currentSideOfBall       = 1;
            previousSideOfBall      = 1;

            if (!ball.GetComponent <BallScript>().ballStopped)
            {
                state = stateOfMatch.running;
                ball.GetComponent <BallScript>().hitted = true;
            }
            //print("no ha empezado");
            break;

        case stateOfMatch.running:
            //doChangesWhileRunning();
            //print("empezamos");
            HotBallLogic();



            break;

        case stateOfMatch.endPoint:

            ball.GetComponent <BallScript>().ballStopped = true;
            ball.GetComponent <BallScript>().hitted      = false;
            RestartTimerBall();
            PM.EndFireTrail();



            if (point == pointOfStart.player1)
            {
                ball.transform.position = startPointP1.position;
                PM.StartParticlesP1();
                currentSideOfBall  = 1;
                previousSideOfBall = 1;
            }
            else
            {
                ball.transform.position = startPointP2.position;
                PM.StartParticlesP2();
                currentSideOfBall  = 2;
                previousSideOfBall = 2;
            }
            StartCoroutine(WaitBetweenRounds());

            state = stateOfMatch.startPoint;
            GameObject.FindObjectOfType <AudioManager>().PlayRandomPitch("EnergyConcentration");

            ball.GetComponent <BallScript>().ResetVelocity();
            ball.GetComponent <BallScript>().ResetMaterial();
            break;

        case stateOfMatch.startPoint:
            //print("estamos aqui");
            if (!ball.GetComponent <BallScript>().ballStopped)
            {
                state = stateOfMatch.running;
                ball.GetComponent <BallScript>().hitted = true;
            }
            break;

        case stateOfMatch.endGame:
            timerEnd += Time.deltaTime;
            if (timerEnd >= TimeShowingWinner)
            {
                GameObject.FindObjectOfType <AudioManager>().StopSound("Fireworks");
                GameObject.FindObjectOfType <AudioManager>().StopSound("CinematicSound");

                GameObject.FindObjectOfType <LevelChanger>().FadeToLevel(0);
            }
            if (WINNER == 1)
            {
                P1.GetComponent <Animator>().SetTrigger("Winner");
                //PM.PlayConfettiP1();
            }
            else
            {
                if (WINNER == 2)
                {
                    P2.GetComponent <Animator>().SetTrigger("Winner");
                    //PM.PlayConfettiP2();
                }
            }

            break;
        }
    }