Ejemplo n.º 1
0
    private void CalScore(TilesType theTilesType, double AvgGapSD, double AvgLineAngleSD, double AvgResidual, ref double scoreOfGap, ref double scoreOfParallel, ref double scoreOfStraight, ref double scoreOfAngle)
    {
#if false
        VarianceThreshold VTH;
        if (theTilesType == TilesType.Square)
        {
            VTH = SquareTileVH;
        }
        else
        {
            VTH = RectangleTileVH;
        }
        scoreOfGap      = ScoreOfVariance(AvgGapSD, VTH.Gap);
        scoreOfParallel = ScoreOfVariance(AvgLineAngleSD, VTH.Parallel);
        scoreOfStraight = ScoreOfVariance(AvgResidual, VTH.Straight);
        scoreOfAngle    = ScoreOfVariance(AngleSD, VTH.Angle);
#endif
        ScoreSlope ss;
        if (theTilesType == TilesType.Square)
        {
            ss = SquareTileSS;
        }
        else
        {
            ss = RectangleTileSS;
        }
        scoreOfGap      = ScoreOfVariance(AvgGapSD, ss.Gap, true);
        scoreOfParallel = ScoreOfVariance(AvgLineAngleSD, ss.Parallel, true);
        scoreOfStraight = ScoreOfVariance(AvgResidual, ss.Straight, true);
        scoreOfAngle    = ScoreOfVariance(AngleSD, ss.Angle, true);
    }
Ejemplo n.º 2
0
        private Grid Add(int row, int column)
        {
            TilesType type = TilesType.White;

            if (row <= offset)
            {
                type = TilesType.Finish;
            }
            else if (row >= total)
            {
                type = TilesType.Start;
            }
            else
            {
                type = (_selected[row] == column) ?
                       TilesType.Black : TilesType.White;
            }
            Grid grid = new Grid()
            {
                Background      = GetBrush(type),
                Tag             = new TilesItem(row, type),
                BorderThickness = new Thickness(1),
                BorderBrush     = new SolidColorBrush(Colors.WhiteSmoke)
            };

            Grid.SetRow(grid, row);
            Grid.SetColumn(grid, column);
            grid.Tapped += Grid_Tapped;
            return(grid);
        }
Ejemplo n.º 3
0
    //Block generation on stage.
    public static Tile[,] GenerateLevel(int index)
    {
        int[,] lvl    = Init(index);
        Tile[,] tiles = new Tile[lvl.GetLength(1), lvl.GetLength(0)];
        int        layer = 100;
        GameObject obj;
        GameObject block;
        TilesType  type = TilesType.None;
        Tile       tile;

        for (int y = lvl.GetLength(0) - 1; y >= 0; y--)
        {
            for (int x = 0; x < lvl.GetLength(1); x++)
            {
                type = (TilesType)lvl[y, x];

                if (type != TilesType.None)
                {
                    obj = TilesResources.tileObjects[type];
                    //Creating a block on stage.
                    block         = Instantiate(obj, new Vector2(InitialPosition.x + x * VectorBias.x, InitialPosition.y + (lvl.GetLength(0) - 1 - y) * VectorBias.y), Quaternion.identity);
                    block.name    = "Block" + type.ToString() + (x + 1) + (lvl.GetLength(0) - y);
                    tile          = block.GetComponent <Tile>();
                    tile.renderer = block.GetComponent <Renderer>();
                    tile.animator = block.GetComponent <Animator>();
                    tile.type     = type;
                    tile.renderer.sortingOrder = layer;
                    tile.animator.Play(block.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash, 0, Random.Range(0f, 1f));
                    tiles[x, lvl.GetLength(0) - 1 - y] = block.GetComponent <Tile>();
                }
                layer++;
            }
        }
        return(tiles);
    }
Ejemplo n.º 4
0
 /// <summary>計算分數</summary>
 public string ScoringByVariance(TilesType theTilesType, bool isTop = true)
 {
     Record = ScoreRecordByVariance(theTilesType, isTop);
     //output += "\t林的分數(修):\t" + scoreOfLinM.ToString("00.0");
     //output += "\t角Y方向離差:\t" + CornerResidualY.ToString();
     //output += "\t角X方向離差:\t" + CornerResidualX.ToString();
     return(Record.ToScoreLine());
 }
