forked from forerunnergames/energy-shot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add energy weapon spin & quit dialog.
Other: - Fix GdUnit4 failing in GitHub Actions by upgrading to the latest version.
- Loading branch information
1 parent
8b2ac35
commit 7b9e02d
Showing
21 changed files
with
403 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ jobs: | |
# identify & distinguish between multiple test report files. | ||
- name: Setup GdUnit4 and run tests | ||
# Using '@v1' won't use the latest version, so specify explicit version. | ||
uses: MikeSchulze/[email protected].1 | ||
uses: MikeSchulze/[email protected].5 | ||
with: | ||
godot-version: '4.3' | ||
godot-status: 'stable' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Godot; | ||
|
||
public partial class ConfirmationDialog2 : MarginContainer | ||
{ | ||
[Signal] public delegate void ConfirmedEventHandler(); | ||
[Signal] public delegate void CanceledEventHandler(); | ||
[Signal] public delegate void ClosedEventHandler(); | ||
private Button _okButton = null!; | ||
private Button _cancelButton = null!; | ||
private Button _closeButton = null!; | ||
|
||
public override void _Ready() | ||
{ | ||
_okButton = GetNode <Button> ("VBoxContainer/MarginContainer/HBoxContainer/OkButton"); | ||
_cancelButton = GetNode <Button> ("VBoxContainer/MarginContainer/HBoxContainer/CancelButton"); | ||
_closeButton = GetNode <Button> ("VBoxContainer/Title/HBoxContainer/VBoxContainer/CloseButton"); | ||
|
||
_okButton.Pressed += () => | ||
{ | ||
Hide(); | ||
EmitSignal (SignalName.Confirmed); | ||
}; | ||
|
||
_cancelButton.Pressed += () => | ||
{ | ||
Hide(); | ||
EmitSignal (SignalName.Canceled); | ||
}; | ||
|
||
_closeButton.Pressed += () => | ||
{ | ||
Hide(); | ||
EmitSignal (SignalName.Closed); | ||
}; | ||
|
||
Hide(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://bmpjrf8pqokyu"] | ||
|
||
[ext_resource type="Script" path="res://ConfirmationDialog2.cs" id="1_yhsco"] | ||
|
||
[node name="ConfirmationDialog2" type="MarginContainer"] | ||
anchors_preset = 8 | ||
anchor_left = 0.5 | ||
anchor_top = 0.5 | ||
anchor_right = 0.5 | ||
anchor_bottom = 0.5 | ||
offset_left = -600.0 | ||
offset_top = -300.0 | ||
offset_right = 600.0 | ||
offset_bottom = 300.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
script = ExtResource("1_yhsco") | ||
|
||
[node name="Panel" type="Panel" parent="."] | ||
layout_mode = 2 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="."] | ||
layout_mode = 2 | ||
|
||
[node name="Title" type="MarginContainer" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="VBoxContainer/Title"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 100 | ||
text = "Quit Game?" | ||
horizontal_alignment = 1 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Title"] | ||
layout_mode = 2 | ||
alignment = 2 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Title/HBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="CloseButton" type="Button" parent="VBoxContainer/Title/HBoxContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_colors/font_color = Color(1, 1, 1, 1) | ||
theme_override_font_sizes/font_size = 50 | ||
text = " X " | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
size_flags_vertical = 3 | ||
theme_override_constants/margin_top = 300 | ||
theme_override_constants/margin_bottom = 50 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer"] | ||
layout_mode = 2 | ||
theme_override_constants/separation = 500 | ||
alignment = 1 | ||
|
||
[node name="CancelButton" type="Button" parent="VBoxContainer/MarginContainer/HBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 50 | ||
text = " CANCEL " | ||
|
||
[node name="OkButton" type="Button" parent="VBoxContainer/MarginContainer/HBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 50 | ||
text = " OK " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Godot; | ||
|
||
public partial class EnergyWeapon : Node3D | ||
{ | ||
[Export] public float MinRotationSpeed = 1.0f; | ||
[Export] public float MaxRotationSpeed = 15.0f; | ||
[Signal] public delegate void ShotEventHandler(); | ||
public float CurrentRotationSpeed { get; private set; } | ||
public bool IsShooting { get; private set; } | ||
private AudioStreamPlayer3D _shootingSound = null!; | ||
private Node3D _muzzle = null!; | ||
private Node3D _pivot = null!; | ||
private Tween? _tween; | ||
public override void _PhysicsProcess (double delta) => _pivot.Rotate (Vector3.Right, CurrentRotationSpeed * (float)delta); | ||
public void Shoot() => SpinUp(); | ||
|
||
public override void _Ready() | ||
{ | ||
_muzzle = GetNode <Node3D> ("Pivot/Muzzle"); | ||
_pivot = GetNode <Node3D> ("Pivot"); | ||
_shootingSound = GetNode <AudioStreamPlayer3D> ("ShootingSound"); | ||
CurrentRotationSpeed = MinRotationSpeed; | ||
} | ||
|
||
private void SpinUp() | ||
{ | ||
IsShooting = true; | ||
_tween?.Kill(); | ||
_tween = CreateTween(); | ||
_tween.TweenProperty (this, "CurrentRotationSpeed", MaxRotationSpeed, 2.0f).SetTrans (Tween.TransitionType.Quad).SetEase (Tween.EaseType.Out); | ||
_tween.Finished += FireShot; | ||
} | ||
|
||
private void FireShot() | ||
{ | ||
_shootingSound.Play(); | ||
EmitSignal (SignalName.Shot); | ||
SpinDown(); | ||
} | ||
|
||
private void SpinDown() | ||
{ | ||
_tween?.Kill(); | ||
_tween = CreateTween(); | ||
_tween.TweenProperty (this, "CurrentRotationSpeed", MinRotationSpeed, 2.0f).SetTrans (Tween.TransitionType.Quad).SetEase (Tween.EaseType.Out); | ||
_tween.Finished += () => IsShooting = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.