public void InitializeDungeon() { map = new BlockType[MapSize, MapSize]; for (int i = 0; i < MapSize; i++) { for (int j = 0; j < MapSize; j++) { map[i, j] = BlockType.OpenSpace; } } //Creates Boundries for the map for (int x = 0; x < MapSize; x++) { map[x, MapSize - 1] = BlockType.Wall; } for (int x = 0; x < MapSize; x++) { map[x, 0] = BlockType.Wall; } for (int z = 0; z < MapSize; z++) { map[MapSize - 1, z] = BlockType.Wall; } for (int z = 0; z < MapSize; z++) { map[0, z] = BlockType.Wall; } }
/* * Information in mapData stored differently! Stored by columns, not rows. * * [2 5] * [1 4] * [0 3] */ void ReadMapDataFromTexture(int level) { Texture2D mapDataTex = Resources.Load <Texture2D>(MapDataPath + level); Width = mapDataTex.width; Height = mapDataTex.height; mapData = new BlockType[Width, Height]; Color pixelColor; for (int i = 0; i < Width; ++i) { for (int j = 0; j < Height; ++j) { pixelColor = mapDataTex.GetPixel(i, j); bool isBlackButNothingAbove = mapDataTex.GetPixel(i, j) == Color.black && mapDataTex.GetPixel(i, j + 1) == Color.white; bool topBlock = j == Height - 1; if (isBlackButNothingAbove && !topBlock) { pixelColor = Color.green; } mapData[i, j] = GetBlockTypeByColor(pixelColor); } } }
public static GraphicsBlockType GetGraphicsBlockTile(BlockType[,] tileMap, int x, int y, BlockType type) { switch (type) { case BlockType.EMPTY: return(GraphicsBlockType.EMPTY); case BlockType.ROCK: var neighbors = new BitArray(4); //RIGHT, UP, LEFT, DOWN neighbors[0] = tileMap[x + 1, y] == type; neighbors[1] = tileMap[x, y + 1] == type; neighbors[2] = tileMap[x - 1, y] == type; neighbors[3] = tileMap[x, y - 1] == type; var intArray = new int[1]; neighbors.CopyTo(intArray, 0); return((GraphicsBlockType)(1 + intArray[0])); case BlockType.IMPASSABLE: return(GraphicsBlockType.IMPASSABLE); case BlockType.CRYSTAL: return(GraphicsBlockType.CRYSTAL); default: return(GraphicsBlockType.EMPTY); } }
private void Tick(object sender, EventArgs e) { User32.GetCursorPos(out var p); this.Text = $"({p.X}, {p.Y})"; using (var screenshot = this.tracker.GetScreenshot()) { var grid = GridUtil.GetGridFromScreeshot(screenshot, this.CurrentGameMode); var blocks = Analizer.AnalizeGridImage(this.templates, grid); this.lastGrid = blocks; (var output, var overlay) = GenerateOutput(blocks); this.pcGrid.Image = grid; this.pcOutput.Image = output; if (this.overlayForm != null) { this.overlayForm.SetImage(overlay); var offset = GridLocator.LocateGrid(this.CurrentGameMode); var rect = this.tracker.GetWindowRect(); this.overlayForm.Location = new Point(rect.Left + offset.X, rect.Top + offset.Y); } } }
public void Initialized() { renderers = new SpriteRenderer[MapManager.Instance.mapAreaSize.x, MapManager.Instance.mapAreaSize.y]; mapblock = new BlockType[MapManager.Instance.mapAreaSize.x, MapManager.Instance.mapAreaSize.y]; ForeachMapArea(renderers, CreatSpriteObject); //StartCoroutine(CreatRenderers()); }
//public Tile[,] _tileMap; public MapInfo(int size, int chunkSize) { this.size = size; this.chunkSize = chunkSize; //_tileMap = new Tile[size, size]; groundMap = new GroundType[size, size]; blockMap = new BlockType[size, size]; }
public Level(int width, int height) { Width = width; Height = height; WidthInPixels = width * BlockSize; HeightInPixels = height * BlockSize; Cells = new BlockType[width, height]; }
public ZoneContent(ZoneLayout zone, ZoneRatio[,] influences, float[,] heightMap, Vector3[,] normalMap, BlockType[,] blocks, Vector3[] objects) { Zone = zone; Influences = influences; HeightMap = heightMap; NormalMap = normalMap; Blocks = blocks; Objects = objects; }
IEnumerator InitMapComponent() { //CreatMapBlock(); yield return(new WaitUntil(mapGenerater.GenerateState)); mapblocks = mapGenerater.GetMap(); CreatMapArea(); SetMapAreaPos(); yield break; }
public ClimatMap(ref HeightMap _height, ref HeatMap _heat, ref MoistureMap _moisture, int _size, int _chunksize) { Height = _height; Heat = _heat; Moisture = _moisture; size = _size; chunksize = _chunksize; Map = new BlockType[size, size]; NoneMap(); }
private void GenerateMap() { map = new BlockType[width, height]; map = RandomFillMapBlock(map); for (int i = 0; i < count; i++) { ObscureMapBlock(map); } ansyIsOK = true; }
private BlockType[,] RandomFillMapBlock(BlockType[,] map) { for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { map[i, j] = RandomBlock(); } } return(map); }
public Level(TileMap[] layers, double[] parallaxes, int width, int height, BlockType[,] collideMap) { Objs = new HashSet <IGameObj>(); Layers = layers; Parallax = parallaxes; if (layers.Length != parallaxes.Length) { throw new ArgumentException("Number of layers and parallax offsets must be the same!"); } Width = width; Height = height; CollideMap = collideMap; }
private void CreateGridData(int x, int y) { if (x <= 0 || y <= 0) { Console.WriteLine("Invalid Size"); Environment.Exit(1); } x = Math.Abs(x); y = Math.Abs(y); this.GridData = new BlockType[x, y]; }
public BlockType[,] GenerateMap(int width, int height, int count) { this.width = width; this.height = height; Debug.Log(width + "||" + height); map = new BlockType[width, height]; map = RandomFillMapBlock(map); for (int i = 0; i < count; i++) { ObscureMapBlock(map); } return(map); }
public void Generate(MapInfo mapInfo) { int xSize = mapInfo.mapSize.x; int ySize = mapInfo.mapSize.y; blockBoard = new BlockType[xSize, ySize]; string[] blockInfos; blockInfos = mapInfo.mapInfoStr.Split(','); // 적합성 체크 if (blockInfos.Length != xSize * ySize) { // 잘못된 맵 정보 Debug.Log("MapInfo Error -----------" + blockInfos.Length + "!=" + xSize * ySize); return; } GameObject bgBlockParent = GameObject.Find("BgBlocks"); // 블록 생성 for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { int blockNum = x + y * xSize; if (blockInfos[blockNum] == "0") { blockBoard[x, y] = BlockType.EMPTY; continue; } float yPosModifier = 0; if (x % 2 == 0) { yPosModifier = -0.5f; } bgBlocks.Add(Instantiate(bgBlockPrefap, new Vector3(x * 0.75f, -y + yPosModifier, 0), Quaternion.identity, bgBlockParent.transform)); HexaBlock block = Instantiate(hexaBlockPrefap, new Vector3(x * 0.75f, -y + yPosModifier, 0), Quaternion.identity, transform).GetComponent <HexaBlock>(); block.SetBlockStatus((BlockStatus)int.Parse(blockInfos[blockNum]), x, y); hexaBlocks.Add(block); blockBoard[x, y] = block.blockType; } } }
public Chunk(int blocksCount, int blockSize, Vector2i position) { BlockSize = blockSize; BlocksCount = blocksCount; Position = position; GridSize = BlocksCount + 1; HeightMap = new float[GridSize, GridSize]; Influence = new ZoneRatio[GridSize, GridSize]; BlockType = new BlockType[BlocksCount, BlocksCount]; NormalMap = new Vector3[BlocksCount, BlocksCount]; //Debug Test(); }
public Chunk(int blocksCount, int blockSize, Vector2i position) { BlockSize = blockSize; BlocksCount = blocksCount; Position = position; GridSize = BlocksCount + 1; HeightMap = new float[GridSize, GridSize]; //Influence = new ZoneRatio[GridSize, GridSize]; BlockType = new BlockType[BlocksCount, BlocksCount]; NormalMap = new Vector3[BlocksCount, BlocksCount]; //Debug Test(); }
private bool _isDecision; // 決定を押したか void Start() { _array = new Array(_cellnum); _blocks = new GameObject("_blocks"); _blocks.transform.parent = transform; _blockType = new BlockType[_cellnum.x, _cellnum.y]; CreateBlockTable(); _enemyParent = GameObject.Find("Enemy"); _player = GameObject.Find("player"); gameObject.AddComponent <SortingGroup>().sortingLayerName = "object"; InitBlocks(); SetInit(); }
public Level(BlockType[,] cells, int playerI, int playerJ) { _cells = cells ?? throw new ArgumentNullException(nameof(cells)); if (playerI < 0 || playerI >= _cells.GetLength(0)) { throw new ArgumentOutOfRangeException($"playerI: {playerI}"); } if (playerJ < 0 || playerJ >= _cells.GetLength(1)) { throw new ArgumentOutOfRangeException($"playerJ: {playerJ}"); } this.playerI = playerI; this.playerJ = playerJ; }
public static int[,] GetGraphicsBlockMap(BlockType[,] blockMap) { int width = blockMap.GetLength(0); int height = blockMap.GetLength(1); var gfxMap = new int[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { var blockType = blockMap[x, y]; gfxMap[x, y] = (int)GetGraphicsBlockTile(blockMap, x, y, blockType); } } return(gfxMap); }
private void start_btn_Click(object sender, EventArgs e) { if (Game_Run) { Game_Run = false; start_btn.Text = "start"; overlay_text = ""; BoardGrid = new BlockType[BoardWidth, BoardWidth]; Omokpan_Paint(null, null); } else { Game_Run = true; start_btn.Text = "stop"; overlay_text = ""; benefit_map = new double[BoardWidth, BoardWidth]; ai_benefit = new double[BoardWidth, BoardWidth]; user_benefit = new double[BoardWidth, BoardWidth]; BoardGrid = new BlockType[BoardWidth, BoardWidth]; Game_Winner = BlockType.Empty; if (cmb_first.Text == "User First") { Ai_stone = BlockType.WhiteStone; User_stone = BlockType.BlackStone; action_Place_stone(User_stone, BoardWidth / 2, BoardWidth / 2); Game_Turn = Ai_stone; timer1.Interval = 500; timer1.Enabled = true; } else { Ai_stone = BlockType.BlackStone; User_stone = BlockType.WhiteStone; action_Place_stone(Ai_stone, BoardWidth / 2, BoardWidth / 2); Game_Turn = User_stone; } } }
public State(int _width = 10, int _height = 10) { // State Size Width = _width; Height = _height; var halfWidth = (int)Width / 2; var halfHeight = (int)Height / 2; Tails = new List <Vector2>(); // Create StateBlock StateBlock = new BlockType[_width, _height]; _Direction = _DEFAULT_DIRECTION; // Set Snake and Food SetHead(new Vector2(halfWidth, halfHeight)); var availableFood = GetAvailableFood(); SetFood(availableFood[Random.Range(0, availableFood.Count)]); }
private BlockType[,] ObscureMapBlock(BlockType[,] map) { Debug.Log(System.DateTime.Now.ToString()); for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { int count = CheckNeighborwall(i, j); if (map[i, j] == BlockType.wall) { map[i, j] = count >= 4 ? BlockType.wall : BlockType.floor; } else { map[i, j] = count >= 5 ? BlockType.wall : BlockType.floor; } } } Debug.Log(System.DateTime.Now.ToString()); return(map); }
public Level Move(int dr, int dc) { int new_r = playerI + dr; int new_c = playerJ + dc; if (!GetBlock(new_r, new_c, out BlockType block)) { return(this); } if (block == BlockType.Empty || block == BlockType.Goal) { return(new Level(_cells, new_r, new_c)); } if (block == BlockType.Wall || block == BlockType.BlockFixed) { return(this); } if (block == BlockType.Block) { int block_r = new_r + dr; int block_c = new_c + dc; if (GetBlock(block_r, block_c, out BlockType cell)) { if (cell == BlockType.Empty || cell == BlockType.Goal) { BlockType[,] newCells = (BlockType[, ])_cells.Clone(); newCells[new_r, new_c] = BlockType.Empty; newCells[block_r, block_c] = cell == BlockType.Empty ? BlockType.Block : BlockType.BlockFixed; return(new Level(newCells, new_r, new_c)); } } } return(this); }
private bool _solved = false; // a flag indicating whether the problem is solved // Use this for initialization void Start() { // initializate the block information and gamObject arrays _mapInformation = new BlockType[NUMBER, NUMBER]; _blockArray = new GameObject[NUMBER, NUMBER]; // initializate the priority queue pqueue = new PriorityQueue <BlNode>(); initializeArray(); for (int i = 0; i < NUMBER; i++) // initialize that all the surrounding { _mapInformation[0, i] = BlockType.blockingblock; _mapInformation[NUMBER - 1, i] = BlockType.blockingblock; _mapInformation[i, 0] = BlockType.blockingblock; _mapInformation[i, NUMBER - 1] = BlockType.blockingblock; } // relocate the cached camera myCamera.transform.position = new Vector3(NUMBER / 2, NUMBER / 2, -10); myCamera.orthographicSize = NUMBER / 2; // show all blocks ShowBlocks(); // initialize the BlNode for the source and saved into the priority queue BlNode st = new BlNode(sour); st.stepScore = 0; st.distanceScore = st.GetDistanceScore(dest); pqueue.Enqueue(st); // start the solve coroutine (show details for each step) StartCoroutine(Solve()); }
protected override Vector3[] DecorateZone(ZoneRatio[,] zoneInfluences, float[,] zoneHeightmap, Vector3[,] zoneNormalmap, BlockType[,] zoneBlocks) { var trees = new List <Vector3>(); var bounds = _zone.Bounds; for (int i = 0; i < 100; i++) { var position = new Vector3(Random.Range(bounds.Min.X, bounds.Max.X), 0, Random.Range(bounds.Min.Z, bounds.Max.Z)); var blockPos = (Vector2i)position; var localBlockPos = blockPos - bounds.Min; //Check zone bounds if (bounds.Contains(blockPos) && !zoneInfluences[localBlockPos.X, localBlockPos.Z].IsEmpty && zoneInfluences[localBlockPos.X, localBlockPos.Z][ZoneType.Forest] > 0.5f) { //Check slopiness if (Vector3.Angle(Vector3.up, zoneNormalmap[localBlockPos.X, localBlockPos.Z]) < 20) { trees.Add(new Vector3(position.x, zoneHeightmap[localBlockPos.X, localBlockPos.Z], position.z)); } } } return(trees.ToArray()); }
private void CreateBlocks(JsonNode root) { width = root.Get<int>("width"); height = root.Get<int>("height"); Blocks = new BlockType[width,height]; var blocksData = root["layers"][0]["data"].GetIntArray(); for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) Blocks[x, y] = (BlockType)blocksData[x + y * width]; }
private (Bitmap output, Bitmap overlay) GenerateOutput(BlockType[,] grid) { var output = new Bitmap(C.TotalColunas * C.BlockWidth, C.TotalLinhas * C.BlockHeight); var overlay = new Bitmap(C.TotalColunas * C.BlockWidth, C.TotalLinhas * C.BlockHeight, PixelFormat.Format32bppArgb); using (var gOutput = Graphics.FromImage(output)) using (var gOverlay = Graphics.FromImage(overlay)) { gOverlay.FillRectangle(new SolidBrush(Color.FromArgb(0, 0, 0, 0)), new Rectangle(0, 0, C.GridWidth, C.GridHeight)); for (var c = 0; c < C.TotalColunas; c++) { for (var l = 0; l < C.TotalLinhas; l++) { var x = c * C.BlockHeight; var y = l * C.BlockWidth; if (grid[c, l] != BlockType.Desconhecido) { var color = ColorUtil.FromBlockType(grid[c, l]); gOutput.FillRectangle(new SolidBrush(color), new Rectangle(c * C.BlockWidth, l * C.BlockHeight, C.BlockWidth, C.BlockHeight)); //gOverlay.FillRectangle(new SolidBrush(color), new Rectangle(c * C.BlockWidth, l * C.BlockHeight, C.BlockWidth, C.BlockHeight)); } else { gOutput.DrawLine(new Pen(Color.Red, 3), x, y, x + C.BlockHeight, y + C.BlockWidth); gOutput.DrawLine(new Pen(Color.Red, 3), x + C.BlockHeight, y, x, y + C.BlockWidth); //gOverlay.DrawLine(new Pen(Color.Red, 3), x, y, x + C.BlockHeight, y + C.BlockWidth); //gOverlay.DrawLine(new Pen(Color.Red, 3), x + C.BlockHeight, y, x, y + C.BlockWidth); } gOutput.DrawRectangle(new Pen(Color.Black), new Rectangle(c * C.BlockWidth, l * C.BlockHeight, C.BlockWidth - 1, C.BlockHeight - 1)); //gOverlay.DrawRectangle(new Pen(Color.Black), new Rectangle(c * C.BlockWidth, l * C.BlockHeight, C.BlockWidth - 1, C.BlockHeight - 1)); // g.DrawString($"{c:D2}, {l:D2}", font, fontBrush, c * C.BlockWidth, l * C.BlockHeight); if (grid[c, l] != BlockType.Desconhecido) { var dir = Mover.RecomendedMove(grid, c, l); if (dir.HasValue) { var size = C.BlockHeight; var arrowWidth = 4; var arrowCapLength = 10; var arrowHeight = C.BlockHeight / 2; var pen = new Pen(Color.Black, arrowWidth); PointF arrowStart, arrowEnd, cap1End, cap2End; if (dir == Direction.Up) { arrowStart = new PointF(x + (size / 2) - (arrowWidth / 2), y + (size / 2) - (arrowHeight / 2)); arrowEnd = new PointF(arrowStart.X, arrowStart.Y + arrowHeight); cap1End = new PointF(arrowStart.X + arrowCapLength, arrowStart.Y + arrowCapLength); cap2End = new PointF(arrowStart.X - arrowCapLength, arrowStart.Y + arrowCapLength); } else if (dir == Direction.Down) { arrowEnd = new PointF(x + (size / 2) - (arrowWidth / 2), y + (size / 2) - (arrowHeight / 2)); arrowStart = new PointF(arrowEnd.X, arrowEnd.Y + arrowHeight); cap1End = new PointF(arrowStart.X - arrowCapLength, arrowStart.Y - arrowCapLength); cap2End = new PointF(arrowStart.X + arrowCapLength, arrowStart.Y - arrowCapLength); } else if (dir == Direction.Left) { arrowStart = new PointF(x + (size / 2) - (arrowHeight / 2), y + (size / 2) - (arrowWidth / 2)); arrowEnd = new PointF(arrowStart.X + arrowHeight, arrowStart.Y); cap1End = new PointF(arrowStart.X + arrowCapLength, arrowStart.Y + arrowCapLength); cap2End = new PointF(arrowStart.X + arrowCapLength, arrowStart.Y - arrowCapLength); } else if (dir == Direction.Right) { arrowEnd = new PointF(x + (size / 2) - (arrowHeight / 2), y + (size / 2) - (arrowWidth / 2)); arrowStart = new PointF(arrowEnd.X + arrowHeight, arrowEnd.Y); cap1End = new PointF(arrowStart.X - arrowCapLength, arrowStart.Y - arrowCapLength); cap2End = new PointF(arrowStart.X - arrowCapLength, arrowStart.Y + arrowCapLength); } else { throw new Exception(); } gOutput.DrawLine(pen, arrowStart, arrowEnd); gOutput.DrawLine(pen, arrowStart, cap1End); gOutput.DrawLine(pen, arrowStart, cap2End); gOverlay.DrawLine(pen, arrowStart, arrowEnd); gOverlay.DrawLine(pen, arrowStart, cap1End); gOverlay.DrawLine(pen, arrowStart, cap2End); } } } } } return(output, overlay); }
public CellContent(Micro.Cell cell, float[,] heightMap, BlockType[,] blocks) { Cell = cell; HeightMap = heightMap; Blocks = blocks; }
void Start() { blocks = new BlockType[width, height]; }
public CollisionMap(int width, int height) { Width = width; Height = height; data = new BlockType[width, height]; }