Placeholders completed for enemy viewer

This commit is contained in:
2024-12-18 16:47:36 -08:00
parent 09e340179d
commit d135be4318
8 changed files with 85 additions and 28 deletions

View File

@@ -24,6 +24,11 @@ public partial class DataViewer : Control
[Node] public DataViewerRepository DataViewerRepository { get; set; } = default!;
#region UI
[Node] public RichTextLabel EnemyName { get; set; } = default!;
[Node] public RichTextLabel Description { get; set; } = default!;
#endregion
private EnemyModelView _currentModel;
private int _modelIndex = 0;
@@ -40,10 +45,6 @@ public partial class DataViewer : Control
CameraPivot.RotateY(_cameraSpeed);
if (Input.IsActionPressed(GameInputs.MoveRight))
CameraPivot.RotateY(-_cameraSpeed);
if (Input.IsActionPressed(GameInputs.MoveUp))
ModelPivot.RotateX(-_cameraSpeed);
if (Input.IsActionPressed(GameInputs.MoveDown))
ModelPivot.RotateX(_cameraSpeed);
if (Input.IsActionPressed(GameInputs.StrafeLeft))
Camera3D.Position = Camera3D.Position.MoveToward(CameraPivot.Position, (float)delta * 2f);
if (Input.IsActionPressed(GameInputs.StrafeRight))
@@ -51,7 +52,7 @@ public partial class DataViewer : Control
Camera3D.Position = Camera3D.Position.Clamp(new Vector3(0, 0, 1), new Vector3(0, 0, 4));
ModelPivot.Rotation = ModelPivot.Rotation.Clamp(Mathf.DegToRad(-60), Mathf.DegToRad(60));
_currentModel.RotateModel(_currentModel.Basis, CameraPivot.Basis.Z);
_currentModel.RotateModel(_currentModel.Basis, CameraPivot.Basis.Z, 0.75f, 0.5f);
if (Input.IsActionJustPressed(GameInputs.Attack))
{
@@ -70,7 +71,6 @@ public partial class DataViewer : Control
// Load previous model
_currentModel.CallDeferred(MethodName.QueueFree);
_modelIndex = (_modelIndex - 1 < 0 ? DataViewerRepository.ModelRepository.Count : _modelIndex) - 1;
GD.Print(_modelIndex);
CallDeferred(MethodName.LoadModel);
}
}
@@ -80,5 +80,7 @@ public partial class DataViewer : Control
var modelScene = DataViewerRepository.ModelRepository.ElementAt(_modelIndex);
_currentModel = modelScene.Instantiate<EnemyModelView>();
ModelPivot.AddChild(_currentModel);
EnemyName.Text = _currentModel.EnemyLoreInfo.Name;
Description.Text = _currentModel.EnemyLoreInfo.Description;
}
}

View File

