diff --git a/src/enemy/Enemy.cs b/src/enemy/Enemy.cs index c63cddb2..a178d588 100644 --- a/src/enemy/Enemy.cs +++ b/src/enemy/Enemy.cs @@ -183,7 +183,6 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide if (enemiesInCurrentRoom.Contains(this)) return room; } - return null; } diff --git a/src/items/effect/EffectItem.cs b/src/items/effect/EffectItem.cs new file mode 100644 index 00000000..359e2851 --- /dev/null +++ b/src/items/effect/EffectItem.cs @@ -0,0 +1,91 @@ +using Chickensoft.AutoInject; +using Chickensoft.Introspection; +using Godot; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace GameJamDungeon; + +[Meta(typeof(IAutoNode))] +public partial class EffectItem : Node3D, IUsableItem +{ + public override void _Notification(int what) => this.Notify(what); + + [Dependency] public IGame Game => this.DependOn(); + + [Dependency] public IPlayer Player => this.DependOn(); + + [Export] + private EffectItemStats _effectItemStats { get; set; } + + [Node] private Sprite3D Sprite { get; set; } = new Sprite3D(); + + [Node] private Area3D Pickup { get; set; } = default!; + + public Guid ID => Guid.NewGuid(); + + public string ItemName => _effectItemStats.Name; + + public string Description => _effectItemStats.Description; + + public float SpawnRate => _effectItemStats.SpawnRate; + + public Texture2D GetTexture() => _effectItemStats.Texture; + + public double ThrowDamage => _effectItemStats.ThrowDamage; + + public float ThrowSpeed => _effectItemStats.ThrowSpeed; + + public void Use() + { + if (_effectItemStats.UsableItemTags.Contains(UsableItemTag.DoubleEXP)) + Game.DoubleEXP(TimeSpan.FromSeconds(30)); + if (_effectItemStats.UsableItemTags.Contains(UsableItemTag.TeleportAllEnemiesToRoom)) + TeleportEnemiesToCurrentRoom(); + } + + public void SetItemStats(InventoryItemStats inventoryItemStats) + { + _effectItemStats = (EffectItemStats)inventoryItemStats; + } + + public void OnReady() + { + Pickup.BodyEntered += OnEntered; + Sprite.Texture = _effectItemStats.Texture; + } + + public void OnEntered(Node3D body) + { + var isAdded = Player.Inventory.TryAdd(this); + if (isAdded) + QueueFree(); + } + + private void TeleportEnemiesToCurrentRoom() + { + var currentFloor = Game.CurrentFloor; + var rooms = currentFloor.Rooms; + var currentRoom = Player.GetCurrentRoom(); + + if (currentRoom is not MonsterRoom) + return; + + var validRooms = rooms.OfType().ToList(); + if (currentRoom is MonsterRoom monsterRoom) + validRooms.Remove(monsterRoom); + + var currentMonsterRoom = (MonsterRoom)currentRoom; + + var enemyList = validRooms.SelectMany(x => x.GetEnemiesInCurrentRoom()); + + foreach (var enemy in enemyList) + { + var spawnPoints = currentMonsterRoom.EnemySpawnPoints.GetChildren().OfType().ToList(); + var spawnPointsGodotCollection = new Godot.Collections.Array(spawnPoints); + var randomSpawnPoint = spawnPointsGodotCollection.PickRandom(); + enemy.SetEnemyGlobalPosition(randomSpawnPoint.GlobalPosition); + } + } +} diff --git a/src/items/effect/EffectItem.cs.uid b/src/items/effect/EffectItem.cs.uid new file mode 100644 index 00000000..a60e153e --- /dev/null +++ b/src/items/effect/EffectItem.cs.uid @@ -0,0 +1 @@ +uid://bl16bjcbosq5j diff --git a/src/items/effect/EffectItem.tscn b/src/items/effect/EffectItem.tscn new file mode 100644 index 00000000..3bbb2f2c --- /dev/null +++ b/src/items/effect/EffectItem.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=3 format=3 uid="uid://d0pl1n1jf77jm"] + +[ext_resource type="Script" uid="uid://bl16bjcbosq5j" path="res://src/items/effect/EffectItem.cs" id="1_yw2rj"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_03cqg"] +size = Vector3(0.778381, 0.929947, 0.731567) + +[node name="EffectItem" type="Node3D"] +script = ExtResource("1_yw2rj") + +[node name="Pickup" type="Area3D" parent="."] +unique_name_in_owner = true +collision_layer = 0 +collision_mask = 4 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0600509, 0.26725, 0.180481) +shape = SubResource("BoxShape3D_03cqg") + +[node name="Sprite" type="Sprite3D" parent="Pickup"] +unique_name_in_owner = true +transform = Transform3D(0.999973, 0.00489444, -0.00548299, -0.00488109, 0.999985, 0.00244357, 0.00549488, -0.00241672, 0.999982, 0, 0, 0) +pixel_size = 0.0005 +billboard = 2 +shaded = true +texture_filter = 0 +render_priority = 100 diff --git a/src/items/effect/EffectItemStats.cs b/src/items/effect/EffectItemStats.cs new file mode 100644 index 00000000..8a7a171c --- /dev/null +++ b/src/items/effect/EffectItemStats.cs @@ -0,0 +1,10 @@ +using Godot; + +namespace GameJamDungeon; + +[GlobalClass] +public partial class EffectItemStats : InventoryItemStats +{ + [Export] + public Godot.Collections.Array UsableItemTags { get; set; } = new Godot.Collections.Array(); +} diff --git a/src/items/effect/EffectItemStats.cs.uid b/src/items/effect/EffectItemStats.cs.uid new file mode 100644 index 00000000..8f75abc8 --- /dev/null +++ b/src/items/effect/EffectItemStats.cs.uid @@ -0,0 +1 @@ +uid://b5w4iw4iqmxtn diff --git a/src/items/effect/resources/DevicRecall.tres b/src/items/effect/resources/DevicRecall.tres new file mode 100644 index 00000000..0f98458c --- /dev/null +++ b/src/items/effect/resources/DevicRecall.tres @@ -0,0 +1,18 @@ +[gd_resource type="Resource" script_class="EffectItemStats" load_steps=3 format=3 uid="uid://bptg6eybj5dxk"] + +[ext_resource type="Script" uid="uid://b5w4iw4iqmxtn" path="res://src/items/effect/EffectItemStats.cs" id="1_0uaie"] +[ext_resource type="Texture2D" uid="uid://c7v5pm32sedkg" path="res://src/items/effect/textures/entropic seal.PNG" id="1_j462p"] + +[resource] +script = ExtResource("1_0uaie") +UsableItemTags = Array[int]([4]) +Name = "Devic Recall" +Description = "Teleports all enemies to current room." +Texture = ExtResource("1_j462p") +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/items/effect/textures/entropic seal.PNG b/src/items/effect/textures/entropic seal.PNG new file mode 100644 index 00000000..bbdd1143 Binary files /dev/null and b/src/items/effect/textures/entropic seal.PNG differ diff --git a/src/items/effect/textures/entropic seal.PNG.import b/src/items/effect/textures/entropic seal.PNG.import new file mode 100644 index 00000000..91844f19 --- /dev/null +++ b/src/items/effect/textures/entropic seal.PNG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c7v5pm32sedkg" +path="res://.godot/imported/entropic seal.PNG-b7de800370bf83e9e4b096c62532ef11.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/items/effect/textures/entropic seal.PNG" +dest_files=["res://.godot/imported/entropic seal.PNG-b7de800370bf83e9e4b096c62532ef11.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=0 diff --git a/src/items/throwable/ThrowableItem.cs b/src/items/throwable/ThrowableItem.cs index 1a35ce85..09f9ebfa 100644 --- a/src/items/throwable/ThrowableItem.cs +++ b/src/items/throwable/ThrowableItem.cs @@ -68,8 +68,6 @@ public partial class ThrowableItem : Node3D, IUsableItem if (_throwableItemStats.HealVTAmount > 0) Player.HealVT(_throwableItemStats.HealVTAmount); - if (_throwableItemStats.UsableItemTags.Contains(UsableItemTag.DoubleEXP)) - Game.DoubleEXP(TimeSpan.FromSeconds(30)); if (_throwableItemStats.ThrowableItemTags.Contains(ThrowableItemTag.TeleportToRandomLocation)) TeleportToRandomRoom(Player); diff --git a/src/items/throwable/ThrowableItemTag.cs b/src/items/throwable/ThrowableItemTag.cs index 51d3369f..ccb617b6 100644 --- a/src/items/throwable/ThrowableItemTag.cs +++ b/src/items/throwable/ThrowableItemTag.cs @@ -13,17 +13,6 @@ public enum UsableItemTag DoubleEXP, IdentifyAllItemsCostHP, BriefImmunity, -} - -public enum EnhancingItemTag -{ - Add1ATK, - Add1DEF, - RaiseLevelBy1, -} - -public enum EffectorItemTag -{ SwapHPandVTWithEntitiesInRoom, TeleportAllEnemiesToRoom, TurnAllEnemiesIntoHealingItem, @@ -33,6 +22,13 @@ public enum EffectorItemTag RandomEffect, } +public enum EnhancingItemTag +{ + Add1ATK, + Add1DEF, + RaiseLevelBy1, +} + public enum BoxItemTag { RandomNewItem, diff --git a/src/map/dungeon/floors/Floor00.tscn b/src/map/dungeon/floors/Floor00.tscn index 7f685167..9040746b 100644 --- a/src/map/dungeon/floors/Floor00.tscn +++ b/src/map/dungeon/floors/Floor00.tscn @@ -15,8 +15,8 @@ [ext_resource type="Texture2D" uid="uid://dyufabjcwlago" path="res://src/map/dungeon/models/Set A/02. Altar/02_ALTAR_FLOOR_ZER0_VER_HAND_CYCLE_MOTIF.png" id="13_1i307"] [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://1fl6s352e2ej" path="res://src/items/throwable/ThrowableItem.tscn" id="16_db2o3"] -[ext_resource type="Resource" uid="uid://lo37qfyxlhx1" path="res://src/items/throwable/resources/Gospel of Dimension.tres" id="17_db2o3"] +[ext_resource type="PackedScene" uid="uid://d0pl1n1jf77jm" path="res://src/items/effect/EffectItem.tscn" id="16_aqomv"] +[ext_resource type="Resource" uid="uid://bptg6eybj5dxk" path="res://src/items/effect/resources/DevicRecall.tres" id="17_db2o3"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3ubi4"] shading_mode = 0 @@ -857,10 +857,6 @@ libraries = { transform = Transform3D(0.857993, 0, 0.513661, 0, 1, 0, -0.513661, 0, 0.857993, -12.7574, -2.40091, 0.250378) shape = SubResource("BoxShape3D_xh2ej") -[node name="ThrowableItem" parent="." instance=ExtResource("16_db2o3")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.469, -2.5, 0) -_throwableItemStats = ExtResource("17_db2o3") - [node name="CSGBox3D" type="CSGBox3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.22379, 0) size = Vector3(1, 1.7, 1) @@ -891,3 +887,7 @@ collision_mask = 8 [node name="CollisionShape3D" type="CollisionShape3D" parent="Room/Room"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 149.05, -4.02862, -1.76389) shape = SubResource("BoxShape3D_ntxe5") + +[node name="EffectItem" parent="." instance=ExtResource("16_aqomv")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.65239, -2.58967, -1.14642) +_effectItemStats = ExtResource("17_db2o3")