Fix annoying issue with LookAt
Add jump scare
This commit is contained in:
@@ -28,47 +28,47 @@ public abstract partial class DungeonRoom : Node3D, IDungeonRoom
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_enemiesInRoom = [];
|
||||
if (_room != null)
|
||||
{
|
||||
_room.BodyEntered += Room_BodyEntered;
|
||||
_room.BodyExited += Room_BodyExited;
|
||||
}
|
||||
_enemiesInRoom = [];
|
||||
if (_room != null)
|
||||
{
|
||||
_room.BodyEntered += Room_BodyEntered;
|
||||
_room.BodyExited += Room_BodyExited;
|
||||
}
|
||||
}
|
||||
|
||||
private void Room_BodyExited(Node3D body)
|
||||
{
|
||||
if (body is IEnemy enemy)
|
||||
_enemiesInRoom = _enemiesInRoom.Remove(enemy);
|
||||
if (body is IPlayer)
|
||||
_isPlayerInRoom = false;
|
||||
if (body is IEnemy enemy)
|
||||
_enemiesInRoom = _enemiesInRoom.Remove(enemy);
|
||||
if (body is IPlayer)
|
||||
_isPlayerInRoom = false;
|
||||
}
|
||||
private void Room_BodyEntered(Node3D body)
|
||||
{
|
||||
if (body is IEnemy enemy)
|
||||
_enemiesInRoom = _enemiesInRoom.Add(enemy);
|
||||
if (body is IPlayer)
|
||||
if (_playerDiscoveredRoom)
|
||||
_isPlayerInRoom = true;
|
||||
else
|
||||
OnPlayerDiscoveringRoom();
|
||||
if (body is IEnemy enemy)
|
||||
_enemiesInRoom = _enemiesInRoom.Add(enemy);
|
||||
if (body is IPlayer)
|
||||
if (_playerDiscoveredRoom)
|
||||
_isPlayerInRoom = true;
|
||||
else
|
||||
OnPlayerDiscoveringRoom();
|
||||
}
|
||||
|
||||
public ImmutableList<IEnemy> GetEnemiesInCurrentRoom()
|
||||
{
|
||||
return _enemiesInRoom;
|
||||
return _enemiesInRoom;
|
||||
}
|
||||
|
||||
private void OnPlayerDiscoveringRoom()
|
||||
{
|
||||
_isPlayerInRoom = true;
|
||||
_playerDiscoveredRoom = true;
|
||||
MinimapShadow.Hide();
|
||||
_isPlayerInRoom = true;
|
||||
_playerDiscoveredRoom = true;
|
||||
MinimapShadow.Hide();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
_room.BodyEntered -= Room_BodyEntered;
|
||||
_room.BodyExited -= Room_BodyExited;
|
||||
_room.BodyEntered -= Room_BodyEntered;
|
||||
_room.BodyExited -= Room_BodyExited;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Zennysoft.Game.Ma/src/map/dungeon/code/JumpScareRoom.cs
Normal file
31
Zennysoft.Game.Ma/src/map/dungeon/code/JumpScareRoom.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class JumpScareRoom : DungeonRoom
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency]
|
||||
public IPlayer Player => this.DependOn<IPlayer>();
|
||||
|
||||
[Node] public Area3D JumpScare { get; set; }
|
||||
|
||||
[Export] public Resource Dialogue { get; set; } = default!;
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
JumpScare.AreaEntered += JumpScare_AreaEntered;
|
||||
}
|
||||
|
||||
private void JumpScare_AreaEntered(Area3D area)
|
||||
{
|
||||
Player.PlayJumpScareAnimation();
|
||||
DialogueController.ShowDialogue(Dialogue, "general");
|
||||
JumpScare.SetMonitoring(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cwqgealqc3w4
|
||||
@@ -19,57 +19,54 @@ public partial class MonsterRoom : DungeonRoom
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
SpawnItems();
|
||||
SpawnItems();
|
||||
}
|
||||
|
||||
public void SpawnEnemies(Godot.Collections.Dictionary<EnemyType, float> enemyInfo)
|
||||
{
|
||||
if (enemyInfo == null || !enemyInfo.Any(x => x.Value > 0))
|
||||
return;
|
||||
if (enemyInfo == null || !enemyInfo.Any(x => x.Value > 0))
|
||||
return;
|
||||
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var enemySpawnPoints = EnemySpawnPoints.GetChildren();
|
||||
var numberOfEnemiesToSpawn = rng.RandiRange(1, enemySpawnPoints.Count);
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var enemySpawnPoints = EnemySpawnPoints.GetChildren();
|
||||
var numberOfEnemiesToSpawn = rng.RandiRange(1, enemySpawnPoints.Count);
|
||||
|
||||
foreach (var spawnPoint in enemySpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfEnemiesToSpawn <= 0)
|
||||
break;
|
||||
numberOfEnemiesToSpawn--;
|
||||
foreach (var spawnPoint in enemySpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfEnemiesToSpawn <= 0)
|
||||
break;
|
||||
numberOfEnemiesToSpawn--;
|
||||
|
||||
var index = rng.RandWeighted([.. enemyInfo.Values]);
|
||||
var selectedEnemy = enemyInfo.ElementAt((int)index);
|
||||
var instantiatedEnemy = EnemyTypeToEnemyConverter.Convert(selectedEnemy.Key);
|
||||
instantiatedEnemy.Position = new Vector3(spawnPoint.Position.X, 0f, spawnPoint.Position.Z);
|
||||
AddChild(instantiatedEnemy);
|
||||
}
|
||||
var index = rng.RandWeighted([.. enemyInfo.Values]);
|
||||
var selectedEnemy = enemyInfo.ElementAt((int)index);
|
||||
var instantiatedEnemy = EnemyTypeToEnemyConverter.Convert(selectedEnemy.Key);
|
||||
instantiatedEnemy.Position = new Vector3(spawnPoint.Position.X, 0f, spawnPoint.Position.Z);
|
||||
AddChild(instantiatedEnemy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// RegularFlame.GetChildren();
|
||||
//
|
||||
private void SpawnItems()
|
||||
{
|
||||
if (ItemSpawnPoints == null)
|
||||
return;
|
||||
if (ItemSpawnPoints == null)
|
||||
return;
|
||||
|
||||
var itemSpawnPoints = ItemSpawnPoints.GetChildren();
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var numberOfItemsToSpawn = rng.RandiRange(1, itemSpawnPoints.Count);
|
||||
itemSpawnPoints.Shuffle();
|
||||
var database = ItemDatabase.Instance;
|
||||
foreach (var spawnPoint in itemSpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfItemsToSpawn <= 0)
|
||||
break;
|
||||
numberOfItemsToSpawn--;
|
||||
var itemSpawnPoints = ItemSpawnPoints.GetChildren();
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var numberOfItemsToSpawn = rng.RandiRange(1, itemSpawnPoints.Count);
|
||||
itemSpawnPoints.Shuffle();
|
||||
var database = ItemDatabase.Instance;
|
||||
foreach (var spawnPoint in itemSpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfItemsToSpawn <= 0)
|
||||
break;
|
||||
numberOfItemsToSpawn--;
|
||||
|
||||
var selectedItem = database.PickItem<InventoryItem>();
|
||||
var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.Position = new Vector3(spawnPoint.Position.X, 0, spawnPoint.Position.Z);
|
||||
AddChild(duplicated);
|
||||
}
|
||||
var selectedItem = database.PickItem<InventoryItem>();
|
||||
var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.Position = new Vector3(spawnPoint.Position.X, 0, spawnPoint.Position.Z);
|
||||
AddChild(duplicated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=17 format=3 uid="uid://dhkbvos11tkdw"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://dhkbvos11tkdw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bccyfmj8ikewh" path="res://src/map/dungeon/code/SpecialRoom.cs" id="1_5m2h2"]
|
||||
[ext_resource type="Script" uid="uid://cwqgealqc3w4" path="res://src/map/dungeon/code/JumpScareRoom.cs" id="1_unlia"]
|
||||
[ext_resource type="Resource" uid="uid://iapl7k07fwt0" path="res://src/npc/Proscenium/JumpScare.dialogue" id="2_fgt65"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc7ubbvnx0jdo" path="res://src/map/dungeon/models/Area 1/Jumpscare/A1-Jumpscare.glb" id="2_umqhi"]
|
||||
[ext_resource type="Texture2D" uid="uid://dw50ys561j8no" path="res://src/map/assets/DUST_1.png" id="5_5m2h2"]
|
||||
|
||||
@@ -31,6 +32,9 @@ albedo_color = Color(0, 0, 0, 1)
|
||||
material = SubResource("StandardMaterial3D_unlia")
|
||||
size = Vector2(20.5, 19)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_unlia"]
|
||||
size = Vector3(6.43689, 5.99969, 4.5957)
|
||||
|
||||
[sub_resource type="Curve" id="Curve_umqhi"]
|
||||
_limits = [-2.0, 2.0, 0.0, 1.0]
|
||||
_data = [Vector2(0.00358423, 0.230769), 0.0, 0.0, 0, 0, Vector2(0.982079, -1.03846), 0.0, 0.0, 0, 0]
|
||||
@@ -68,7 +72,8 @@ subdivide_depth = 1
|
||||
|
||||
[node name="JumpScareRoom" type="Node3D"]
|
||||
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -8.509, -3.41755, -8.60795)
|
||||
script = ExtResource("1_5m2h2")
|
||||
script = ExtResource("1_unlia")
|
||||
Dialogue = ExtResource("2_fgt65")
|
||||
|
||||
[node name="Model" type="Node3D" parent="."]
|
||||
|
||||
@@ -129,6 +134,15 @@ layers = 2
|
||||
sorting_offset = 100.0
|
||||
mesh = SubResource("PlaneMesh_unlia")
|
||||
|
||||
[node name="JumpScare" type="Area3D" parent="Room"]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 64
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Room/JumpScare"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.112, 4.54046, 4.67285)
|
||||
shape = SubResource("BoxShape3D_unlia")
|
||||
|
||||
[node name="Lights" type="Node3D" parent="."]
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="Lights"]
|
||||
|
||||
Reference in New Issue
Block a user