mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 06:45:33 +00:00
Shooting
This commit is contained in:
parent
1229613def
commit
341f76d885
17 changed files with 156 additions and 55 deletions
24
Resources/Bullets/icicle_gun_bullets_3D.tres
Normal file
24
Resources/Bullets/icicle_gun_bullets_3D.tres
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://csmq6hngkx41e"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://byc67yxbkefyk" path="res://Scenes/Weapons/bullet_3D.tscn" id="1_qojek"]
|
||||
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="3_xep6w"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_xep6w")
|
||||
BulletScene = ExtResource("1_qojek")
|
||||
BulletSpeed = 10.0
|
||||
Direction = Vector2(1, 0)
|
||||
BulletDamage = 0.4
|
||||
MaxDamage = 1.0
|
||||
Knockback = 100.0
|
||||
LifeTime = 10.0
|
||||
DestroyOnCollision = true
|
||||
Owner = 1
|
||||
DamageType = 3
|
||||
RotateSprite = false
|
||||
Controllable = false
|
||||
Freezable = true
|
||||
Grazeable = false
|
||||
GrazeValue = 0.2
|
||||
Attributes = 256
|
||||
TimeModifiers = []
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cs3ihltcn2166"]
|
||||
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cs3ihltcn2166"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="1_itajb"]
|
||||
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="2_eaoas"]
|
||||
[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_hy2hk"]
|
||||
[ext_resource type="Resource" uid="uid://bohkmf6g1fi2o" path="res://Resources/Weapons/IcicleGun_3D.tres" id="3_nh721"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_hy2hk")
|
||||
|
|
@ -14,6 +15,7 @@ Item = 9
|
|||
Tier = 0
|
||||
Price = 0
|
||||
WeaponData = ExtResource("1_itajb")
|
||||
WeaponData3D = ExtResource("3_nh721")
|
||||
Amount = 1
|
||||
Max = 1
|
||||
PickupIfMaxed = false
|
||||
|
|
|
|||
26
Resources/Weapons/IcicleGun_3D.tres
Normal file
26
Resources/Weapons/IcicleGun_3D.tres
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=5 format=3 uid="uid://bohkmf6g1fi2o"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://csmq6hngkx41e" path="res://Resources/Bullets/icicle_gun_bullets_3D.tres" id="1_d2kl0"]
|
||||
[ext_resource type="AudioStream" uid="uid://jsv3yjluv1au" path="res://SFX/Weapons/Reload_01.wav" id="2_sdmjb"]
|
||||
[ext_resource type="AudioStream" uid="uid://d16xfhll0fujt" path="res://SFX/Ice_Shot.wav" id="3_hj8fq"]
|
||||
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="4_ld57e"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("4_ld57e")
|
||||
Name = &"Icicle Gun"
|
||||
BulletData = ExtResource("1_d2kl0")
|
||||
Priority = 1
|
||||
AmmoPerShot = 1
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 100
|
||||
ReloadTime = 0.1
|
||||
AutoReload = true
|
||||
InfiniteAmmo = true
|
||||
ItemKey = &"ICICLE_GUN"
|
||||
AmmoKey = &""
|
||||
BulletsPerShot = 1
|
||||
SpreadAngle = 5.0
|
||||
RandomSpread = 2.5
|
||||
_rotationOffset = 0.0
|
||||
ReloadSound = ExtResource("2_sdmjb")
|
||||
ShootSound = ExtResource("3_hj8fq")
|
||||
|
|
@ -81,12 +81,12 @@ FallSpeed = 100.0
|
|||
script = ExtResource("6_habpy")
|
||||
Root = NodePath("..")
|
||||
|
||||
[node name="MouseAimProvider" type="Node3D" parent="."]
|
||||
script = ExtResource("9_2ffwi")
|
||||
|
||||
[node name="InputProvider" type="Node" parent="."]
|
||||
script = ExtResource("7_4cdxq")
|
||||
|
||||
[node name="MouseAimProvider" type="Node3D" parent="InputProvider"]
|
||||
script = ExtResource("9_2ffwi")
|
||||
|
||||
[node name="Shadow" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, -0.29, 0)
|
||||
mesh = SubResource("QuadMesh_fg04g")
|
||||
|
|
@ -128,6 +128,9 @@ bus = &"Effects"
|
|||
[node name="AudioListener3D" type="AudioListener3D" parent="."]
|
||||
current = true
|
||||
|
||||
[node name="WeaponOffset" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.267617, 0, -0.24769)
|
||||
|
||||
[node name="WeaponModule" type="Node" parent="." node_paths=PackedStringArray("WeaponProvider", "InputProvider", "Storage")]
|
||||
script = ExtResource("15_el8as")
|
||||
WeaponProvider = NodePath("WeaponProvider")
|
||||
|
|
@ -138,8 +141,5 @@ Storage = NodePath("../Storage")
|
|||
script = ExtResource("16_olwak")
|
||||
StorageModule = NodePath("../../Storage")
|
||||
WeaponTemplate = ExtResource("17_olwak")
|
||||
WeaponRightOffset = NodePath("../Marker3D")
|
||||
WeaponLeftOffset = NodePath("../Marker3D")
|
||||
|
||||
[node name="Marker3D" type="Marker3D" parent="WeaponModule"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.267617, 0, -0.24769)
|
||||
WeaponRightOffset = NodePath("../../WeaponOffset")
|
||||
WeaponLeftOffset = NodePath("../../WeaponOffset")
|
||||
|
|
|
|||
|
|
@ -444,12 +444,12 @@ script = ExtResource("7_pmkfo")
|
|||
_animatedSprite = NodePath("../Legs")
|
||||
BlinkMaterial = ExtResource("4_5qlss")
|
||||
|
||||
[node name="MouseAimProvider" type="Node2D" parent="."]
|
||||
script = ExtResource("20_3rkrn")
|
||||
|
||||
[node name="InputProvider" type="Node" parent="."]
|
||||
script = ExtResource("8_i6wc8")
|
||||
|
||||
[node name="MouseAimProvider" type="Node2D" parent="InputProvider"]
|
||||
script = ExtResource("20_3rkrn")
|
||||
|
||||
[node name="CrosshairProvider" type="Node2D" parent="." node_paths=PackedStringArray("StorageModule", "AnimatedSprite")]
|
||||
script = ExtResource("9_s0ir4")
|
||||
StorageModule = NodePath("../Storage")
|
||||
|
|
|
|||
29
Scenes/Weapons/bullet_3D.tscn
Normal file
29
Scenes/Weapons/bullet_3D.tscn
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://byc67yxbkefyk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cg6y36s7buapp" path="res://Scripts/Weapons/Bullet3D.cs" id="1_48dvc"]
|
||||
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="2_pklkt"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_pklkt"]
|
||||
radius = 0.172059
|
||||
|
||||
[node name="Bullet" type="Area3D" groups=["bullets"]]
|
||||
collision_layer = 8
|
||||
collision_mask = 85
|
||||
script = ExtResource("1_48dvc")
|
||||
Speed = 200.0
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Sprite" type="Sprite3D" parent="."]
|
||||
pixel_size = 0.05
|
||||
billboard = 1
|
||||
texture_filter = 0
|
||||
texture = ExtResource("2_pklkt")
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_pklkt")
|
||||
|
||||
[node name="VisibleOnScreenNotifier" type="VisibleOnScreenNotifier3D" parent="."]
|
||||
|
||||
[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="VisibleOnScreenNotifier" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||
|
|
@ -47,7 +47,7 @@ public partial class KeyboardInputProvider : InputProvider
|
|||
|
||||
private void DelayedRegisterGameManager()
|
||||
{
|
||||
_mouseAImProvider = GetNodeOrNull<IMouseAimProvider>("MouseAimProvider");
|
||||
_mouseAImProvider = this.GetParent().GetNodeOrNull<IMouseAimProvider>("MouseAimProvider");
|
||||
|
||||
if (_mouseAImProvider is null)
|
||||
{
|
||||
|
|
@ -57,10 +57,18 @@ public partial class KeyboardInputProvider : InputProvider
|
|||
if (GameManager.Instance is null)
|
||||
{
|
||||
GD.Print("No GameManager found for keyboard inputprovider");
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.GameStateChange += InstanceOnGameStateChange;
|
||||
}
|
||||
|
||||
GameManager.Instance.GameStateChange += InstanceOnGameStateChange;
|
||||
if (GameController.Instance is not null)
|
||||
{
|
||||
GameController.Instance.GameStateChange += InstanceOnGameStateChange;
|
||||
}
|
||||
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@ public partial class MouseAimProvider3D : Node3D, IMouseAimProvider
|
|||
|
||||
return mouseWorldPos - screenPosition;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -53,10 +53,12 @@ public partial class IsoMovementModule : ModuleBase<PlayerState, CharacterBody3D
|
|||
if (rightStickInput.Length() > 0.1f) // If the right stick is moved
|
||||
{
|
||||
PlayerStorage.FacingDirection = rightStickInput;
|
||||
PlayerStorage.AimingDirection = rightStickInput;
|
||||
}
|
||||
else if (movementInput != Vector2.Zero) // Fall back to movement direction
|
||||
{
|
||||
PlayerStorage.FacingDirection = movementInput;
|
||||
PlayerStorage.AimingDirection = rightStickInput;
|
||||
}
|
||||
// }
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,10 @@ public partial class PlayerWeaponModule3D : ModuleBase<PlayerState, CharacterBod
|
|||
return;
|
||||
}
|
||||
|
||||
if (!InputProvider.GetShootPressed()) return;
|
||||
WeaponProvider.Shoot(Storage.AimingDirection);
|
||||
if (InputProvider.GetShootPressed())
|
||||
{
|
||||
WeaponProvider.Shoot(Storage.AimingDirection);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleWeaponSwitch()
|
||||
|
|
|
|||
|
|
@ -221,9 +221,12 @@ public partial class PlayerWeaponProvider3D : Node
|
|||
if (maybeExistingWeapon is not null) return maybeExistingWeapon;
|
||||
|
||||
var weapon = WeaponTemplate.Instantiate<Weapon3D>();
|
||||
this.AddChild(weapon);
|
||||
_parent.AddChild(weapon);
|
||||
|
||||
weapon.GlobalPosition = _parent.GlobalPosition;
|
||||
|
||||
//this.CreateSibling<Weapon>(WeaponTemplate);
|
||||
weapon.WeaponData = startingItem.WeaponData;
|
||||
weapon.WeaponData = startingItem.WeaponData3D;
|
||||
|
||||
weapon.Sprite.Texture = startingItem.InventorySprite;
|
||||
|
||||
|
|
|
|||
|
|
@ -124,10 +124,10 @@ public partial class PoolingManager : Node
|
|||
|
||||
private IBullet InstantiateBullet(BulletResource bulletData)
|
||||
{
|
||||
var bullet = bulletData.BulletScene.Instantiate<Bullet>();
|
||||
var bullet = bulletData.BulletScene.Instantiate<Node>();
|
||||
this.AddChild(bullet);
|
||||
//this.CreateChild<Bullet>(bulletData.BulletScene);
|
||||
return bullet;
|
||||
return bullet as IBullet;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public partial class LootItem : Resource
|
|||
[Export] public int Price { get; set; }
|
||||
[Export] public ItemEffectResource ItemEffect { get; private set; }
|
||||
[Export] public WeaponResource WeaponData { get; set; }
|
||||
[Export] public WeaponResource WeaponData3D { get; set; }
|
||||
[Export] public int Amount;
|
||||
[Export] public int Max;
|
||||
[Export] public bool PickupIfMaxed;
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
[Signal]
|
||||
public delegate void OnDestroyEventHandler();
|
||||
|
||||
private AudioStreamPlayer2D _grazeSound;
|
||||
private GpuParticles2D _grazeParticles;
|
||||
private AudioStreamPlayer3D _grazeSound;
|
||||
private GpuParticles3D _grazeParticles;
|
||||
|
||||
private CollisionShape2D _collisionShape2D;
|
||||
private CollisionShape3D _collisionShape;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer2D>("AudioStreamPlayer2D");
|
||||
_grazeParticles = GetNodeOrNull<GpuParticles2D>("GrazeParticles");
|
||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer3D>("AudioStreamPlayer");
|
||||
_grazeParticles = GetNodeOrNull<GpuParticles3D>("GrazeParticles");
|
||||
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
|
||||
}
|
||||
|
||||
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
||||
|
|
@ -77,12 +77,12 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
{
|
||||
Enabled = true;
|
||||
Show();
|
||||
if (this._collisionShape2D is null)
|
||||
if (this._collisionShape is null)
|
||||
{
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
|
||||
}
|
||||
|
||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false);
|
||||
_collisionShape.SetDeferred(CollisionShape3D.PropertyName.Disabled, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -96,12 +96,12 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
Hide();
|
||||
}
|
||||
|
||||
if (this._collisionShape2D is null)
|
||||
if (this._collisionShape is null)
|
||||
{
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_collisionShape = GetNode<CollisionShape3D>("CollisionShape2D");
|
||||
}
|
||||
|
||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
||||
_collisionShape.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
||||
}
|
||||
|
||||
public void Graze()
|
||||
|
|
@ -209,7 +209,9 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
ControlBullet(delta);
|
||||
}
|
||||
|
||||
//this.Position += ((float)(Speed * delta) * _direction);
|
||||
var newPos2D = ((float)(Speed * delta) * _direction);
|
||||
|
||||
this.Position += new Vector3(newPos2D.X, 0, newPos2D.Y);
|
||||
}
|
||||
|
||||
private void ControlBullet(double delta)
|
||||
|
|
@ -232,7 +234,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
Destroy();
|
||||
}
|
||||
|
||||
private void _on_body_entered(Node2D body)
|
||||
private void _on_body_entered(Node3D body)
|
||||
{
|
||||
if (body.IsInGroup("Solid"))
|
||||
{
|
||||
|
|
@ -247,7 +249,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
// }
|
||||
}
|
||||
|
||||
private void _on_area_entered(Area2D area)
|
||||
private void _on_area_entered(Area3D area)
|
||||
{
|
||||
if (area.IsInGroup("Solid"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Godot;
|
|||
|
||||
namespace Cirno.Scripts.Weapons;
|
||||
|
||||
public partial class Weapon3D : Node
|
||||
public partial class Weapon3D : Node3D
|
||||
{
|
||||
[Export]
|
||||
public WeaponResource WeaponData { get; set; }
|
||||
|
|
@ -103,18 +103,18 @@ public partial class Weapon3D : Node
|
|||
}
|
||||
|
||||
// Check for battery if it's used
|
||||
if (UsesBattery)
|
||||
{
|
||||
if (GameManager.Instance.Player.Shield.CurrentResource >= WeaponData.AmmoPerShot)
|
||||
{
|
||||
GameManager.Instance.Player.Shield.CurrentResource -= WeaponData.AmmoPerShot;
|
||||
}
|
||||
else
|
||||
{
|
||||
EmitSignalEmpty();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (UsesBattery)
|
||||
// {
|
||||
// if (GameManager.Instance.Player.Shield.CurrentResource >= WeaponData.AmmoPerShot)
|
||||
// {
|
||||
// GameManager.Instance.Player.Shield.CurrentResource -= WeaponData.AmmoPerShot;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// EmitSignalEmpty();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Out of ammo?
|
||||
if (LoadedAmmo < WeaponData.AmmoPerShot)
|
||||
|
|
|
|||
|
|
@ -3,25 +3,26 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cybpmpb0d8yva"
|
||||
path="res://.godot/imported/Projectile.png-a3a119d8fd8345a39899211a3cae4b28.ctex"
|
||||
path.s3tc="res://.godot/imported/Projectile.png-a3a119d8fd8345a39899211a3cae4b28.s3tc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Projectile.png"
|
||||
dest_files=["res://.godot/imported/Projectile.png-a3a119d8fd8345a39899211a3cae4b28.ctex"]
|
||||
dest_files=["res://.godot/imported/Projectile.png-a3a119d8fd8345a39899211a3cae4b28.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/mode=2
|
||||
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/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
|
|
@ -31,4 +32,4 @@ 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
|
||||
detect_3d/compress_to=0
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue