コード例 #1
0
    void AddToGrid(TerisBlock teris)
    {
        if (teris.isBomb)
        {
            BombEffect(teris);
        }
        else
        {
            foreach (Transform children in teris.transform)
            {
                int roundedX = Mathf.RoundToInt(children.transform.position.x);
                int roundedY = Mathf.RoundToInt(children.transform.position.y);
                grid[roundedX, roundedY] = children;
                if (CheckForGameover(roundedY))
                {
                    break;
                }
            }
            switch (teris.ID)
            {
            case 1:
                falled1 = true;
                break;

            case 2:
                falled2 = true;
                break;
            }
            teris.enabled = false;
        }

        CheckForLines();
        CheckTwoTerisFalled();
    }
コード例 #2
0
    IEnumerator StartNewRound()
    {
        waitingForNextRound = true;
        yield return(new WaitForSeconds(0.01f));

        teris1 = null;
        teris2 = null;
        NewTetromino();
    }
コード例 #3
0
 void AddToGridNew2(TerisBlock teris1, TerisBlock teris2)
 {
     teris1.transform.SetParent(allTiles);
     teris2.transform.SetParent(allTiles);
     falled1        = true;
     falled2        = true;
     teris1.enabled = false;
     teris2.enabled = false;
     CheckForLines();
     CheckTwoTerisFalled();
 }
コード例 #4
0
ファイル: TerisBlock.cs プロジェクト: RongHua778/Teris-and-2
 public void CheckClash(TerisBlock another)
 {
     foreach (Vector3 pos in currentPoints)
     {
         if (another.currentPoints.Contains(pos))
         {
             another.MoveBack();
             break;
         }
     }
 }
コード例 #5
0
    void AddToGrid(TerisBlock teris1, TerisBlock teris2)
    {
        teris1.transform.SetParent(alltiles);
        teris2.transform.SetParent(alltiles);
        if (teris1.isBomb)
        {
            BombEffect(teris1);
        }
        else
        {
            foreach (Transform children in teris1.transform)
            {
                int roundedX = Mathf.RoundToInt(children.transform.position.x);
                int roundedY = Mathf.RoundToInt(children.transform.position.y);
                grid[roundedX, roundedY] = children;
                if (CheckForGameover(roundedY))
                {
                    break;
                }
            }
            teris1.enabled = false;
        }
        if (teris2.isBomb)
        {
            BombEffect(teris2);
        }
        else
        {
            foreach (Transform children in teris2.transform)
            {
                int roundedX = Mathf.RoundToInt(children.transform.position.x);
                int roundedY = Mathf.RoundToInt(children.transform.position.y);
                grid[roundedX, roundedY] = children;
                if (CheckForGameover(roundedY))
                {
                    break;
                }
            }
            teris2.enabled = false;
        }

        falled1 = true;
        falled2 = true;

        CheckForLines();
        CheckTwoTerisFalled();
    }
コード例 #6
0
    void AddToGridNew(TerisBlock teris)
    {
        teris.transform.SetParent(allTiles);
        switch (teris.ID)
        {
        case 1:
            falled1 = true;
            break;

        case 2:
            falled2 = true;
            break;
        }
        teris.enabled = false;
        CheckForLines();
        CheckTwoTerisFalled();
    }
コード例 #7
0
    void BombEffect(TerisBlock teris)
    {
        teris.isBomb  = false;
        teris.enabled = false;
        GameObject effect = Instantiate(Resources.Load <GameObject>("Effect/Bomb_Anim_Effect"), teris.transform.position, Quaternion.identity);

        Sound.Instance.PlayEffect("Explosion");
        StartCoroutine(camShake.Shake(.15f, .25f));


        Transform children = teris.transform.GetChild(0);
        int       roundedX = Mathf.RoundToInt(children.transform.position.x);
        int       roundedY = Mathf.RoundToInt(children.transform.position.y);

        for (int x = roundedX - 2; x < roundedX + 3; x++)
        {
            for (int y = roundedY - 2; y < roundedY + 3; y++)
            {
                int newx = Mathf.Clamp(x, 0, 9);
                int newy = Mathf.Clamp(y, 0, 19);
                if (grid[newx, newy] != null)
                {
                    Destroy(grid[newx, newy].gameObject);
                    grid[newx, newy] = null;
                }
            }
        }

        switch (teris.ID)
        {
        case 1:
            falled1 = true;
            break;

        case 2:
            falled2 = true;
            break;
        }

        Destroy(effect, 0.55f);
        teris.gameObject.SetActive(false);
    }
コード例 #8
0
    public void NewTetromino()
    {
        if (Game.Instance.gameOver)
        {
            return;
        }
        falled1 = false;
        falled2 = false;

        GameObject go1 = Instantiate(Resources.Load <GameObject>(next1.prefabPath), spawnPoint1.position, Quaternion.identity);

        teris1    = go1.GetComponent <TerisBlock>();
        teris1.ID = 1;
        GameObject go2 = Instantiate(Resources.Load <GameObject>(next2.prefabPath), spawnPoint2.position, Quaternion.identity);

        teris2              = go2.GetComponent <TerisBlock>();
        teris2.ID           = 2;
        waitingForNextRound = false;

        RandomNextTeris();
    }
コード例 #9
0
ファイル: TerisBlock.cs プロジェクト: RongHua778/Teris-and-2
 public bool CheckRotClash(TerisBlock another, bool isBlock)
 {
     foreach (Vector3 pos in currentPoints)
     {
         if (another.currentPoints.Contains(pos))
         {
             if (isBlock)
             {
                 another.RotBack();
                 return(false);
             }
             else
             {
                 RotBack();
                 another.RotBack();
                 return(false);
             }
         }
     }
     return(true);
 }
コード例 #10
0
    void BombEffect(TerisBlock teris)
    {
        if (teris.transform.GetChild(0).GetComponent <Animator>() != null)
        {
            teris.transform.GetChild(0).GetComponent <Animator>().SetTrigger("Dispear");
        }
        teris.enabled = false;
        GameObject effect   = Instantiate(Resources.Load <GameObject>("Effect/BombEffect"), teris.transform.position, Quaternion.identity);
        Transform  children = teris.transform.GetChild(0);
        int        roundedX = Mathf.RoundToInt(children.transform.position.x);
        int        roundedY = Mathf.RoundToInt(children.transform.position.y);

        for (int x = roundedX - 2; x < roundedX + 3; x++)
        {
            for (int y = roundedY - 2; y < roundedY + 3; y++)
            {
                int newx = Mathf.Clamp(x, 0, 9);
                int newy = Mathf.Clamp(y, 0, 20);
                if (grid[newx, newy] != null)
                {
                    Destroy(grid[newx, newy].gameObject);
                    grid[newx, newy] = null;
                }
            }
        }

        switch (teris.ID)
        {
        case 1:
            falled1 = true;
            break;

        case 2:
            falled2 = true;
            break;
        }

        Destroy(effect, 2f);
        Destroy(teris.gameObject, 0.5f);
    }
コード例 #11
0
ファイル: Command.cs プロジェクト: RongHua778/Teris-and-2
 public override void execute(TerisBlock teris1, TerisBlock teris2)
 {
 }
コード例 #12
0
ファイル: Command.cs プロジェクト: RongHua778/Teris-and-2
 public abstract void execute(TerisBlock teris1, TerisBlock teris2);