HexTile3Ds can now be positioned by specifying offset coordinates.
parent
5d39ec2b21
commit
d673b8c44f
|
@ -24,9 +24,29 @@ public class HexTile3D : Spatial
|
|||
private SpatialMaterial _deepGrassMaterial;
|
||||
private SpatialMaterial _previousMaterial;
|
||||
|
||||
private HexGrid _hexGrid;
|
||||
|
||||
public HexCell Cell = new HexCell();
|
||||
public bool IsMouseOver = false;
|
||||
|
||||
public Vector2 OffsetCoords
|
||||
{
|
||||
get
|
||||
{
|
||||
return Cell.OffsetCoords;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Cell.OffsetCoords = value;
|
||||
Transform tile3dTransform = this.Transform;
|
||||
Vector2 cellPlaneCoords = _hexGrid.GetHexCenter(Cell);
|
||||
tile3dTransform.origin.x = cellPlaneCoords.x;
|
||||
tile3dTransform.origin.z = cellPlaneCoords.y;
|
||||
this.Transform = tile3dTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private TileType _type;
|
||||
public TileType Type
|
||||
{
|
||||
|
@ -54,6 +74,11 @@ public class HexTile3D : Spatial
|
|||
}
|
||||
}
|
||||
|
||||
HexTile3D()
|
||||
{
|
||||
_hexGrid = new HexGrid();
|
||||
}
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
|
@ -123,14 +123,13 @@ public class StreamContainer : Spatial
|
|||
if (!_coordToTile.Keys.Contains(offsetCoords))
|
||||
{
|
||||
HexTile3D tile3d = (HexTile3D)_hexTileScene.Instance();
|
||||
HexCell cell = new HexCell();
|
||||
cell.OffsetCoords = offsetCoords;
|
||||
Vector2 cellPlaneCoords = _hexGrid.GetHexCenter(cell);
|
||||
Transform tile3dTransform = Transform.Identity;
|
||||
tile3dTransform.origin = new Vector3(cellPlaneCoords.x, GD.Randf() * 0.1f, cellPlaneCoords.y);
|
||||
tile3d.Transform = tile3dTransform;
|
||||
tile3d.OffsetCoords = offsetCoords;
|
||||
_activeTiles.AddChild(tile3d);
|
||||
|
||||
Transform tileTransform = tile3d.Transform;
|
||||
tileTransform.origin.y = GD.Randf() * 0.2f;
|
||||
tile3d.Transform = tileTransform;
|
||||
|
||||
tile3d.Type = HexTile3D.ValidTileTypes[_tileTypeRandom.Next(HexTile3D.ValidTileTypes.Length)];
|
||||
_coordToTile[offsetCoords] = tile3d;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue