예제 #1
0
 public void MatrUpdate()
 {
     for (int ix = 0; ix < fieldSize; ix++)
     {
         for (int iy = 0; iy < fieldSize; iy++)
         {
             ChipCore SelCore = (ChipCore)chipField[ix, iy].gameObject.GetComponent("ChipCore");
             SelCore.SetPosX(ix);
             SelCore.SetPosY(iy);
         }
     }
 }
예제 #2
0
 public void MatrCheckDown()
 {
     for (int ix = 0; ix < fieldSize; ix++)
     {
         for (int iy = 0; iy < fieldSize; iy++)
         {
             ChipCore SelCore = (ChipCore)chipField[ix, iy].gameObject.GetComponent("ChipCore");
             if (SelCore.GetCurType() == 0)
             {
                 SelCore.GetComponent <Renderer>().enabled = false;
                 ChipDown(ix, iy);
             }
         }
     }
 }
예제 #3
0
 public void NullCheck()
 {
     for (int ix = 0; ix < fieldSize; ix++)
     {
         for (int iy = 0; iy < fieldSize; iy++)
         {
             ChipCore ChCo = (ChipCore)chipField[ix, iy].gameObject.GetComponent <ChipCore>();
             if (ChCo.GetMFlag() == true)
             {
                 ChCo.SetType(0);
             }
         }
     }
     MatrUpdate();
 }
예제 #4
0
    public void CreatChip(int ix, int iy)
    {
        int rand = Random.Range(1, DibsSize);

        chipField[ix, iy] = (GameObject)Instantiate(dibs[rand], new  Vector3(ix, 0, iy), Quaternion.Euler(-90, 0, 0));
        ChipCore ChCo = chipField[ix, iy].gameObject.AddComponent <ChipCore>();

        chipField[ix, iy].GetComponent <Renderer>().material.SetColor("_Color", Color.white);
        if (UniCollider != null)
        {
            chipField[ix, iy].GetComponent <MeshCollider>().sharedMesh = UniCollider;
        }
        ChCo.SetPosX(ix);
        ChCo.SetPosY(iy);
        ChCo.Speed = ChSpeed;
        ChCo.SetType(rand);
    }
예제 #5
0
    public int VertTriMatch(int x, int y)
    {
        int vertmatch = 0;

        if (y > 0 && y < fieldSize - 1)
        {
            ChipCore ChCo   = (ChipCore)chipField[x, y - 1].gameObject.GetComponent <ChipCore>();
            ChipCore PrevCh = (ChipCore)chipField[x, y].gameObject.GetComponent <ChipCore>();
            ChipCore NextCh = (ChipCore)chipField[x, y + 1].gameObject.GetComponent <ChipCore>();
            if (PrevCh.GetCurType() == ChCo.GetCurType() && ChCo.GetCurType() == NextCh.GetCurType() && ChCo.GetCurType() != 0)
            {
                PrevCh.SetMFlag(true);
                ChCo.SetMFlag(true);
                NextCh.SetMFlag(true);
                TimerD     = timer + WaitTime;
                vertmatch += 1;
            }
            vertmatch += VertTriMatch(x, y + 1);
        }
        return(vertmatch);
    }
예제 #6
0
    public int GorTriMatch(int x, int y)
    {
        int gormatch = 0;

        if (x > 0 && x < fieldSize - 1)
        {
            ChipCore ChCo   = (ChipCore)chipField[x - 1, y].gameObject.GetComponent <ChipCore>();
            ChipCore PrevCh = (ChipCore)chipField[x, y].gameObject.GetComponent <ChipCore>();
            ChipCore NextCh = (ChipCore)chipField[x + 1, y].gameObject.GetComponent <ChipCore>();
            if (PrevCh.GetCurType() == ChCo.GetCurType() && ChCo.GetCurType() == NextCh.GetCurType() && ChCo.GetCurType() != 0)
            {
                PrevCh.SetMFlag(true);
                ChCo.SetMFlag(true);
                NextCh.SetMFlag(true);
                TimerD    = timer + WaitTime;
                gormatch += 1;
            }
            gormatch += GorTriMatch(x + 1, y);
        }
        return(gormatch);
    }
