Exemplo n.º 1
0
 /// <summary> 巡回ステート時の処理 </summary>
 private IEnumerator RandomWalk()
 {
     while (!FindPlayer())
     {
         // 距離マップ
         int[,] distanceMap = new int[mapRange.x, mapRange.y];
         // 目的地ランダマイズ
         Vector2Int destination = RandomDestination();
         //Debug.Log("random destination"+destination);
         // 移動マップ記録
         _influenceMap.DetureMatrixOperate(destination, j => _passableMap[j.x, j.y],
                                           (xCount, yCount, distance) => { distanceMap[xCount, yCount] = distance; });
         // 移動
         int        step    = distanceMap[EnemyPosition.x, EnemyPosition.y];
         Vector2Int stepPos = EnemyPosition;
         while (EnemyPosition != destination && !FindPlayer())
         {
             _influenceMap.NextPoint(EnemyPosition, (x, y) =>
             {
                 if (step > distanceMap[x, y] && _passableMap[x, y])
                 {
                     step    = distanceMap[x, y];
                     stepPos = new Vector2Int(x, y);
                 }
             });
             yield return(Move(stepPos - EnemyPosition, walkTime));
         }
     }
 }
Exemplo n.º 2
0
 //敵の影響マップ生成関数
 private float[,] EnemyMapping()
 {
     float[,] result = new float[mapRange.x, mapRange.y];
     influenceMap.DetureMatrixOperate(enemyPos, (judge) =>
     {
         return(passableMap[judge.x, judge.y] == true);
     },
                                      (xcount, ycount, distance) =>
     {
         if (distance > 1)
         {
             result[xcount, ycount] = 1.0f - (float)1 / (distance - 1);
         }
     });
     return(result);
 }