1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 01:24:23 +00:00

Add cloud to spawn sheeps

This commit is contained in:
Lorenzo Rossi 2024-04-14 22:36:14 +02:00
parent 59498009d7
commit beb42d04ed
4 changed files with 168 additions and 4 deletions

View file

@ -16,3 +16,4 @@ func spawn():
func _ready():
if parent == null:
parent = MainGame.get_ancestor(self).get_node("SpawnedEntities")

14
entities/cloud.gd Normal file
View file

@ -0,0 +1,14 @@
extends Node2D
class_name Cloud
@onready var player = $"AnimationPlayer"
@onready var spawner = $"Spawner"
func _ready():
spawner.spawn()
var player = $"AnimationPlayer"
player.play("fade_out")
await player.animation_finished
queue_free()

123
entities/cloud.tscn Normal file
View file

@ -0,0 +1,123 @@
[gd_scene load_steps=8 format=3 uid="uid://eqb3vfbvjefp"]
[ext_resource type="Script" path="res://entities/cloud.gd" id="1_8jsek"]
[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="3_naxi5"]
[ext_resource type="PackedScene" uid="uid://cyrg770fsetyu" path="res://behaviours/spawner.tscn" id="4_0cics"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_08frh"]
[sub_resource type="Animation" id="Animation_mqmwg"]
resource_name = "fade_out"
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:modulate:r")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 1)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:modulate:g")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 1)
}
tracks/2/type = "bezier"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite:modulate:b")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 1)
}
tracks/3/type = "bezier"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Sprite:modulate:a")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"handle_modes": PackedInt32Array(0, 0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 1)
}
[sub_resource type="Animation" id="Animation_rrrnd"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite:modulate:r")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite:modulate:g")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/2/type = "bezier"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite:modulate:b")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/3/type = "bezier"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Sprite:modulate:a")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_fs8h8"]
_data = {
"RESET": SubResource("Animation_rrrnd"),
"fade_out": SubResource("Animation_mqmwg")
}
[node name="Cloud" type="Node2D"]
script = ExtResource("1_8jsek")
[node name="Sprite" type="Sprite2D" parent="."]
position = Vector2(1.90735e-06, -9.53674e-07)
scale = Vector2(64.4688, 51.1875)
texture = SubResource("PlaceholderTexture2D_08frh")
[node name="Spawner" parent="." instance=ExtResource("4_0cics")]
scene = ExtResource("3_naxi5")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_fs8h8")
}

View file

@ -1,17 +1,23 @@
[gd_scene load_steps=9 format=3 uid="uid://cxj5aud02f40j"]
[gd_scene load_steps=13 format=3 uid="uid://cxj5aud02f40j"]
[ext_resource type="Script" path="res://scenes/game/main_game.gd" id="1_wiglu"]
[ext_resource type="PackedScene" uid="uid://cyrg770fsetyu" path="res://behaviours/spawner.tscn" id="2_bx37o"]
[ext_resource type="PackedScene" uid="uid://dm068vaseh45n" path="res://scenes/game/game_camera.tscn" id="2_db5xs"]
[ext_resource type="PackedScene" uid="uid://brvbtvt4em32" path="res://behaviours/counter.tscn" id="3_p6jw3"]
[ext_resource type="PackedScene" uid="uid://eqb3vfbvjefp" path="res://entities/cloud.tscn" id="3_whlmm"]
[ext_resource type="PackedScene" uid="uid://7j1b55t8tafg" path="res://scenes/game/cursor_magnet.tscn" id="3_xbolm"]
[ext_resource type="PackedScene" uid="uid://uoxwjpmgg27a" path="res://entities/gold.tscn" id="4_eu7q4"]
[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="5_63bwb"]
[ext_resource type="Texture2D" uid="uid://dyvkvmw7wxwe5" path="res://icon.svg" id="9_8kxq4"]
[sub_resource type="TileSet" id="TileSet_g2dkm"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p1lg5"]
size = Vector2(1280, 720)
[sub_resource type="CircleShape2D" id="CircleShape2D_3du4x"]
radius = 29.14
[node name="MainGame" type="Node2D"]
script = ExtResource("1_wiglu")
@ -19,6 +25,10 @@ script = ExtResource("1_wiglu")
tile_set = SubResource("TileSet_g2dkm")
format = 2
[node name="CloudSpawner" parent="." instance=ExtResource("2_bx37o")]
position = Vector2(41.795, -60.05)
scene = ExtResource("3_whlmm")
[node name="PlayArea" type="Area2D" parent="."]
[node name="Shape" type="CollisionShape2D" parent="PlayArea"]
@ -64,7 +74,23 @@ position = Vector2(456, -7)
[node name="Sheep" parent="." instance=ExtResource("5_63bwb")]
position = Vector2(-135, -134)
[node name="Sheep2" parent="." instance=ExtResource("5_63bwb")]
position = Vector2(-462, -77)
[node name="SpawnedEntities" type="Node2D" parent="."]
[node name="Cloud" parent="." instance=ExtResource("3_whlmm")]
position = Vector2(-3, -112)
[node name="Node2D" type="Node2D" parent="."]
position = Vector2(590, 317)
scale = Vector2(11.285, 11.285)
[node name="Sprite2D" type="Sprite2D" parent="Node2D"]
scale = Vector2(0.03, 0.029)
texture = ExtResource("9_8kxq4")
[node name="Area2D" type="Area2D" parent="Node2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node2D/Area2D"]
scale = Vector2(0.0886132, 0.0886132)
shape = SubResource("CircleShape2D_3du4x")
[connection signal="mouse_entered" from="Node2D/Area2D" to="CloudSpawner" method="spawn"]