working spder bomb

This commit is contained in:
Maddo 2025-02-28 11:17:28 +01:00
commit f1f40a91dd
17 changed files with 400 additions and 105 deletions

View 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"

View 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"

View 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"

View 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")

View file

@ -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"]
[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"]
particle_flag_disable_z = true
radial_velocity_min = -2.23517e-05
radial_velocity_max = 30.38
radial_velocity_max = 145.49
gravity = Vector3(0, 0, 0)
linear_accel_min = -23.2
linear_accel_max = -2.23517e-06
scale_min = 0.5
scale_max = 0.5
color = Color(0.054902, 0.494118, 1, 1)
color_ramp = SubResource("GradientTexture1D_hkx2s")
[node name="IceBulletParticle" type="GPUParticles2D"]
emitting = false
amount = 4
process_material = SubResource("ParticleProcessMaterial_f8iyl")
lifetime = 0.4
one_shot = true
process_material = SubResource("ParticleProcessMaterial_f8iyl")
script = ExtResource("1_rk44q")
LifeTime = 1.0
AutoStart = true

View 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"]

View file

@ -264,6 +264,7 @@ shape = SubResource("CircleShape2D_e6woi")
debug_color = Color(1, 0.00817797, 0.0443347, 0.42)
[node name="Weapon" parent="." node_paths=PackedStringArray("Muzzle") instance=ExtResource("9_wblq0")]
scale = Vector2(1.38995, 1.96064)
WeaponData = ExtResource("9_84o8f")
BulletScene = ExtResource("2_ov36d")
Muzzle = NodePath("../Muzzle")
@ -281,9 +282,9 @@ MaxResource = 25.0
[node name="ShieldParticles" type="GPUParticles2D" parent="."]
emitting = false
amount = 32
process_material = SubResource("ParticleProcessMaterial_hmqi5")
lifetime = 0.4
one_shot = true
process_material = SubResource("ParticleProcessMaterial_hmqi5")
[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"]

File diff suppressed because one or more lines are too long

View file

@ -28,6 +28,8 @@ public partial class Bullet : Area2D
private GameManager _gameManager;
[Signal] public delegate void OnDestroyEventHandler();
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
{
_bulletInfo = bulletInfo;
@ -234,11 +236,11 @@ public partial class Bullet : Area2D
{
if (_bulletInfo?.DestructionParticlesScene != null)
{
var particle = this.CreateSibling<AutodeleteParticle>(_bulletInfo.DestructionParticlesScene);
this.CreateSibling<Node2D>(_bulletInfo.DestructionParticlesScene);
particle.Init();
//particle.Init();
}
EmitSignal(SignalName.OnDestroy);
QueueFree();
}
}

View file

@ -9,7 +9,7 @@ using Cirno.Scripts.Utils;
public partial class GameManager : Node2D
{
public static GameManager Instance { get; private set;}
public static GameManager Instance { get; private set; }
private Hud _hud;
private PlayerMovement _player;
@ -25,7 +25,7 @@ public partial class GameManager : Node2D
[Export] public PackedScene PlayerTemplate { get; set; }
[Export] public Dictionary<int, NodePath> SpawnMarkers { get; private set; } = new();
//[Export] public Marker2D PlayerSpawnMarker { get; set; }
[Export] public PackedScene WeaponTemplate { get; private set; }
@ -51,12 +51,12 @@ public partial class GameManager : Node2D
[Signal]
public delegate void PlayerRespawnedEventHandler();
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
Instance = this;
Instance = this;
_hud = GetNodeOrNull<Hud>("HUD");
if (_hud == null) GD.Print("No HUD in scene.");
@ -74,7 +74,7 @@ public partial class GameManager : Node2D
{
this.GameStateChange += _hud.OnGameStateChanged;
}
if (_inventoryManager != null && _hud != null)
{
_inventoryManager.ItemAdded += (item, currentAmount) => _hud.AddInventoryItem(item, currentAmount);
@ -82,7 +82,7 @@ public partial class GameManager : Node2D
}
PlayerRespawned += OnPlayerRespawned;
GameState = GameState.Playing;
//_ = DelayPlayerSpawn();
@ -102,9 +102,9 @@ public partial class GameManager : Node2D
StartingEquipment.AddRange(mapStartData.StartingEquipment);
}
public void ApplySessionState(SessionSettings settings)
public void ApplySessionState(SessionSettings settings)
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
@ -137,7 +137,7 @@ public partial class GameManager : Node2D
_player.ShieldChanged += (newShield, maxShield) => _hud.UpdateShield(newShield, maxShield);
_player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
_player.Death += () =>
{
// Show Game Over
@ -149,7 +149,7 @@ public partial class GameManager : Node2D
GD.Print("No player and hud in scene");
return;
}
if (_inventoryManager is not null)
{
_inventoryManager.ItemAdded += (LootItem item, int amount) =>
@ -161,23 +161,25 @@ public partial class GameManager : Node2D
};
_inventoryManager.WeaponEquip += _player.EquipWeapon;
_inventoryManager.ItemUsed += _player.UseItem;
}
SpawnWeapons();
}
public void SpawnPlayer()
{
if (_player != null) return;
//_player = this.CreateChild<PlayerMovement>(PlayerTemplate, PlayerSpawnMarker.Position );
_player = PlayerTemplate.Instantiate<PlayerMovement>();
this.CallDeferred("add_child", _player);
_player.Transform = this.GlobalTransform;
_player.GlobalPosition = GetStartPosition();
//_player.GlobalPosition = PlayerSpawnMarker.Position;
CameraTargetPlayer();
@ -197,11 +199,11 @@ public partial class GameManager : Node2D
if (SpawnMarkers.TryGetValue(MapStartData.EggIndex, out var spawnMarker))
{
var marker = GetNode<Node2D>(spawnMarker);
return marker.Position; // Why position and not globalposition? I have no idea
}
}
var m = GetNode<Node2D>(SpawnMarkers.First().Value);
return m.GlobalPosition;
}
@ -222,7 +224,7 @@ public partial class GameManager : Node2D
{
_cameraTarget.Position += offset.Value;
}
}
private void SpawnWeapons()
@ -305,12 +307,13 @@ public partial class GameManager : Node2D
}
}
public GameState ToggleControlMode() {
if (GameState is GameState.Playing)
public GameState ToggleControlMode()
{
if (GameState is GameState.Playing)
{
ChangeState(GameState.Controlling);
}
else if (GameState is GameState.Controlling)
else if (GameState is GameState.Controlling)
{
ChangeState(GameState.Playing);
}

View file

@ -8,20 +8,23 @@ using Cirno.Scripts.Resources;
public partial class InventoryManager : Node2D
{
public bool RedKeycard { get; set; }
private Dictionary<string, ItemContainer> _itemsDict = new Dictionary<string, ItemContainer>();
public List<ItemContainer> Items => _itemsDict.Where(x => x.Value.Count > 0).Select(x => x.Value).ToList();
[Signal]
public delegate void ItemAddedEventHandler(LootItem item, int currentAmount);
[Signal]
public delegate void ItemRemovedEventHandler(string itemKey, int currentAmount);
[Signal]
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.
public override void _Ready()
{
@ -31,12 +34,12 @@ public partial class InventoryManager : Node2D
public override void _Process(double delta)
{
}
public bool HasItems(List<string> itemKeys)
{
return itemKeys.Aggregate(false, (current, item) => current || GetItemCount(item) > 0);
}
public int GetItemCount(string itemKey)
{
return _itemsDict.TryGetValue(itemKey, out var itm) ? itm.Count : 0;
@ -47,20 +50,20 @@ public partial class InventoryManager : Node2D
if (!_itemsDict.TryGetValue(itemKey, out var itm)) return 0;
int removed = Math.Min(itm.Count, amount);
itm.Count -= amount;
if (itm.Count <= 0)
{
_itemsDict.Remove(itemKey);
}
EmitSignal(nameof(ItemRemoved), itemKey, itm.Count);
return removed;
}
public bool AddItem(LootItem item)
{
//var item = new LootItem() { Item = type, Amount = amount };
@ -73,7 +76,7 @@ public partial class InventoryManager : Node2D
Count = item.Amount,
});
GD.Print($"Added new ({item.ItemKey}) {item.Item} x{item.Amount}");
EmitSignal(nameof(ItemAdded), item, item.Amount);
}
else
@ -82,7 +85,7 @@ public partial class InventoryManager : Node2D
{
itm.Count += item.Amount;
}
else
else
{
if (item.PickupIfMaxed)
{
@ -95,10 +98,10 @@ public partial class InventoryManager : Node2D
}
EmitSignal(nameof(ItemAdded), item, itm.Count);
}
return true;
}
public void AddRedKeycard()
{
RedKeycard = true;
@ -114,29 +117,27 @@ public partial class InventoryManager : Node2D
if (!_itemsDict.TryGetValue(itemKey, out var itm)) return false;
if (itm.Count == 0) return false;
GD.Print($"Used item in manager {itemKey}");
switch (itm.Item.Item)
{
case ItemTypes.Medkit:
// Heal
break;
// Heal
case ItemTypes.FrogBomb:
// Use Bomb
break;
// Use Bomb
case ItemTypes.Bomb:
// Bomb
break;
// Bomb
case ItemTypes.Mine:
break;
case ItemTypes.Battery:
EmitSignal(SignalName.ItemUsed, itm.Item, itm.Count);
break;
case ItemTypes.Weapon:
// Equip weapon
EmitSignal(SignalName.WeaponEquip, itm.Item.ItemKey);
break;
}
return true;
}
}

