mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-03 06:21:16 +00:00
working spder bomb
This commit is contained in:
parent
6125565d8c
commit
f1f40a91dd
17 changed files with 400 additions and 105 deletions
18
Resources/Bullets/Spider_Bomb_Bullet.tres
Normal file
18
Resources/Bullets/Spider_Bomb_Bullet.tres
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://dwxn7f1ue0m4s"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://64ax2lj77sr1" path="res://Scenes/Weapons/Bullets/spider_bomb_bullet.tscn" id="1_8gj5r"]
|
||||||
|
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="1_f2i0g"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_f2i0g")
|
||||||
|
BulletScene = ExtResource("1_8gj5r")
|
||||||
|
BulletSpeed = 40.0
|
||||||
|
Direction = Vector2(1, 0)
|
||||||
|
BulletDamage = 0.0
|
||||||
|
LifeTime = 50.0
|
||||||
|
DestroyOnCollision = true
|
||||||
|
Owner = 1
|
||||||
|
DamageType = 0
|
||||||
|
Controllable = true
|
||||||
|
TimeModifiers = null
|
||||||
|
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||||
43
Resources/Items/Spider_Bomb_Pickup.tres
Normal file
43
Resources/Items/Spider_Bomb_Pickup.tres
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
[gd_resource type="Resource" script_class="LootItem" load_steps=7 format=3 uid="uid://dhbltvgsa3g88"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="1_lus3u"]
|
||||||
|
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="1_qd764"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://huo14jdekj6n" path="res://Sprites/Bullets/spiderbomb.png" id="1_v5a4k"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dwxn7f1ue0m4s" path="res://Resources/Bullets/Spider_Bomb_Bullet.tres" id="2_gpot4"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_gpot4"]
|
||||||
|
atlas = ExtResource("1_v5a4k")
|
||||||
|
region = Rect2(0, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_v5a4k"]
|
||||||
|
script = ExtResource("1_qd764")
|
||||||
|
Name = "Spider Bomb"
|
||||||
|
BulletData = ExtResource("2_gpot4")
|
||||||
|
RateOfFire = 1.0
|
||||||
|
BulletCapacity = 10
|
||||||
|
ReloadTime = 1.0
|
||||||
|
AutoReload = true
|
||||||
|
InfiniteAmmo = true
|
||||||
|
BulletsPerShot = 1
|
||||||
|
SpreadAngle = 0.0
|
||||||
|
RandomSpread = 0.0
|
||||||
|
ItemKey = "SPIDER_BOMB"
|
||||||
|
AmmoKey = "SPIDER_BOMB"
|
||||||
|
_rotationOffset = 0.0
|
||||||
|
metadata/_custom_type_script = "uid://b6fmrnipv88bk"
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_lus3u")
|
||||||
|
ItemName = "Spider Bomb"
|
||||||
|
ItemDescription = "A bomb that spiders"
|
||||||
|
ItemKey = "SPIDER_BOMB"
|
||||||
|
Item = 5
|
||||||
|
WeaponData = SubResource("Resource_v5a4k")
|
||||||
|
Amount = 1
|
||||||
|
Max = 10
|
||||||
|
PickupIfMaxed = false
|
||||||
|
ConsumeOnUse = false
|
||||||
|
UiType = 0
|
||||||
|
Selectable = true
|
||||||
|
InventorySprite = SubResource("AtlasTexture_gpot4")
|
||||||
|
metadata/_custom_type_script = "uid://epnwjptvks3t"
|
||||||
34
Resources/Weapons/Spider_Bomb.tres
Normal file
34
Resources/Weapons/Spider_Bomb.tres
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://m7obu15t73df"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="1_m8p4s"]
|
||||||
|
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="1_wdsus"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_hoooo"]
|
||||||
|
script = ExtResource("1_m8p4s")
|
||||||
|
BulletSpeed = 100.0
|
||||||
|
Direction = Vector2(1, 0)
|
||||||
|
BulletDamage = 1.0
|
||||||
|
LifeTime = 10.0
|
||||||
|
DestroyOnCollision = true
|
||||||
|
Owner = 0
|
||||||
|
DamageType = 0
|
||||||
|
Controllable = false
|
||||||
|
TimeModifiers = null
|
||||||
|
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_wdsus")
|
||||||
|
Name = "Spider Bomb"
|
||||||
|
BulletData = SubResource("Resource_hoooo")
|
||||||
|
RateOfFire = 0.4
|
||||||
|
BulletCapacity = 20
|
||||||
|
ReloadTime = 1.0
|
||||||
|
AutoReload = true
|
||||||
|
InfiniteAmmo = true
|
||||||
|
BulletsPerShot = 1
|
||||||
|
SpreadAngle = 0.0
|
||||||
|
RandomSpread = 0.0
|
||||||
|
ItemKey = ""
|
||||||
|
AmmoKey = ""
|
||||||
|
_rotationOffset = 0.0
|
||||||
|
metadata/_custom_type_script = "uid://b6fmrnipv88bk"
|
||||||
34
Scenes/Items/SpiderBomb_Pickup.tscn
Normal file
34
Scenes/Items/SpiderBomb_Pickup.tscn
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[gd_scene load_steps=7 format=3 uid="uid://cvctgw8eo2f7e"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_bdsed"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dhbltvgsa3g88" path="res://Resources/Items/Spider_Bomb_Pickup.tres" id="2_bdsed"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://huo14jdekj6n" path="res://Sprites/Bullets/spiderbomb.png" id="3_bdsed"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_6vv2s"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fyf8h"]
|
||||||
|
atlas = ExtResource("3_bdsed")
|
||||||
|
region = Rect2(0, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_qfvur"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fyf8h")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[node name="SpiderBomb" type="Area2D" groups=["Interactable"]]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 2
|
||||||
|
script = ExtResource("1_bdsed")
|
||||||
|
LootTable = [ExtResource("2_bdsed")]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_6vv2s")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
|
sprite_frames = SubResource("SpriteFrames_qfvur")
|
||||||
|
|
@ -1,23 +1,28 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://dfbmny3s4rili"]
|
[gd_scene load_steps=5 format=3 uid="uid://dfbmny3s4rili"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c4molirtle8a0" path="res://Scripts/Components/AutodeleteParticle.cs" id="1_rk44q"]
|
[ext_resource type="Script" uid="uid://c4molirtle8a0" path="res://Scripts/Components/AutodeleteParticle.cs" id="1_rk44q"]
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_xc6bb"]
|
||||||
|
colors = PackedColorArray(0, 0.45098, 0.886275, 1, 0.729412, 1, 1, 1)
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_hkx2s"]
|
||||||
|
gradient = SubResource("Gradient_xc6bb")
|
||||||
|
|
||||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_f8iyl"]
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_f8iyl"]
|
||||||
particle_flag_disable_z = true
|
particle_flag_disable_z = true
|
||||||
radial_velocity_min = -2.23517e-05
|
radial_velocity_min = -2.23517e-05
|
||||||
radial_velocity_max = 30.38
|
radial_velocity_max = 145.49
|
||||||
gravity = Vector3(0, 0, 0)
|
gravity = Vector3(0, 0, 0)
|
||||||
linear_accel_min = -23.2
|
linear_accel_min = -23.2
|
||||||
linear_accel_max = -2.23517e-06
|
linear_accel_max = -2.23517e-06
|
||||||
scale_min = 0.5
|
|
||||||
scale_max = 0.5
|
|
||||||
color = Color(0.054902, 0.494118, 1, 1)
|
color = Color(0.054902, 0.494118, 1, 1)
|
||||||
|
color_ramp = SubResource("GradientTexture1D_hkx2s")
|
||||||
|
|
||||||
[node name="IceBulletParticle" type="GPUParticles2D"]
|
[node name="IceBulletParticle" type="GPUParticles2D"]
|
||||||
emitting = false
|
emitting = false
|
||||||
amount = 4
|
|
||||||
process_material = SubResource("ParticleProcessMaterial_f8iyl")
|
|
||||||
lifetime = 0.4
|
lifetime = 0.4
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_f8iyl")
|
||||||
script = ExtResource("1_rk44q")
|
script = ExtResource("1_rk44q")
|
||||||
LifeTime = 1.0
|
LifeTime = 1.0
|
||||||
|
AutoStart = true
|
||||||
|
|
|
||||||
58
Scenes/Weapons/Bullets/spider_bomb_bullet.tscn
Normal file
58
Scenes/Weapons/Bullets/spider_bomb_bullet.tscn
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
[gd_scene load_steps=8 format=3 uid="uid://64ax2lj77sr1"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dsa4b75hdig8p" path="res://Scripts/Bullet.cs" id="1_nrcj1"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://huo14jdekj6n" path="res://Sprites/Bullets/spiderbomb.png" id="2_nrcj1"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||||
|
radius = 2.23607
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_lhjit"]
|
||||||
|
atlas = ExtResource("2_nrcj1")
|
||||||
|
region = Rect2(0, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ibnjy"]
|
||||||
|
atlas = ExtResource("2_nrcj1")
|
||||||
|
region = Rect2(16, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_w1jch"]
|
||||||
|
atlas = ExtResource("2_nrcj1")
|
||||||
|
region = Rect2(32, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_co0jb"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_lhjit")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ibnjy")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_w1jch")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 87
|
||||||
|
script = ExtResource("1_nrcj1")
|
||||||
|
Speed = 200.0
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_jxptd")
|
||||||
|
|
||||||
|
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
|
sprite_frames = SubResource("SpriteFrames_co0jb")
|
||||||
|
autoplay = "default"
|
||||||
|
frame = 1
|
||||||
|
frame_progress = 0.375255
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||||
|
|
@ -264,6 +264,7 @@ shape = SubResource("CircleShape2D_e6woi")
|
||||||
debug_color = Color(1, 0.00817797, 0.0443347, 0.42)
|
debug_color = Color(1, 0.00817797, 0.0443347, 0.42)
|
||||||
|
|
||||||
[node name="Weapon" parent="." node_paths=PackedStringArray("Muzzle") instance=ExtResource("9_wblq0")]
|
[node name="Weapon" parent="." node_paths=PackedStringArray("Muzzle") instance=ExtResource("9_wblq0")]
|
||||||
|
scale = Vector2(1.38995, 1.96064)
|
||||||
WeaponData = ExtResource("9_84o8f")
|
WeaponData = ExtResource("9_84o8f")
|
||||||
BulletScene = ExtResource("2_ov36d")
|
BulletScene = ExtResource("2_ov36d")
|
||||||
Muzzle = NodePath("../Muzzle")
|
Muzzle = NodePath("../Muzzle")
|
||||||
|
|
@ -281,9 +282,9 @@ MaxResource = 25.0
|
||||||
[node name="ShieldParticles" type="GPUParticles2D" parent="."]
|
[node name="ShieldParticles" type="GPUParticles2D" parent="."]
|
||||||
emitting = false
|
emitting = false
|
||||||
amount = 32
|
amount = 32
|
||||||
process_material = SubResource("ParticleProcessMaterial_hmqi5")
|
|
||||||
lifetime = 0.4
|
lifetime = 0.4
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_hmqi5")
|
||||||
|
|
||||||
[connection signal="area_entered" from="InteractionController" to="." method="_on_interaction_controller_area_entered"]
|
[connection signal="area_entered" from="InteractionController" to="." method="_on_interaction_controller_area_entered"]
|
||||||
[connection signal="area_exited" from="InteractionController" to="." method="_on_interaction_controller_area_exited"]
|
[connection signal="area_exited" from="InteractionController" to="." method="_on_interaction_controller_area_exited"]
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -28,6 +28,8 @@ public partial class Bullet : Area2D
|
||||||
|
|
||||||
private GameManager _gameManager;
|
private GameManager _gameManager;
|
||||||
|
|
||||||
|
[Signal] public delegate void OnDestroyEventHandler();
|
||||||
|
|
||||||
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
||||||
{
|
{
|
||||||
_bulletInfo = bulletInfo;
|
_bulletInfo = bulletInfo;
|
||||||
|
|
@ -234,11 +236,11 @@ public partial class Bullet : Area2D
|
||||||
{
|
{
|
||||||
if (_bulletInfo?.DestructionParticlesScene != null)
|
if (_bulletInfo?.DestructionParticlesScene != null)
|
||||||
{
|
{
|
||||||
var particle = this.CreateSibling<AutodeleteParticle>(_bulletInfo.DestructionParticlesScene);
|
this.CreateSibling<Node2D>(_bulletInfo.DestructionParticlesScene);
|
||||||
|
|
||||||
particle.Init();
|
//particle.Init();
|
||||||
}
|
}
|
||||||
|
EmitSignal(SignalName.OnDestroy);
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ using Cirno.Scripts.Utils;
|
||||||
|
|
||||||
public partial class GameManager : Node2D
|
public partial class GameManager : Node2D
|
||||||
{
|
{
|
||||||
public static GameManager Instance { get; private set;}
|
public static GameManager Instance { get; private set; }
|
||||||
private Hud _hud;
|
private Hud _hud;
|
||||||
|
|
||||||
private PlayerMovement _player;
|
private PlayerMovement _player;
|
||||||
|
|
@ -55,7 +55,7 @@ public partial class GameManager : Node2D
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
_hud = GetNodeOrNull<Hud>("HUD");
|
_hud = GetNodeOrNull<Hud>("HUD");
|
||||||
if (_hud == null) GD.Print("No HUD in scene.");
|
if (_hud == null) GD.Print("No HUD in scene.");
|
||||||
|
|
@ -161,6 +161,8 @@ public partial class GameManager : Node2D
|
||||||
};
|
};
|
||||||
|
|
||||||
_inventoryManager.WeaponEquip += _player.EquipWeapon;
|
_inventoryManager.WeaponEquip += _player.EquipWeapon;
|
||||||
|
|
||||||
|
_inventoryManager.ItemUsed += _player.UseItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpawnWeapons();
|
SpawnWeapons();
|
||||||
|
|
@ -305,7 +307,8 @@ public partial class GameManager : Node2D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameState ToggleControlMode() {
|
public GameState ToggleControlMode()
|
||||||
|
{
|
||||||
if (GameState is GameState.Playing)
|
if (GameState is GameState.Playing)
|
||||||
{
|
{
|
||||||
ChangeState(GameState.Controlling);
|
ChangeState(GameState.Controlling);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ public partial class InventoryManager : Node2D
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void WeaponEquipEventHandler(string itemKey);
|
public delegate void WeaponEquipEventHandler(string itemKey);
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void ItemUsedEventHandler(LootItem itemKey, int totalCount);
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|
@ -114,21 +117,19 @@ public partial class InventoryManager : Node2D
|
||||||
if (!_itemsDict.TryGetValue(itemKey, out var itm)) return false;
|
if (!_itemsDict.TryGetValue(itemKey, out var itm)) return false;
|
||||||
|
|
||||||
if (itm.Count == 0) return false;
|
if (itm.Count == 0) return false;
|
||||||
|
GD.Print($"Used item in manager {itemKey}");
|
||||||
|
|
||||||
switch (itm.Item.Item)
|
switch (itm.Item.Item)
|
||||||
{
|
{
|
||||||
case ItemTypes.Medkit:
|
case ItemTypes.Medkit:
|
||||||
// Heal
|
// Heal
|
||||||
break;
|
|
||||||
case ItemTypes.FrogBomb:
|
case ItemTypes.FrogBomb:
|
||||||
// Use Bomb
|
// Use Bomb
|
||||||
break;
|
|
||||||
case ItemTypes.Bomb:
|
case ItemTypes.Bomb:
|
||||||
// Bomb
|
// Bomb
|
||||||
break;
|
|
||||||
case ItemTypes.Mine:
|
case ItemTypes.Mine:
|
||||||
break;
|
|
||||||
case ItemTypes.Battery:
|
case ItemTypes.Battery:
|
||||||
|
EmitSignal(SignalName.ItemUsed, itm.Item, itm.Count);
|
||||||
break;
|
break;
|
||||||
case ItemTypes.Weapon:
|
case ItemTypes.Weapon:
|
||||||
// Equip weapon
|
// Equip weapon
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
|
|
||||||
[Export] public float MaxHealth = 32f;
|
[Export] public float MaxHealth = 32f;
|
||||||
[Export] public float MaxShield = 32f;
|
[Export] public float MaxShield = 32f;
|
||||||
[Export] public Shader BlinkShader {get;set;}
|
[Export] public Shader BlinkShader { get; set; }
|
||||||
[Export] public Sprite2D HitboxSprite { get; set; }
|
[Export] public Sprite2D HitboxSprite { get; set; }
|
||||||
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
||||||
|
|
||||||
|
|
@ -216,6 +216,43 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
EquipWeapon(weapon);
|
EquipWeapon(weapon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UseItem(LootItem item, int currentAmount)
|
||||||
|
{
|
||||||
|
GD.Print($"Used item on player {item.ItemKey}");
|
||||||
|
|
||||||
|
switch (item.Item)
|
||||||
|
{
|
||||||
|
case ItemTypes.FrogBomb:
|
||||||
|
|
||||||
|
_inventoryManager.RemoveItem(item.ItemKey, 1);
|
||||||
|
// emit projectile
|
||||||
|
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, item.WeaponData.BulletData.BulletScene, this.GlobalPosition);
|
||||||
|
|
||||||
|
var bulletData = item.WeaponData.MakeBullet(this.GlobalPosition);
|
||||||
|
|
||||||
|
bullet.Initialize(bulletData, _gameManager);
|
||||||
|
|
||||||
|
//bullet.SetDirection(ShootDirection);
|
||||||
|
bullet.SetDirection(_facingDirection);
|
||||||
|
bullet.Speed = item.WeaponData.BulletData.BulletSpeed;
|
||||||
|
RequestMovementDisable(true);
|
||||||
|
// set camera
|
||||||
|
_gameManager.CameraTargetObject(bullet);
|
||||||
|
// set event destroy
|
||||||
|
bullet.OnDestroy += () =>
|
||||||
|
{
|
||||||
|
_gameManager.CameraTargetPlayer();
|
||||||
|
RequestMovementDisable(false);
|
||||||
|
};
|
||||||
|
// go back
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
//var item = _inventoryManager.getitem
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Triggered by event in inventorymanager
|
||||||
public void EquipWeapon(Weapon weapon)
|
public void EquipWeapon(Weapon weapon)
|
||||||
{
|
{
|
||||||
EquippedWeapon = weapon;
|
EquippedWeapon = weapon;
|
||||||
|
|
@ -313,7 +350,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
private Vector2 GetRightStickInput()
|
private Vector2 GetRightStickInput()
|
||||||
{
|
{
|
||||||
return new Vector2(
|
return new Vector2(
|
||||||
Input.GetAxis("aim_left","aim_right"),
|
Input.GetAxis("aim_left", "aim_right"),
|
||||||
Input.GetAxis("aim_up", "aim_down")
|
Input.GetAxis("aim_up", "aim_down")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +373,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
if (Input.IsActionJustPressed(_shootActionName))
|
if (Input.IsActionJustPressed(_shootActionName))
|
||||||
Respawn();
|
Respawn();
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
SetAnimation();
|
SetAnimation();
|
||||||
if (!_canMove) return;
|
if (!_canMove) return;
|
||||||
|
|
@ -395,7 +433,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
if (_isDestroyed) return;
|
if (_isDestroyed) return;
|
||||||
if (!_canMove) return;
|
if (!_canMove) return;
|
||||||
|
|
||||||
Velocity = _movementDirection * MovementSpeed;
|
Velocity = _movementDirection * MovementSpeed;
|
||||||
|
|
||||||
MoveAndSlide();
|
MoveAndSlide();
|
||||||
}
|
}
|
||||||
|
|
@ -458,20 +496,25 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
GD.Print($"Player damaged for {damage}");
|
GD.Print($"Player damaged for {damage}");
|
||||||
if (_isDestroyed) return;
|
if (_isDestroyed) return;
|
||||||
|
|
||||||
if (CurrentShield > 0 && type is not DamageType.Explosive or DamageType.Acid) {
|
if (CurrentShield > 0 && type is not DamageType.Explosive or DamageType.Acid)
|
||||||
|
{
|
||||||
// Reduce shield
|
// Reduce shield
|
||||||
PlayShieldAnimation();
|
PlayShieldAnimation();
|
||||||
CurrentShield -= damage;
|
CurrentShield -= damage;
|
||||||
if (CurrentShield < 0 ) {
|
if (CurrentShield < 0)
|
||||||
|
{
|
||||||
CurrentHealth -= Math.Abs(CurrentShield);
|
CurrentHealth -= Math.Abs(CurrentShield);
|
||||||
CurrentShield = 0;
|
CurrentShield = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (type is DamageType.Fire) {
|
{
|
||||||
|
if (type is DamageType.Fire)
|
||||||
|
{
|
||||||
CurrentHealth -= damage * 2;
|
CurrentHealth -= damage * 2;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
CurrentHealth -= damage;
|
CurrentHealth -= damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
BIN
Sprites/Actors/Focus_Circle.aseprite
(Stored with Git LFS)
BIN
Sprites/Actors/Focus_Circle.aseprite
(Stored with Git LFS)
Binary file not shown.
BIN
Sprites/Actors/Focus_Circle.png
(Stored with Git LFS)
BIN
Sprites/Actors/Focus_Circle.png
(Stored with Git LFS)
Binary file not shown.
BIN
Sprites/Bullets/spiderbomb.aseprite
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/spiderbomb.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Sprites/Bullets/spiderbomb.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/spiderbomb.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Bullets/spiderbomb.png.import
Normal file
34
Sprites/Bullets/spiderbomb.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://huo14jdekj6n"
|
||||||
|
path="res://.godot/imported/spiderbomb.png-1f93fcb1c2d0dce68743f4753f72f392.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Bullets/spiderbomb.png"
|
||||||
|
dest_files=["res://.godot/imported/spiderbomb.png-1f93fcb1c2d0dce68743f4753f72f392.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue