mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 18:25:55 +00:00
Selective bullet rotation
This commit is contained in:
parent
538f4f215f
commit
5624d0178c
8 changed files with 52 additions and 10 deletions
|
|
@ -30,6 +30,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = false
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -74,6 +75,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -111,6 +113,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = false
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -148,6 +151,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = false
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -185,6 +189,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = false
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -222,6 +227,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -281,6 +287,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 0
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -326,6 +333,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -371,6 +379,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = false
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
@ -416,6 +425,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = false
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
RotateSprite = true
|
||||
Controllable = false
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
|
|
|
|||
|
|
@ -45,11 +45,10 @@ shape = SubResource("RectangleShape2D_2ewfl")
|
|||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_p2bv2")
|
||||
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||
[node name="RigidBody2D" type="StaticBody2D" parent="."]
|
||||
visible = false
|
||||
collision_layer = 64
|
||||
collision_mask = 10
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||
position = Vector2(0, -3)
|
||||
|
|
|
|||
|
|
@ -45,11 +45,10 @@ shape = SubResource("RectangleShape2D_2ewfl")
|
|||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_2gaf4")
|
||||
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||
[node name="RigidBody2D" type="StaticBody2D" parent="."]
|
||||
visible = false
|
||||
collision_layer = 64
|
||||
collision_mask = 10
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||
position = Vector2(0, -3)
|
||||
|
|
|
|||
|
|
@ -45,11 +45,10 @@ shape = SubResource("RectangleShape2D_2ewfl")
|
|||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_v070w")
|
||||
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||
[node name="RigidBody2D" type="StaticBody2D" parent="."]
|
||||
visible = false
|
||||
collision_layer = 64
|
||||
collision_mask = 10
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||
position = Vector2(0, -3)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=155 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=157 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"]
|
||||
|
|
@ -144,7 +144,7 @@ script = ExtResource("98_gvbi8")
|
|||
BulletResource = ExtResource("95_f37sa")
|
||||
bulletCount = 1
|
||||
rotationSpeed = 0.0
|
||||
_rotationOffset = 90.0
|
||||
_rotationOffset = 0.0
|
||||
duration = 1.4
|
||||
spread = 0.0
|
||||
burstInterval = 1.0
|
||||
|
|
@ -297,11 +297,39 @@ _data = {
|
|||
}
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="Resource" id="Resource_fuaed"]
|
||||
[sub_resource type="Resource" id="Resource_b57kd"]
|
||||
script = ExtResource("99_j6vrf")
|
||||
Patterns = Array[Object]([SubResource("Resource_xhinl")])
|
||||
metadata/_custom_type_script = "uid://bngko08ho85p6"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_mgwgx"]
|
||||
script = ExtResource("98_gvbi8")
|
||||
BulletResource = ExtResource("95_f37sa")
|
||||
bulletCount = 1
|
||||
rotationSpeed = 0.0
|
||||
_rotationOffset = 90.0
|
||||
duration = 1.4
|
||||
spread = 0.0
|
||||
burstInterval = 1.0
|
||||
ShotsPerBurst = 1
|
||||
BurstRate = 0.8
|
||||
_targetPlayer = false
|
||||
OverrideOwner = true
|
||||
Owner = 0
|
||||
OverrideDamageType = false
|
||||
DamageType = 0
|
||||
OverrideControllable = false
|
||||
Controllable = false
|
||||
OverrideCreationModifier = false
|
||||
TimeModifiers = Array[ExtResource("44_j86ly")]([])
|
||||
WaitForCompletion = true
|
||||
metadata/_custom_type_script = "uid://c0ndqalsc4jve"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_fuaed"]
|
||||
script = ExtResource("99_j6vrf")
|
||||
Patterns = Array[Object]([SubResource("Resource_mgwgx")])
|
||||
metadata/_custom_type_script = "uid://bngko08ho85p6"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_l476f"]
|
||||
script = ExtResource("45_emjoj")
|
||||
ActivationType = 5
|
||||
|
|
@ -1358,7 +1386,7 @@ ActivationType = 1
|
|||
[node name="InvisibleBulletEmitter" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("96_ygp23")]
|
||||
position = Vector2(-715, 56)
|
||||
rotation = -1.5708
|
||||
Script = SubResource("Resource_f37sa")
|
||||
Script = SubResource("Resource_b57kd")
|
||||
|
||||
[node name="InvisibleBulletEmitter2" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("96_ygp23")]
|
||||
position = Vector2(-2136, -227)
|
||||
|
|
|
|||
|
|
@ -117,16 +117,19 @@ public partial class Bullet : Area2D
|
|||
//SetRotationDegrees(RotationDegrees + degrees);
|
||||
float radians = Mathf.DegToRad(degrees);
|
||||
_direction = _direction.Rotated(radians).Normalized(); // Rotate direction
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotation(Rotation + radians);
|
||||
}
|
||||
|
||||
public virtual void RotateSpriteDegrees(float degrees)
|
||||
{
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotationDegrees(RotationDegrees + degrees);
|
||||
}
|
||||
|
||||
public virtual void RotateSprite(float radians)
|
||||
{
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotation(Rotation + radians);
|
||||
}
|
||||
|
||||
|
|
@ -156,6 +159,7 @@ public partial class Bullet : Area2D
|
|||
|
||||
_direction = normalized;
|
||||
|
||||
if (!BulletInfo.RotateSprite) return;
|
||||
SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2);
|
||||
|
||||
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ public class BulletInfo
|
|||
public float RotationOffset { get; set; }
|
||||
//public double Time { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public bool RotateSprite { get; set; } = false;
|
||||
public bool Controllabe { get; set; } = false;
|
||||
public PackedScene BulletScene { get; set; }
|
||||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public partial class BulletResource : Resource
|
|||
[Export] public bool DestroyOnCollision = true;
|
||||
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
[Export] public bool RotateSprite = false;
|
||||
[Export] public bool Controllable = false;
|
||||
[Export] public bool Grazeable { get; set; } = true;
|
||||
[Export] public float GrazeValue { get; set; } = 0.2f;
|
||||
|
|
@ -45,6 +46,7 @@ public partial class BulletResource : Resource
|
|||
LifeTime = LifeTime,
|
||||
DestroyOnCollision = DestroyOnCollision,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
RotateSprite = RotateSprite,
|
||||
Controllabe = Controllable,
|
||||
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
|
||||
Grazeable = Grazeable,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue