コード例 #1
0
ファイル: Player.cs プロジェクト: MullaN/multiplier
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name.Contains("Enemy"))
     {
         scoring.GameOver();
     }
 }
コード例 #2
0
ファイル: Spawner.cs プロジェクト: Arylos07/Tetris-Mobile
    public IEnumerator DestroyGroups(GameObject[] objects)
    {
        if (timer != null)
        {
            timer.runTimer = false;
        }

        foreach (GameObject obj in objects)
        {
            yield return(new WaitForSeconds(0.025f));

            Destroy(obj);
        }

        if (isGauntlet == false)
        {
            Scoring.GameOver();
        }
        else if (isGauntlet == true)
        {
            timer.runTimer = false;
            settings.ResetSpeed(reduce);
            Scoring.GauntletOver();
        }
    }
コード例 #3
0
    // Get new tetrimino
    private void NewTetrimino()
    {
        int bagIndex, index;

        if (upNext == null)
        {
            if (bag.Count == 0)
            {
                for (int i = 0; i < Tetrominos.Length; i++)
                {
                    bag.Add(i);
                }
            }

            bagIndex = (int)Random.Range(0, bag.Count);
            index    = bag[bagIndex];
            bag.RemoveAt(bagIndex);
            upNext       = Instantiate(Tetrominos[index], new Vector3(-10, 14, 0), Quaternion.identity);
            upNext.speed = levelNum + 1;
        }

        upNext.transform.position = new Vector3(5, 17, 0);
        upNext.Enable();
        if (!CheckPos(upNext.transform))
        {
            Destroy(upNext.transform.gameObject);
            gameOver = true;
            Scoring.GameOver();
        }

        if (bag.Count == 0)
        {
            for (int i = 0; i < Tetrominos.Length; i++)
            {
                bag.Add(i);
            }
        }

        bagIndex = (int)Random.Range(0, bag.Count);
        index    = bag[bagIndex];
        bag.RemoveAt(bagIndex);

        upNext       = Instantiate(Tetrominos[index], new Vector3(-10, 14, 0), Quaternion.identity);
        upNext.speed = levelNum + 1;
    }
コード例 #4
0
    private void OnCollisionEnter(Collision collision)
    {
        if (livesRemaining > 0)
        {
            if (collision.gameObject.tag.ToString() == "Basket")
            {
                launched = false;

                score.IncrementScore();

                rigid.velocity = new Vector3(0, 0, 0);
                rigid.gameObject.transform.localPosition = new Vector3(0f, 1.5f, 80f);

                NewPos();
                Launch();
            }

            if (collision.gameObject.tag.ToString() == "Platform" && livesRemaining > 1)
            {
                launched = false;

                livesRemaining--;
                lives.DecreaseLives();

                rigid.velocity = new Vector3(0, 0, 0);
                rigid.gameObject.transform.localPosition = new Vector3(0f, 1.5f, 80f);

                NewPos();
                Launch();
            }

            else if (collision.gameObject.tag.ToString() == "Platform" && livesRemaining <= 1)
            {
                livesRemaining--;
                lives.DecreaseLives();

                score.GameOver();
                Invoke("EndLevel", 4);
            }
        }
    }