예제 #7
0
    public int AvaVertCheck(int inx, int iny)
    {
        int      AvMatchs = 0;
        ChipCore ChCo     = (ChipCore)chipField[inx, iny].gameObject.GetComponent <ChipCore>();

        if (iny + 1 < fieldSize)
        {
            ChipCore ChCo2 = (ChipCore)chipField[inx, iny + 1].gameObject.GetComponent <ChipCore>();
            if (ChCo.GetCurType() == ChCo2.GetCurType())
            {
                if (iny - 1 >= 0)
                {
                    if (inx - 1 >= 0)
                    {
                        ChipCore ChCoUpR = (ChipCore)chipField[inx - 1, iny - 1].gameObject.GetComponent <ChipCore>();
                        if (ChCo.GetCurType() == ChCoUpR.GetCurType())
                        {
                            AvMatchs++;
                        }
                    }
                    if (inx + 1 < fieldSize)
                    {
                        ChipCore ChCoDnR = (ChipCore)chipField[inx + 1, iny - 1].gameObject.GetComponent <ChipCore>();
                        if (ChCo.GetCurType() == ChCoDnR.GetCurType())
                        {
                            AvMatchs++;
                        }
                    }
                }
                if (iny - 2 >= 0)
                {
                    ChipCore ChCoAOR = (ChipCore)chipField[inx, iny - 2].gameObject.GetComponent <ChipCore>();
                    {
                        if (ChCo.GetCurType() == ChCoAOR.GetCurType())
                        {
                            AvMatchs++;
                        }
                    }
                }
                if (iny + 2 < fieldSize)
                {
                    if (inx - 1 >= 0)
                    {
                        ChipCore ChCoUpL = (ChipCore)chipField[inx - 1, iny + 2].gameObject.GetComponent <ChipCore>();
                        if (ChCoUpL.GetCurType() == ChCo.GetCurType())
                        {
                            AvMatchs++;
                        }
                    }
                    if (inx < fieldSize - 1)
                    {
                        ChipCore ChCoDnL = (ChipCore)chipField[inx + 1, iny + 2].gameObject.GetComponent <ChipCore>();
                        if (ChCo.GetCurType() == ChCoDnL.GetCurType())
                        {
                            AvMatchs++;
                        }
                    }
                }

                if (iny < fieldSize - 3)
                {
                    ChipCore ChCoAOL = (ChipCore)chipField[inx, iny + 3].gameObject.GetComponent <ChipCore>();
                    if (ChCoAOL.GetCurType() == ChCo.GetCurType())
                    {
                        AvMatchs++;
                    }
                }
            }
        }
        if ((inx >= 1 && inx < fieldSize - 1) && (iny >= 1 && iny < fieldSize - 1))
        {
            ChipCore Left  = (ChipCore)chipField[inx, iny + 1].gameObject.GetComponent <ChipCore>();
            ChipCore Rigth = (ChipCore)chipField[inx, iny - 1].gameObject.GetComponent <ChipCore>();
            ChipCore Up    = (ChipCore)chipField[inx - 1, iny].gameObject.GetComponent <ChipCore>();
            ChipCore Down  = (ChipCore)chipField[inx + 1, iny].gameObject.GetComponent <ChipCore>();
            if (Left.GetCurType() == Up.GetCurType() && Up.GetCurType() == Rigth.GetCurType())
            {
                AvMatchs++;
            }
            if (Left.GetCurType() == Down.GetCurType() && Down.GetCurType() == Rigth.GetCurType())
            {
                AvMatchs++;
            }
        }


        return(AvMatchs);
    }