Example #1
0
 void reviveAllPlayers()
 {
     player1.GetComponent <P1>().isSad = false;
     player2.GetComponent <P2>().isSad = false;
     player3.GetComponent <P3>().isSad = false;
     player4.GetComponent <P4>().isSad = false;
 }
Example #2
0
    void Update()
    {
        if (P1 != null)
        {
            newPosP1 = P1.GetComponent <Transform>();
        }
        if (P2 != null)
        {
            newPosP2 = P2.GetComponent <Transform>();
        }

        // Player 1 leads
        if (newPosP1.position.x > newPosP2.position.x)
        {
            ranking[0] = "player 1";
            ranking[1] = "player 2";
        }

        // Player 2 leads
        if (newPosP2.position.x > newPosP1.position.x)
        {
            ranking[0] = "player 2";
            ranking[1] = "player 1";
        }
    }
Example #3
0
    public void ComputeSpringForces()
    {
        ClothNode p1node       = P1.GetComponent <ClothNode>();
        ClothNode p2node       = P2.GetComponent <ClothNode>();
        Vector3   displacement = P2.transform.position - P1.transform.position;
        float     distance     = displacement.magnitude;
        Vector3   direction    = displacement / distance;

        // 1 Dimension velocities b/c a spring exists in 1 Dimension      // Used in Dampen Force formula
        float node1Velocity = Vector3.Dot(displacement.normalized, p1node.velocity);
        float node2Velocity = Vector3.Dot(displacement.normalized, p2node.velocity);

        // Spring Force = -spring factor * (distance - rest length)
        float Fspring = -springConstant * (distance - restLength);
        // Dampen Force = -Dampen Factor * (difference of velocity)
        float Fdampen = -damperConstant * (node2Velocity - node1Velocity);

        // 1 Dimension Spring Dampen Force  // Sum of Spring Force and Dampen Force
        float SpringDampenforce = Fspring + Fdampen;

        // Converting it back into a 3 Dimensional force
        Vector3 p2force = SpringDampenforce * direction;
        Vector3 p1force = -p2force;

        // Applying it to nodes
        p1node.force += p1force;
        p2node.force += p2force;
    }
Example #4
0
    public void activation()
    {
        QnsCall();
        ReadEntries();
        LogGameItems();

        //Player two's turn
        if (x1 == false)
        {
            O1.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            O1.SetActive(false);
            O2.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            O2.SetActive(false);
            O3.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            O3.SetActive(false);
            O4.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            O4.SetActive(false);
            T1.SetActive(false);
            HideOptBox1();

            P1.SetActive(true);
            P2.SetActive(true);
            P3.SetActive(true);
            P4.SetActive(true);
            T2.SetActive(true);
            ShowOptBox2();
            tr2.resetClock2();

            optionTxt2();
            x1 = true;
        }

        //Player one's turn
        else
        {
            P1.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            P1.SetActive(false);
            P2.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            P2.SetActive(false);
            P3.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            P3.SetActive(false);
            P4.GetComponent <CanvasGroup> ().blocksRaycasts = true;
            P4.SetActive(false);
            T2.SetActive(false);
            HideOptBox2();


            O1.SetActive(true);
            O2.SetActive(true);
            O3.SetActive(true);
            O4.SetActive(true);
            T1.SetActive(true);
            ShowOptBox1();
            tr1.resetClock1();

            optionTxt1();
            x1 = false;
        }
    }
 public void Select_SinglePlayer()
 {
     P1.GetComponent <CharacterSelection>().playersSelected = true;
     P2.GetComponent <CharacterSelection>().playersSelected = true;
     CharacterStoredInfo.instance.singlePlayer = true;
     Canvas_Start.SetActive(false);
     Canvas_Options.SetActive(false);
     SceneManager.LoadScene("Chapters&Levels");
 }
Example #6
0
    public void SinglePlayer()
    {
        P1.GetComponent <CharacterSelection>().playersSelected = true;
        P2.GetComponent <CharacterSelection>().playersSelected = true;
        CharacterStoredInfo.instance.singlePlayer = true;
        levelStart.SetActive(false);
        levelSelect.SetActive(true);
        EventSystem es = GameObject.Find("EventSystem").GetComponent <EventSystem>();

        es.SetSelectedGameObject(null);
        es.SetSelectedGameObject(levelSelectFirstButton);
    }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        ball.gameObject.transform.position += ball.transform.forward * Time.deltaTime * speedBall;
        P1.GetComponent <Animator>().SetTrigger("run");
        P2.GetComponent <Animator>().SetTrigger("run");
        P1.transform.position = new Vector3(P1.transform.position.x, 0, P1.transform.position.z);
        P2.transform.position = new Vector3(P2.transform.position.x, 0, P2.transform.position.z);
        timer += Time.deltaTime;
        P1.gameObject.transform.position += P1.gameObject.transform.forward * Time.deltaTime * characterSpeed2;
        P2.gameObject.transform.position += P2.gameObject.transform.forward * Time.deltaTime * characterSpeed2;


        if (timer >= timeToChange)
        {
            GameObject.FindObjectOfType <LevelChanger>().FadeToNextLevel();
        }
    }
