Sun scoring and zombie hat impulse
This commit is contained in:
parent
0e5dee50f7
commit
6608fb8389
9 changed files with 62 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
11
scripts/components/gui/SunCounterImage.cs
Normal file
11
scripts/components/gui/SunCounterImage.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using Godot;
|
||||
using Newlon;
|
||||
using System;
|
||||
|
||||
public partial class SunCounterImage : Control
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Sun.Counter = this;
|
||||
}
|
||||
}
|
||||
1
scripts/components/gui/SunCounterImage.cs.uid
Normal file
1
scripts/components/gui/SunCounterImage.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0ekxnoq6cyt4
|
||||
|
|
@ -33,6 +33,7 @@ public partial class RuntimeLevelData : Node
|
|||
{
|
||||
SunCount += amount;
|
||||
}
|
||||
|
||||
public void SpendSun(int amount)
|
||||
{
|
||||
SunCount -= amount;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue