Example #1
0
    // Update is called once per frame
    void Update()
    {
        //get currLap from check point script of entity's
        currLapP1 = checkpointP1Script.currLap;
        currLapP2 = checkpointP2Script.currLap;

        //get rank from the rankScrip's getter GetRank
        rankP1 = rankScript.GetRank(checkpointP1Script);
        rankP2 = rankScript.GetRank(checkpointP2Script);

        //according to the currlap, decide which sprite to render
        //it has to be (currlap - 1), you know why.
        lapCountP1Sprite.sprite = lapSpriteList[currLapP1 - 1];
        lapCountP2Sprite.sprite = lapSpriteList[currLapP2 - 1];

        //according to the rank, decide which sprite to render
        //it has to be (currlap - 1), you know why
        rankP1Sprite.sprite = rankSpriteList[rankP1 - 1];
        rankP2Sprite.sprite = rankSpriteList[rankP2 - 1];

        //if player1 doesn't possess items
        if (player1.HasItem == false)
        {
            //no matter what icon inside it's currently in the frame,
            //make it transparent (alpha = 0)
            itemP1Sprite.color = new Color(1, 1, 1, 0);
            //this method is a faking method, it doesn't actually destroy the icon
            //only hiding it. Will have to improve if possible ( use Destroy(); and Instantiate(); )
        }

        //if player1 doesn't possess items
        if (player2.HasItem == false)
        {
            //no matter what icon inside it's currently in the frame,
            //make it transparent (alpha = 0)
            itemP2Sprite.color = new Color(1, 1, 1, 0);
            //this method is a faking method, it doesn't actually destroy the icon
            //only hiding it. Will have to improve if possible ( use Destroy(); and Instantiate(); )
        }


        //press start button to pause the game
        if (XCI.GetButtonDown(XboxButton.Start, controller))
        {
            //Switch game states to pause
            gameManager.SwitchGameState(GameStateID.Pause);
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        //get currLap from check point script of entity's
        currLap = checkpointScript.currLap;
        //get rank from the rankScrip's getter GetRank
        rank = rankScript.GetRank(checkpointScript);
        //according to the currlap, decide which sprite to render
        //it has to be (currlap - 1), you know why
        lapCountSprite.sprite = lapSpriteList[currLap - 1];

        //according to the rank, decide which sprite to render
        //it has to be (currlap - 1), you know why
        rankSprite.sprite = rankSpriteList[rank - 1];

        //if entity doesn't possess items
        if (entity.HasItem == false)
        {
            //no matter what icon inside it's currently in the frame,
            //make it transparent (alpha = 0)
            itemSprite.color = new Color(1, 1, 1, 0);
            //this method is a faking method, it doesn't actually destroy the icon
            //only hiding it. Will have to improve if possible ( use Destroy(); and Instantiate(); )
        }

        //press start button to pause
        if (XCI.GetButtonDown(XboxButton.Start))
        {
            gameManager.SwitchGameState(GameStateID.Pause);
        }

        //Check if the race is complete
        if (currLap > maxLaps)
        {
            //If you win
            if (rank == 1)
            {
                //You win the race
                playerManager.Win = true;
                gameManager.SwitchGameState(GameStateID.Victory);
            }
            else
            {
                //You lose the race
                playerManager.Win = false;
                gameManager.SwitchGameState(GameStateID.Victory);
            }
        }
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        //Obtain the checkpoint
        currLap = carCheckpoint.currLap;

        if (hasFinished == false)
        {
            //Obtain the rank
            currRank = rank.GetRank(carCheckpoint);
        }

        //If we have exceeded the amount of laps
        if (currLap > maxLaps)
        {
            //Stop driving
            drive.AbilityToDrive = false;
            hasFinished          = true;

            if (currRank == 1)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = first;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 2)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = second;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 3)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = third;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 4)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = fourth;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 5)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = fifth;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 6)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = sixth;

                //Display the rank
                displayRank.SetActive(true);
            }
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        //Obtain the checkpoint
        currLap = carCheckpoint.currLap;

        if (hasFinished == false)
        {
            //Obtain the rank
            currRank = rank.GetRank(carCheckpoint);
        }


        //If we have exceeded the amount of laps
        if (currLap > maxLaps)
        {
            //Stop driving
            drive.AbilityToDrive = false;
            hasFinished          = true;

            if (currRank == 1)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = first;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 2)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = second;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 3)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = third;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 4)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = fourth;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 5)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = fifth;

                //Display the rank
                displayRank.SetActive(true);
            }
            else if (currRank == 6)
            {
                //Set the image of the sprite renderer
                spriteRenderer.sprite = sixth;

                //Display the rank
                displayRank.SetActive(true);
            }
        }

        //Check if both players have finished the race
        if (hasFinished == true && check.HasFinished == true)
        {
            //Start the timer
            mainMenuTimer += Time.deltaTime;

            //If the timer exceeds 3 seconds
            if (mainMenuTimer > 3.0f)
            {
                //Switch states
                gameManager.SwitchGameState(GameStateID.MainMenu);
            }
        }
    }