Minor tweaking
parent
c3bca6b208
commit
4d391ff5b3
|
@ -9,22 +9,27 @@
|
|||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Node",
|
||||
"base": "Reference",
|
||||
"class": "ClickableComponent",
|
||||
"language": "GDScript",
|
||||
"path": "res://components/ClickableComponent.gd"
|
||||
}, {
|
||||
"base": "KinematicBody2D",
|
||||
"base": "Reference",
|
||||
"class": "CollisionLine",
|
||||
"language": "GDScript",
|
||||
"path": "res://utils/CollisionLine.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"base": "Reference",
|
||||
"class": "ColorComponent",
|
||||
"language": "GDScript",
|
||||
"path": "res://components/ColorComponent.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "GameTile",
|
||||
"language": "GDScript",
|
||||
"path": "res://utils/GameTile.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "HexCell",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/gdhexgrid/HexCell.gd"
|
||||
|
@ -44,17 +49,12 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://utils/IslandGenerator.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "IslandTile",
|
||||
"language": "GDScript",
|
||||
"path": "res://utils/IslandTile.gd"
|
||||
}, {
|
||||
"base": "Object",
|
||||
"class": "SpringDamper",
|
||||
"language": "GDScript",
|
||||
"path": "res://utils/SpringDamper.gd"
|
||||
}, {
|
||||
"base": "Sprite",
|
||||
"base": "Reference",
|
||||
"class": "TintedSpriteComponent",
|
||||
"language": "GDScript",
|
||||
"path": "res://components/TintedSpriteComponent.gd"
|
||||
|
@ -63,11 +63,11 @@ _global_script_class_icons={
|
|||
"ClickableComponent": "",
|
||||
"CollisionLine": "",
|
||||
"ColorComponent": "",
|
||||
"GameTile": "",
|
||||
"HexCell": "",
|
||||
"HexTile3D": "",
|
||||
"Island": "",
|
||||
"IslandGenerator": "",
|
||||
"IslandTile": "",
|
||||
"SpringDamper": "",
|
||||
"TintedSpriteComponent": ""
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ func _ready():
|
|||
func _process(delta):
|
||||
fps_label.text = "FPS: " + str(Performance.get_monitor(Performance.TIME_FPS))
|
||||
player_pos_label.text = "Pos: " + str(player.transform.origin)
|
||||
|
||||
# query world what is happening on
|
||||
|
||||
|
||||
func on_island_tile_selected(island, tile):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://entities/PlayerEntity.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scenes/HexGrid3DTest.gd" type="Script" id=2]
|
||||
|
@ -6,6 +6,7 @@
|
|||
[ext_resource path="res://scenes/Island.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://assets/water_diffuse.png" type="Texture" id=5]
|
||||
[ext_resource path="res://components/MovableComponent.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://scenes/World.gd" type="Script" id=7]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id=4]
|
||||
radius = 0.2
|
||||
|
@ -178,6 +179,7 @@ shape = SubResource( 5 )
|
|||
max_speed = 3
|
||||
|
||||
[node name="World" type="Spatial" parent="."]
|
||||
script = ExtResource( 7 )
|
||||
|
||||
[node name="Scene" type="Spatial" parent="World"]
|
||||
|
||||
|
@ -189,6 +191,7 @@ max_speed = 3
|
|||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12.2668, 0, 0 )
|
||||
|
||||
[node name="Water" type="Spatial" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="Water" type="MeshInstance" parent="Water"]
|
||||
transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, -0.1, 0 )
|
||||
|
|
|
@ -11,13 +11,13 @@ signal tile_mouse_entered
|
|||
#var cube_coords = Vector3(0, 0, 0) setget set_cube_coords, get_cube_coords
|
||||
|
||||
func set_tiletype(type):
|
||||
var IslandTile = load("res://utils/IslandTile.gd").new()
|
||||
var GameTile = load("res://utils/GameTile.gd").new()
|
||||
|
||||
var mesh = $Mesh
|
||||
|
||||
if type == IslandTile.TileType.Sand:
|
||||
if type == GameTile.TileType.Sand:
|
||||
mesh.set_surface_material(0, preload("res://materials/SandTile.tres"))
|
||||
elif type == IslandTile.TileType.Grass:
|
||||
elif type == GameTile.TileType.Grass:
|
||||
mesh.set_surface_material(0, preload("res://materials/GrassTile.tres"))
|
||||
else:
|
||||
mesh.set_surface_material(0, preload("res://materials/DeepGrassTile.tres"))
|
||||
|
|
|
@ -2,7 +2,7 @@ tool
|
|||
extends Spatial
|
||||
class_name Island
|
||||
|
||||
onready var IslandTile = preload("res://utils/IslandTile.gd")
|
||||
onready var GameTile = preload("res://utils/GameTile.gd")
|
||||
|
||||
export var generate: bool = false setget do_generate
|
||||
export var level_size: int = 10
|
||||
|
@ -19,15 +19,15 @@ func reset():
|
|||
node.queue_free()
|
||||
|
||||
|
||||
func create_tile_for_hex(hex):
|
||||
func create_tile_for_hex(game_tile):
|
||||
var hexgrid = preload("res://addons/gdhexgrid/HexGrid.gd").new()
|
||||
var HexTile3D = preload("res://scenes/HexTile3D.tscn")
|
||||
|
||||
var tile = HexTile3D.instance()
|
||||
var pos = hexgrid.get_hex_center_from_offset(hex.offset_coords)
|
||||
var height = 0.0 if hex.type == IslandTile.TileType.Sand else 0.1 + rand_range(0.0, 0.05)
|
||||
var pos = hexgrid.get_hex_center_from_offset(game_tile.offset_coords)
|
||||
var height = 0.0 if game_tile.type == GameTile.TileType.Sand else 0.1 + rand_range(0.0, 0.05)
|
||||
|
||||
tile.set_tiletype(hex.type)
|
||||
tile.set_tiletype(game_tile.type)
|
||||
tile.transform.origin = Vector3(pos.x, height, pos.y)
|
||||
tile.connect("tile_selected", self, "on_tile_selected")
|
||||
tile.connect("tile_mouse_entered", self, "on_tile_hover")
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
extends Spatial
|
||||
|
||||
var GameTile = load("res://utils/GameTile.gd")
|
||||
var HexCell = preload("res://addons/gdhexgrid/HexCell.gd")
|
||||
|
||||
var has_tiles_initialized = false
|
||||
export var size = [200, 200]
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
func create_ocean_tiles():
|
||||
|
||||
var islands
|
||||
pass
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
extends "res://addons/gdhexgrid/HexCell.gd"
|
||||
class_name IslandTile
|
||||
class_name GameTile
|
||||
|
||||
enum TileType { Sand, Grass, DeepGrass, Rock }
|
||||
enum TileType { Sand, Grass, DeepGrass, Rock, Water }
|
||||
|
||||
var type = TileType.Sand
|
||||
|
|
@ -1,14 +1,15 @@
|
|||
class_name IslandGenerator
|
||||
extends Node
|
||||
|
||||
var IslandTile = preload("res://utils/IslandTile.gd")
|
||||
var GameTile = load("res://utils/GameTile.gd")
|
||||
var HexCell = preload("res://addons/gdhexgrid/HexCell.gd")
|
||||
|
||||
func hex_cell_to_island_tile (hex: HexCell) -> IslandTile:
|
||||
var tile = IslandTile.new()
|
||||
|
||||
func hex_cell_to_island_tile (hex: HexCell) -> GameTile:
|
||||
var tile = GameTile.new()
|
||||
tile.fromHexCell(hex)
|
||||
return tile
|
||||
|
||||
|
||||
|
||||
func random_walk(walk_size):
|
||||
var hexgrid = preload("res://addons/gdhexgrid/HexGrid.gd").new()
|
||||
|
@ -38,6 +39,7 @@ func random_walk(walk_size):
|
|||
|
||||
return tiles
|
||||
|
||||
|
||||
func extrude_tiles(tiles):
|
||||
var old_tiles = tiles
|
||||
|
||||
|
@ -59,12 +61,12 @@ func extrude_tiles(tiles):
|
|||
|
||||
func mark_sand_tiles(tiles):
|
||||
for tile in tiles.values():
|
||||
tile.type = IslandTile.TileType.Grass if randi() % 2 else IslandTile.TileType.DeepGrass
|
||||
tile.type = GameTile.TileType.Grass if randi() % 2 else GameTile.TileType.DeepGrass
|
||||
var tile_neighbours = tile.get_all_adjacent()
|
||||
|
||||
for neighbour in tile_neighbours:
|
||||
if not neighbour.offset_coords in tiles.keys():
|
||||
tile.type = IslandTile.TileType.Sand
|
||||
tile.type = GameTile.TileType.Sand
|
||||
break
|
||||
|
||||
return tiles
|
||||
|
|
Loading…
Reference in New Issue