Ejemplo n.º 5
0
    public void TileExplode()
    {
        if (m_currentTilesType == TilesScript.TilesType.WALL)/////////// ça doit être dans le tileScripte
        {
            m_currentTilesType = TilesScript.TilesType.NORMAL;
            walkableTile       = true;
            SwitchSprite();
        }
        destroyTile = false;

        if (_currentPlayerOnTile)
        {
            _currentPlayerOnTile.Die();
        }
    }
Ejemplo n.º 6
0
    public SampleFile(MCvBox2D[,] theTiles, TilesType theTilesType)
    {
        TilesType = theTilesType;
        int Length0 = theTiles.GetLength(0);
        int Length1 = theTiles.GetLength(1);

        boxs = new myBox[Length0, Length1];

        for (int i = 0; i < Length0; i++)
        {
            for (int j = 0; j < Length1; j++)
            {
                boxs[i, j] = new myBox(theTiles[i, j]);
            }
        }
    }
Ejemplo n.º 7
0
    //随机生成关卡(测试用)
    public void RandomLevel()
    {
        DestroyMap();

        int[,] map = new int[Level.map_1.GetLength(0), Level.map_1.GetLength(1)];
        for (int x = 0; x < map.GetLength(0); x++)
        {
            for (int y = 0; y < map.GetLength(1); y++)
            {
                int i = Random.Range(0, TilesType.GetNames(typeof(TilesType)).Length *3);
                if (i > TilesType.GetNames(typeof(TilesType)).Length - 1 && i != 11 && i != 12)
                {
                    i = 0;
                }
                map[x, y] = i;
            }
        }
        BoardSetup(map);
    }
Ejemplo n.º 8
0
    /// <summary>由目前資料計算分數,並輸出分數物件</summary>
    /// <param name="theTilesType"></param>
    /// <returns></returns>
    private ScoreRecord ScoreRecordByVariance(TilesType theTilesType, bool isTop = true)
    {
        ScoreRecord record = new ScoreRecord();

        //處理檔名
        string[] FileInfo = Path.GetFileName(fileName).Split('_');

        if (FileInfo.Length == 3)
        {
            record.Subject      = FileInfo[0];
            record.SubjectState = FileInfo[1];
            record.RegionId     = Convert.ToInt32(FileInfo[2]);
            record.TopDown      = isTop ? "上" : "下";
        }

        ScoreSlope selectSS = theTilesType == TilesType.Square ? SquareTileSS : RectangleTileSS;

        record.GI  = (GapHSD + GapVSD) / 2;
        record.LPI = (RowAngleSD + ColumnAngleSD) / 2;
        record.LSI = (RowResidualAvg + ColumnResidualAvg) / 2;
        record.AI  = AngleSD;
        double scoreOfGap      = 0;
        double scoreOfParallel = 0;
        double scoreOfStraight = 0;
        double scoreOfAngle    = 0;
        double LinResidualAvg  = (ResidualAvgX3m + ResidualAvgY3m) / 2;
        double scoreOfLin      = 100 - 20 * LinResidualAvg;

        record.FangLingIndex = LinResidualAvg;
        double scoreOfLinM = 100 + selectSS.FangAndLing * ((CornerResidualX + CornerResidualY) / 2);

        CalScore(theTilesType, record.GI, record.LPI, record.LSI
                 , ref scoreOfGap, ref scoreOfParallel, ref scoreOfStraight, ref scoreOfAngle);
        record.GS  = scoreOfGap;
        record.LPS = scoreOfParallel;
        record.LSS = scoreOfStraight;
        record.AS  = scoreOfAngle;
        return(record);
    }
