mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:45:33 +00:00
Weapon Sprites
This commit is contained in:
parent
b4a35ac3d4
commit
f4f193af7a
19 changed files with 321 additions and 42 deletions
23
Resources/Weapons/EnemyWeapon.tres
Normal file
23
Resources/Weapons/EnemyWeapon.tres
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://cdfmedtgp2rcn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="1_c5ala"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_8ycgt"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_8ycgt")
|
||||
Name = "Enemy Weapon"
|
||||
BulletScene = ExtResource("1_c5ala")
|
||||
RateOfFire = 0.4
|
||||
BulletCapacity = 4
|
||||
ReloadTime = 1.0
|
||||
AutoReload = true
|
||||
InfiniteAmmo = true
|
||||
BulletsPerShot = 1
|
||||
SpreadAngle = 0.0
|
||||
RandomSpread = 0.0
|
||||
BulletSpeed = 50.0
|
||||
bulletPerShotCount = 1
|
||||
_rotationOffset = 0.0
|
||||
spread = 0.0
|
||||
owner = 2
|
||||
_timeModifiers = null
|
||||
23
Resources/Weapons/IcicleGun.tres
Normal file
23
Resources/Weapons/IcicleGun.tres
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://b8apu0l5fm4k"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_yby7n"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_m8dps")
|
||||
Name = "Icicle Gun"
|
||||
BulletScene = ExtResource("1_yby7n")
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 4
|
||||
ReloadTime = 0.8
|
||||
AutoReload = true
|
||||
InfiniteAmmo = true
|
||||
BulletsPerShot = 1
|
||||
SpreadAngle = 0.0
|
||||
RandomSpread = 0.0
|
||||
BulletSpeed = 300.0
|
||||
bulletPerShotCount = 1
|
||||
_rotationOffset = 0.0
|
||||
spread = 0.0
|
||||
owner = 1
|
||||
_timeModifiers = null
|
||||
23
Resources/Weapons/IcicleRepeater.tres
Normal file
23
Resources/Weapons/IcicleRepeater.tres
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://yuc0v7gojgep"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_lmn8t"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_f4135"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_f4135")
|
||||
Name = "Icicle Gun"
|
||||
BulletScene = ExtResource("1_lmn8t")
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 100
|
||||
ReloadTime = 0.4
|
||||
AutoReload = true
|
||||
InfiniteAmmo = true
|
||||
BulletsPerShot = 1
|
||||
SpreadAngle = 0.0
|
||||
RandomSpread = 0.0
|
||||
BulletSpeed = 300.0
|
||||
bulletPerShotCount = 1
|
||||
_rotationOffset = 0.0
|
||||
spread = 0.0
|
||||
owner = 1
|
||||
_timeModifiers = null
|
||||
|
|
@ -59,8 +59,6 @@ one_shot = true
|
|||
|
||||
[node name="Weapon" parent="." instance=ExtResource("4_xc6nm")]
|
||||
BulletScene = ExtResource("5_g1p0m")
|
||||
BulletCapacity = 4
|
||||
BulletSpeed = 50.0
|
||||
|
||||
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
|
||||
target_desired_distance = 64.0
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=13 format=3 uid="uid://v8s3kubgb2qg"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://v8s3kubgb2qg"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Enemy.cs" id="1_lpwdj"]
|
||||
[ext_resource type="Texture2D" uid="uid://buwohektt3k00" path="res://Sprites/Actors/Robot1.png" id="2_hqnpo"]
|
||||
[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="2_ogldd"]
|
||||
[ext_resource type="Script" path="res://Scripts/Components/ProximityPlayerDetection.cs" id="3_1nqn5"]
|
||||
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="4_2k1dv"]
|
||||
[ext_resource type="Resource" uid="uid://cdfmedtgp2rcn" path="res://Resources/Weapons/EnemyWeapon.tres" id="5_ieij6"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d7fe2"]
|
||||
atlas = ExtResource("2_hqnpo")
|
||||
|
|
@ -79,9 +80,8 @@ wait_time = 0.4
|
|||
one_shot = true
|
||||
|
||||
[node name="Weapon" parent="." instance=ExtResource("4_2k1dv")]
|
||||
WeaponData = ExtResource("5_ieij6")
|
||||
BulletScene = ExtResource("2_ogldd")
|
||||
BulletCapacity = 4
|
||||
BulletSpeed = 50.0
|
||||
|
||||
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
|
||||
target_desired_distance = 64.0
|
||||
|
|
|
|||
13
Scenes/Items/IcicleGun.tscn
Normal file
13
Scenes/Items/IcicleGun.tscn
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://q7hau0tl3vsr"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="1_exv8g"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jtwy2"]
|
||||
|
||||
[node name="IcicleGun" type="Area2D"]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_exv8g")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_jtwy2")
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=28 format=3 uid="uid://bghghp5ep4w2j"]
|
||||
[gd_scene load_steps=29 format=3 uid="uid://bghghp5ep4w2j"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
|
||||
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://cfb3nsay84xdb" path="res://Scenes/Weapons/crosshair.tscn" id="6_l43rf"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf37ce6jskdel" path="res://Sprites/SmallHitbox.png" id="7_msn8i"]
|
||||
[ext_resource type="Script" path="res://Scenes/InteractionController.cs" id="7_uvgjg"]
|
||||
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="9_84o8f"]
|
||||
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="9_wblq0"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ai4rh"]
|
||||
|
|
@ -210,12 +211,9 @@ 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")]
|
||||
WeaponData = ExtResource("9_84o8f")
|
||||
BulletScene = ExtResource("2_ov36d")
|
||||
Muzzle = NodePath("../Muzzle")
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 100
|
||||
ReloadTime = 0.4
|
||||
BulletSpeed = 300.0
|
||||
|
||||
[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
|
|
@ -89,6 +89,7 @@ public class BulletInfo
|
|||
public Vector2 Position { get; set; }
|
||||
public Vector2 Direction { get; set; }
|
||||
public float Speed { get; set; }
|
||||
public float LifeTime { get; set; }
|
||||
public BulletOwner Owner { get; set; }
|
||||
public int BulletCount { get; set; }
|
||||
public float RotationSpeed { get; set; }
|
||||
|
|
|
|||
42
Scripts/Resources/WeaponResource.cs
Normal file
42
Scripts/Resources/WeaponResource.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using Cirno.Scripts.Components;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class WeaponResource : Resource
|
||||
{
|
||||
[Export]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene BulletScene { get; set; }
|
||||
|
||||
[Export] public double RateOfFire = 0.4f;
|
||||
|
||||
[Export] public int BulletCapacity = 20;
|
||||
|
||||
[Export] public double ReloadTime = 1.0f;
|
||||
|
||||
[Export] public bool AutoReload = true;
|
||||
|
||||
[Export] public bool InfiniteAmmo = true;
|
||||
|
||||
[Export] public int BulletsPerShot = 1;
|
||||
|
||||
[Export] public float SpreadAngle = 0f;
|
||||
[Export] public float RandomSpread = 0f;
|
||||
|
||||
#region Bullet spawn data
|
||||
|
||||
[Export] public float BulletSpeed = 100f;
|
||||
[Export] public float BulletDamage = 1;
|
||||
[Export] private float _rotationOffset = 0f;
|
||||
[Export] private BulletOwner owner = BulletOwner.None;
|
||||
[Export] private Resource _modifier;
|
||||
[Export] private Array<Resource> _timeModifiers;
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
@ -2,32 +2,21 @@ using Godot;
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
public partial class Weapon : Node2D
|
||||
{
|
||||
|
||||
[Export]
|
||||
public WeaponResource WeaponData { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene BulletScene { get; set; }
|
||||
|
||||
[Export]
|
||||
public Marker2D Muzzle { get; set; }
|
||||
|
||||
[Export] public double RateOfFire = 0.4f;
|
||||
|
||||
[Export] public int BulletCapacity = 20;
|
||||
|
||||
[Export] public double ReloadTime = 1.0f;
|
||||
|
||||
[Export] public float BulletSpeed = 100f;
|
||||
|
||||
[Export] public bool AutoReload = true;
|
||||
|
||||
[Export] public bool InfiniteAmmo = true;
|
||||
|
||||
[Export] public int BulletsPerShot = 1;
|
||||
|
||||
[Export] public float BulletsSpreadAngle = 0f;
|
||||
|
||||
public int Ammo { get; set; } = 0;
|
||||
|
||||
public int LoadedAmmo { get; private set; }
|
||||
|
|
@ -53,16 +42,16 @@ public partial class Weapon : Node2D
|
|||
|
||||
public void Reload()
|
||||
{
|
||||
_cooldownTimer.Start(ReloadTime);
|
||||
_cooldownTimer.Start(WeaponData.ReloadTime);
|
||||
|
||||
if (InfiniteAmmo)
|
||||
if (WeaponData.InfiniteAmmo)
|
||||
{
|
||||
LoadedAmmo = BulletCapacity;
|
||||
LoadedAmmo = WeaponData.BulletCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Calculate subtraction, etc
|
||||
LoadedAmmo = BulletCapacity;
|
||||
LoadedAmmo = WeaponData.BulletCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +66,7 @@ public partial class Weapon : Node2D
|
|||
// Out of ammo?
|
||||
if (LoadedAmmo <= 0)
|
||||
{
|
||||
if (AutoReload)
|
||||
if (WeaponData.AutoReload)
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
|
|
@ -86,11 +75,11 @@ public partial class Weapon : Node2D
|
|||
|
||||
// TODO: Shoot at muzzle position, need to provide a way to turn it, on a radius?
|
||||
|
||||
float halfSpread = BulletsSpreadAngle / 2f;
|
||||
float spreadStep = BulletsPerShot > 1 ? BulletsSpreadAngle / (BulletsPerShot - 1) : 0;
|
||||
float halfSpread = WeaponData.SpreadAngle / 2f;
|
||||
float spreadStep = WeaponData.BulletsPerShot > 1 ? WeaponData.SpreadAngle / (WeaponData.BulletsPerShot - 1) : 0;
|
||||
|
||||
|
||||
for (int i = 0; i < BulletsPerShot; i++)
|
||||
for (int i = 0; i < WeaponData.BulletsPerShot; i++)
|
||||
{
|
||||
// Calculate angle offset for this bullet
|
||||
float spreadOffset = -halfSpread + (spreadStep * i);
|
||||
|
|
@ -98,7 +87,7 @@ public partial class Weapon : Node2D
|
|||
// Rotate the ShootDirection by the spread angle
|
||||
Vector2 spreadDirection = ShootDirection.Rotated(Mathf.DegToRad(spreadOffset));
|
||||
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, BulletScene, _muzzle.GlobalPosition);
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, WeaponData.BulletScene, _muzzle.GlobalPosition);
|
||||
|
||||
if (bullet == null)
|
||||
{
|
||||
|
|
@ -108,11 +97,11 @@ public partial class Weapon : Node2D
|
|||
|
||||
//bullet.SetDirection(ShootDirection);
|
||||
bullet.SetDirection(spreadDirection);
|
||||
bullet.Speed = BulletSpeed;
|
||||
bullet.Speed = WeaponData.BulletSpeed;
|
||||
}
|
||||
|
||||
LoadedAmmo -= 1;
|
||||
|
||||
_cooldownTimer.Start(RateOfFire);
|
||||
_cooldownTimer.Start(WeaponData.RateOfFire);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
Sprites/Items/Ice_Shotgun.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Items/Ice_Shotgun.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Items/Ice_Shotgun.png.import
Normal file
34
Sprites/Items/Ice_Shotgun.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b46usr10jhmev"
|
||||
path="res://.godot/imported/Ice_Shotgun.png-dd1ea79451cc6e92cbb8950dee9ae79d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Items/Ice_Shotgun.png"
|
||||
dest_files=["res://.godot/imported/Ice_Shotgun.png-dd1ea79451cc6e92cbb8950dee9ae79d.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
|
||||
BIN
Sprites/Items/Icicle_Gun.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Items/Icicle_Gun.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Items/Icicle_Gun.png.import
Normal file
34
Sprites/Items/Icicle_Gun.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://duwiasewxvcb5"
|
||||
path="res://.godot/imported/Icicle_Gun.png-9b35e9376441b673558b1800d9bc4b4e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Items/Icicle_Gun.png"
|
||||
dest_files=["res://.godot/imported/Icicle_Gun.png-9b35e9376441b673558b1800d9bc4b4e.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
|
||||
BIN
Sprites/Items/Snowball_Bazooka.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Items/Snowball_Bazooka.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Items/Snowball_Bazooka.png.import
Normal file
34
Sprites/Items/Snowball_Bazooka.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bvxnra17u1uic"
|
||||
path="res://.godot/imported/Snowball_Bazooka.png-a6fad3ed46e13a4a7e3f663fb0125f0e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Items/Snowball_Bazooka.png"
|
||||
dest_files=["res://.godot/imported/Snowball_Bazooka.png-a6fad3ed46e13a4a7e3f663fb0125f0e.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
|
||||
BIN
Sprites/Items/Ying_Yang_Gun.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Items/Ying_Yang_Gun.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Items/Ying_Yang_Gun.png.import
Normal file
34
Sprites/Items/Ying_Yang_Gun.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://61kfxc7k3do"
|
||||
path="res://.godot/imported/Ying_Yang_Gun.png-d9d5fde2dcfe741e21c3da70ba6d503b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Items/Ying_Yang_Gun.png"
|
||||
dest_files=["res://.godot/imported/Ying_Yang_Gun.png-d9d5fde2dcfe741e21c3da70ba6d503b.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