mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 16:05:53 +00:00
Bullet emitter
This commit is contained in:
parent
2e8bb70348
commit
e9a9653c20
6 changed files with 84 additions and 11 deletions
23
Scenes/Activable/BulletEmitter.tscn
Normal file
23
Scenes/Activable/BulletEmitter.tscn
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://cd36ch65jijg0"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Activables/BulletEmitter.cs" id="1_11khd"]
|
||||
[ext_resource type="Script" path="res://Scripts/Components/BulletSpawner.cs" id="2_cr25o"]
|
||||
[ext_resource type="PackedScene" uid="uid://bi3f14klscvlw" path="res://Scenes/Weapons/Bullets/enemyBullet_mid_red.tscn" id="2_tvufl"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="3_njoox"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pcsuf"]
|
||||
script = ExtResource("3_njoox")
|
||||
BulletScene = ExtResource("2_tvufl")
|
||||
BulletSpeed = 20.0
|
||||
BulletDamage = 4.0
|
||||
LifeTime = 4.0
|
||||
Owner = 0
|
||||
DamageType = 2
|
||||
TimeModifiers = Array[Object]([])
|
||||
|
||||
[node name="BulletEmitter" type="Node2D"]
|
||||
script = ExtResource("1_11khd")
|
||||
BulletResource = SubResource("Resource_pcsuf")
|
||||
|
||||
[node name="BulletSpawner" type="Node2D" parent="."]
|
||||
script = ExtResource("2_cr25o")
|
||||
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_glhl1"]
|
||||
|
||||
[node name="DialogueStarter" type="Area2D" node_paths=PackedStringArray("_dialogueEndActivationTargets")]
|
||||
[node name="DialogueStarter" type="Area2D" node_paths=PackedStringArray("_targets")]
|
||||
monitoring = false
|
||||
monitorable = false
|
||||
script = ExtResource("1_nlikr")
|
||||
_trackName = ""
|
||||
_dialogueEndActivationTargets = []
|
||||
_targets = []
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_glhl1")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=56 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=57 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
|
||||
|
|
@ -48,6 +48,7 @@
|
|||
[ext_resource type="Script" path="res://Scripts/Resources/Events/DialogueStartEvent.cs" id="46_i0omr"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdti0hnbs3e63" path="res://Scenes/Actors/RoamingSusan.tscn" id="47_u1ve6"]
|
||||
[ext_resource type="PackedScene" uid="uid://b0pb078xylxy" path="res://Scenes/Interactable/Valve.tscn" id="48_8usll"]
|
||||
[ext_resource type="PackedScene" uid="uid://cd36ch65jijg0" path="res://Scenes/Activable/BulletEmitter.tscn" id="49_64oga"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_8wuck"]
|
||||
|
||||
|
|
@ -383,18 +384,16 @@ DefeatScript = NodePath("../BossBattleEndScript")
|
|||
position = Vector2(-794, -127)
|
||||
Target = NodePath("DialogueStarter")
|
||||
|
||||
[node name="DialogueStarter" parent="Computer" node_paths=PackedStringArray("_targets") instance=ExtResource("32_68v02")]
|
||||
[node name="DialogueStarter" parent="Computer" instance=ExtResource("32_68v02")]
|
||||
_trackName = "computer1"
|
||||
_targets = []
|
||||
|
||||
[node name="Computer2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-1464, -276)
|
||||
Target = NodePath("DialogueStarter")
|
||||
|
||||
[node name="DialogueStarter" parent="Computer2" node_paths=PackedStringArray("_targets") instance=ExtResource("32_68v02")]
|
||||
[node name="DialogueStarter" parent="Computer2" instance=ExtResource("32_68v02")]
|
||||
position = Vector2(291.847, -32.7126)
|
||||
_trackName = "computer2"
|
||||
_targets = []
|
||||
|
||||
[node name="Ammo1" parent="." instance=ExtResource("34_17pjh")]
|
||||
position = Vector2(-790, -381)
|
||||
|
|
@ -440,4 +439,7 @@ position = Vector2(-707, 53)
|
|||
|
||||
[node name="Valve" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("48_8usll")]
|
||||
position = Vector2(-697, 25)
|
||||
Target = NodePath("")
|
||||
Target = NodePath("../BulletEmitter")
|
||||
|
||||
[node name="BulletEmitter" parent="." instance=ExtResource("49_64oga")]
|
||||
position = Vector2(-728, 57)
|
||||
|
|
|
|||
50
Scripts/Activables/BulletEmitter.cs
Normal file
50
Scripts/Activables/BulletEmitter.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
||||
public partial class BulletEmitter : Node2D, IActivable
|
||||
{
|
||||
|
||||
[Export]
|
||||
public BulletResource BulletResource { get; set; }
|
||||
|
||||
[Export]
|
||||
private bool _isEmitting { get; set; } = false;
|
||||
|
||||
[Export] public float Spread { get; set; } = 0f;
|
||||
|
||||
[Export] public float Rotation { get; set; } = 0f;
|
||||
|
||||
private BulletSpawner _bulletSpawner;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_bulletSpawner = GetNode<BulletSpawner>("BulletSpawner");
|
||||
}
|
||||
|
||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
switch (activationType)
|
||||
{
|
||||
case ActivationType.Toggle:
|
||||
break;
|
||||
case ActivationType.Enable:
|
||||
_bulletSpawner.SpawnBullet(BulletResource.MakeBullet(this.GlobalPosition, 1, Spread, Rotation));
|
||||
break;
|
||||
case ActivationType.Disable:
|
||||
break;
|
||||
case ActivationType.Use:
|
||||
_bulletSpawner.SpawnBullet(BulletResource.MakeBullet(this.GlobalPosition, 1, Spread, Rotation));
|
||||
break;
|
||||
case ActivationType.Destroy:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(activationType), activationType, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ public partial class BulletSpawner : Node2D
|
|||
float baseAngle = Mathf.Atan2(baseDirection.Y, baseDirection.X);
|
||||
|
||||
float offsetRadians = Mathf.DegToRad(bulletInfo.RotationOffset);
|
||||
float spreadStep = Mathf.DegToRad(bulletInfo.Spread) / (bulletInfo.BulletCount - 1); // Ensure proper spread spacing
|
||||
float spreadStep = Mathf.DegToRad(bulletInfo.Spread) / Mathf.Max(1,bulletInfo.BulletCount - 1); // Ensure proper spread spacing, also add 1 if 0
|
||||
float angle = baseAngle + offsetRadians + (spreadStep * i);
|
||||
// float angle = baseAngle + Mathf.DegToRad(bulletInfo.RotationOffset + (bulletInfo.Spread / bulletInfo.BulletCount) * i);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,8 +74,6 @@ public partial class Door : Activable
|
|||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(activationType), activationType, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SetState(DoorState state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue