Ejemplo n.º 1
0
    //幅優先探索 basePosition:始点座標 judgePosition:通行可能条件 dMOFunction:各座標に対する処理
    public void DetureMatrixOperate(Vector2Int basePosition, JudgePosition judgePosition, DMOFunction dMOFunction)
    {
        int[,] searchMatrix = new int[mapRange.x, mapRange.y];
        Queue <SearchAgent> searchAgent = new Queue <SearchAgent>();

        searchAgent.Enqueue(new SearchAgent()
        {
            position = basePosition, distance = 1
        });
        searchMatrix[basePosition.x, basePosition.y] = 1;
        while (0 < searchAgent.Count)
        {
            SearchAgent current = searchAgent.Dequeue();
            NextPoint(current.position, (x, y) =>
            {
                if (searchMatrix[x, y] == 0 && judgePosition(new Vector2Int(x, y)) == true)
                {
                    searchAgent.Enqueue(new SearchAgent()
                    {
                        position = new Vector2Int(x, y), distance = current.distance + 1
                    });
                    searchMatrix[x, y] = current.distance + 1;
                }
            });
        }
        MatrixOperate((xcount, ycount) =>
        {
            dMOFunction(xcount, ycount, searchMatrix[xcount, ycount]);
        });
    }
Ejemplo n.º 2
0
 //2座標間の折れ線迂回距離を返す
 public int PolygonalDistance(Vector2Int basePos, Vector2Int destination, JudgePosition passable)
 {
     int[,] matrix = new int[mapRange.x, mapRange.y];
     DetureMatrixOperate(basePos, passable, (xcount, ycount, value) =>
     {
         matrix[xcount, ycount] = value;
     });
     if (matrix[destination.x, destination.y] == 0)
     {
         Debug.Log("第二引数の座標は通行不可、もしくはたどり着けない座標です。(InfluenceMap)");
     }
     return(matrix[destination.x, destination.y] - 1);
 }
Ejemplo n.º 3
0
        public static ObservableCollection <JudgePosition> GetJudgePositions(int matchID)
        {
            if (!CheckDBConnection())
            {
                return(null);
            }
            SqlDataReader sr = null;
            ObservableCollection <JudgePosition> positions = new ObservableCollection <JudgePosition>();

            try
            {
                SqlCommand sqlCmd = DVCommon.g_DataBaseCon.CreateCommand();
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.CommandText = "Proc_SY_GetJudgePositions";
                sqlCmd.Parameters.Add("@MatchID", SqlDbType.Int).Value = matchID;
                sqlCmd.Parameters.Add("@LanguageCode", SqlDbType.NVarChar, 10).Value = "ENG";
                sr = sqlCmd.ExecuteReader();

                while (sr.Read())
                {
                    JudgePosition pos = new JudgePosition();
                    pos.Position   = (string)GetNoNullValue(sr, "F_PositionShortName", "");
                    pos.PositionID = (int)GetNoNullValue(sr, "F_PositionID", "");
                    positions.Add(pos);
                }
                return(positions);
            }
            catch (System.Exception ex)
            {
                AthleticsCommon.LastErrorMsg = "GetJudgePositions():" + ex.Message;
                return(null);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }