Coin Spawner tweaks, grid-free movement on island
parent
626238ddbe
commit
d7049b43ed
|
@ -2,15 +2,15 @@
|
|||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-9e2c68854eff2ba15efab32e39b37c44.stex"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/gdhexgrid/icon.png"
|
||||
dest_files=[ "res://.import/icon.png-9e2c68854eff2ba15efab32e39b37c44.stex" ]
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
|||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
|
|
|
@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
|||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:zoom="1.979899"
|
||||
inkscape:cx="193.12383"
|
||||
inkscape:cy="-78.795116"
|
||||
inkscape:cy="128.13748"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
|
@ -49,7 +49,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
@ -119,7 +119,7 @@
|
|||
sodipodi:nodetypes="cc" />
|
||||
<g
|
||||
id="g2020"
|
||||
transform="matrix(0.7487091,0,0,0.7487091,22.654087,15.131824)">
|
||||
transform="matrix(0.7487091,0,0,0.7487091,22.011525,15.311364)">
|
||||
<rect
|
||||
y="60.764866"
|
||||
x="34.11235"
|
||||
|
@ -150,5 +150,54 @@
|
|||
id="path1969"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccccccccc" />
|
||||
<ellipse
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#241c1c;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
||||
id="path891"
|
||||
cx="71.115189"
|
||||
cy="57.663963"
|
||||
rx="4.9444861"
|
||||
ry="7.4835467" />
|
||||
<ellipse
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#241c1c;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
||||
id="path893"
|
||||
cx="70.914734"
|
||||
cy="46.973183"
|
||||
rx="3.4076865"
|
||||
ry="4.4099469" />
|
||||
<path
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#241c1c;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
||||
d="m 76.576478,56.227926 c 0.974202,3.635771 0.665907,6.877365 -0.688596,7.240302 -1.354503,0.362937 -3.24229,-2.290218 -4.216492,-5.925988 -0.974202,-3.635771 -0.665907,-6.877365 0.688596,-7.240302 1.354503,-0.362937 3.24229,2.290218 4.216492,5.925988 z"
|
||||
id="path895"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="sssss" />
|
||||
<path
|
||||
style="fill:#ffff00;fill-rule:evenodd;stroke:#c0be08;stroke-width:0.59500003;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 67.774315,45.866354 c 0,0 -2.666291,1.274117 -3.073598,2.53906 -0.268239,0.833048 0.668174,2.539061 0.668174,2.539061 l 1.202713,-1.469983 2.004521,-0.400904 z"
|
||||
id="path897"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cscccc" />
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
||||
id="path899"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="-70.017845"
|
||||
sodipodi:cy="-46.00531"
|
||||
sodipodi:rx="1.0151163"
|
||||
sodipodi:ry="1.603617"
|
||||
sodipodi:start="0"
|
||||
sodipodi:end="6.2530804"
|
||||
d="m -69.002729,-46.00531 a 1.0151163,1.603617 0 0 1 -1.007476,1.603571 1.0151163,1.603617 0 0 1 -1.022641,-1.579434 1.0151163,1.603617 0 0 1 0.992083,-1.627345 1.0151163,1.603617 0 0 1 1.037574,1.554938 l -1.014656,0.04827 z"
|
||||
transform="scale(-1)" />
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:0.28627451;stroke:#000000;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path901"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="69.808182"
|
||||
sodipodi:cy="46.459103"
|
||||
sodipodi:rx="0.20966499"
|
||||
sodipodi:ry="0.45379427"
|
||||
sodipodi:start="0"
|
||||
sodipodi:end="6.2530784"
|
||||
d="m 70.017847,46.459103 a 0.20966499,0.45379427 0 0 1 -0.208087,0.453781 0.20966499,0.45379427 0 0 1 -0.211219,-0.44695 0.20966499,0.45379427 0 0 1 0.204907,-0.46051 0.20966499,0.45379427 0 0 1 0.214304,0.440018 l -0.20957,0.01366 z" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
|||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
|
|
|
@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
|||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
|
|
|
@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
|||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
|
|
|
@ -5,7 +5,7 @@ onready var Coin = preload("./Coin.tscn")
|
|||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
var coin_spread = 50
|
||||
var coin_spread = 100
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
@ -17,7 +17,8 @@ func _ready():
|
|||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
func emit_coins (num, _position = null):
|
||||
func create_coins (num, _position = null):
|
||||
var result = []
|
||||
for i in range (num):
|
||||
var coin = Coin.instance()
|
||||
|
||||
|
@ -25,10 +26,12 @@ func emit_coins (num, _position = null):
|
|||
if _position != null:
|
||||
coin.position = _position
|
||||
|
||||
coin.velocity = Vector2 (rand_range(-coin_spread, coin_spread), rand_range (-coin_spread, coin_spread))
|
||||
coin.velocity = Vector2 (2 * rand_range(-coin_spread, coin_spread), rand_range (-coin_spread, coin_spread))
|
||||
coin.z_pos = 0
|
||||
coin.z_vel = rand_range(300, 800)
|
||||
add_child(coin)
|
||||
result.push_back(coin)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
|
@ -37,4 +40,6 @@ func _unhandled_input(event):
|
|||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and event.pressed:
|
||||
emit_coins(25, relative_pos)
|
||||
var coins = create_coins(25, relative_pos)
|
||||
for coin in coins:
|
||||
add_child(coin)
|
||||
|
|
|
@ -186,6 +186,7 @@ script = ExtResource( 2 )
|
|||
z_index = -1
|
||||
|
||||
[node name="GridHighlight" type="Node2D" parent="World"]
|
||||
visible = false
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="World"]
|
||||
|
|
|
@ -543,7 +543,10 @@ func update_navigation_target_island(start_world: Vector2, target_world: Vector2
|
|||
player_navigation_path.append(target_world_coord)
|
||||
|
||||
|
||||
func update_player_navigation_target(target_world: Vector2):
|
||||
func update_player_navigation_target(mouse_pos: Vector2):
|
||||
var target_tile = Globals.HexGrid.get_hex_center(Globals.ScreenToHex(mouse_pos, WorldCamera))
|
||||
var target_world = Globals.ScreenToWorld(mouse_pos, WorldCamera)
|
||||
|
||||
var start_world = PlayerChar.transform.origin
|
||||
|
||||
player_navigation_path = []
|
||||
|
@ -553,13 +556,16 @@ func update_player_navigation_target(target_world: Vector2):
|
|||
var player_near_anchor = check_player_near_anchor()
|
||||
|
||||
if current_island != null:
|
||||
update_navigation_target_island(start_world, target_world)
|
||||
update_navigation_target_island(start_world, target_tile)
|
||||
if current_island.get_tile_by_world_coord(target_tile) != null:
|
||||
player_navigation_path.append(target_world)
|
||||
|
||||
if len(player_navigation_path) == 0 and player_near_anchor:
|
||||
start_world = Globals.HexToWorld(anchor_tile)
|
||||
|
||||
if current_island == null or (len(player_navigation_path) == 0 and player_near_anchor):
|
||||
update_navigation_target_ocean(start_world, target_world)
|
||||
update_navigation_target_ocean(start_world, target_tile)
|
||||
player_navigation_path.append(target_world)
|
||||
|
||||
var planning_duration_msec = OS.get_system_time_msecs() - start_timestamp
|
||||
|
||||
|
@ -580,7 +586,7 @@ func handle_game_event(event):
|
|||
if event is InputEventMouseButton:
|
||||
# Move main character
|
||||
if event.pressed and event.button_index == BUTTON_LEFT:
|
||||
update_player_navigation_target (Globals.HexGrid.get_hex_center(Globals.ScreenToHex(get_global_mouse_position(), WorldCamera)))
|
||||
update_player_navigation_target (get_global_mouse_position())
|
||||
|
||||
return false
|
||||
|
||||
|
|
Loading…
Reference in New Issue