private void AddTilesFor(Layer layer, List <TileObj> tileObjs) { DrawLayer engineLayer = DrawLayer.Playground; if (layer.Props.Has("drawLayer")) { string drawLayer = layer.Props.GetString("drawLayer"); engineLayer = (DrawLayer)Enum.Parse(typeof(DrawLayer), drawLayer); } for (int i = 0; i < layer.Grid.Size(); i++) { TileInstance inst = layer.Grid.At(i); if (inst == null) { continue; } string texture = inst.Type.ImagePath; int tOffX = inst.Type.OffX; int tOffY = inst.Type.OffY; int width = inst.Type.Width; int height = inst.Type.Height; int posX = inst.PosX; int posY = inst.PosY; TileObj obj = new TileObj(texture, tOffX, tOffY, posX, posY, width, height); tileObjs.Add(obj); if (inst.Type.Props.Has("collidable") && inst.Type.Props.GetBool("collidable")) { obj.RigidBody = new Rigidbody(obj); obj.RigidBody.Collider = ColliderFactory.CreateBoxFor(obj); obj.RigidBody.Type = RigidBodyType.TileObj; } } }
//タイル情報のテンプレート作成 static TileObj addTileTlt(String _image, TileGroup _group, TileType _type, int[] _cost) { TileObj newTile = new TileObj(_type, _group, _cost); newTile.tBase = Resources.Load <TileBase>("TileBase/" + _image); return(newTile); }
public static TileObj set(TileType _type, Vector2Int pos) { TileObj setTile = (TileObj)uTileTlt.FirstOrDefault(t => t.tileType == _type).MemberwiseClone(); setTile.pos_x = pos.x; setTile.pos_y = pos.y; return(setTile); }
// 視界を開ける public void openView(Vector2Int Pos) { if (tileMap[Pos.x, Pos.y].getType() == TileType.None) { TileObj.set(baseMap.tileMap[Pos.x, Pos.y].getType(), new Vector2Int(Pos.x, Pos.y)); tileList.Add(tileMap[Pos.x, Pos.y]); } }
public void SwapObject(GameObject NewObj, Vector2 coordnates, TileObj ObjectID) { if (TileObject != null && TileObjectStor.ObjDict[coordnates] != TileObj.lilipad && TileObjectStor.ObjDict[coordnates] != TileObj.none) { RemoveObject(coordnates); TileObject = GameObject.Instantiate(NewObj); TileObjectStor.ObjDict[coordnates] = ObjectID; ActivateObject(); } }
/// <summary> /// マップを生成します /// </summary> public void putTile(TileType type, int pos_X, int pos_Y) { //Tilemapに描写 var position = new Vector2Int(offset_stg2tile_x(pos_X), offset_stg2tile_y(pos_Y)); if (tileMap[pos_X, pos_Y] != null) //前のが残っている場合は消す { tileList.Remove(tileMap[pos_X, pos_Y]); } tileMap[pos_X, pos_Y] = TileObj.set(type, new Vector2Int(pos_X, pos_Y)); tileList.Add(tileMap[pos_X, pos_Y]); mainMap.SetTile(new Vector3Int(position.x, position.y, 0), tileMap[pos_X, pos_Y].tBase); }
public void InitGameData() { objDic.Clear(); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { int random = UnityEngine.Random.Range(1, 7); mapInfo[i, j] = random; TileObj tileObj = new TileObj(); tileObj.x = (j + 1 / 2f) * spriteWidth - width / 2 + offSetX; //(j+1/2f)*tileWidth-Screen.width/2 tileObj.y = (i + 1 / 2f) * spriteHeight - height / 2f; objDic.Add(i + "," + j, tileObj); } } }
//Configuração inicial public void Initialize(int x, int y, string name) { //Configura tamanho do grid gridSize = new Coord(x, y); //Cria Tile tile = new TileObj(name); //Configura Alturas heightMap = new HeightMap(gridSize); // Configura Centros centreMap = new CentreMap(gridSize, tile.Size); LimitGrid(); }
// Start is called before the first frame update void Awake() { TileObj.initTileTlt(); ast = gameObject.GetComponent <astar>(); instance = this; }
public void InitGameData() { objDic.Clear(); for(int i = 0;i<row;i++) { for(int j = 0;j<column;j++) { int random = UnityEngine.Random.Range(1,7); mapInfo[i,j] = random; TileObj tileObj = new TileObj(); tileObj.x = (j+1/2f)*spriteWidth-width/2+offSetX; //(j+1/2f)*tileWidth-Screen.width/2 tileObj.y = (i+1/2f)*spriteHeight-height/2f; objDic.Add(i+","+j,tileObj); } } }