mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-15 21:23:47 +00:00
Cheat Gun
This commit is contained in:
parent
f2e6025b35
commit
cb27f33a6d
21 changed files with 620 additions and 436 deletions
|
|
@ -1,8 +1,16 @@
|
||||||
[gd_resource type="Resource" script_class="BossPhase" load_steps=5 format=3 uid="uid://da1vjfavqs7u2"]
|
[gd_resource type="Resource" script_class="BossPhase" load_steps=7 format=3 uid="uid://da1vjfavqs7u2"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c034favdy56p0" path="res://Scenes/Weapons/Bullets/enemyBullet_star_yellow.tscn" id="1_0bb8a"]
|
[ext_resource type="PackedScene" uid="uid://c034favdy56p0" path="res://Scenes/Weapons/Bullets/enemyBullet_star_yellow.tscn" id="1_0bb8a"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="1_7asq8"]
|
[ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="1_7asq8"]
|
||||||
[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="1_ys2v3"]
|
[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="1_ys2v3"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Resources/Modifiers/DelayedContinuousRotationModifier.cs" id="2_t0hje"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_n6wfp"]
|
||||||
|
script = ExtResource("2_t0hje")
|
||||||
|
TimeInSeconds = 0.0
|
||||||
|
ModifierType = 0
|
||||||
|
Value = 80.0
|
||||||
|
Continuous = false
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_q4pcc"]
|
[sub_resource type="Resource" id="Resource_q4pcc"]
|
||||||
script = ExtResource("1_ys2v3")
|
script = ExtResource("1_ys2v3")
|
||||||
|
|
@ -17,7 +25,7 @@ spread = 360.0
|
||||||
owner = 2
|
owner = 2
|
||||||
_damageType = 0
|
_damageType = 0
|
||||||
_bulletDamage = 1.0
|
_bulletDamage = 1.0
|
||||||
_timeModifiers = null
|
_timeModifiers = Array[Object]([SubResource("Resource_n6wfp")])
|
||||||
_targetPlayer = false
|
_targetPlayer = false
|
||||||
WaitForCompletion = true
|
WaitForCompletion = true
|
||||||
|
|
||||||
|
|
|
||||||
14
Resources/Bullets/cheat_bullet.tres
Normal file
14
Resources/Bullets/cheat_bullet.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://bopwqpmxoy1rd"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_i4nah"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="2_dbvc7"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_dbvc7")
|
||||||
|
BulletScene = ExtResource("1_i4nah")
|
||||||
|
BulletSpeed = 100.0
|
||||||
|
BulletDamage = 50.0
|
||||||
|
LifeTime = 10.0
|
||||||
|
Owner = 1
|
||||||
|
DamageType = 0
|
||||||
|
TimeModifiers = null
|
||||||
18
Resources/Items/Cheat_Gun_Item.tres
Normal file
18
Resources/Items/Cheat_Gun_Item.tres
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cfq121rs3bsu8"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://pemr2lrv3ylk" path="res://Scenes/HUD/Items/ying_yang_gun_huditem.tscn" id="1_i6xgq"]
|
||||||
|
[ext_resource type="Resource" uid="uid://ckppo2seg313h" path="res://Resources/Weapons/Cheat_Gun.tres" id="2_0na1t"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="3_i0e51"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_i0e51")
|
||||||
|
ItemName = "Cheat Gun"
|
||||||
|
ItemKey = "CheatGun"
|
||||||
|
Item = 9
|
||||||
|
WeaponData = ExtResource("2_0na1t")
|
||||||
|
Amount = 1
|
||||||
|
Max = 1
|
||||||
|
PickupIfMaxed = true
|
||||||
|
ConsumeOnUse = false
|
||||||
|
UiType = 1
|
||||||
|
HudItemScene = ExtResource("1_i6xgq")
|
||||||
19
Resources/Weapons/Cheat_Gun.tres
Normal file
19
Resources/Weapons/Cheat_Gun.tres
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://ckppo2seg313h"]
|
||||||
|
|
||||||
|
[ext_resource type="Resource" uid="uid://bopwqpmxoy1rd" path="res://Resources/Bullets/cheat_bullet.tres" id="1_7fekn"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="1_d3tbp"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_d3tbp")
|
||||||
|
Name = "Cheat Gun"
|
||||||
|
BulletData = ExtResource("1_7fekn")
|
||||||
|
RateOfFire = 0.4
|
||||||
|
BulletCapacity = 200
|
||||||
|
ReloadTime = 0.1
|
||||||
|
AutoReload = true
|
||||||
|
InfiniteAmmo = true
|
||||||
|
BulletsPerShot = 1
|
||||||
|
SpreadAngle = 0.0
|
||||||
|
RandomSpread = 0.0
|
||||||
|
AmmoKey = ""
|
||||||
|
_rotationOffset = 0.0
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=5 format=3 uid="uid://b8apu0l5fm4k"]
|
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://b8apu0l5fm4k"]
|
||||||
|
|
||||||
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_85ef1"]
|
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_85ef1"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_yby7n"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dfbmny3s4rili" path="res://Scenes/Particles/IceBulletParticle.tscn" id="2_icuny"]
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"]
|
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_m8dps")
|
script = ExtResource("2_m8dps")
|
||||||
Name = "Icicle Gun"
|
Name = "Icicle Gun"
|
||||||
BulletData = ExtResource("1_85ef1")
|
BulletData = ExtResource("1_85ef1")
|
||||||
BulletScene = ExtResource("1_yby7n")
|
|
||||||
DestructionParticlesScene = ExtResource("2_icuny")
|
|
||||||
RateOfFire = 0.1
|
RateOfFire = 0.1
|
||||||
BulletCapacity = 4
|
BulletCapacity = 4
|
||||||
ReloadTime = 0.2
|
ReloadTime = 0.2
|
||||||
|
|
@ -20,10 +16,4 @@ BulletsPerShot = 1
|
||||||
SpreadAngle = 0.0
|
SpreadAngle = 0.0
|
||||||
RandomSpread = 0.0
|
RandomSpread = 0.0
|
||||||
AmmoKey = ""
|
AmmoKey = ""
|
||||||
BulletSpeed = 300.0
|
|
||||||
BulletDamage = 1.0
|
|
||||||
LifeTime = 10.0
|
|
||||||
_rotationOffset = 0.0
|
_rotationOffset = 0.0
|
||||||
owner = 1
|
|
||||||
_damageType = 0
|
|
||||||
_timeModifiers = null
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ public partial class Barrel : Area2D, IDestructible
|
||||||
[Export] public PackedScene ExplosionParticles { get; set; }
|
[Export] public PackedScene ExplosionParticles { get; set; }
|
||||||
[Export] public BulletResource ExplosionData { get; set; }
|
[Export] public BulletResource ExplosionData { get; set; }
|
||||||
|
|
||||||
|
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.None;
|
||||||
|
|
||||||
private GameManager _gameManager;
|
private GameManager _gameManager;
|
||||||
|
|
||||||
private float _currentHealth = 0f;
|
private float _currentHealth = 0f;
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ func smooth_damp(current: float, target: float, current_velocity: float, smooth_
|
||||||
return [output, current_velocity]
|
return [output, current_velocity]
|
||||||
|
|
||||||
func _unhandled_input(_event: InputEvent) -> void:
|
func _unhandled_input(_event: InputEvent) -> void:
|
||||||
if Input.is_key_pressed(KEY_1):
|
if Input.is_action_just_pressed("debug_camera_1"):
|
||||||
pixel_snap = not pixel_snap
|
pixel_snap = not pixel_snap
|
||||||
print("Camera pixel snap: ", pixel_snap)
|
print("Camera pixel snap: ", pixel_snap)
|
||||||
if Input.is_key_pressed(KEY_2):
|
if Input.is_action_just_pressed("debug_camera_2"):
|
||||||
enable_smoothing = not enable_smoothing
|
enable_smoothing = not enable_smoothing
|
||||||
print("Camera smoothing: ", enable_smoothing)
|
print("Camera smoothing: ", enable_smoothing)
|
||||||
|
|
||||||
|
|
|
||||||
7
Scenes/HUD/Items/ying_yang_gun_huditem.tscn
Normal file
7
Scenes/HUD/Items/ying_yang_gun_huditem.tscn
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://pemr2lrv3ylk"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://61kfxc7k3do" path="res://Sprites/Items/Ying_Yang_Gun.png" id="1_l8amd"]
|
||||||
|
|
||||||
|
[node name="YingYangGun" type="TextureRect"]
|
||||||
|
texture = ExtResource("1_l8amd")
|
||||||
|
stretch_mode = 2
|
||||||
19
Scenes/Items/Cheat_Gun_Pickup.tscn
Normal file
19
Scenes/Items/Cheat_Gun_Pickup.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://4q82gggqax87"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Interactables/ItemPickup.cs" id="1_vx8ix"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cfq121rs3bsu8" path="res://Resources/Items/Cheat_Gun_Item.tres" id="2_si1ac"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://61kfxc7k3do" path="res://Sprites/Items/Ying_Yang_Gun.png" id="4_pj6iu"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jtwy2"]
|
||||||
|
|
||||||
|
[node name="CheaetGun" type="Area2D" groups=["Interactable"]]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
|
script = ExtResource("1_vx8ix")
|
||||||
|
LootTable = [ExtResource("2_si1ac")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("4_pj6iu")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_jtwy2")
|
||||||
19
Scenes/Items/Ice_Shotgun_Pickup.tscn
Normal file
19
Scenes/Items/Ice_Shotgun_Pickup.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://ddwcib46ttlrp"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Interactables/ItemPickup.cs" id="1_gpoff"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dau0s8ob7qnpc" path="res://Resources/Items/IceShotgun.tres" id="2_l5f4t"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b46usr10jhmev" path="res://Sprites/Items/Ice_Shotgun.png" id="3_w7kfy"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jtwy2"]
|
||||||
|
|
||||||
|
[node name="IceShotgun" type="Area2D" groups=["Interactable"]]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
|
script = ExtResource("1_gpoff")
|
||||||
|
LootTable = [ExtResource("2_l5f4t")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("3_w7kfy")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_jtwy2")
|
||||||
|
|
@ -6,7 +6,9 @@
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jtwy2"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jtwy2"]
|
||||||
|
|
||||||
[node name="IcicleGun" type="Area2D"]
|
[node name="IcicleGun" type="Area2D" groups=["Interactable"]]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
script = ExtResource("1_rdvi1")
|
script = ExtResource("1_rdvi1")
|
||||||
LootTable = [ExtResource("2_6qt07")]
|
LootTable = [ExtResource("2_6qt07")]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,10 @@
|
||||||
radius = 4.0
|
radius = 4.0
|
||||||
|
|
||||||
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||||
collision_layer = 128
|
collision_layer = 136
|
||||||
collision_mask = 71
|
collision_mask = 87
|
||||||
script = ExtResource("1_w5w28")
|
script = ExtResource("1_w5w28")
|
||||||
Speed = 200.0
|
Speed = 200.0
|
||||||
Owner = 2
|
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ collision_layer = 8
|
||||||
collision_mask = 85
|
collision_mask = 85
|
||||||
script = ExtResource("1_jvxw3")
|
script = ExtResource("1_jvxw3")
|
||||||
Speed = 200.0
|
Speed = 200.0
|
||||||
Owner = 1
|
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -9,8 +9,7 @@ using Cirno.Scripts.Resources;
|
||||||
|
|
||||||
public partial class Bullet : Area2D
|
public partial class Bullet : Area2D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export] public float Speed = 1900f;
|
||||||
public float Speed = 1900f;
|
|
||||||
|
|
||||||
public BulletOwner BulletOwner => _bulletInfo?.Owner ?? BulletOwner.None;
|
public BulletOwner BulletOwner => _bulletInfo?.Owner ?? BulletOwner.None;
|
||||||
|
|
||||||
|
|
@ -45,7 +44,6 @@ public partial class Bullet : Area2D
|
||||||
|
|
||||||
// Ugly hack to make instances unique
|
// Ugly hack to make instances unique
|
||||||
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
|
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyTimeModifiers(double delta)
|
private void ApplyTimeModifiers(double delta)
|
||||||
|
|
@ -93,6 +91,16 @@ public partial class Bullet : Area2D
|
||||||
//Rotation = radians;
|
//Rotation = radians;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void RotateSpriteDegrees(float degrees)
|
||||||
|
{
|
||||||
|
SetRotationDegrees(RotationDegrees + degrees);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void RotateSprite(float radians)
|
||||||
|
{
|
||||||
|
SetRotation(Rotation + radians);
|
||||||
|
}
|
||||||
|
|
||||||
public void FacePlayer()
|
public void FacePlayer()
|
||||||
{
|
{
|
||||||
if (_gameManager.Player != null)
|
if (_gameManager.Player != null)
|
||||||
|
|
@ -119,7 +127,7 @@ public partial class Bullet : Area2D
|
||||||
|
|
||||||
_direction = normalized;
|
_direction = normalized;
|
||||||
|
|
||||||
SetRotation(Mathf.Atan2(normalized.Y,normalized.X) + Mathf.Pi / 2);
|
SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2);
|
||||||
|
|
||||||
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +136,6 @@ public partial class Bullet : Area2D
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
_elapsedTime += delta;
|
_elapsedTime += delta;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
public override void _PhysicsProcess(double delta)
|
||||||
|
|
@ -160,7 +167,6 @@ public partial class Bullet : Area2D
|
||||||
// Debug.WriteLine("Collision with destroyable object body");
|
// Debug.WriteLine("Collision with destroyable object body");
|
||||||
// QueueFree();
|
// QueueFree();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _on_area_entered(Area2D area)
|
private void _on_area_entered(Area2D area)
|
||||||
|
|
@ -171,16 +177,29 @@ public partial class Bullet : Area2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (area.IsInGroup("Destroyable") && area is IDestructible destructible)
|
if (area.IsInGroup("Destroyable") && area is IDestructible destructible &&
|
||||||
|
CanHit(BulletOwner, destructible.BulletGroup))
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("Collision with destroyable object area");
|
// hit
|
||||||
|
|
||||||
destructible.Hit(Damage, DamageType);
|
destructible.Hit(Damage, DamageType);
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanHit(BulletOwner bulletOwner, BulletOwner targetGroup)
|
||||||
|
{
|
||||||
|
// If either is None, it always hits
|
||||||
|
if (bulletOwner == BulletOwner.None || targetGroup == BulletOwner.None)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, it hits only if they are different groups
|
||||||
|
return bulletOwner != targetGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
if (_bulletInfo?.DestructionParticlesScene != null)
|
if (_bulletInfo?.DestructionParticlesScene != null)
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,9 @@ public partial class GameManager : Node2D
|
||||||
|
|
||||||
public Vector2? PlayerPosition => _player?.GlobalPosition ?? null;
|
public Vector2? PlayerPosition => _player?.GlobalPosition ?? null;
|
||||||
|
|
||||||
[Export]
|
[Export] public PackedScene PlayerTemplate { get; set; }
|
||||||
public PackedScene PlayerTemplate { get; set; }
|
|
||||||
|
|
||||||
[Export]
|
[Export] public Marker2D PlayerSpawnMarker { get; set; }
|
||||||
public Marker2D PlayerSpawnMarker { get; set; }
|
|
||||||
|
|
||||||
[Export] public PackedScene WeaponTemplate { get; private set; }
|
[Export] public PackedScene WeaponTemplate { get; private set; }
|
||||||
|
|
||||||
|
|
@ -87,8 +85,11 @@ public partial class GameManager : Node2D
|
||||||
if (PlayerSpawnMarker != null)
|
if (PlayerSpawnMarker != null)
|
||||||
{
|
{
|
||||||
SpawnPlayer();
|
SpawnPlayer();
|
||||||
|
}
|
||||||
SpawnWeapons();
|
else
|
||||||
|
{
|
||||||
|
GD.Print("No player spawn marker in scene.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_player != null && _hud != null)
|
if (_player != null && _hud != null)
|
||||||
|
|
@ -99,6 +100,24 @@ public partial class GameManager : Node2D
|
||||||
|
|
||||||
_player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
|
_player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GD.Print("No player and hud in scene");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_inventoryManager is not null)
|
||||||
|
{
|
||||||
|
_inventoryManager.ItemAdded += (LootItem item, int amount) =>
|
||||||
|
{
|
||||||
|
if (item.Item == ItemTypes.Weapon)
|
||||||
|
{
|
||||||
|
SpawnPlayerWeapon(item);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
SpawnWeapons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SpawnPlayer()
|
public void SpawnPlayer()
|
||||||
|
|
@ -144,14 +163,28 @@ public partial class GameManager : Node2D
|
||||||
|
|
||||||
foreach (var startingItem in StartingEquipment)
|
foreach (var startingItem in StartingEquipment)
|
||||||
{
|
{
|
||||||
switch (startingItem.Item)
|
// Now automatically taken care of by the event
|
||||||
|
// switch (startingItem.Item)
|
||||||
|
// {
|
||||||
|
// case ItemTypes.Weapon:
|
||||||
|
// SpawnPlayerWeapon(startingItem);
|
||||||
|
//
|
||||||
|
// //_player.EquippedWeapon ??= weapon;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
_inventoryManager.AddItem(startingItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpawnPlayerWeapon(LootItem startingItem)
|
||||||
{
|
{
|
||||||
case ItemTypes.Weapon:
|
|
||||||
if (WeaponTemplate == null)
|
if (WeaponTemplate == null)
|
||||||
{
|
{
|
||||||
GD.Print("Could not spawn weapon because template is null");
|
GD.Print("Could not spawn weapon because template is null");
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var weapon = _player.CreateChild<Weapon>(WeaponTemplate);
|
var weapon = _player.CreateChild<Weapon>(WeaponTemplate);
|
||||||
weapon.WeaponData = startingItem.WeaponData;
|
weapon.WeaponData = startingItem.WeaponData;
|
||||||
|
|
||||||
|
|
@ -161,13 +194,6 @@ public partial class GameManager : Node2D
|
||||||
{
|
{
|
||||||
_player.EquipWeapon(weapon);
|
_player.EquipWeapon(weapon);
|
||||||
}
|
}
|
||||||
|
|
||||||
//_player.EquippedWeapon ??= weapon;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_inventoryManager.AddItem(startingItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnBulletsContainer()
|
private void SpawnBulletsContainer()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
public interface IDestructible
|
public interface IDestructible
|
||||||
{
|
{
|
||||||
|
public BulletOwner BulletGroup { get; set; }
|
||||||
public void Hit(float damage, DamageType type = DamageType.Neutral);
|
public void Hit(float damage, DamageType type = DamageType.Neutral);
|
||||||
public bool IsDestroyed();
|
public bool IsDestroyed();
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
private InventoryManager _inventoryManager;
|
private InventoryManager _inventoryManager;
|
||||||
|
|
||||||
[Export] public Sprite2D HitboxSprite { get; set; }
|
[Export] public Sprite2D HitboxSprite { get; set; }
|
||||||
|
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
||||||
private bool _isStrafing { get; set; }
|
private bool _isStrafing { get; set; }
|
||||||
|
|
||||||
private bool _canMove = true;
|
private bool _canMove = true;
|
||||||
|
|
@ -179,6 +179,16 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
// public void ItemAdded(LootItem item, int amount)
|
||||||
|
// {
|
||||||
|
// switch (item.Item)
|
||||||
|
// {
|
||||||
|
// case ItemTypes.Weapon:
|
||||||
|
// AddWeapon(item.WeaponData);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public void AddWeapon(Weapon weapon)
|
public void AddWeapon(Weapon weapon)
|
||||||
{
|
{
|
||||||
EquippedWeapons.Add(weapon);
|
EquippedWeapons.Add(weapon);
|
||||||
|
|
@ -443,7 +453,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
private void _on_damage_hit_box_area_entered(Area2D area)
|
private void _on_damage_hit_box_area_entered(Area2D area)
|
||||||
{
|
{
|
||||||
if (!_canMove) return;
|
if (!_canMove) return;
|
||||||
if (area is Bullet bullet && bullet.BulletOwner != BulletOwner.Player)
|
if (area is Bullet bullet && bullet.BulletOwner != BulletGroup)
|
||||||
{
|
{
|
||||||
this.Hit(bullet.Damage, bullet.DamageType);
|
this.Hit(bullet.Damage, bullet.DamageType);
|
||||||
bullet.QueueFree();
|
bullet.QueueFree();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Resources.Modifiers;
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class DelayedContinuousRotationModifier : TimeModifier
|
||||||
|
{
|
||||||
|
public override void Update(Bullet bullet, double delta)
|
||||||
|
{
|
||||||
|
bullet.RotateSpriteDegrees((float)(Value * delta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -89,10 +89,11 @@ texture = ExtResource("1_70kxh")
|
||||||
4:0/0 = 0
|
4:0/0 = 0
|
||||||
5:0/0 = 0
|
5:0/0 = 0
|
||||||
6:0/0 = 0
|
6:0/0 = 0
|
||||||
6:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(8, -6, -6, -6, -6, 2, 8, 2)
|
6:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-6, -6, -6, 2, 8, 2, 8, -6)
|
||||||
7:0/0 = 0
|
7:0/0 = 0
|
||||||
7:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -6, 6, -6, 6, 2, -8, 2)
|
7:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -6, -8, 2, 6, 2, 6, -6)
|
||||||
8:0/0 = 0
|
8:0/0 = 0
|
||||||
|
8:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-4, -6, -4, 8, 4, 8, 4, -6)
|
||||||
9:0/0 = 0
|
9:0/0 = 0
|
||||||
0:1/0 = 0
|
0:1/0 = 0
|
||||||
0:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_l8pdw")
|
0:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_l8pdw")
|
||||||
|
|
@ -110,6 +111,7 @@ texture = ExtResource("1_70kxh")
|
||||||
6:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_uanwu")
|
6:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_uanwu")
|
||||||
7:1/0 = 0
|
7:1/0 = 0
|
||||||
8:1/0 = 0
|
8:1/0 = 0
|
||||||
|
8:1/0/physics_layer_1/polygon_0/points = PackedVector2Array(-4, -8, -4, 2, 4, 2, 4, -8)
|
||||||
9:1/0 = 0
|
9:1/0 = 0
|
||||||
0:2/animation_columns = 2
|
0:2/animation_columns = 2
|
||||||
0:2/animation_frame_0/duration = 1.0
|
0:2/animation_frame_0/duration = 1.0
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,16 @@ use_item={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"key_label":0,"unicode":117,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"key_label":0,"unicode":117,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
debug_camera_1={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194336,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
debug_camera_2={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194337,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue