Add Effect items, implement teleport enemies to current room

This commit is contained in:
2025-03-03 01:48:56 -08:00
parent 4ac70b1ca7
commit 990da695f2
12 changed files with 195 additions and 20 deletions

View File

@@ -183,7 +183,6 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
if (enemiesInCurrentRoom.Contains(this))
return room;
}
return null;
}

View File

@@ -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<IGame>();
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
[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<MonsterRoom>().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<Marker3D>().ToList();
var spawnPointsGodotCollection = new Godot.Collections.Array<Marker3D>(spawnPoints);
var randomSpawnPoint = spawnPointsGodotCollection.PickRandom();
enemy.SetEnemyGlobalPosition(randomSpawnPoint.GlobalPosition);
}
}
}

View File

@@ -0,0 +1 @@
uid://bl16bjcbosq5j

View File

@@ -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

View File

@@ -0,0 +1,10 @@
using Godot;
namespace GameJamDungeon;
[GlobalClass]
public partial class EffectItemStats : InventoryItemStats
{
[Export]
public Godot.Collections.Array<UsableItemTag> UsableItemTags { get; set; } = new Godot.Collections.Array<UsableItemTag>();
}

View File

@@ -0,0 +1 @@
uid://b5w4iw4iqmxtn

View File

@@ -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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@@ -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

View File

@@ -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);

View File

@@ -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,

View File

@@ -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")