//単純な2重for文で2次元配列を操作する public void MatrixOperate(MOFunction mOFunction) { for (int x = 0; x < mapRange.x; x++) { for (int y = 0; y < mapRange.y; y++) { mOFunction(x, y); } } }
//隣の4座標を操作 public void NextPoint(Vector2Int basePos, MOFunction mOFunction) { for (int ang = 0; ang < 4; ang++) { Vector2Int judgePos = new Vector2Int(basePos.x + (int)Mathf.Cos(ang * Mathf.PI / 2), basePos.y + (int)Mathf.Sin(ang * Mathf.PI / 2)); if (WithinMapRange(judgePos) == true) { mOFunction(judgePos.x, judgePos.y); } } }