public void EditTileData(int type) { BuildTileData tiledata = TileSlotList [CurrentSelectedTile].GetComponent <BuildTileData> (); CurrentGameMap.MapTileList [CurrentSelectedTile].TileType = type; tiledata.tile = CurrentGameMap.MapTileList [CurrentSelectedTile]; tiledata.StartTileData(); }
public void EditTileGameobject(int type, int id) { DeleteTileGameobject(); BuildTileData tiledata = TileSlotList [CurrentSelectedTile].GetComponent <BuildTileData> (); int objtype = type; int objid = id; int positionx = tiledata.Xposition; int positiony = tiledata.Yposition; MapObject newmapobject = new MapObject(objtype, objid, positionx, positiony); CurrentGameMap.MapObjectList.Add(newmapobject); tiledata.tileobject = newmapobject; tiledata.StartTileData(); }
private void CreateGameMap() { TileSlotList.Clear(); int tilenumber = 0; for (int x = 0; x < CurrentGameMap.SizeX; x++) { for (int y = 0; y < CurrentGameMap.SizeY; y++) { Vector3 tilePosition = new Vector3((-CurrentGameMap.SizeX / 2 + 0.5f + x) * TileScale.x, (-CurrentGameMap.SizeY / 2 + 0.5f + y) * TileScale.y, 0); Transform newTile = Instantiate(tilePrefab, tilePosition, Quaternion.Euler(Vector3.right * 0)) as Transform; newTile.gameObject.transform.localScale = TileScale; newTile.transform.SetParent(MapPanel.transform, false); TileSlotList.Add(newTile.gameObject); BuildTileData tiledata = newTile.GetComponent <BuildTileData> (); tiledata.TileID = tilenumber; tilenumber = tilenumber + 1; tiledata.Xposition = x; tiledata.Yposition = y; tiledata.tileobject = new MapObject(); for (int i = 0; i < CurrentGameMap.MapObjectList.Count; i++) { if (CurrentGameMap.MapObjectList [i].PositionX == x && CurrentGameMap.MapObjectList [i].PositionY == y) { tiledata.tileobject = CurrentGameMap.MapObjectList [i]; //Debug.Log ("Found " + tiledata.tileobject.Type + " thing at " + x + " and " + y); break; } else { } } MapTile newmaptile = new MapTile(); for (int i = 0; i < CurrentGameMap.MapTileList.Count; i++) { if (CurrentGameMap.MapTileList [i].PositionX == x && CurrentGameMap.MapTileList [i].PositionY == y) { newmaptile = CurrentGameMap.MapTileList [i]; } } tiledata.tile = newmaptile; tiledata.StartTileData(); } } }