Ejemplo n.º 9
0
    /// <summary>從磁磚組(MCvBox2D[,])獲得該磁磚組的各行列之趨勢線</summary>
    /// <param name="theTilesType">瓷磚類型</param>
    /// <param name="Tiles">磁磚組</param>
    /// <returns>各行列之趨勢線</returns>
    public static TrendLine TilesLineAngle(TilesType theTilesType, MCvBox2D[,] Tiles)
    {
        switch (theTilesType)
        {
        case TilesType.Square:
            TrendLine SquareTrendLine
                = new TrendLine(SquareGrids.COLUMN_COUNT, SquareGrids.ROW_COUNT);
            #region 水平趨勢線
            for (int rowNum = 0; rowNum < SquareGrids.ROW_COUNT; rowNum++)
            {
                double[] Xdata = new double[SquareGrids.COLUMN_COUNT];
                double[] Ydata = new double[SquareGrids.COLUMN_COUNT];
                for (int columnNum = 0; columnNum < SquareGrids.COLUMN_COUNT; columnNum++)
                {
                    Xdata[columnNum] = Tiles[columnNum, rowNum].center.X;
                    Ydata[columnNum] = Tiles[columnNum, rowNum].center.Y * -1;
                }
                myStatistics.TrendLine TrendLine = new myStatistics.TrendLine(Xdata, Ydata);
                if (TrendLine.Angle() < -45)
                {
                    SquareTrendLine.Horizontal[rowNum] = TrendLine.Angle() + 180f;
                }
                else
                {
                    SquareTrendLine.Horizontal[rowNum] = TrendLine.Angle();
                }
            }
            #endregion
            #region 垂直趨勢線
            for (int columnNum = 0; columnNum < SquareGrids.COLUMN_COUNT; columnNum++)
            {
                double[] Xdata = new double[SquareGrids.ROW_COUNT];
                double[] Ydata = new double[SquareGrids.ROW_COUNT];
                for (int rowNum = 0; rowNum < SquareGrids.ROW_COUNT; rowNum++)
                {
                    Xdata[rowNum] = Tiles[columnNum, rowNum].center.X;
                    Ydata[rowNum] = Tiles[columnNum, rowNum].center.Y * -1;
                }
                myStatistics.TrendLine TrendLine = new myStatistics.TrendLine(Ydata, Xdata);
                if (TrendLine.Angle() < -45)
                {
                    SquareTrendLine.Vertical[columnNum] = myTool.CorrectingAngle_YXtoXY(TrendLine.Angle()) + 180f;
                }
                else
                {
                    SquareTrendLine.Vertical[columnNum] = myTool.CorrectingAngle_YXtoXY(TrendLine.Angle());
                }
            }
            #endregion



            return(SquareTrendLine);

        case TilesType.Rectangle:
            TrendLine RectangleTrendLine
                = new TrendLine(RectangleGrids.columnCount, RectangleGrids.ROW_COUNT);
            #region 水平趨勢線
            for (int rowNum = 0; rowNum < RectangleGrids.ROW_COUNT; rowNum++)
            {
                double[] Xdata = new double[RectangleGrids.columnCount];
                double[] Ydata = new double[RectangleGrids.columnCount];
                for (int columnNum = 0; columnNum < RectangleGrids.columnCount; columnNum++)
                {
                    Xdata[columnNum] = Tiles[columnNum, rowNum].center.X;
                    Ydata[columnNum] = Tiles[columnNum, rowNum].center.Y * -1;
                }
                myStatistics.TrendLine TrendLine = new myStatistics.TrendLine(Xdata, Ydata);
                if (TrendLine.Angle() < -45)
                {
                    RectangleTrendLine.Horizontal[rowNum] = TrendLine.Angle() + 180f;
                }
                else
                {
                    RectangleTrendLine.Horizontal[rowNum] = TrendLine.Angle();
                }
            }
            #endregion
            #region 垂直趨勢線
            for (int columnNum = 0; columnNum < RectangleGrids.columnCount; columnNum++)
            {
                double[] Xdata = new double[RectangleGrids.ROW_COUNT];
                double[] Ydata = new double[RectangleGrids.ROW_COUNT];
                for (int rowNum = 0; rowNum < RectangleGrids.ROW_COUNT; rowNum++)
                {
                    Xdata[rowNum] = Tiles[columnNum, rowNum].center.X;
                    Ydata[rowNum] = Tiles[columnNum, rowNum].center.Y * -1;
                }
                myStatistics.TrendLine TrendLine = new myStatistics.TrendLine(Ydata, Xdata);
                if (TrendLine.Angle() < -45)
                {
                    RectangleTrendLine.Vertical[columnNum] = myTool.CorrectingAngle_YXtoXY(TrendLine.Angle()) + 180f;
                }
                else
                {
                    RectangleTrendLine.Vertical[columnNum] = myTool.CorrectingAngle_YXtoXY(TrendLine.Angle());
                }
            }
            #endregion

            return(RectangleTrendLine);

        default:
            return(new TrendLine(0, 0));
        }
    }
Ejemplo n.º 10
0
 private SolidColorBrush GetBrush(TilesType type)
 {
     return(new SolidColorBrush(colours[(int)type]));
 }
Ejemplo n.º 11
0
 public TilesItem(int row, TilesType type)
 {
     Row  = row;
     Type = type;
 }