예제 #1
0
    public bool RotateCCW(Field field, out SearchNode sn)
    {
        bool   ok            = false;
        Mino   tmp           = mino.Clone();
        int    size          = tmp.GetSize();
        int    newRotationId = (tmp.GetRotationId() + 3) % 4;
        string k             = "z";


        if (size == 3)
        {
            if (field.IsValid(tmp, newRotationId, tmp.GetPosition()))//如果可以直接转进去
            {
                tmp.CCWRotate();
                ok = true;
            }
            else//如果不能就做踢墙检定
            {
                Vector2Int o = Game.WallKickOffset(field, tmp, tmp.GetRotationId(), newRotationId, tmp.GetPosition());
                if (o != new Vector2Int(0, 0))
                {
                    tmp.CCWRotate();
                    tmp.Move(o);
                    k  = "Z";
                    ok = true;
                }
                else
                {
                    ok = false;
                }
            }
        }
        else if (size == 5)
        {
            Vector2Int o = Game.WallKickOffset_I(field, tmp, tmp.GetRotationId(), newRotationId, tmp.GetPosition(), out bool iSpin);
            if (o != new Vector2Int(0, 0))
            {
                tmp.CCWRotate();
                tmp.Move(o);
                if (iSpin)
                {
                    k = "Z";
                }
                ok = true;
            }
            else
            {
                ok = false;
            }
        }
        sn = new SearchNode(tmp, op + k);
        return(ok);
    }
예제 #2
0
파일: Game.cs 프로젝트: ks233/KS-Mino
    List <Vector2Int> GetAllCoordinates()//mino四个格子的坐标
    {
        List <Vector2Int> l = new List <Vector2Int>();
        int size            = activeMino.GetSize();

        if (size == 3)
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    if (activeMino.array[j, i] == 1)
                    {
                        l.Add(new Vector2Int(i - 1 + activeMino.GetPosition().x, j - 1 + activeMino.GetPosition().y));
                    }
                }
            }
        }
        else if (size == 5)
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    if (activeMino.array[j, i] == 1)
                    {
                        l.Add(new Vector2Int(i - 2 + activeMino.GetPosition().x, j - 2 + activeMino.GetPosition().y));
                    }
                }
            }
        }

        else if (size == 2)
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    l.Add(new Vector2Int(i + activeMino.GetPosition().x, j + activeMino.GetPosition().y));
                }
            }
        }
        return(l);
    }
예제 #3
0
파일: Game.cs 프로젝트: ks233/KS-Mino
 public void NewMino(int minoId)
 {
     if (minoId != 0)
     {
         activeMino = new Mino(minoId)
         {
             position = new Vector2Int(4, 20)
         };
         if (!field.IsValid(activeMino, activeMino.GetPosition()))
         {
             GameOver();
         }
     }
     else
     {
         GameOver();
     }
 }
예제 #4
0
    private void UpdateActiveMinoDisplay()
    {
        DestroyAllChild(ActiveMinoParent);
        Mino tmpMino = game.GetActiveMino();

        //方块
        List <Vector2Int> l = Field.GetAllCoordinates(game.activeMino);
        int ghostDist       = tmpMino.GetPosition().y - game.GetGhostY();

        foreach (Vector2Int v in l)
        {
            DisplayUtils.InstChild(MinoTiles[tmpMino.GetIdInt() - 1], new Vector3(v.x, v.y, 0), ActiveMinoParent);
            if (game.Playing())
            {
                DisplayUtils.InstChild(MinoTiles[tmpMino.GetIdInt() - 1], new Vector3(v.x, v.y - ghostDist, 0), ActiveMinoParent, 1, 0.5f);
            }
        }
    }