Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
🩹 UPDATE: Fix some major crashes and remove a debug skip.
Browse files Browse the repository at this point in the history
  • Loading branch information
LennyPhoenix committed Dec 2, 2020
1 parent a060c15 commit b88fefb
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 81 deletions.
47 changes: 27 additions & 20 deletions App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public override void _Ready()
UpdateMasterVolume(Settings.MasterVolume * 100);
UpdateSFXVolume(Settings.SFXVolume * 100);
UpdateMusicVolume(Settings.MusicVolume * 100);

UpdateVolume();
}

public override void _Process(float delta)
Expand All @@ -66,26 +68,7 @@ public override void _Process(float delta)
IntroAnimationPlayer.Play("Show");
}

Array sfx2D = GetTree().GetNodesInGroup("SFXAudio2D");

foreach (AudioStreamPlayer2D audioStream in sfx2D)
{
audioStream.VolumeDb = -20 + (20 * Settings.MasterVolume * Settings.SFXVolume);
}

Array sfx = GetTree().GetNodesInGroup("SFXAudio");

foreach (AudioStreamPlayer audioStream in sfx)
{
audioStream.VolumeDb = -20 + (20 * Settings.MasterVolume * Settings.SFXVolume);
}

Array music = GetTree().GetNodesInGroup("MusicAudio");

foreach (AudioStreamPlayer audioStream in music)
{
audioStream.VolumeDb = -20 + (20 * Settings.MasterVolume * Settings.MusicVolume);
}
UpdateVolume();
}

public void _OnWin()
Expand Down Expand Up @@ -175,4 +158,28 @@ public void UpdateMusicVolume(float value)
}
MusicVolumeLabel.Text = "Music Volume: " + value.ToString() + "%";
}

public void UpdateVolume()
{
Array sfx2D = GetTree().GetNodesInGroup("SFXAudio2D");

foreach (AudioStreamPlayer2D audioStream in sfx2D)
{
audioStream.VolumeDb = -50f + (50f * Settings.MasterVolume * Settings.SFXVolume);
}

Array sfx = GetTree().GetNodesInGroup("SFXAudio");

foreach (AudioStreamPlayer audioStream in sfx)
{
audioStream.VolumeDb = -50f + (50f * Settings.MasterVolume * Settings.SFXVolume);
}

Array music = GetTree().GetNodesInGroup("MusicAudio");

foreach (AudioStreamPlayer audioStream in music)
{
audioStream.VolumeDb = -50f + (50f * Settings.MasterVolume * Settings.MusicVolume);
}
}
}
2 changes: 1 addition & 1 deletion Assets/SFX/Song.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
edit/loop=true
compress/mode=0
41 changes: 20 additions & 21 deletions Source/Buildings/Turrets/Minigun.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
[ext_resource path="res://Source/Projectiles/ProjectileEmitter.tscn" type="PackedScene" id=4]
[ext_resource path="res://Assets/Buildings/Turrets/Minigun.png" type="Texture" id=5]

[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 25, 25 )

[sub_resource type="CircleShape2D" id=1]
radius = 192.0

[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 24, 24 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 25, 25 )

[sub_resource type="Animation" id=2]
resource_name = "Shoot"
[sub_resource type="Animation" id=3]
length = 0.15
step = 0.013
tracks/0/type = "value"
Expand All @@ -32,6 +28,9 @@ tracks/0/keys = {
"values": [ Vector2( 0, 0 ), Vector2( -2, 0 ), Vector2( -3, 0 ), Vector2( 0, 0 ) ]
}

[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 24, 24 )

[sub_resource type="OccluderPolygon2D" id=5]
polygon = PoolVector2Array( -23, -24, 23, -24, 23, -23, 24, -23, 24, 23, 23, 23, 23, 24, -23, 24, -23, 23, -24, 23, -24, -23, -23, -23 )

