From f153a53d8d57b7b2f98559ab144c346dc212d268 Mon Sep 17 00:00:00 2001 From: Zenny Date: Mon, 3 Mar 2025 21:04:44 -0800 Subject: [PATCH] Sine Morphization implementation --- src/app/state/AppLogic.g.puml | 2 +- src/enemy/Enemy.cs | 2 +- src/enemy/IEnemy.cs | 2 ++ .../enemy_types/01. sproingy/Sproingy.tscn | 4 ++- .../01. sproingy/SproingyModelView.tscn | 1 + src/enemy/state/EnemyLogic.g.puml | 2 +- src/game/Game.cs | 2 -- src/game/GameLogic.g.puml | 8 +++--- src/items/consumable/ConsumableItem.tscn | 3 +- src/items/effect/EffectItem.cs | 28 ++++++++++++++++++- .../effect/resources/SineMorphization.tres | 18 ++++++++++++ src/map/dungeon/floors/Floor00.tscn | 2 +- src/player/state/PlayerLogic.g.puml | 4 +-- 13 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 src/items/effect/resources/SineMorphization.tres diff --git a/src/app/state/AppLogic.g.puml b/src/app/state/AppLogic.g.puml index 4197ba37..885c336b 100644 --- a/src/app/state/AppLogic.g.puml +++ b/src/app/state/AppLogic.g.puml @@ -2,8 +2,8 @@ state "AppLogic State" as GameJamDungeon_AppLogic_State { state "SetupGameScene" as GameJamDungeon_AppLogic_State_SetupGameScene state "InGame" as GameJamDungeon_AppLogic_State_InGame - state "MainMenu" as GameJamDungeon_AppLogic_State_MainMenu state "LoadingScreen" as GameJamDungeon_AppLogic_State_LoadingScreen + state "MainMenu" as GameJamDungeon_AppLogic_State_MainMenu } GameJamDungeon_AppLogic_State_InGame --> GameJamDungeon_AppLogic_State_MainMenu : GameOver diff --git a/src/enemy/Enemy.cs b/src/enemy/Enemy.cs index ebd6d611..f3b9abfc 100644 --- a/src/enemy/Enemy.cs +++ b/src/enemy/Enemy.cs @@ -168,7 +168,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide _attackTimer.Timeout -= OnAttackTimeout; } - public Vector3 EnemyGlobalPosition => GlobalPosition; + public Vector3 GetEnemyGlobalPosition() => GlobalPosition; public void SetEnemyGlobalPosition(Vector3 target) { diff --git a/src/enemy/IEnemy.cs b/src/enemy/IEnemy.cs index a8199df3..534ffedf 100644 --- a/src/enemy/IEnemy.cs +++ b/src/enemy/IEnemy.cs @@ -22,5 +22,7 @@ public interface IEnemy : IKillable public void SetEnemyGlobalPosition(Vector3 target); + public Vector3 GetEnemyGlobalPosition(); + public IDungeonRoom GetCurrentRoom(); } diff --git a/src/enemy/enemy_types/01. sproingy/Sproingy.tscn b/src/enemy/enemy_types/01. sproingy/Sproingy.tscn index 302d5f48..592008c4 100644 --- a/src/enemy/enemy_types/01. sproingy/Sproingy.tscn +++ b/src/enemy/enemy_types/01. sproingy/Sproingy.tscn @@ -24,13 +24,15 @@ DropsSoulGemChance = 0.75 metadata/_custom_type_script = ExtResource("2_oln85") [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cwfph"] +radius = 0.106078 +height = 1.23076 [sub_resource type="CylinderShape3D" id="CylinderShape3D_jbgmx"] height = 5.0 radius = 1.0 [sub_resource type="SphereShape3D" id="SphereShape3D_8vcnq"] -radius = 1.20703 +radius = 0.762524 [node name="Sproingy" type="CharacterBody3D"] process_mode = 1 diff --git a/src/enemy/enemy_types/01. sproingy/SproingyModelView.tscn b/src/enemy/enemy_types/01. sproingy/SproingyModelView.tscn index 638fb768..37806bed 100644 --- a/src/enemy/enemy_types/01. sproingy/SproingyModelView.tscn +++ b/src/enemy/enemy_types/01. sproingy/SproingyModelView.tscn @@ -693,6 +693,7 @@ script = ExtResource("1_oh25a") [node name="Sprite3D" type="Sprite3D" parent="."] transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0) +pixel_size = 0.003 billboard = 2 alpha_cut = 1 texture_filter = 0 diff --git a/src/enemy/state/EnemyLogic.g.puml b/src/enemy/state/EnemyLogic.g.puml index 56b5459d..72ff7d28 100644 --- a/src/enemy/state/EnemyLogic.g.puml +++ b/src/enemy/state/EnemyLogic.g.puml @@ -2,8 +2,8 @@ state "EnemyLogic State" as GameJamDungeon_EnemyLogic_State { state "Alive" as GameJamDungeon_EnemyLogic_State_Alive { state "Activated" as GameJamDungeon_EnemyLogic_State_Activated { - state "FollowPlayer" as GameJamDungeon_EnemyLogic_State_FollowPlayer state "Attacking" as GameJamDungeon_EnemyLogic_State_Attacking + state "FollowPlayer" as GameJamDungeon_EnemyLogic_State_FollowPlayer state "Patrolling" as GameJamDungeon_EnemyLogic_State_Patrolling } state "Idle" as GameJamDungeon_EnemyLogic_State_Idle diff --git a/src/game/Game.cs b/src/game/Game.cs index 02692a67..ea09247e 100644 --- a/src/game/Game.cs +++ b/src/game/Game.cs @@ -5,7 +5,6 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using System; -using System.Collections.Immutable; using static GameJamDungeon.GameLogic.State; [Meta(typeof(IAutoNode))] @@ -188,7 +187,6 @@ public partial class Game : Node3D, IGame public void EnemyDefeated(Vector3 defeatedLocation, EnemyStatResource resource) { Player.GainExp(resource.ExpFromDefeat * GameRepo.EXPRate); - DropRestorative(defeatedLocation); } private void DropRestorative(Vector3 vector) diff --git a/src/game/GameLogic.g.puml b/src/game/GameLogic.g.puml index 98664baf..1b460d73 100644 --- a/src/game/GameLogic.g.puml +++ b/src/game/GameLogic.g.puml @@ -2,12 +2,12 @@ state "GameLogic State" as GameJamDungeon_GameLogic_State { state "GameStarted" as GameJamDungeon_GameLogic_State_GameStarted state "Playing" as GameJamDungeon_GameLogic_State_Playing { - state "FloorClearedDecisionState" as GameJamDungeon_GameLogic_State_FloorClearedDecisionState - state "Paused" as GameJamDungeon_GameLogic_State_Paused state "AskForTeleport" as GameJamDungeon_GameLogic_State_AskForTeleport - state "Resuming" as GameJamDungeon_GameLogic_State_Resuming - state "MinimapOpen" as GameJamDungeon_GameLogic_State_MinimapOpen + state "FloorClearedDecisionState" as GameJamDungeon_GameLogic_State_FloorClearedDecisionState state "InventoryOpened" as GameJamDungeon_GameLogic_State_InventoryOpened + state "MinimapOpen" as GameJamDungeon_GameLogic_State_MinimapOpen + state "Paused" as GameJamDungeon_GameLogic_State_Paused + state "Resuming" as GameJamDungeon_GameLogic_State_Resuming } state "Quit" as GameJamDungeon_GameLogic_State_Quit } diff --git a/src/items/consumable/ConsumableItem.tscn b/src/items/consumable/ConsumableItem.tscn index 57251f48..3073d825 100644 --- a/src/items/consumable/ConsumableItem.tscn +++ b/src/items/consumable/ConsumableItem.tscn @@ -6,7 +6,6 @@ size = Vector3(0.778381, 0.929947, 0.731567) [node name="ConsumableItem" type="Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.75, 0) script = ExtResource("1_26bad") [node name="Pickup" type="Area3D" parent="."] @@ -17,7 +16,7 @@ collision_mask = 4 [node name="Sprite" type="Sprite3D" parent="Pickup"] unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0322805, 0) -pixel_size = 0.0015 +pixel_size = 0.001 billboard = 2 shaded = true double_sided = false diff --git a/src/items/effect/EffectItem.cs b/src/items/effect/EffectItem.cs index 72e27b4f..2af4833d 100644 --- a/src/items/effect/EffectItem.cs +++ b/src/items/effect/EffectItem.cs @@ -45,6 +45,8 @@ public partial class EffectItem : Node3D, IUsableItem TeleportEnemiesToCurrentRoom(); if (_effectItemStats.UsableItemTags.Contains(UsableItemTag.KillHalfEnemiesInRoom)) KillHalfEnemiesInRoom(); + if (_effectItemStats.UsableItemTags.Contains(UsableItemTag.TurnAllEnemiesIntoHealingItem)) + TurnAllEnemiesInRoomIntoHealingItem(); } public void SetItemStats(InventoryItemStats inventoryItemStats) @@ -101,8 +103,32 @@ public partial class EffectItem : Node3D, IUsableItem var enemyList = currentMonsterRoom.GetEnemiesInCurrentRoom().ToList(); var enemiesToKill = enemyList.Count / 2; for (var i = 0; i < enemiesToKill; i++) - { enemyList[i].Die(); + } + + private void TurnAllEnemiesInRoomIntoHealingItem() + { + var currentRoom = Player.GetCurrentRoom(); + var currentEnemies = currentRoom.EnemiesInRoom; + foreach (var enemy in currentEnemies) + { + enemy.Die(); + DropHealingItem(enemy.GetEnemyGlobalPosition()); } } + + private void DropHealingItem(Vector3 vector) + { + var consumableFolder = "res://src/items/consumable"; + var restorativeScene = GD.Load($"{consumableFolder}/ConsumableItem.tscn"); + var consumable = restorativeScene.Instantiate(); + var resourceFiles = DirAccess.GetFilesAt($"{consumableFolder}/resources"); + var rng = new RandomNumberGenerator(); + rng.Randomize(); + var randomResource = resourceFiles[rng.RandiRange(0, resourceFiles.Length - 1)]; + var randomFile = ResourceLoader.Load($"{consumableFolder}/resources/{randomResource}"); + consumable.SetItemStats(randomFile); + Game.AddChild(consumable); + consumable.GlobalPosition = vector; + } } diff --git a/src/items/effect/resources/SineMorphization.tres b/src/items/effect/resources/SineMorphization.tres new file mode 100644 index 00000000..d6c2935d --- /dev/null +++ b/src/items/effect/resources/SineMorphization.tres @@ -0,0 +1,18 @@ +[gd_resource type="Resource" script_class="EffectItemStats" load_steps=3 format=3 uid="uid://cwh5w1yabwrxf"] + +[ext_resource type="Script" uid="uid://b5w4iw4iqmxtn" path="res://src/items/effect/EffectItemStats.cs" id="1_ksb1c"] +[ext_resource type="Texture2D" uid="uid://c7v5pm32sedkg" path="res://src/items/effect/textures/entropic seal.PNG" id="1_vqhky"] + +[resource] +script = ExtResource("1_ksb1c") +UsableItemTags = Array[int]([5]) +Name = "Sine Morphization" +Description = "Turns all enemies in room to healing item." +Texture = ExtResource("1_vqhky") +SpawnRate = 0.5 +ThrowSpeed = 12.0 +HealHPAmount = 0 +HealVTAmount = 0 +ThrowDamage = 5 +ItemTags = Array[int]([]) +metadata/_custom_type_script = "uid://b5w4iw4iqmxtn" diff --git a/src/map/dungeon/floors/Floor00.tscn b/src/map/dungeon/floors/Floor00.tscn index 2dbe44c3..186f2830 100644 --- a/src/map/dungeon/floors/Floor00.tscn +++ b/src/map/dungeon/floors/Floor00.tscn @@ -16,7 +16,7 @@ [ext_resource type="Texture2D" uid="uid://4k6vtn4oip5f" path="res://src/map/dungeon/models/Set A/02. Altar/02_ALTAR_FLOOR_ZER0_VER_TILE4.png" id="14_qqc7i"] [ext_resource type="Texture2D" uid="uid://cururtxtgylxf" path="res://src/map/dungeon/models/Set A/02. Altar/02_ALTAR_FLOOR_ZER0_VER_COLUMN.jpg" id="15_ojbcg"] [ext_resource type="PackedScene" uid="uid://d0pl1n1jf77jm" path="res://src/items/effect/EffectItem.tscn" id="16_aqomv"] -[ext_resource type="Resource" uid="uid://cxfu683mhpu6v" path="res://src/items/effect/resources/DevicBalance.tres" id="17_db2o3"] +[ext_resource type="Resource" uid="uid://cwh5w1yabwrxf" path="res://src/items/effect/resources/SineMorphization.tres" id="17_db2o3"] [ext_resource type="Resource" uid="uid://bptg6eybj5dxk" path="res://src/items/effect/resources/DevicRecall.tres" id="18_ntxe5"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3ubi4"] diff --git a/src/player/state/PlayerLogic.g.puml b/src/player/state/PlayerLogic.g.puml index 52f96da4..8f57bf9d 100644 --- a/src/player/state/PlayerLogic.g.puml +++ b/src/player/state/PlayerLogic.g.puml @@ -1,11 +1,11 @@ @startuml PlayerLogic state "PlayerLogic State" as GameJamDungeon_PlayerLogic_State { - state "Disabled" as GameJamDungeon_PlayerLogic_State_Disabled state "Alive" as GameJamDungeon_PlayerLogic_State_Alive { - state "Idle" as GameJamDungeon_PlayerLogic_State_Idle state "Attacking" as GameJamDungeon_PlayerLogic_State_Attacking + state "Idle" as GameJamDungeon_PlayerLogic_State_Idle } state "Dead" as GameJamDungeon_PlayerLogic_State_Dead + state "Disabled" as GameJamDungeon_PlayerLogic_State_Disabled } GameJamDungeon_PlayerLogic_State_Alive --> GameJamDungeon_PlayerLogic_State_Alive : PhysicsTick