mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:05:34 +00:00
Made crosshair into a module
This commit is contained in:
parent
625466d2d7
commit
ddadb9bd04
10 changed files with 93 additions and 36 deletions
|
|
@ -1,6 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="BossPhase" load_steps=4 format=3 uid="uid://da1vjfavqs7u2"]
|
||||
[gd_resource type="Resource" script_class="BossPhase" load_steps=5 format=3 uid="uid://da1vjfavqs7u2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cdd6q2h0t1hhq" path="res://Scripts/Resources/BossPhase.cs" id="1_7asq8"]
|
||||
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="1_ykywc"]
|
||||
[ext_resource type="Script" uid="uid://c0ndqalsc4jve" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="1_ys2v3"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_q4pcc"]
|
||||
|
|
@ -22,7 +23,7 @@ DamageType = 0
|
|||
OverrideControllable = false
|
||||
Controllable = false
|
||||
OverrideCreationModifier = false
|
||||
TimeModifiers = []
|
||||
TimeModifiers = Array[ExtResource("1_ykywc")]([])
|
||||
WaitForCompletion = true
|
||||
|
||||
[resource]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_resource type="Resource" script_class="BulletScript" load_steps=5 format=3 uid="uid://cmra7n6so1x4u"]
|
||||
[gd_resource type="Resource" script_class="BulletScript" load_steps=6 format=3 uid="uid://cmra7n6so1x4u"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://dqnvesdj0dk3v" path="res://Resources/Bullets/simple_enemy_bullet.tres" id="1_lkipe"]
|
||||
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="2_omk5v"]
|
||||
[ext_resource type="Script" uid="uid://c0ndqalsc4jve" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="2_v7d4m"]
|
||||
[ext_resource type="Script" uid="uid://bngko08ho85p6" path="res://Scripts/Resources/BulletScript.cs" id="3_omk5v"]
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ DamageType = 0
|
|||
OverrideControllable = false
|
||||
Controllable = false
|
||||
OverrideCreationModifier = false
|
||||
TimeModifiers = []
|
||||
TimeModifiers = Array[ExtResource("2_omk5v")]([])
|
||||
WaitForCompletion = true
|
||||
metadata/_custom_type_script = "uid://c0ndqalsc4jve"
|
||||
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ _damageReceiver = NodePath("../../DamageReceiver")
|
|||
_activationProvider = NodePath("../../InteractionProvider")
|
||||
_interactionController = NodePath("../../InteractionController")
|
||||
_storageModule = NodePath("../../Storage")
|
||||
_moduleNodes = [NodePath("../../InteractionController"), NodePath("../../ItemUser"), NodePath("../../ConveyorBeltMover"), NodePath("../../AutoPickupModule"), NodePath("../../GrazingModule"), NodePath("../../FreezeModule")]
|
||||
_moduleNodes = [NodePath("../../InteractionController"), NodePath("../../ItemUser"), NodePath("../../ConveyorBeltMover"), NodePath("../../AutoPickupModule"), NodePath("../../GrazingModule"), NodePath("../../FreezeModule"), NodePath("../../CrosshairProvider")]
|
||||
|
||||
[node name="Cutscene" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("_animationProvider")]
|
||||
script = ExtResource("4_22ff8")
|
||||
|
|
@ -428,17 +428,17 @@ lifetime = 0.4
|
|||
one_shot = true
|
||||
process_material = SubResource("ParticleProcessMaterial_0pqs8")
|
||||
|
||||
[node name="LegsAnimationProvider" type="Node2D" parent="." node_paths=PackedStringArray("_animatedSprite", "_shieldParticles")]
|
||||
[node name="LegsAnimationProvider" type="Node2D" parent="." node_paths=PackedStringArray("_animatedSprite")]
|
||||
script = ExtResource("7_pmkfo")
|
||||
_animatedSprite = NodePath("../Legs")
|
||||
_shieldParticles = NodePath("")
|
||||
BlinkMaterial = ExtResource("4_5qlss")
|
||||
|
||||
[node name="InputProvider" type="Node2D" parent="."]
|
||||
script = ExtResource("8_i6wc8")
|
||||
|
||||
[node name="CrosshairProvider" type="Node2D" parent="." node_paths=PackedStringArray("AnimatedSprite")]
|
||||
[node name="CrosshairProvider" type="Node2D" parent="." node_paths=PackedStringArray("StorageModule", "AnimatedSprite")]
|
||||
script = ExtResource("9_s0ir4")
|
||||
StorageModule = NodePath("../Storage")
|
||||
AnimatedSprite = NodePath("Crosshair")
|
||||
CrosshairDistance = 35.0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=167 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=168 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"]
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://cmr6fclttrpkb" path="res://Scenes/Items/Ammo1.tscn" id="34_17pjh"]
|
||||
[ext_resource type="PackedScene" uid="uid://byjq8xpx4crfd" path="res://Scenes/Interactable/control_pad_blue_keycard.tscn" id="35_gdbcj"]
|
||||
[ext_resource type="PackedScene" uid="uid://d0yes7huiyisw" path="res://Scenes/Items/Blue_Keycard.tscn" id="35_rblsn"]
|
||||
[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="36_7lma1"]
|
||||
[ext_resource type="PackedScene" uid="uid://r25rq6ijgm6m" path="res://Scenes/Items/Green_Keycard.tscn" id="36_f8fh1"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnbtou2fklyvp" path="res://Scenes/Actors/alarm_sign.tscn" id="36_rd6f6"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsbk2l40er2da" path="res://Scenes/Props/Box_Blue.tscn" id="37_gtga7"]
|
||||
|
|
@ -297,7 +298,7 @@ ActivationType = 0
|
|||
Targets = Array[NodePath]([NodePath("../Rumia")])
|
||||
WaitForCompletion = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ldb17"]
|
||||
[sub_resource type="Resource" id="Resource_jm0wb"]
|
||||
resource_local_to_scene = true
|
||||
script = ExtResource("49_0si7g")
|
||||
Target = NodePath(".")
|
||||
|
|
@ -687,7 +688,7 @@ position = Vector2(-1832, -99)
|
|||
|
||||
[node name="Chest2" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-679, -408)
|
||||
LootTable = [ExtResource("76_dskij"), ExtResource("77_wma5c"), ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("77_wma5c"), ExtResource("77_wma5c"), ExtResource("77_wma5c"), ExtResource("77_wma5c"), ExtResource("76_dskij")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("76_dskij"), ExtResource("77_wma5c"), ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("94_gd7x4"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("6_khabp"), ExtResource("77_wma5c"), ExtResource("77_wma5c"), ExtResource("77_wma5c"), ExtResource("77_wma5c"), ExtResource("76_dskij")])
|
||||
|
||||
[node name="Valve" parent="Parallax2D/Factory Tilemaps/Debug Room" node_paths=PackedStringArray("Target") instance=ExtResource("48_8usll")]
|
||||
position = Vector2(-666, -545)
|
||||
|
|
@ -991,7 +992,7 @@ position = Vector2(-1488, -544)
|
|||
|
||||
[node name="Chest" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-920, -424)
|
||||
LootTable = [ExtResource("27_y1lom"), ExtResource("28_u0dff"), ExtResource("29_wb5l5"), ExtResource("30_0d2o6"), ExtResource("5_nqier")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("27_y1lom"), ExtResource("28_u0dff"), ExtResource("29_wb5l5"), ExtResource("30_0d2o6"), ExtResource("5_nqier")])
|
||||
|
||||
[node name="RedKeycard_Switch_2" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Target") instance=ExtResource("17_e3v0b")]
|
||||
position = Vector2(-1095, 132)
|
||||
|
|
@ -1241,7 +1242,7 @@ Events = Array[ExtResource("66_ldb17")]([SubResource("Resource_068l7"), SubResou
|
|||
|
||||
[node name="BossBattleStartScript" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-1487, -396)
|
||||
Events = Array[ExtResource("66_ldb17")]([SubResource("Resource_4f4id"), SubResource("Resource_s2o7m"), SubResource("Resource_b1dht"), SubResource("Resource_xrgpy"), SubResource("Resource_ldb17")])
|
||||
Events = Array[ExtResource("66_ldb17")]([SubResource("Resource_4f4id"), SubResource("Resource_s2o7m"), SubResource("Resource_b1dht"), SubResource("Resource_xrgpy"), SubResource("Resource_jm0wb")])
|
||||
|
||||
[node name="Enemy13" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("47_u1ve6")]
|
||||
position = Vector2(-1657, -788)
|
||||
|
|
@ -1370,7 +1371,7 @@ position = Vector2(-2000, -736)
|
|||
[node name="ControlPad8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
|
||||
position = Vector2(-2027, -735)
|
||||
Targets = [NodePath("../HorizontalForceField")]
|
||||
Requirements = [ExtResource("84_ma1ta")]
|
||||
Requirements = Array[ExtResource("36_7lma1")]([ExtResource("84_ma1ta")])
|
||||
|
||||
[node name="Ammo6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")]
|
||||
position = Vector2(-872, -220)
|
||||
|
|
@ -1434,35 +1435,35 @@ position = Vector2(-1624, -813)
|
|||
|
||||
[node name="Chest3" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-376, 54)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")])
|
||||
|
||||
[node name="Chest5" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-1048, -139)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g"), ExtResource("4_swym2")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g"), ExtResource("4_swym2")])
|
||||
|
||||
[node name="Chest6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-2104, -362)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g"), ExtResource("4_swym2")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g"), ExtResource("4_swym2")])
|
||||
|
||||
[node name="Chest4" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-823, 67)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")])
|
||||
|
||||
[node name="Chest7" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-1417, 326)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")])
|
||||
|
||||
[node name="Chest10" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-1515, 408)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")])
|
||||
|
||||
[node name="Chest8" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-1544, 552)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")])
|
||||
|
||||
[node name="Chest9" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("25_4b2ed")]
|
||||
position = Vector2(-1384, 231)
|
||||
LootTable = [ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")]
|
||||
LootTable = Array[ExtResource("36_7lma1")]([ExtResource("6_khabp"), ExtResource("94_gd7x4"), ExtResource("95_srv0g")])
|
||||
|
||||
[node name="Ammo13" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")]
|
||||
position = Vector2(-392, 52)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components.FSM;
|
||||
using Cirno.Scripts.Components.FSM.Player;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
||||
public partial class PlayerCrosshairProvider : Node2D
|
||||
public partial class PlayerCrosshairProvider : PlayerNode2DModule
|
||||
{
|
||||
[Export] public PlayerStorageModule StorageModule { get; set; }
|
||||
[Export]
|
||||
public AnimatedSprite2D AnimatedSprite { get; private set; }
|
||||
|
||||
[Export]
|
||||
public float CrosshairDistance { get; private set; }
|
||||
|
||||
|
||||
public bool Enabled { get; set; } = false;
|
||||
public void UpdatePosition(Vector2 facingDirection)
|
||||
{
|
||||
AnimatedSprite.Position = CalculateCrosshairPosition(facingDirection);
|
||||
|
|
@ -20,13 +24,37 @@ public partial class PlayerCrosshairProvider : Node2D
|
|||
return facingDirection * CrosshairDistance;
|
||||
}
|
||||
|
||||
// public void Show()
|
||||
// {
|
||||
// AnimatedSprite.Show();
|
||||
// }
|
||||
//
|
||||
// public void Hide()
|
||||
// {
|
||||
// AnimatedSprite.Hide();
|
||||
// }
|
||||
public override void EnterState(PlayerState state)
|
||||
{
|
||||
Enabled = true;
|
||||
AnimatedSprite.Show();
|
||||
}
|
||||
|
||||
public override void ExitState(PlayerState state)
|
||||
{
|
||||
Enabled = false;
|
||||
AnimatedSprite.Hide();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
AnimatedSprite.Hide();
|
||||
}
|
||||
|
||||
public override void Init(IStateMachine<PlayerState, CharacterBody2D> machine)
|
||||
{
|
||||
AnimatedSprite.Hide();
|
||||
}
|
||||
|
||||
public override void Process(double delta)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
}
|
||||
|
||||
public override void PhysicsProcess(double delta)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
AnimatedSprite.Position = CalculateCrosshairPosition(StorageModule.FacingDirection);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Components.FSM.Player;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
|
@ -9,6 +10,7 @@ namespace Cirno.Scripts.Components.Actors;
|
|||
|
||||
public partial class PlayerWeaponProvider : Node2D
|
||||
{
|
||||
[Export] public PlayerStorageModule StorageModule { get; set; }
|
||||
[Export] public PackedScene WeaponTemplate { get; private set; }
|
||||
public Array<Weapon> EquippedWeapons { get; set; } = [];
|
||||
|
||||
|
|
@ -157,6 +159,8 @@ public partial class PlayerWeaponProvider : Node2D
|
|||
|
||||
var weapon = this.CreateSibling<Weapon>(WeaponTemplate);
|
||||
weapon.WeaponData = startingItem.WeaponData;
|
||||
|
||||
weapon.Texture = startingItem.InventorySprite;
|
||||
|
||||
this.AddWeapon(weapon);
|
||||
return weapon;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public partial class Active : PlayerStateBase
|
|||
_animationProvider.SetAnimationSpeed(MainObject.Velocity);
|
||||
_animationProvider.SetAnimation(FacingDirection);
|
||||
|
||||
_crosshairProvider.UpdatePosition(FacingDirection);
|
||||
//_crosshairProvider.UpdatePosition(FacingDirection);
|
||||
|
||||
HandleShoot();
|
||||
|
||||
|
|
|
|||
21
Scripts/Components/FSM/Player/PlayerNode2DModule.cs
Normal file
21
Scripts/Components/FSM/Player/PlayerNode2DModule.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM;
|
||||
|
||||
public abstract partial class PlayerNode2DModule : Node2D, IModule<PlayerState, CharacterBody2D>
|
||||
{
|
||||
public IStateMachine<PlayerState, CharacterBody2D> StateMachine { get; private set; }
|
||||
|
||||
public CharacterBody2D CharacterBody => StateMachine.MainObject;
|
||||
|
||||
|
||||
public abstract void EnterState(PlayerState state);
|
||||
public abstract void ExitState(PlayerState state);
|
||||
|
||||
public virtual void Init(IStateMachine<PlayerState, CharacterBody2D> machine)
|
||||
{
|
||||
StateMachine = machine;
|
||||
}
|
||||
public abstract void Process(double delta);
|
||||
public abstract void PhysicsProcess(double delta);
|
||||
}
|
||||
1
Scripts/Components/FSM/Player/PlayerNode2DModule.cs.uid
Normal file
1
Scripts/Components/FSM/Player/PlayerNode2DModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bkowl104hcpu7
|
||||
|
|
@ -6,7 +6,7 @@ using Cirno.Scripts.Components;
|
|||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
|
||||
public partial class Weapon : Node2D
|
||||
public partial class Weapon : Sprite2D
|
||||
{
|
||||
|
||||
[Export]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue