Exemplo n.º 1
0
    IEnumerator DoGameOverStuff()
    {
        Grid.maskInteraction = SpriteMaskInteraction.None;
        var originalA = Grid.color.a;

        while (Grid.color.a > 0.01f)
        {
            Grid.color = Grid.color.withAlpha(Mathf.Lerp(Grid.color.a, 0f, 0.12f));
            yield return(null);
        }
        while (Grid.color.a < originalA)
        {
            Grid.color = Grid.color.withAlpha(Mathf.Lerp(Grid.color.a, 1f, 0.12f));
            yield return(null);
        }
        while (Grid.color.a > 0.01f)
        {
            Grid.color = Grid.color.withAlpha(Mathf.Lerp(Grid.color.a, 0f, 0.3f));
            yield return(null);
        }
        while (Grid.color.a < originalA)
        {
            Grid.color = Grid.color.withAlpha(Mathf.Lerp(Grid.color.a, 1f, 0.3f));
            yield return(null);
        }
        Grid.color = Grid.color.withAlpha(originalA);
        yield return(new WaitForSeconds(Mathf.Lerp(0.8f, 1.5f, Random.value)));

        Grid.color = Grid.color.withAlpha(originalA);


        TextEndTime.text      = TimeAlive.ToString("0.00s");
        TextEndScore.text     = Score.ToString("0");
        TextEndStar.text      = BestStar.ToString("0");
        TextEndBestTime.text  = PlayerPrefs.GetFloat("MaxTime").ToString("0.00s");
        TextEndBestScore.text = PlayerPrefs.GetFloat("MaxScore").ToString("0");
        TextEndBestStar.text  = PlayerPrefs.GetFloat("MaxStar").ToString("0");
        foreach (var t in EndTexts)
        {
            t.gameObject.SetActive(true);
            BloopSound.PlayWithPitchRange(0.8f, 1.15f, 1.6f);
            BloopSound.PlayWithPitchRange(0.8f, 1.15f, 1.6f);
            yield return(new WaitForSeconds(Mathf.Lerp(0.1f, 0.45f, Random.value)));
        }

        canRestart = true;
    }
Exemplo n.º 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        var stunBlock = collision.collider.GetComponent <StunBlock>();

        if (stunBlock)
        {
            GeneratingLine = false;
            stunTime       = stunBlock.StunTime;
            rb.velocity    = Vector2.zero;
            var hit = collision.GetContact(0);
            rb.AddForce(hit.normal * stunBlock.PushForce, ForceMode2D.Impulse);
            // particles
            var particles = Instantiate(HitParticlesPrefab, hit.point, Quaternion.Euler(0, 0, hit.normal.angleDeg() - 30));
            // sound
            HurtSound.PlayWithPitchRange(0.8f, 1.2f);
        }
    }
Exemplo n.º 3
0
 void FixedUpdate()
 {
     if (triggers > 0)
     {
         triggered             = true;
         scorePerSecondBuffer += Time.deltaTime;
         if (scorePerSecondBuffer >= ScorePerSecondBuffer)
         {
             score += ScorePerSecond * Time.deltaTime;
         }
     }
     // die and give score
     {
         if (triggered && triggers == 0)
         {
             Scorer.Inst.OnStarGet(score, transform.position);
             Destroy(gameObject);
             StarGetSound.PlayWithPitchRange(0.7f, 1.25f);
         }
     }
 }