public static Grid Combine(Grid[,] subgrids) { var subgridCount = subgrids.GetLength(0); var innerSize = subgrids[0, 0].Size; var size = subgridCount * innerSize; var content = new char[size, size]; for (int i = 0; i < subgridCount; i++) { for (int j = 0; j < subgridCount; j++) { for (int ii = 0; ii < innerSize; ii++) { for (int jj = 0; jj < innerSize; jj++) { content[i * innerSize + ii, j *innerSize + jj] = subgrids[i, j].content[ii, jj]; } } } } return(new Grid { content = content }); }
public void Init(int width, int height) { int widthNum = width / mGridWidth + 1; int heightNum = height / mGridHeight + 1; mGrids = new Grid[widthNum, heightNum]; }
/// <summary> /// A* search algorithm /// </summary> /// <param name="sNode">start point x coordinate</param> /// <param name="eNode">start point y coordinate</param> /// <param name="blocks">the tiled map blocks info.</param> /// <param name="allowDiagonals">is allow diagonal.</param> /// <returns>Return the shortest path from start point to end point.otherwise return empty list.</returns> /// <example> /// Dependency <see cref="Point" /> {@link Point#equals} method /// </example> private static LinkedList <Point> Find(Node sNode, Node eNode, Grid[,] blocks, bool allowDiagonals) { var opened = new List <Node>(); var cked = new HashSet <Node>(); opened.Add(sNode); var paths = new LinkedList <Point>(); while (opened.Count > 0) { var minNode = opened[0]; opened.RemoveAt(0); if (minNode.Equals(eNode) || cked.Contains(eNode) // unreachable point ) { while (minNode.Parent != null) { paths.AddFirst(new Point(minNode.X, minNode.Y)); minNode = minNode.Parent; } break; } var rounds = Rounds(minNode, blocks, allowDiagonals); foreach (var current in rounds) { if (blocks[current.X, current.Y] != null && !blocks[current.X, current.Y].IsWalkable()) { cked.Add(current); continue; } if (cked.Contains(current)) { continue; } var parent = current.Parent; var cost = parent.X == current.X || parent.Y == current.Y ? COST_STRAIGHT : COST_DIAGONAL; int index; if ((index = opened.IndexOf(current)) != -1) { if (parent.G + cost < opened[index].G) { Gn(current, cost); Fn(current); opened.Insert(index, current); } } else { Gn(current, cost); Hn(current, eNode); Fn(current); opened.Add(current); } } cked.Add(minNode); opened.Sort((o1, o2) => o1.F - o2.F); } return(paths); }
/// <summary> /// generates a main building (buggy) /// </summary> /// <param name="grids">grids to generate on</param> /// <param name="emptyGrids">empty grids</param> public void generateMainBuilding(Grid[,] grids, List <Grid> emptyGrids, Vector2 size) { int r = 0; bool isInGrid = true; do { r = Random.Range(0, emptyGrids.Count); Vector2 index = emptyGrids[r].getIndex(); isInGrid = true; foreach (Vector2 offset in GhostMainBuilding.getGridOffsets()) { if (index.x + offset.x >= mapGrid.getMapSize()[0] || index.x + offset.x < 0 || index.y + offset.y >= mapGrid.getMapSize()[1] || index.y + offset.y < 0) { isInGrid = false; } } } while (!isInGrid); GameObject building = spawner.spawnMainBuilding(new Vector2(emptyGrids[r].getPos().x + GhostMainBuilding.getOffset().x, emptyGrids[r].getPos().y + GhostMainBuilding.getOffset().y)); Vector2 mainIndex = emptyGrids[r].getIndex(); foreach (Vector2 offset in GhostMainBuilding.getGridOffsets()) { grids[(int)(mainIndex.x + offset.x), (int)(mainIndex.y + offset.y)].block(building); mapGrid.removeEmptyGrid(grids[(int)(mainIndex.x + offset.x), (int)(mainIndex.y + offset.y)]); } foreach (Vector2 offset in GhostMainBuilding.getStorageOffset()) { mapGrid.addStorages(mapGrid.getGrid()[(int)(mainIndex.x + offset.x), (int)(mainIndex.y + offset.y)]); } }
// ------------------------------------------------------------------------------- public static void Node(Grid[,] Grids, int Value, int Node) { // int Index = 0; int X = 40; int Y = 15; Console.SetCursorPosition(X, Y); Console.WriteLine("s_Value={0}", Value); Y += 2; Console.SetCursorPosition(X, Y); Console.WriteLine("Node={0}", Node); Y += 1; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (Node == Grids[i, j].Node) { Console.SetCursorPosition(X, Y); Console.WriteLine(" "); Console.SetCursorPosition(X, Y); Console.WriteLine("{0} [{1},{2}]={3} Node={4} {5}:{6}", Index, i, j, Grids[i, j].Control, Grids[i, j].Node, Value, Grids[i, j].Value); Y++; Index++; }// } } }
public mapBuilder() { tileType = 0; numRows = 15; numCols = 15; cells = new Grid[numRows, numCols]; mapSpaces = new Tile[numRows, numCols]; InitializeComponent(); for (int r = 0; r < numRows; r++) { for (int c = 0; c < numCols; c++) { Grid cell = new Grid(); mapSpaces[r,c] = new Tile(r,c, 0); mapSpaces[r,c].Click += new RoutedEventHandler(Space_Click); ImageBrush backgroundImage; backgroundImage = new ImageBrush(mapSpaces[r, c].terrainImage.terrainImage); mapSpaces[r, c].Background = backgroundImage; //Set the background of the tile button to the terrain image. mapSpaces[r,c].BorderThickness = new Thickness(0); cells[r, c] = cell; cell.Children.Add(mapSpaces[r,c]); Map.Children.Add(cell); } } for(int i = 0; i <= 3; i++) { Tile nextTile = new Tile(0, 0, i); ImageBrush backgroundImage; backgroundImage = new ImageBrush(nextTile.terrainImage.terrainImage); nextTile.Background = backgroundImage; nextTile.Click += new RoutedEventHandler(Tile_Type_Click); Tiles.Children.Add(nextTile); } }
private bool CheckDiagonals(Grid[,] gridMap) { var isCorrect = false; var iInit = 0; var iModifier = 1; for (int i = 0; i < 3 && !isCorrect; i += 2) { for (int j = 0; j < 2; j++) { if (gridMap[i + iInit, j].PlayerID != gridMap[(i + iInit) + iModifier, j + 1].PlayerID || (gridMap[i + iInit, j].PlayerID == -1)) { isCorrect = false; iInit = 0; iModifier = -1; break; } else { iInit += iModifier; isCorrect = true; } } } return(isCorrect); }
void Awake() { Grids = new Grid[(int)GameSize.x, (int)GameSize.y]; GamePanel.sizeDelta = MapSize; GamePanel.anchoredPosition = -MapSize / 2; Histroys = new List <Histroy>(); }
private void Awake() { Grids = new Grid[RowNum, ColumnNum]; int rowLength = Grids.GetLength(0); int columnLength = Grids.GetLength(1); for (int i = 0; i < rowLength - 1; i++) { for (int j = 0; j < columnLength; j++) { Grids[i, j] = new WallGrid(new Vector2Int(i, j), Instantiate(Resources.Load("WallGrid") as GameObject, transform)); Grids[i, j].WorldPosition = new Vector2(j * WallGridSize.x, -i * WallGridSize.y); Grids[i, j].gameObject.transform.localPosition = Grids[i, j].WorldPosition; } } for (int j = 0; j < columnLength; j++) { int i = rowLength - 1; Grids[i, j] = new GroundGrid(new Vector2Int(i, j), Instantiate(Resources.Load("GroundGrid") as GameObject, transform)); Grids[i, j].WorldPosition = new Vector2(j * WallGridSize.x, -i * WallGridSize.y + 0.3f); Grids[i, j].gameObject.transform.localPosition = Grids[i, j].WorldPosition; } m_OccupyCraftAndStorage(); }
/// <summary> /// 初始化操作 /// </summary> void Init() { //计算行列数 // 单位1,放大20倍,每行放20个格子 int x = (int)(plane.localScale.x * 20); int y = (int)(plane.localScale.z * 20); row = x; colomn = y; // 创建20*20的格子 grids = new Grid[x, y]; objs = new GameObject[x, y]; // 白色方块起始坐标(-2,0,-2) Vector3 startPos = new Vector3(plane.localScale.x * -2, 0, plane.localScale.z * -2); //生成参考物体(Cube) for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { grids [i, j] = new Grid(i, j); GameObject item = (GameObject)Instantiate(reference, new Vector3(i * 0.5f, 0, j * 0.5f) + startPos, Quaternion.identity); item.GetComponentInChildren <Reference> ().x = i; item.GetComponentInChildren <Reference> ().y = j; objs [i, j] = item; } } }
void OnDisable() { allGrids = null; openGrids.Clear(); closeGrids.Clear(); }
/// <summary> /// 初始化操作 /// </summary> void Init() { //计算行列数 int x = (int)(plane.localScale.x * 20); int y = (int)(plane.localScale.z * 20); row = x; colomn = y; grids = new Grid[x, y]; objs = new GameObject[x, y]; //起始坐标 Vector3 startPos = new Vector3(plane.localScale.x * -5, 0, plane.localScale.z * -5); //生成参考物体(Cube) for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { grids [i, j] = new Grid(i, j); GameObject item = (GameObject)Instantiate(reference, new Vector3(i * 0.5f, 0, j * 0.5f) + startPos, Quaternion.identity); item.transform.GetChild(0).GetComponent <Reference> ().x = i; item.transform.GetChild(0).GetComponent <Reference> ().y = j; objs [i, j] = item; } } }
//初始化 void Init() { //计算行列数 size = 20; grids = new Grid[size, size]; allgrids = new int[size, size, size, size]; objs = new GameObject[size, size]; //起始坐标 Vector3 startPos = new Vector3(plane.localScale.x * -5, 0, (float)plane.localScale.z * -5); //生成参考物体(Cube) for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { grids [i, j] = new Grid(i, j); GameObject item = (GameObject)Instantiate(reference, new Vector3(i * 0.5f, 0, j * 0.5f) + startPos + new Vector3((float)0.2, (float)0.0, (float)0.2), Quaternion.identity); item.transform.GetChild(0).GetComponent <Reference> ().x = i; item.transform.GetChild(0).GetComponent <Reference> ().y = j; objs [i, j] = item; } } }
public void Release() { if (this.mCheckGrids != null) { for (int index = 0; index < this.mCheckGrids.Length; ++index) { this.mCheckGrids[index] = (Grid)null; } this.mCheckGrids = (Grid[])null; } if (this.mMoveRoutes != null) { this.mMoveRoutes.Clear(); this.mMoveRoutes = (List <Grid>)null; } this.mMoveStep = 0; if (this.mRoot != null) { this.mRoot.Release(); this.mRoot = (BattleMapRoot)null; } if (this.mGrid == null) { return; } for (int index1 = 0; index1 < this.mHeight; ++index1) { for (int index2 = 0; index2 < this.mWidth; ++index2) { this.mGrid[index2, index1] = (Grid)null; } } this.mGrid = (Grid[, ])null; }
void Awake() { grid = this.transform.FindChild("Grid"); prefab = this.transform.FindChild("Prefab"); prefab.gameObject.SetActive(false); grids = new Grid[Width, Height]; for (int j = 0; j < Height; j++) { for (int i = 0; i < Width; i++) { grids[i, j] = JerryUtil.CloneGo <Grid>(new JerryUtil.CloneGoData() { parant = grid, prefab = prefab.gameObject, clean = false, active = true, name = string.Format("{0}_{1}", j, i), }); grids[i, j].Init(new Grid.GridData() { x = i, y = j, state = GetState(i, j), }); } } }
public InitBaseGrid(string inOvenName) { this.ovenName = inOvenName; try { rowCount = Server.getRowSizeFromDB(ovenName); columnCount = Server.getColumnSizeFromDB(ovenName); this.height = rowCount * rowSize; this.width = columnCount * colSize; } catch (Exception e) { MessageBox.Show("An Error has Occured, Please Contact System Admin with the Following Information: " + e.Message); Environment.Exit(1); } locationLabel = new Label[rowCount + 1, columnCount + 1]; Icolbl = new Grid[rowCount + 1, columnCount + 1]; lbl = new Label[rowCount + 1, columnCount + 1]; panels = new Border[rowCount + 1, columnCount + 1]; myCells = new Cell[rowCount + 1, columnCount + 1]; retGrid = initBaseGrid(new Grid()); retGrid = initGrid(retGrid); retGrid = initPanels(retGrid); Server.readAllFromDataBase(ovenName); InitFromDataBase(); //Ask someone about this! }
public static void MoveLeft(List <GameNumber> allNumber, Grid[,] allGrid, int boardSize) { if (allNumber == null || allGrid == null || allGrid.Length != boardSize * boardSize) { return; } }
void InitBlock() { allGrid = new Grid[GRID_WIDTH, GRID_HEIGHT]; allBlock = new List <BlockController>(); allNumber = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; for (int y = 0; y < GRID_WIDTH; y++) { for (int x = 0; x < GRID_HEIGHT; x++) { if (x == (GRID_WIDTH - 1) && y == (GRID_HEIGHT - 1)) { allGrid[x, y] = new Grid(x, y, 0); allGrid[x, y].number = 0; continue; } int index = Random.Range(0, allNumber.Count); int randomNumber = allNumber[index]; allGrid[x, y] = new Grid(x, y, randomNumber); allNumber.RemoveAt(index); BlockController theBlock = Instantiate(BlockPrefabs, new Vector3(-3 + x * girdLenght, 3 - y * girdLenght, transform.position.z), Quaternion.identity).GetComponent <BlockController>(); theBlock.UpdateText(randomNumber); theBlock.x = x; theBlock.y = y; theBlock.number = randomNumber; allBlock.Add(theBlock); allGrid[x, y].number = randomNumber; } } }
void Start() { // 初始化雷区 map = new Grid[row, col]; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { map[i, j] = new Grid(); } } // 布雷 for (int i = 0; i < boomNumber; i++) { int x = Random.Range(0, row); int y = Random.Range(0, col); if (map[x, y].hasBoom) { i--; // 如果已经有雷,重复计算 } else { map[x, y].hasBoom = true; } } // 计算格子数 ComputeNum1(); }
public GameBoardPrototype() { InitializeComponent(); DataContext = GameBoardViewModel.GetInstance(); _tileRack = new TileRack(ref TileRackUi); _playerPane = new PlayerPane(); PlayerPanel.ItemsSource = _playerPane.PlayerList; _gameBoardArray = new Grid[GameBoardDimension, GameBoardDimension]; _dirtyTiles = new List<Rectangle>(); GenerateGrid(); _playedTiles = new List<Grid>(); UiTester(); // // Background grid initialization // //_background = new BackgroundGrid(); //_background.PolygonGrid.SetValue(Grid.ColumnSpanProperty, 3); //RootGrid.Children.Insert(0, _background.PolygonGrid); //_background.BeginSubtleAnimation(); }
public void LoadLevel(int id) { var mapFile = MapReader.Instance.ReadFile(id); Width = MapReader.Instance.mapWidth; Height = MapReader.Instance.mapHeight; _map = new Grid[Height, Width]; for (int x = 0; x < Height; x++) { for (int y = 0; y < Width; y++) { var e = Contexts.Default.CreateEntity(); e.Add <PosComp>().SetValue(new Vector2Int(x, y)); e.Add <TagComp>().SetValue((Tag)mapFile[x, y]); Helper.SetEntityName(e); if (_map[x, y] == null) { _map[x, y] = new Grid(); } _map[x, y].Add(e.creationIndex); _gameObjects.Add(e.creationIndex, GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("Sprite"))); GameObjectChangedEvent(e.creationIndex); } } Contexts.Default.AddUnique <DataComp>().SetValue(this); }
public void MakeGame(Transform environ, int _mapIndex) { mapIndex = _mapIndex; currentMap = mapSource[mapIndex]; environmentParent = environ; grids = new Grid[currentMap.width, currentMap.height]; movers = new List <Mover>(); portals = new List <Grid_Portal>(); GenerateMap(); InitializePortals(); floorColor = gridMatcher[0].matchObj.GetComponent <Renderer>().sharedMaterial.color; foreach (Mover m in movers) { m.StartMovement(); } foreach (Grid_Portal p in portals) { if (portals.IndexOf(p) % 2 == 0) { if (p.GetPairPortal() != null) { Vector3 src = MapInfo.mapInfo.ConvertGrid2World(p); Vector3 dest = MapInfo.mapInfo.ConvertGrid2World(p.GetPairPortal()); Vector3 middlePoint = (src + dest) / 2; GameObject t = Instantiate(tunnel, middlePoint + Vector3.up, Quaternion.identity); t.transform.forward = (src - dest).normalized; t.transform.localScale = new Vector3(1f, 1f, Vector3.Distance(src, dest) / 2); t.transform.SetParent(environmentParent); } } } }
/// <summary> /// 方法:检查当前节点周边的节点 /// </summary> /// <param name="sg">当前节点</param> /// <param name="eg">终点</param> /// <param name="map">Map类的实例</param> protected void CheckAround(Grid sg, Grid eg, Map map) { int gridmapRow = map.LenY; //获取地图的行数 int gridmapCol = map.LenX; //获取地图的列数 Grid[,] gridmap = map.m_Data; for (int i = sg.X - 1; i < sg.X + 2; i++) { for (int j = sg.Y - 1; j < sg.Y + 2; j++) { if (i < 0 || i > gridmapCol - 1 || j < 0 || j > gridmapRow - 1) { continue; } if (gridmap[j, i].LandAttribute == 0 || IsInList(i, j, closeList) || (i == sg.X && j == sg.Y)) { continue; } gridmap[j, i].HCostAttribute = GetGridCostH(i, j, eg); if (!IsInList(i, j, openList)) { gridmap[j, i].fatherGrid = sg; gridmap[j, i].GCostAttribute = GetGridCostG(i, j, sg); openList.Add(gridmap[j, i]); } else if (gridmap[j, i].GCostAttribute > GetGridCostG(i, j, sg)) { gridmap[j, i].GCostAttribute = GetGridCostG(i, j, sg); gridmap[j, i].fatherGrid = sg; } } } }
private Grid[,] PopulateWithUnits(Grid[,] grids) { int otherSide = grids.GetLength(1) - 1; int end = grids.GetLength(0) - 1; Unit[] occupants; for (int x = 1; x < end; x++) { occupants = new Unit[1]; occupants[0] = NewUnit(Unit.UNIT_TYPES.CUBE, Player.TEAM.GREEN, new Vector2(x, 0)); occupants[0].SetGrid(grids[x, 0]); grids[x, 0].SetOccupants(occupants); occupants = new Unit[1]; occupants[0] = NewUnit(Unit.UNIT_TYPES.PYRAMID, Player.TEAM.GREEN, new Vector2(x, 1)); occupants[0].SetGrid(grids[x, 1]); grids[x, 1].SetOccupants(occupants); occupants = new Unit[1]; occupants[0] = NewUnit(Unit.UNIT_TYPES.PYRAMID, Player.TEAM.RED, new Vector2(x, otherSide - 1)); occupants[0].SetGrid(grids[x, otherSide - 1]); grids[x, otherSide - 1].SetOccupants(occupants); occupants = new Unit[1]; occupants[0] = NewUnit(Unit.UNIT_TYPES.CUBE, Player.TEAM.RED, new Vector2(x, otherSide)); occupants[0].SetGrid(grids[x, otherSide]); grids[x, otherSide].SetOccupants(occupants); } return(grids); }
public bool Deserialize(JSON_Map src) { this.mWidth = src.w; this.mHeight = src.h; if (src.grid.Length != this.mWidth * this.mHeight) { throw new Exception("Grid size does not match width x height"); } this.mGrid = new Grid[this.mWidth, this.mHeight]; for (int index1 = 0; index1 < this.mHeight; ++index1) { for (int index2 = 0; index2 < this.mWidth; ++index2) { Grid grid = new Grid(); JSON_MapGrid jsonMapGrid = src.grid[index2 + index1 * this.mWidth]; grid.x = index2; grid.y = index1; grid.height = jsonMapGrid.h; grid.tile = jsonMapGrid.tile; grid.geo = MonoSingleton <GameManager> .Instance.GetGeoParam(jsonMapGrid.tile); grid.cost = grid.geo == null ? 1 : (int)grid.geo.cost; this.mGrid[index2, index1] = grid; } } this.mRoot = new BattleMapRoot(); this.mRoot.Initialize(this.mWidth, this.mHeight, this.mGrid); this.ResetMoveRoutes(); return(true); }
void CreateMap() { row = 6; col = 7; m_grids = new Grid[6, 7]; int[,] config = new int[6, 7] { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0 }, { 0, 1, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { GridState state = GridState.FREE; if (config[r, c] == 1) { state = GridState.FULL; } m_grids[r, c] = AddGrid(r, c, state); } } m_NPC = AddNPC(3, 1); }
void InitNewMap(Vector3 basePosition) { curGenerateInfo = new RoomGenerateParam(); roomList.Clear(); usedGrid = 0; var size = new int[] { MapSize.x, MapSize.y }; var startIndex = new int[] { 0, 0 }; grids = (Grid[, ])Array.CreateInstance(typeof(Grid), size, startIndex); for (int row = 0; row < MapSize.x; ++row) { for (int col = 0; col < MapSize.y; ++col) { var grid = new Grid(); grid.index = new Vector2Int(row, col); grids[row, col] = grid; grid.position = basePosition + new Vector3((col - 1) * Data.GridSize.x, -(row - 1) * Data.GridSize.y, 0); //door pos grid.upDoor.position = grid.position + new Vector3(0, Data.GroundSize.y * 0.5f + Data.DoorHeight * 0.5f, 0); grid.downDoor.position = grid.position + new Vector3(0, -Data.GroundSize.y * 0.5f - Data.DoorHeight * 0.5f, 0); grid.leftDoor.position = grid.position + new Vector3(-Data.GroundSize.x * 0.5f - Data.DoorHeight * 0.5f, 0, 0); grid.rightDoor.position = grid.position + new Vector3(Data.GroundSize.x * 0.5f + Data.DoorHeight * 0.5f, 0, 0); } } }
public mapBuilder() { tileType = 0; numRows = 15; numCols = 15; cells = new Grid[numRows, numCols]; mapSpaces = new Tile[numRows, numCols]; InitializeComponent(); for (int r = 0; r < numRows; r++) { for (int c = 0; c < numCols; c++) { Grid cell = new Grid(); mapSpaces[r, c] = new Tile(r, c, 0); mapSpaces[r, c].Click += new RoutedEventHandler(Space_Click); ImageBrush backgroundImage; backgroundImage = new ImageBrush(mapSpaces[r, c].terrainImage.terrainImage); mapSpaces[r, c].Background = backgroundImage; //Set the background of the tile button to the terrain image. mapSpaces[r, c].BorderThickness = new Thickness(0); cells[r, c] = cell; cell.Children.Add(mapSpaces[r, c]); Map.Children.Add(cell); } } for (int i = 0; i <= 3; i++) { Tile nextTile = new Tile(0, 0, i); ImageBrush backgroundImage; backgroundImage = new ImageBrush(nextTile.terrainImage.terrainImage); nextTile.Background = backgroundImage; nextTile.Click += new RoutedEventHandler(Tile_Type_Click); Tiles.Children.Add(nextTile); } }
public Game(Player player1, Player player2) { InitializeComponent(); _player1 = new Player(player1.Name); _player2 = new Player(player2.Name); UpdateLabels(); _p1Shots = new Grid[, ] { { P2GA1, P2GB1, P2GC1, P2GD1, P2GE1, P2GF1, P2GG1, P2GH1, P2GI1, P2GJ1 }, { P2GA2, P2GB2, P2GC2, P2GD2, P2GE2, P2GF2, P2GG2, P2GH2, P2GI2, P2GJ2 }, { P2GA3, P2GB3, P2GC3, P2GD3, P2GE3, P2GF3, P2GG3, P2GH3, P2GI3, P2GJ3 }, { P2GA4, P2GB4, P2GC4, P2GD4, P2GE4, P2GF4, P2GG4, P2GH4, P2GI4, P2GJ4 }, { P2GA5, P2GB5, P2GC5, P2GD5, P2GE5, P2GF5, P2GG5, P2GH5, P2GI5, P2GJ5 }, { P2GA6, P2GB6, P2GC6, P2GD6, P2GE6, P2GF6, P2GG6, P2GH6, P2GI6, P2GJ6 }, { P2GA7, P2GB7, P2GC7, P2GD7, P2GE7, P2GF7, P2GG7, P2GH7, P2GI7, P2GJ7 }, { P2GA8, P2GB8, P2GC8, P2GD8, P2GE8, P2GF8, P2GG8, P2GH8, P2GI8, P2GJ8 }, { P2GA9, P2GB9, P2GC9, P2GD9, P2GE9, P2GF9, P2GG9, P2GH9, P2GI9, P2GJ9 }, { P2GA10, P2GB10, P2GC10, P2GD10, P2GE10, P2GF10, P2GG10, P2GH10, P2GI10, P2GJ10 } }; _p2Shots = new Grid[, ] { { P1GA1, P1GB1, P1GC1, P1GD1, P1GE1, P1GF1, P1GG1, P1GH1, P1GI1, P1GJ1 }, { P1GA2, P1GB2, P1GC2, P1GD2, P1GE2, P1GF2, P1GG2, P1GH2, P1GI2, P1GJ2 }, { P1GA3, P1GB3, P1GC3, P1GD3, P1GE3, P1GF3, P1GG3, P1GH3, P1GI3, P1GJ3 }, { P1GA4, P1GB4, P1GC4, P1GD4, P1GE4, P1GF4, P1GG4, P1GH4, P1GI4, P1GJ4 }, { P1GA5, P1GB5, P1GC5, P1GD5, P1GE5, P1GF5, P1GG5, P1GH5, P1GI5, P1GJ5 }, { P1GA6, P1GB6, P1GC6, P1GD6, P1GE6, P1GF6, P1GG6, P1GH6, P1GI6, P1GJ6 }, { P1GA7, P1GB7, P1GC7, P1GD7, P1GE7, P1GF7, P1GG7, P1GH7, P1GI7, P1GJ7 }, { P1GA8, P1GB8, P1GC8, P1GD8, P1GE8, P1GF8, P1GG8, P1GH8, P1GI8, P1GJ8 }, { P1GA9, P1GB9, P1GC9, P1GD9, P1GE9, P1GF9, P1GG9, P1GH9, P1GI9, P1GJ9 }, { P1GA10, P1GB10, P1GC10, P1GD10, P1GE10, P1GF10, P1GG10, P1GH10, P1GI10, P1GJ10 } }; }
//setting variable for Grid public GridManager(int X, int Y, int size, CDrawer _canvas) { Bsize = size; Xsize = X; Ysize = Y; arrayGrid = initGrid(X, Y); canvas = _canvas; }
public ChessBoard(GameMainWindow gameMainWindow, ChessPiece chessPiece) { this.gameMainWindow = gameMainWindow; this.chessPiece = chessPiece; buttonToGrid = new Dictionary <Button, Grid>(); grids = new Grid[11, 10]; }
void InitGridArray() { vertical = (int)Camera.main.orthographicSize + Constants.gridNumberOffset_Row; horizontal = (int)(vertical * Camera.main.aspect) + Constants.gridNumberOffset_Column; column = horizontal * 2; row = vertical * 2; gridArray = new Grid[column, row]; }
public pathFinder(bool[,] bMap) { //read map map = new Grid[bMap.GetLength(0), bMap.GetLength(1)]; for (int r = 0; r < map.GetLength(0); r++) { for (int c = 0; c < map.GetLength(1); c++) { map[r, c] = new Grid(); map[r, c].Walkable = bMap[r, c]; } } }
public Map(int width, int height) { grids = new Grid[width, height]; area = new Rectangle (width, height); foreach (Point p in area) { grids[p.X, p.Y] = new Grid (); } ItemFactory.Instance.Created += OnItemCreated; MonsterFactory.Instance.Created += OnActorCreated; }
public GridMap(int w, int h) { W = w; H = h; M = new Grid[W, H]; for (int x = 0; x < W; ++x) { for (int y = 0; y < H; ++y) { this[x, y] = Grid.Free; } } img = new Bitmap(W, H); }
public GridManager(int width, int height) { this.width = width; this.height = height; manager = new Grid[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { manager[i, j] = new Grid(); } } }
// Use this for initialization public void InitializeGrids() { // set grid size Grid grid = gridObject.GetComponent<Grid>(); gridHeight = grid.height; gridWidth = grid.width; grids = new Grid[gridNumberX, gridNumberY]; // spawn grids for(int i = 0; i < gridNumberY; ++i) { float y = ((gridNumberY - 1) * 0.5f - i) * gridHeight; for (int j = 0; j < gridNumberX; ++j) { float x = ((gridNumberX - 1) * 0.5f - j) * gridWidth; Vector3 position = new Vector3(x, y, 0); Grid gridInstance = (Grid)Instantiate(grid, position, Quaternion.identity); gridInstance.setPosition(position); grids[j, i] = gridInstance; gridInstance.transform.SetParent(transform, false); } } }
public void CreateWorld(float world_size, float grid_size) { gridSize = grid_size; gridNum = (int)(world_size / gridSize + 1.0f - Utility.MIN_FLOAT); worldSize = gridSize * gridNum; GridPos.SetGridNum(gridNum); grid = new Grid[gridNum, gridNum]; for (int i = 0; i < gridNum; i++) { for (int j = 0; j < gridNum; j++) { Grid g = new Grid(); g.centerPos = GridPosToCenterPos(i, j); grid[i, j] = g; } } }
public void DrawGrid(int rows, int cols) { this.rows = rows; this.cols = cols; this.cells = new Canvas[rows, cols]; this.containers = new Grid[rows, cols]; for (int i = 0; i < rows; i++) { board.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(CellHeight) }); } for (int i = 0; i < cols; i++) { board.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(CellWidth) }); } for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { var border = new Border() { BorderThickness = new Thickness(CellBorderThickness), BorderBrush = new SolidColorBrush(Colors.DarkCyan) }; Grid.SetRow(border, i); Grid.SetColumn(border, j); board.Children.Add(border); var innerGrid = new Grid(); border.Child = innerGrid; containers[i, j] = innerGrid; var canvas = new Canvas { Background = new SolidColorBrush(Colors.Azure) }; innerGrid.Children.Add(canvas); cells[i, j] = canvas; } } }
void InitGrids(Vector3 from, int w, int h, Vector3 scale) { gridArray = new Grid[w, h]; from += new Vector3(scale.x * .5f, scale.y *.5f, 0); for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) { var pos = from + new Vector3(i*scale.x,j* scale.y,0); var g = Instantiate(PREFAB_GRID, pos, Quaternion.identity) as Grid; g.transform.localScale = scale; g.name = "G " + i + " " + j; g.transform.parent = transform; g.init(); gridArray[i, j] = g; } }
/// <summary> /// bmpからGridMapを生成 /// </summary> /// <param name="bitmap"></param> public GridMap(Bitmap bitmap) { W = bitmap.Width; H = bitmap.Height; M = new Grid[W, H]; BitmapAccess access = new BitmapAccess(bitmap); access.BeginAccess(); // bmpからGridMapを生成 for (int x = 0; x < W; ++x) { for (int y = 0; y < H; ++y) { Color c = access[x, y]; if (c == GridColor_Fill) { // 障害物 this[x, y] = Grid.Fill; } else if (c == GridColor_Free) { // 何もないところ this[x, y] = Grid.Free; } else if (c == GridColor_RedArea) { // 異常地帯 壁の中 this[x, y] = Grid.RedArea; } else if (c == GridColor_GreenArea) { // 位置補正エリア this[x, y] = Grid.GreenArea; } else if (c == GridColor_BlueArea) { // スローエリア this[x, y] = Grid.BlueArea; } else { // それ以外 this[x, y] = Grid.Unknown; } } } access.EndAccess(); }