Added automated mushroom glowing
This commit is contained in:
parent
9f224b3d69
commit
cf3c8d82f1
6 changed files with 223 additions and 31 deletions
79
entities/mushroom_glow.tscn
Normal file
79
entities/mushroom_glow.tscn
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://dr3yiqpdu3iox"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/scripts/mushroom_glow.gd" id="1_erigl"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0v24ggq57237" path="res://resources/particles/smallcircle.png" id="2_o6y3e"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_urhq0"]
|
||||
resource_name = "GlowFlicker"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("InnerGlow:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(2, 2), Vector2(1.95, 1.95), Vector2(2, 2), Vector2(1.95, 1.95), Vector2(2, 2), Vector2(1.9375, 1.9375), Vector2(1.95, 1.95), Vector2(2, 2), Vector2(2.05, 2.05), Vector2(1.9875, 1.9875), Vector2(2, 2)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7ivlt"]
|
||||
_data = {
|
||||
"GlowFlicker": SubResource("Animation_urhq0")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_lk3bq"]
|
||||
resource_name = "OuterGlowPulse"
|
||||
length = 5.0
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("OuterGlow:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1, 2, 3, 3.9, 5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(2.7, 2.7), Vector2(2.8, 2.8), Vector2(2.7, 2.7), Vector2(2.8, 2.8), Vector2(2.6, 2.6), Vector2(2.7, 2.7)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vprws"]
|
||||
_data = {
|
||||
"OuterGlowPulse": SubResource("Animation_lk3bq")
|
||||
}
|
||||
|
||||
[node name="MushroomGlow" type="Node2D"]
|
||||
script = ExtResource("1_erigl")
|
||||
|
||||
[node name="GlowAnimation" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_7ivlt")
|
||||
}
|
||||
autoplay = "GlowFlicker"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_vprws")
|
||||
}
|
||||
autoplay = "OuterGlowPulse"
|
||||
|
||||
[node name="InnerGlow" type="PointLight2D" parent="."]
|
||||
scale = Vector2(2, 2)
|
||||
color = Color(0.298039, 0.772549, 0.980392, 1)
|
||||
energy = 1.95
|
||||
shadow_enabled = true
|
||||
shadow_filter = 2
|
||||
shadow_filter_smooth = 7.5
|
||||
texture = ExtResource("2_o6y3e")
|
||||
|
||||
[node name="OuterGlow" type="PointLight2D" parent="."]
|
||||
scale = Vector2(2.7, 2.7)
|
||||
color = Color(1, 0.811765, 0.235294, 1)
|
||||
energy = 0.7
|
||||
shadow_filter = 2
|
||||
shadow_filter_smooth = 7.5
|
||||
texture = ExtResource("2_o6y3e")
|
||||
23
entities/scripts/mushroom_glow.gd
Normal file
23
entities/scripts/mushroom_glow.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends Node2D
|
||||
class_name MushroomGlow
|
||||
|
||||
@onready var inner_glow : PointLight2D = $InnerGlow
|
||||
@onready var outer_glow : PointLight2D = $OuterGlow
|
||||
@onready var animation : AnimationPlayer = $GlowAnimation
|
||||
|
||||
@export var colour_name : String = "blue"
|
||||
|
||||
func _ready() -> void:
|
||||
Log.pr("And dog said let their be light...")
|
||||
Log.pr(position, global_position)
|
||||
set_light_colour(colour_name)
|
||||
animation.play("GlowFlicker")
|
||||
|
||||
|
||||
func set_light_colour(colour : String) -> void:
|
||||
if colour == "blue":
|
||||
inner_glow.color = "4cc5fa"
|
||||
outer_glow.color = "00b4ff"
|
||||
elif colour == "yellow":
|
||||
inner_glow.color = "ffcf3c"
|
||||
outer_glow.color = "ffcf3c"
|
||||
|
|
@ -3,10 +3,14 @@ class_name CustomTileMap
|
|||
|
||||
var astar : AStarGrid2D = AStarGrid2D.new()
|
||||
@onready var fog_overlay : ColorRect = $FogOverlay
|
||||
@onready var mushroom_glow_container : Node2D = $MushroomGlowContainer
|
||||
|
||||
|
||||
@onready var tilemap_size : Vector2i = get_used_rect().end - get_used_rect().position
|
||||
@onready var map_rect : Rect2i = Rect2i(Vector2i.ZERO, tilemap_size)
|
||||
|
||||
var mushroom_glow : PackedScene = load("res://entities/mushroom_glow.tscn")
|
||||
|
||||
var highlighted_tiles : Array = []
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -79,6 +83,7 @@ func _unhandled_input(event : InputEvent) -> void:
|
|||
redraw_surrounding_tiles(surrounding_cells)
|
||||
|
||||
update_passable()
|
||||
check_for_visible_gatherables()
|
||||
|
||||
# Check if the tile is already highlighted
|
||||
#if highlighted_tiles.has(tile_position):
|
||||
|
|
@ -97,6 +102,11 @@ func redraw_surrounding_tiles(positions : Array) -> void:
|
|||
set_cells_terrain_connect(0, walls, 0, 1)
|
||||
|
||||
func check_for_visible_gatherables() -> void:
|
||||
|
||||
# Remove all existing glowing lights
|
||||
for child in mushroom_glow_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
## Loop through the tiles on the gatherables layer and check if the thing on
|
||||
# the layer below them is a wall, if it is they need to be hidden.
|
||||
for i in tilemap_size.x:
|
||||
|
|
@ -107,9 +117,18 @@ func check_for_visible_gatherables() -> void:
|
|||
# Get the tile data from the base layer
|
||||
var below_tile_data : TileData = get_cell_tile_data(0, coords)
|
||||
if below_tile_data and below_tile_data.get_custom_data('navtype') == 'wall':
|
||||
Log.pr("Gatherable is on a wall tile, it should be hidden!")
|
||||
Log.pr("This is behind a wall...")
|
||||
else:
|
||||
if tile_data.get_custom_data('glowcolour'):
|
||||
var glow_colour : String = tile_data.get_custom_data('glowcolour')
|
||||
Log.pr("Glow colour: " + str(glow_colour))
|
||||
var glow : MushroomGlow = mushroom_glow.instantiate()
|
||||
glow.set_position(coords * get_tileset().tile_size + get_tileset().tile_size / 2)
|
||||
glow.colour_name = glow_colour
|
||||
mushroom_glow_container.add_child.call_deferred(glow)
|
||||
Log.pr(glow)
|
||||
# Log.pr(below_tile_data)
|
||||
#if tile_data and tile_data.get_custom_data('navtype') == 'gatherable':
|
||||
# var below_tile_data : TileData = get_cell_tile_data(0, coords + Vector2i(0, 1))
|
||||
# if below_tile_data and below_tile_data.get_custom_data('navtype') == 'wall':
|
||||
# set_cellv(coords, -1)
|
||||
# set_cellv(coords, -1)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
BIN
resources/root.png
Normal file
BIN
resources/root.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 608 B |
34
resources/root.png.import
Normal file
34
resources/root.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dugu0bnmrbc3d"
|
||||
path="res://.godot/imported/root.png-a9e375604325015c29525e06b551c927.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/root.png"
|
||||
dest_files=["res://.godot/imported/root.png-a9e375604325015c29525e06b551c927.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Loading…
Add table
Add a link
Reference in a new issue