diff --git a/scenes/entities/Zombies/cone_zombie.tscn b/scenes/entities/Zombies/cone_zombie.tscn index 9ef48fe..e7d2b35 100644 --- a/scenes/entities/Zombies/cone_zombie.tscn +++ b/scenes/entities/Zombies/cone_zombie.tscn @@ -45,6 +45,10 @@ freeze = true script = ExtResource("3_w70im") data = NodePath("../..") deathTimer = NodePath("Timer") +falloffImpulseMin = Vector2(0, 1) +falloffImpulseMax = Vector2(1, 0) +falloffOffsetMin = Vector2(1, 0) +Impulse = 100.0 [node name="Sprite" type="Sprite2D" parent="CanvasGroup/Hat" index="0"] position = Vector2(-1, -12) diff --git a/scenes/gui/sun_counter.tscn b/scenes/gui/sun_counter.tscn index d876cff..c22cf10 100644 --- a/scenes/gui/sun_counter.tscn +++ b/scenes/gui/sun_counter.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://ky35veswaytr"] +[gd_scene load_steps=7 format=3 uid="uid://ky35veswaytr"] [ext_resource type="Texture2D" uid="uid://bhp3vuvwf7lak" path="res://assets/sprites/gui/suncounter.tres" id="1_e5x4k"] [ext_resource type="Theme" uid="uid://b8l285cjcgeyi" path="res://resources/themes/GameStyle.tres" id="1_vhhcn"] [ext_resource type="Texture2D" uid="uid://c47rflkf2wap0" path="res://assets/sprites/sun.tres" id="2_gugre"] [ext_resource type="Script" uid="uid://dwxohya1exdkh" path="res://scripts/components/gui/SunCounter.cs" id="3_qhmb8"] +[ext_resource type="Script" uid="uid://0ekxnoq6cyt4" path="res://scripts/components/gui/SunCounterImage.cs" id="4_c68ge"] [sub_resource type="LabelSettings" id="LabelSettings_lxkq5"] font_size = 10 @@ -31,7 +32,9 @@ offset_left = -22.5 offset_top = -22.513 offset_right = 22.5 offset_bottom = 22.487 +pivot_offset = Vector2(23, 22) texture = ExtResource("2_gugre") +script = ExtResource("4_c68ge") [node name="Label" type="Label" parent="."] process_mode = 3 diff --git a/scenes/prototype_survival.tscn b/scenes/prototype_survival.tscn index b7918b5..d7922b2 100644 --- a/scenes/prototype_survival.tscn +++ b/scenes/prototype_survival.tscn @@ -164,6 +164,10 @@ collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Lines/Floor5"] shape = SubResource("WorldBoundaryShape2D_3ghv7") +[node name="Marker2D" type="Marker2D" parent="."] +position = Vector2(191, 5) +gizmo_extents = 601.6 + [connection signal="timeout" from="SunSpawner/Timer" to="SunSpawner" method="Spawn"] [connection signal="timeout" from="ZombieSequencer/Timer" to="ZombieSequencer" method="FormSquad"] [connection signal="timeout" from="SurvivalAI/Timer" to="SurvivalAI" method="SummonWave"] diff --git a/scenes/sun.tscn b/scenes/sun.tscn index f39a8ac..9c51759 100644 --- a/scenes/sun.tscn +++ b/scenes/sun.tscn @@ -157,7 +157,7 @@ libraries = { shape = SubResource("CircleShape2D_7hl7x") [node name="DeathTimer" type="Timer" parent="."] -wait_time = 30.0 +wait_time = 22.0 one_shot = true autostart = true diff --git a/scripts/Sun.cs b/scripts/Sun.cs index ef3053a..d5b341e 100644 --- a/scripts/Sun.cs +++ b/scripts/Sun.cs @@ -6,27 +6,44 @@ namespace Newlon; public partial class Sun : Area2D { + public static Control Counter; + [Export] public int amount = 25; [Export] private Timer _deathTimer; [Export] private AnimationPlayer _rotation; [Export] private AnimationPlayer _fade; + private bool scoring; + public override void _Ready() { _rotation.SpeedScale = 1.0f + GD.Randf() / 2.0f; } public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx) { + if (scoring) return; + if (@event.IsActionPressed("primary_action")) { - RuntimeLevelData.Instance.AddSun(amount); - QueueFree(); + + _fade.Stop(); + scoring = true; + + var tween = CreateTween(); + tween.TweenInterval(0.1); + tween.TweenProperty(this, "global_position", GetCanvasTransform().AffineInverse() * (Counter.GlobalPosition + Counter.PivotOffset), 0.5).SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out); + tween.TweenCallback(Callable.From(() => + { + RuntimeLevelData.Instance.AddSun(amount); + QueueFree(); + })); } } public override void _Process(double delta) { - if (_deathTimer.TimeLeft/_deathTimer.WaitTime <= 0.25) + if (scoring) return; + if (_deathTimer.TimeLeft / _deathTimer.WaitTime <= 0.25) { _fade.Play("main"); } diff --git a/scripts/components/gui/SunCounterImage.cs b/scripts/components/gui/SunCounterImage.cs new file mode 100644 index 0000000..ecb6288 --- /dev/null +++ b/scripts/components/gui/SunCounterImage.cs @@ -0,0 +1,11 @@ +using Godot; +using Newlon; +using System; + +public partial class SunCounterImage : Control +{ + public override void _Ready() + { + Sun.Counter = this; + } +} diff --git a/scripts/components/gui/SunCounterImage.cs.uid b/scripts/components/gui/SunCounterImage.cs.uid new file mode 100644 index 0000000..c05e487 --- /dev/null +++ b/scripts/components/gui/SunCounterImage.cs.uid @@ -0,0 +1 @@ +uid://0ekxnoq6cyt4 diff --git a/scripts/components/level/RuntimeLevelData.cs b/scripts/components/level/RuntimeLevelData.cs index 04f2b44..6234d4f 100644 --- a/scripts/components/level/RuntimeLevelData.cs +++ b/scripts/components/level/RuntimeLevelData.cs @@ -33,6 +33,7 @@ public partial class RuntimeLevelData : Node { SunCount += amount; } + public void SpendSun(int amount) { SunCount -= amount; diff --git a/scripts/components/particles/FallParticle.cs b/scripts/components/particles/FallParticle.cs index b8598e1..1770bed 100644 --- a/scripts/components/particles/FallParticle.cs +++ b/scripts/components/particles/FallParticle.cs @@ -1,12 +1,16 @@ using Godot; using Newlon.Components.Level; using Newlon.Components.Zombies; -using System; public partial class FallParticle : RigidBody2D { [Export] private RuntimeZombieData data; [Export] private Timer deathTimer; + [Export] private Vector2 falloffImpulseMin = Vector2.Zero; + [Export] private Vector2 falloffImpulseMax = Vector2.Zero; + [Export] private Vector2 falloffOffsetMin = Vector2.Zero; + [Export] private Vector2 falloffOffsetMax = Vector2.Zero; + [Export] private float Impulse; public void FallOff() { SetDeferred("freeze", false); @@ -14,7 +18,17 @@ public partial class FallParticle : RigidBody2D { AddCollisionExceptionWith(floor); } - Callable.From(()=>{ Reparent(PoolContainer.Instance.Zombies); }).CallDeferred(); + Callable.From(() => + { + Reparent(PoolContainer.Instance.Zombies); + ApplyImpulse(RandomVector(falloffImpulseMin, falloffImpulseMax).Normalized() * Impulse, RandomVector(falloffOffsetMin, falloffOffsetMax)); + }).CallDeferred(); + deathTimer.Start(); } + + private Vector2 RandomVector(Vector2 min, Vector2 max) + { + return new Vector2((float)GD.RandRange(min.X,max.X),(float)GD.RandRange(min.Y,max.Y)); + } }