View file

@ -13,7 +13,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
[Export]
public int Speed { get; set; } = 400;
[Export]
public int StrafeSpeed { get; set; } = 200;
@ -27,7 +27,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
[Export]
public string GameOverScene { get; set; }
[Export]
public Texture2D WingsSprite { get; set; }
@ -42,14 +42,14 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
private Vector2 _movementDirection { get; set; }
private Vector2 _facingDirection { get; set; }
private Vector2 _rightStickInput { get; set; }
private Sprite2D _crosshair;
[Export] public float MaxHealth = 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 BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
@ -67,10 +67,10 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
public Array<Weapon> EquippedWeapons { get; set; } = new Array<Weapon>();
public int CurrentWeaponIndex { get; set; } = 0;
//private float _currentHealth = 0f;
//private float _currentShield = 0f;
private bool _isDestroyed = false;
private GameManager _gameManager;
@ -79,14 +79,14 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
private ActorResourceProvider _healthProvider;
private ActorResourceProvider _shieldProvider;
private bool _isStrafing { get; set; }
private bool _canMove = true;
[Signal]
public delegate void HealthChangedEventHandler(float newHealth, float maxHealth);
[Signal]
public delegate void ShieldChangedEventHandler(float newShield, float maxShield);
@ -95,7 +95,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
[Signal]
public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
[Signal]
public delegate void DeathEventHandler();
@ -104,7 +104,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
get => _healthProvider.CurrentResource;
set => _healthProvider.CurrentResource = value;
}
public float CurrentShield
{
get => _shieldProvider.CurrentResource;
@ -126,7 +126,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
_healthProvider = GetNode<ActorResourceProvider>("HealthProvider");
_shieldProvider = GetNode<ActorResourceProvider>("ShieldProvider");
@ -154,18 +154,18 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
_inventoryManager = this.GetInventoryManager();
_gameManager.GameStateChange += GameManagerOnGameStateChange;
if (SelectorScene != null)
{
_selector = this.CreateSibling<Selector>(SelectorScene, this.GlobalPosition);
_selector.Visible = false;
}
_lastCheckPointPosition = GlobalPosition;
_ = UnTeleport();
}
private void GameManagerOnGameStateChange(GameState state)
{
switch (state)
@ -181,7 +181,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
case GameState.Dialogue:
_canMove = false;
break;
}
}
@ -200,7 +200,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
_canMove = true;
}
}
public void AddWeapon(Weapon weapon)
{
EquippedWeapons.Add(weapon);
@ -215,7 +215,44 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
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)
{
EquippedWeapon = weapon;
@ -229,10 +266,10 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
CurrentWeaponIndex = EquippedWeapons.Count - 1;
}
EquipWeapon(EquippedWeapons[CurrentWeaponIndex]);
}
public void PreviousWeapon()
{
CurrentWeaponIndex -= 1;
@ -240,7 +277,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
CurrentWeaponIndex = 0;
}
EquipWeapon(EquippedWeapons[CurrentWeaponIndex]);
}
@ -309,11 +346,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
return Input.GetVector("left", "right", "up", "down");
}
private Vector2 GetRightStickInput()
{
return new Vector2(
Input.GetAxis("aim_left","aim_right"),
Input.GetAxis("aim_left", "aim_right"),
Input.GetAxis("aim_up", "aim_down")
);
}
@ -328,7 +365,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
//var cPos = new Vector2(this.Position.X + CrosshairDistance * Godot.Mathf.Cos(angle), this.Position.Y + CrosshairDistance * Godot.Mathf.Sin(angle));
}
public override void _Process(double delta)
{
if (_isDestroyed)
@ -336,8 +373,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
if (Input.IsActionJustPressed(_shootActionName))
Respawn();
return;
};
}
;
SetAnimation();
if (!_canMove) return;
@ -349,9 +387,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
HitboxSprite.Visible = _isStrafing;
}
_rightStickInput = GetRightStickInput();
// Update Facing Direction
if (!_isStrafing)
{
@ -377,8 +415,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
PreviousWeapon();
}
_crosshair.Position = CalculateCrosshairPosition();
_crosshair.Position = CalculateCrosshairPosition();
}
public void Respawn()
@ -394,8 +432,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
{
if (_isDestroyed) return;
if (!_canMove) return;
Velocity = _movementDirection * MovementSpeed;
Velocity = _movementDirection * MovementSpeed;
MoveAndSlide();
}
@ -415,19 +453,19 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
_selector.AddInteractable(interactable);
//_selector.SelectedInteractable = interactable;
}
}
private void _on_interaction_controller_area_exited(Area2D area)
{
if (!_canMove) return;
if (area.IsInGroup("Interactable") && area is Interactable interactable)
if (area.IsInGroup("Interactable") && area is Interactable interactable)
{
Debug.WriteLine($"Interactable {area.Name} Exited");
EmitSignal(nameof(InteractableAreaExited), interactable);
if (_selector == null) return;
_selector.RemoveInteractable(interactable);
}
@ -458,20 +496,25 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
GD.Print($"Player damaged for {damage}");
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
PlayShieldAnimation();
CurrentShield -= damage;
if (CurrentShield < 0 ) {
if (CurrentShield < 0)
{
CurrentHealth -= Math.Abs(CurrentShield);
CurrentShield = 0;
}
}
else {
if (type is DamageType.Fire) {
else
{
if (type is DamageType.Fire)
{
CurrentHealth -= damage * 2;
}
else {
else
{
CurrentHealth -= damage;
}
@ -483,13 +526,13 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
Explode();
}
private void PlayShieldAnimation()
private void PlayShieldAnimation()
{
if (_shieldParticles is null) return;
_shieldParticles.Emitting = true;
}
public void Blink()
public void Blink()
{
if (BlinkShader != null)
{
@ -506,7 +549,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
await ToSignal(tween, "finished");
}
public async Task Teleport()
public async Task Teleport()
{
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;
@ -516,7 +559,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
await ToSignal(tween, "finished");
}
public async Task UnTeleport()
public async Task UnTeleport()
{
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;

BIN
Sprites/Actors/Focus_Circle.aseprite (Stored with Git LFS)

Binary file not shown.

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

Binary file not shown.

BIN
Sprites/Bullets/spiderbomb.png (Stored with Git LFS) Normal file

Binary file not shown.

View 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