Example #8
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 #9
0
 private void RestartPlayers()
 {
     if (P1.GetComponent <PlayerMovement>().defeated)
     {
         P1.GetComponent <PlayerMovement>().defeated = false;
         P1.transform.position = P1initialPosition.position;
         P1.GetComponent <PlayerMovement>().RestartAnimations();
         //P1.GetComponent<PlayerMovement>().isOnGround = false;
     }
     if (P2.GetComponent <PlayerMovement>().defeated)
     {
         P2.GetComponent <PlayerMovement>().defeated = false;
         P2.transform.position = P2initialPosition.position;
         P2.GetComponent <PlayerMovement>().RestartAnimations();
         //P2.GetComponent<PlayerMovement>().isOnGround = false;
     }
     StartCoroutine(WaitBeforeWakingUp());
 }
Example #10
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 #11
0
    private void RestartPlayersEndGame()
    {
        if (P1.GetComponent <PlayerMovement>().defeated)
        {
            //P1.GetComponent<PlayerMovement>().defeated = false;
            P1.transform.position = P1initialPosition.position;
            P1.transform.rotation = P1initialPosition.rotation;
            //print("BREACKPOINT1");
            P1.GetComponent <PlayerMovement>().isOnGround = true;

            //P1.GetComponent<PlayerMovement>().RestartAnimations();
            //P1.GetComponent<PlayerMovement>().isOnGround = false;
        }
        if (P2.GetComponent <PlayerMovement>().defeated)
        {
            //P2.GetComponent<PlayerMovement>().defeated = false;
            P2.transform.position = P2initialPosition.position;
            P2.transform.rotation = P2initialPosition.rotation;
            P2.GetComponent <PlayerMovement>().isOnGround = true;

            //P2.GetComponent<PlayerMovement>().RestartAnimations();
            //P2.GetComponent<PlayerMovement>().isOnGround = false;
        }
    }
Example #12
0
    private void Update()
    {
        moveInput.x = Input.GetAxisRaw("HorizontalP" + playerId);

        if (!characterSelected && !playersSelected)
        {
            if (moveInput.x < 0 && position > positionMin && !changedLocation)
            {
                position--;
                changedLocation = true;
            }

            if (moveInput.x > 0 && position < positionMax && !changedLocation)
            {
                position++;
                changedLocation = true;
            }

            if (moveInput == Vector2.zero)
            {
                changedLocation = false;
            }

            switch (position)
            {
            case -1:
                transform.position = controllerNight.position;
                if (Input.GetButtonDown("JumpP" + playerId))
                {
                    P1.GetComponent <CharacterSelection>().controllerNight.gameObject.SetActive(false);
                    P2.GetComponent <CharacterSelection>().controllerNight.gameObject.SetActive(false);
                    P1.GetComponent <CharacterSelection>().positionMin++;
                    P2.GetComponent <CharacterSelection>().positionMin++;
                    CharacterStoredInfo.instance.night = playerId;
                    checkmark.SetActive(true);
                    characterSelected = true;

                    if (P1.transform.position.x == P2.transform.position.x)
                    {
                        if (!P1.GetComponent <CharacterSelection>().characterSelected)
                        {
                            P1.GetComponent <CharacterSelection>().position++;
                        }

                        if (!P2.GetComponent <CharacterSelection>().characterSelected)
                        {
                            P2.GetComponent <CharacterSelection>().position++;
                        }
                    }
                }
                break;

            case 0:
                transform.position = controllerStart.position;
                break;

            case 1:
                transform.position = controllerDay.position;
                if (Input.GetButtonDown("JumpP" + playerId))
                {
                    P1.GetComponent <CharacterSelection>().controllerDay.gameObject.SetActive(false);
                    P2.GetComponent <CharacterSelection>().controllerDay.gameObject.SetActive(false);
                    P1.GetComponent <CharacterSelection>().positionMax--;
                    P2.GetComponent <CharacterSelection>().positionMax--;
                    CharacterStoredInfo.instance.day = playerId;
                    checkmark.SetActive(true);
                    characterSelected = true;

                    if (P1.transform.position.x == P2.transform.position.x)
                    {
                        if (!P1.GetComponent <CharacterSelection>().characterSelected)
                        {
                            P1.GetComponent <CharacterSelection>().position--;
                            Debug.Log("P1");
                        }

                        if (!P2.GetComponent <CharacterSelection>().characterSelected)
                        {
                            P2.GetComponent <CharacterSelection>().position--;
                            Debug.Log("P2");
                        }
                    }
                }
                break;
            }
        }

        if (P1.GetComponent <CharacterSelection>().characterSelected&& P2.GetComponent <CharacterSelection>().characterSelected)
        {
            if (Input.GetButtonDown("JumpP" + playerId))
            {
                P1.GetComponent <CharacterSelection>().playersSelected = true;
                P2.GetComponent <CharacterSelection>().playersSelected = true;
                SceneManager.LoadScene("Chapters&Levels");
            }
        }
    }
