Esempio n. 1
0
 public override void OnEnd()
 {
     if (GetComponent <AudioSource>())
     {
         GetComponent <AudioSource>().Play();
     }
     freestyleText.SetActive(false);
     freestyleUI.SetActive(false);
     if (playerOneScore > playerTwoScore)
     {
         scoringSystem.AddFirstPlayerScore(freestylePrize, freestylePrize, false);
     }
     else if (playerTwoScore > playerOneScore)
     {
         scoringSystem.AddFirstPlayerScore(freestylePrize, freestylePrize, false);
     }
     else
     {
         int temp = Random.Range(0, 2);
         if (temp == 0)
         {
             scoringSystem.AddFirstPlayerScore(freestylePrize, freestylePrize, false);
         }
         else
         {
             scoringSystem.AddSecondPlayerScore(freestylePrize, freestylePrize, false);
         }
     }
     foreach (DiscoballRetract dr in canvas.GetComponentsInChildren <DiscoballRetract>())
     {
         dr.Extend();
     }
     foreach (FreestyleDiscoball dr in canvas.GetComponentsInChildren <FreestyleDiscoball>())
     {
         dr.Retract();
     }
     Debug.Log(playerOneScore + " " + playerTwoScore);
 }
Esempio n. 2
0
    public override bool OnUpdate()
    {
        if (started == true && isPaused == false)
        {
            timingP1.enabled = true;
            timingP2.enabled = true;
            accumulatedTime += Time.deltaTime;
            if (accumulatedTime <= GetTiming())
            {
                AnimateTiming(GetTiming(), accumulatedTime);
                CheckTiming(accumulatedTime);
            }
            else
            {
                if (moveRatedP1 == false)
                {
                    scoringSystem.AddFirstPlayerScore(inputCheck.CheckScore(lastMove, 1, InputCheck.Players.PlayerOne), inputCheck.GetMaxScore(lastMove), false);
                }
                if (moveRatedP2 == false)
                {
                    scoringSystem.AddSecondPlayerScore(inputCheck.CheckScore(lastMove, 1, InputCheck.Players.PlayerTwo), inputCheck.GetMaxScore(lastMove), false);
                }
                lastPairIndex++;
                if (timingPairs.Length <= lastPairIndex)
                {
                    started                = false;
                    stateFinished          = true;
                    instruction.sprite     = voidSprite;
                    nextInstruction.sprite = voidSprite;
                    lastPairIndex          = 0;
                    accumulatedTime        = 0f;
                    return(false);
                }

                moveRatedP1        = false;
                moveRatedP2        = false;
                accumulatedTime    = 0f;
                instruction.sprite = timingPairs[lastPairIndex].firstValue.moveInstruction;

                if (lastPairIndex + 1 <= timingPairs.Length - 1)
                {
                    nextInstruction.sprite = timingPairs[lastPairIndex + 1].firstValue.moveInstruction;
                }
                else
                {
                    nextInstruction.sprite = voidSprite;
                }
                timingP1.sprite = voidSprite;
                timingP2.sprite = voidSprite;
                //timingObjectP1Small.GetComponent<SpriteRenderer>().sprite = voidSprite;
                //timingObjectP2Small.GetComponent<SpriteRenderer>().sprite = voidSprite;
                timingP1.gameObject.transform.localScale = new Vector3(scaleTiming, scaleTiming, 1);
                timingP1.color = new Color(1f, 1f, 1f, 0.25f);
                timingP2.gameObject.transform.localScale = timingP1.gameObject.transform.localScale;
                timingP2.color  = timingP1.color;
                timingP1.sprite = instruction.sprite;
                timingP2.sprite = timingP1.sprite;
                timingObjectP1Small.GetComponent <SpriteRenderer>().sprite = timingP1.sprite;
                timingObjectP2Small.GetComponent <SpriteRenderer>().sprite = timingP2.sprite;
                lastMove = timingPairs[lastPairIndex].firstValue;
            }
        }
        else if (intro == true)
        {
            timingP1.sprite  = voidSprite;
            timingP2.sprite  = voidSprite;
            accumulatedTime += Time.deltaTime;
            if (accumulatedTime >= introTime)
            {
                timingP1.enabled = true;
                timingP2.enabled = true;
                timingP1.sprite  = instruction.sprite;
                timingP2.sprite  = instruction.sprite;
                timingObjectP1Small.GetComponent <SpriteRenderer>().sprite = timingP1.sprite;
                timingObjectP2Small.GetComponent <SpriteRenderer>().sprite = timingP2.sprite;
                timingP1.gameObject.transform.localScale = new Vector3(scaleTiming, scaleTiming, 1);
                timingP1.color = new Color(1f, 1f, 1f, 0.25f);
                timingP2.gameObject.transform.localScale = new Vector3(scaleTiming, scaleTiming, 1);
                timingP2.color  = new Color(1f, 1f, 1f, 0.25f);
                started         = true;
                intro           = false;
                accumulatedTime = 0f;
            }
        }

        return(true);
    }