Expand All @@ -55,56 +54,56 @@ ProjectileEmitters = [ NodePath("Rotate/Top/TopEmitter"), NodePath("Rotate/Top/M
[node name="ShootTimer" parent="." index="0"]
wait_time = 0.05

[node name="HealthManager" parent="." index="3"]
MaxHealth = 300.0
Collider = SubResource( 4 )

[node name="CircleRenderer" parent="TargetArea" index="0"]
Radius = 192.0

[node name="CollisionShape2D" parent="TargetArea" index="1"]
shape = SubResource( 1 )

[node name="Sprite" parent="." index="6"]
[node name="HealthManager" parent="." index="7"]
MaxHealth = 300.0
Collider = SubResource( 2 )

[node name="Sprite" parent="." index="9"]
texture = ExtResource( 5 )
vframes = 2

[node name="CollisionShape2D" parent="." index="7"]
shape = SubResource( 3 )

[node name="Top" parent="Rotate" index="0"]
texture = ExtResource( 5 )
vframes = 2
frame = 1

[node name="AnimationPlayer" parent="Rotate/Top" index="0"]
anims/Shoot = SubResource( 2 )
anims/Shoot = SubResource( 3 )

[node name="TopEmitter" parent="Rotate/Top" index="1" instance=ExtResource( 4 )]
position = Vector2( 18, -3 )
Projectile = ExtResource( 2 )
AccuracySteps = 10
AccuracyAngle = 6
VelocityModifier = 150
AccuracySteps = 10

[node name="MiddleEmitter" parent="Rotate/Top" index="2" instance=ExtResource( 4 )]
position = Vector2( 18, 0 )
Projectile = ExtResource( 2 )
AccuracySteps = 10
AccuracyAngle = 6
VelocityModifier = 150
AccuracySteps = 10

[node name="BottomEmitter" parent="Rotate/Top" index="3" instance=ExtResource( 4 )]
position = Vector2( 18, 3 )
Projectile = ExtResource( 2 )
AccuracySteps = 10
AccuracyAngle = 6
VelocityModifier = 150
AccuracySteps = 10

[node name="LightOccluder2D" parent="." index="9"]
[node name="CollisionShape2D" parent="." index="11"]
shape = SubResource( 4 )

[node name="LightOccluder2D" parent="." index="12"]
occluder = SubResource( 5 )

[node name="Warning" parent="." index="10"]
[node name="Warning" parent="." index="13"]
scale = Vector2( 3, 3 )

[node name="InputConnection" parent="Highlights" index="0"]
Expand Down
10 changes: 5 additions & 5 deletions Source/Buildings/Turrets/Turret.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ wait_time = 0.25
IconType = 0
Root = NodePath("../Rotate")

[node name="MapWrapper" parent="." index="2"]
[node name="MapWrapper" parent="." index="5"]
AdditionalOffsetPaths = [ NodePath("../Sprite"), NodePath("../LightOccluder2D"), NodePath("../CollisionShape2D"), NodePath("../Rotate") ]

[node name="HealthManager" parent="." index="3"]
[node name="HealthManager" parent="." index="6"]
MaxHealth = 200.0

[node name="TargetArea" type="Area2D" parent="." index="4"]
[node name="TargetArea" type="Area2D" parent="." index="7"]
visible = false
monitorable = false
collision_layer = 0
Expand All @@ -44,13 +44,13 @@ Radius = 128.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="TargetArea" index="1"]
material = ExtResource( 3 )

[node name="Rotate" type="Node2D" parent="." index="8"]
[node name="Rotate" type="Node2D" parent="." index="10"]

[node name="Top" type="Sprite" parent="Rotate" index="0"]
light_mask = 2

[node name="AnimationPlayer" type="AnimationPlayer" parent="Rotate/Top" index="0"]

[node name="Warning" parent="." index="10"]
[node name="Warning" parent="." index="13"]
modulate = Color( 1, 1, 1, 0.501961 )
[connection signal="timeout" from="ShootTimer" to="." method="_OnTimeout"]
7 changes: 7 additions & 0 deletions Source/Entities/Enemies/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public async void RecalculatePath()
{
continue;
}

float dist = GlobalPosition.DistanceTo(building.GlobalPosition);

if (dist < closestDistance && !building.Deleting)
Expand All @@ -156,6 +157,12 @@ public async void RecalculatePath()
await ToSignal(GetTree().CreateTimer(0.01f), "timeout");
}

if (!IsInstanceValid(closest))
{
RecalculatePath();
return;
}

target = closest;

NavigationManager.QueueAgent(this, target.GlobalPosition, (Array<Vector2> newPath) =>
Expand Down
4 changes: 4 additions & 0 deletions Source/Entities/Enemies/FlyingEnemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public override void _Process(float delta)
{
Rotate(delta, target.GlobalPosition.AngleToPoint(GlobalPosition));
}
else
{
RecalculatePath();
}

MoveVec = new Vector2(1, 0).Rotated(RotateGroup.GlobalRotation);

Expand Down
2 changes: 1 addition & 1 deletion Source/NavigationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void _Ready()

public void QueueAgent(Node2D agent, Vector2 targetLocation, Action<Godot.Collections.Array<Vector2>> callback)
{
if (navQueue.ContainsKey(agent) && navQueue[agent].Target.Round() == targetLocation.Round())
if (navQueue.ContainsKey(agent))
{
return;
}
Expand Down
5 changes: 0 additions & 5 deletions Source/Planet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ public override void _Process(float delta)
LaunchButton.Disabled = true;
LaunchButton.SelfModulate = new Color(1, 1, 1, 0.75f);
}

if (Input.IsKeyPressed((int)KeyList.Alt))
{
Core.Items[Item.BlastiumCell]++;
}
}

if (waveStarted)
Expand Down
Loading

0 comments on commit b88fefb

Please sign in to comment.