@@ -1,11 +1,15 @@
[gd_scene load_steps=6 format=3 uid="uid://c7wjbgbrdivol"]
[gd_scene load_steps=8 format=3 uid="uid://c7wjbgbrdivol"]
[ext_resource type="Script" path="res://src/data_viewer/DataViewer.cs" id="1_1qako"]
[ext_resource type="Theme" uid="uid://daxuhpmyxwxck" path="res://src/inventory_menu/InventoryDialogueSelectionStyle.tres" id="2_bef6s"]
[ext_resource type="PackedScene" uid="uid://c16i1gmg6yu5a" path="res://src/data_viewer/DataViewerRepository.tscn" id="3_ejdn0"]
[ext_resource type="Texture2D" uid="uid://djvga5kh0ncqa" path="res://src/map/dungeon/models/antechamber_1/ANTECHAMBER_TYPE1_VER2_8311.png" id="3_hpkd1"]
[ext_resource type="PackedScene" uid="uid://bjg8wyvp8q6oc" path="res://src/enemy/enemy_types/michael/MichaelModelView.tscn" id="4_bef6s"]
[ext_resource type="PackedScene" uid="uid://bli0t0d6ommvi" path="res://src/enemy/enemy_types/sproingy/SproingyModelView.tscn" id="5_hpkd1"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dvixg"]
albedo_texture = ExtResource("3_hpkd1")
[node name="DataViewer" type="Control"]
layout_mode = 3
anchors_preset = 15
@@ -13,13 +17,18 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_1qako")
_cameraSpeed = 0.015
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
@@ -33,8 +42,10 @@ theme_override_constants/separation = 0
[node name="LeftPanel" type="Panel" parent="CenterContainer/VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(390, 0)
layout_mode = 2
size_flags_horizontal = 3
[node name="TextEdit" type="RichTextLabel" parent="CenterContainer/VBoxContainer/HBoxContainer/LeftPanel"]
[node name="EnemyName" type="RichTextLabel" parent="CenterContainer/VBoxContainer/HBoxContainer/LeftPanel"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -60,15 +71,25 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.82392, 0)
[node name="CameraPivot" type="Node3D" parent="CenterContainer/VBoxContainer/HBoxContainer/SubViewportContainer/SubViewport"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1, 0)
[node name="Camera3D" type="Camera3D" parent="CenterContainer/VBoxContainer/HBoxContainer/SubViewportContainer/SubViewport/CameraPivot"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.82023e-08, 0, 3.1233)
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CenterContainer/VBoxContainer/HBoxContainer/SubViewportContainer/SubViewport"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.47154, 0)
radius = 1.5
height = 5.46951
material = SubResource("StandardMaterial3D_dvixg")
[node name="SpotLight3D" type="SpotLight3D" parent="CenterContainer/VBoxContainer/HBoxContainer/SubViewportContainer/SubViewport"]
transform = Transform3D(1, 0, 0, 0, 0.0417012, 0.99913, 0, -0.99913, 0.0417012, 0, 4.88492, 0)
[node name="RightPanel" type="Panel" parent="CenterContainer/VBoxContainer/HBoxContainer"]
custom_minimum_size = Vector2(390, 0)
layout_mode = 2
size_flags_horizontal = 3
[node name="TextEdit" type="RichTextLabel" parent="CenterContainer/VBoxContainer/HBoxContainer/RightPanel"]
layout_mode = 1
@@ -94,13 +115,8 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
[node name="RotationLabel" type="Label" parent="CenterContainer/VBoxContainer/BottomPanel"]
[node name="Description" type="RichTextLabel" parent="CenterContainer/VBoxContainer/BottomPanel"]
unique_name_in_owner = true
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
[node name="TextEdit" type="RichTextLabel" parent="CenterContainer/VBoxContainer/BottomPanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -126,4 +142,4 @@ text = "Press ○ to exit"
[node name="DataViewerRepository" parent="." instance=ExtResource("3_ejdn0")]
unique_name_in_owner = true
ModelRepository = Array[PackedScene]([ExtResource("4_bef6s"), ExtResource("5_hpkd1")])
ModelRepository = Array[PackedScene]([ExtResource("5_hpkd1"), ExtResource("4_bef6s")])

View File

@@ -0,0 +1,14 @@
using Godot;
namespace GameJamDungeon
{
[GlobalClass]
public partial class EnemyLoreInfo : Resource
{
[Export]
public string Name { get; set; }
[Export]
public string Description { get; set; }
}
}

View File

@@ -12,6 +12,8 @@ public interface IEnemyModelView : INode3D
public void PlayDeathAnimation();
public void RotateModel(Basis enemyBasis, Vector3 cameraDirection);
public void RotateModel(Basis enemyBasis, Vector3 cameraDirection, float rotateUpperThreshold, float rotateLowerThreshold);
}
[Meta(typeof(IAutoNode))]
@@ -25,6 +27,8 @@ public partial class EnemyModelView : Node3D, IEnemyModelView
public override void _Notification(int what) => this.Notify(what);
[Export] public EnemyLoreInfo EnemyLoreInfo { get; set; } = default!;
[Node] public AnimatedSprite2D AnimatedSprite { get; set; } = default!;
[Node] public IHitbox Hitbox { get; set; } = default!;
@@ -59,11 +63,10 @@ public partial class EnemyModelView : Node3D, IEnemyModelView
tweener.TweenCallback(Callable.From(QueueFree));
}
public void RotateModel(Basis enemyBasis, Vector3 cameraDirection)
{
var rotateUpperThreshold = 0.85f;
var rotateLowerThreshold = 0.3f;
public void RotateModel(Basis enemyBasis, Vector3 cameraDirection) => RotateModel(enemyBasis, cameraDirection, 0.85f, 0.3f);
public void RotateModel(Basis enemyBasis, Vector3 cameraDirection, float rotateUpperThreshold, float rotateLowerThreshold)
{
var enemyForwardDirection = enemyBasis.Z;
var enemyLeftDirection = enemyBasis.X;

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="EnemyLoreInfo" load_steps=2 format=3 uid="uid://6d7ivtna8dqb"]
[ext_resource type="Script" path="res://src/enemy/EnemyLoreInfo.cs" id="1_xsclu"]
[resource]
script = ExtResource("1_xsclu")
Name = "Michael"
Description = "This one doesn't like fun at all."
metadata/_custom_type_script = ExtResource("1_xsclu")

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=100 format=3 uid="uid://bjg8wyvp8q6oc"]
[gd_scene load_steps=101 format=3 uid="uid://bjg8wyvp8q6oc"]
[ext_resource type="Script" path="res://src/enemy/EnemyModelView.cs" id="1_iajg3"]
[ext_resource type="Texture2D" uid="uid://clpqh2pyqljkn" path="res://src/enemy/enemy_types/michael/animations/IDLE_WALK/BACK/Michael_Walk_Idle_Back (1).png" id="2_3g180"]
[ext_resource type="Resource" uid="uid://6d7ivtna8dqb" path="res://src/enemy/enemy_types/michael/MichaelLoreInfo.tres" id="2_fssmb"]
[ext_resource type="Texture2D" uid="uid://b0dec8ak2bo5t" path="res://src/enemy/enemy_types/michael/animations/IDLE_WALK/BACK/Michael_Walk_Idle_Back (2).png" id="3_fssmb"]
[ext_resource type="Texture2D" uid="uid://tnmyksd68vmv" path="res://src/enemy/enemy_types/michael/animations/IDLE_WALK/BACK/Michael_Walk_Idle_Back (3).png" id="4_oy7vk"]
[ext_resource type="Texture2D" uid="uid://duwipvc2kl6xa" path="res://src/enemy/enemy_types/michael/animations/IDLE_WALK/BACK/Michael_Walk_Idle_Back (4).png" id="5_7jsk6"]
@@ -549,6 +550,7 @@ graph_offset = Vector2(-190, -62.0526)
[node name="EnemyModelView" type="Node3D"]
script = ExtResource("1_iajg3")
EnemyLoreInfo = ExtResource("2_fssmb")
[node name="Sprite" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.209741, 0)

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="EnemyLoreInfo" load_steps=2 format=3 uid="uid://bctxs1jlkhgmc"]
[ext_resource type="Script" path="res://src/enemy/EnemyLoreInfo.cs" id="1_220d4"]
[resource]
script = ExtResource("1_220d4")
Name = "Sproingy"
Description = "A guy who likes to have fun."
metadata/_custom_type_script = ExtResource("1_220d4")