Example #13
0
 private void SetCharSelectionActive()
 {
     P1.GetComponent <CharacterSelection>().playersSelected = false;
     P2.GetComponent <CharacterSelection>().playersSelected = false;
 }
Example #14
0
    public GameObject Pt;  // collision point


    private void Start()
    {
        P1.GetComponent <Renderer>().material.color = Color.black;
        P2.GetComponent <Renderer>().material.color = Color.black;
        Pt.GetComponent <Renderer>().material.color = Color.red;
    }
Example #15
0
 private void RestartMovementPlayers()
 {
     P1.GetComponent <PlayerMovement>().isOnGround = false;
     P2.GetComponent <PlayerMovement>().isOnGround = false;
 }
Example #16
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        ball.gameObject.transform.position += ball.transform.forward * Time.deltaTime * speedBall;
        P1.transform.position = new Vector3(P1.transform.position.x, 0, P1.transform.position.z);
        P2.transform.position = new Vector3(P2.transform.position.x, 0, P2.transform.position.z);

        switch (state)
        {
        case 1:
            //ball.gameObject.transform.position += ball.transform.forward * Time.deltaTime * speedBall;
            if (timer >= endPhase1)
            {
                state = 2;
            }
            break;

        case 2:
            P1.GetComponent <Animator>().SetTrigger("mirar");
            P2.GetComponent <Animator>().SetTrigger("mirar");
            if (timer >= endPhase2)
            {
                state = 3;
            }
            break;

        case 3:

            if (!DRAW_SCENE)
            {
                Vector3    relativePos1 = ball.transform.position - P1.transform.position;
                Quaternion rotation1    = Quaternion.LookRotation(relativePos1);
                P1.transform.rotation = Quaternion.Slerp(P1.transform.rotation, rotation1, Time.deltaTime * steerVelocity);

                Vector3    relativePos2 = ball.transform.position - P1.transform.position;
                Quaternion rotation2    = Quaternion.LookRotation(relativePos1);
                P2.transform.rotation = Quaternion.Slerp(P2.transform.rotation, rotation2, Time.deltaTime * steerVelocity);
            }

            //P2.transform.rotation = Quaternion.Slerp(P2.transform.rotation, rotation, Time.deltaTime * steerVelocity);

            //P2.transform.rotation = rotation;
            P1.GetComponent <Animator>().SetTrigger("run");
            P2.GetComponent <Animator>().SetTrigger("run");

            P1.gameObject.transform.position += P1.gameObject.transform.forward * Time.deltaTime * characterSpeed;
            P2.gameObject.transform.position += P2.gameObject.transform.forward * Time.deltaTime * characterSpeed;

            if (timer >= endPhase3)
            {
                state = 4;
            }
            break;

        case 4:

            if (!DRAW_SCENE)
            {
                Vector3    relativePos3 = ball.transform.position - P1.transform.position;
                Quaternion rotation3    = Quaternion.LookRotation(relativePos3);
                P1.transform.rotation = Quaternion.Slerp(P1.transform.rotation, rotation3, Time.deltaTime * steerVelocity);

                Vector3    relativePos4 = ball.transform.position - P1.transform.position;
                Quaternion rotation4    = Quaternion.LookRotation(relativePos4);
                P2.transform.rotation = Quaternion.Slerp(P2.transform.rotation, rotation4, Time.deltaTime * steerVelocity);

                /*relativePos = ball.transform.position - transform.position;
                 * rotation = Quaternion.LookRotation(relativePos);
                 * P1.transform.rotation = Quaternion.Slerp(P1.transform.rotation, rotation, Time.deltaTime * steerVelocity);
                 * P2.transform.rotation = Quaternion.Slerp(P2.transform.rotation, rotation, Time.deltaTime * steerVelocity);*/
                P1.gameObject.transform.position += P1.gameObject.transform.forward * Time.deltaTime * characterSpeed2;
                P2.gameObject.transform.position += P2.gameObject.transform.forward * Time.deltaTime * characterSpeed2;
            }

            /* else
             * {
             *   P1.gameObject.transform.position += P1.gameObject.transform.forward * Time.deltaTime * characterSpeed2;
             *   P2.gameObject.transform.position += P2.gameObject.transform.forward * Time.deltaTime * characterSpeed2;
             * }
             */


            if (timer >= endPhase4)
            {
                if (!DRAW_SCENE)
                {
                    GameObject.FindObjectOfType <LevelChanger>().FadeToNextLevel();
                }
                else
                {
                    GameObject.FindObjectOfType <LevelChanger>().FadeToLevel(0);
                    GameObject.FindObjectOfType <AudioManager>().StopSound("TitleTheme");
                }
            }

            break;
        }
    }
Example #17
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;
        }
    }