View File

@@ -1,8 +1,9 @@
[gd_scene load_steps=85 format=3 uid="uid://bli0t0d6ommvi"]
[gd_scene load_steps=86 format=3 uid="uid://bli0t0d6ommvi"]
[ext_resource type="Script" path="res://src/enemy/EnemyModelView.cs" id="1_0vbio"]
[ext_resource type="Texture2D" uid="uid://dd0ia6isdqg61" path="res://src/enemy/enemy_types/sproingy/animations/ATTACK/Layer 1.png" id="1_pbx41"]
[ext_resource type="Texture2D" uid="uid://bs4ico5ouo5d3" path="res://src/enemy/enemy_types/sproingy/animations/ATTACK/Layer 2.png" id="2_0vbio"]
[ext_resource type="Resource" uid="uid://bctxs1jlkhgmc" path="res://src/enemy/enemy_types/sproingy/SproingyLoreInfo.tres" id="2_53wuj"]
[ext_resource type="Texture2D" uid="uid://85ki5mc4h0vs" path="res://src/enemy/enemy_types/sproingy/animations/ATTACK/Layer 3.png" id="3_lae8t"]
[ext_resource type="Texture2D" uid="uid://bwt1m2frb3r0e" path="res://src/enemy/enemy_types/sproingy/animations/ATTACK/Layer 4.png" id="4_53wuj"]
[ext_resource type="Texture2D" uid="uid://ckssl1np6vnlu" path="res://src/enemy/enemy_types/sproingy/animations/ATTACK/Layer 5.png" id="5_d5bmw"]
@@ -311,7 +312,7 @@ tracks/1/keys = {
[sub_resource type="Animation" id="Animation_1tda5"]
resource_name = "idle_back_walk"
length = 1.25001
length = 1.16667
loop_mode = 1
step = 0.0833333
tracks/0/type = "value"
@@ -469,10 +470,11 @@ states/idle_front_walk/position = Vector2(331, -12)
states/idle_left_walk/node = SubResource("AnimationNodeAnimation_dvj10")
states/idle_left_walk/position = Vector2(331, 196.947)
transitions = ["Start", "idle_front_walk", SubResource("AnimationNodeStateMachineTransition_vljb2"), "idle_front_walk", "idle_left_walk", SubResource("AnimationNodeStateMachineTransition_3xv6a"), "idle_left_walk", "idle_front_walk", SubResource("AnimationNodeStateMachineTransition_0h1op"), "idle_front_walk", "idle_back_walk", SubResource("AnimationNodeStateMachineTransition_361b7"), "idle_back_walk", "idle_front_walk", SubResource("AnimationNodeStateMachineTransition_wftla"), "idle_back_walk", "idle_left_walk", SubResource("AnimationNodeStateMachineTransition_gqqkl"), "idle_left_walk", "idle_back_walk", SubResource("AnimationNodeStateMachineTransition_5cj36"), "idle_front_walk", "attack", SubResource("AnimationNodeStateMachineTransition_4t05h"), "attack", "idle_front_walk", SubResource("AnimationNodeStateMachineTransition_8hgxu"), "attack", "idle_back_walk", SubResource("AnimationNodeStateMachineTransition_fq2yw"), "attack", "idle_left_walk", SubResource("AnimationNodeStateMachineTransition_yqm0k"), "idle_back_walk", "attack", SubResource("AnimationNodeStateMachineTransition_bmy1k"), "idle_left_walk", "attack", SubResource("AnimationNodeStateMachineTransition_mxl7w")]
graph_offset = Vector2(-190, -62.0526)
graph_offset = Vector2(46.1163, -62.0526)
[node name="EnemyModelView" type="Node3D"]
script = ExtResource("1_0vbio")
EnemyLoreInfo = ExtResource("2_53wuj")
[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)