Add plastique item
Add Door object Initial work for look up animation
This commit is contained in:
27
Zennysoft.Game.Ma/src/map/Door.cs
Normal file
27
Zennysoft.Game.Ma/src/map/Door.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Door : Node3D, IDoor
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
||||
}
|
||||
|
||||
private void AnimationPlayer_AnimationFinished(StringName animName)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
public void Demolish()
|
||||
{
|
||||
AnimationPlayer.Play("explode");
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/map/Door.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/map/Door.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cyb308jlbnwi4
|
||||
5
Zennysoft.Game.Ma/src/map/IDoor.cs
Normal file
5
Zennysoft.Game.Ma/src/map/IDoor.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
|
||||
public interface IDoor : INode3D
|
||||
{
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/map/IDoor.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/map/IDoor.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b12bqf810dfr
|
||||
@@ -34,73 +34,73 @@ public partial class Map : Node3D, IMap
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
this.Provide();
|
||||
this.Provide();
|
||||
}
|
||||
|
||||
public void InitializeMapData()
|
||||
{
|
||||
CurrentFloorNumber.OnNext(-1);
|
||||
CurrentFloorNumber.OnNext(-1);
|
||||
}
|
||||
|
||||
public IDungeonRoom GetPlayersCurrentRoom()
|
||||
{
|
||||
var rooms = CurrentFloor.Rooms;
|
||||
var playersRoom = rooms.SingleOrDefault(x => x.IsPlayerInRoom);
|
||||
return playersRoom;
|
||||
var rooms = CurrentFloor.Rooms;
|
||||
var playersRoom = rooms.SingleOrDefault(x => x.IsPlayerInRoom);
|
||||
return playersRoom;
|
||||
}
|
||||
|
||||
public Transform3D GetPlayerSpawnPosition() => CurrentFloor.GetPlayerSpawnPoint();
|
||||
|
||||
public async Task LoadFloor()
|
||||
{
|
||||
var floor = MapOrder.GetChildren().OfType<FloorNode>().ElementAt(CurrentFloorNumber.Value + 1);
|
||||
var sceneToLoad = LayoutToScenePathConverter.Convert(floor);
|
||||
await LoadFloor(sceneToLoad);
|
||||
if (CurrentFloor is DungeonFloor dungeonFloor && floor is DungeonFloorNode dungeonFloorNode)
|
||||
dungeonFloor.SpawnEnemies(dungeonFloorNode);
|
||||
var floor = MapOrder.GetChildren().OfType<FloorNode>().ElementAt(CurrentFloorNumber.Value + 1);
|
||||
var sceneToLoad = LayoutToScenePathConverter.Convert(floor);
|
||||
await LoadFloor(sceneToLoad);
|
||||
if (CurrentFloor is DungeonFloor dungeonFloor && floor is DungeonFloorNode dungeonFloorNode)
|
||||
dungeonFloor.SpawnEnemies(dungeonFloorNode);
|
||||
}
|
||||
|
||||
public async Task LoadFloor(string sceneName)
|
||||
{
|
||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out");
|
||||
ClearMap();
|
||||
var newFloor = await LoadNewFloor(sceneName);
|
||||
AddChild(newFloor);
|
||||
InitializeFloor(newFloor);
|
||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, ("fade_in"));
|
||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out");
|
||||
ClearMap();
|
||||
var newFloor = await LoadNewFloor(sceneName);
|
||||
AddChild(newFloor);
|
||||
InitializeFloor(newFloor);
|
||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, ("fade_in"));
|
||||
}
|
||||
|
||||
public void ClearMap()
|
||||
{
|
||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out");
|
||||
CurrentFloor?.CallDeferred(MethodName.QueueFree, []);
|
||||
SpawnPointCreated?.Invoke(new Transform3D(Basis.Identity, new Vector3(-999, -999, -999)));
|
||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out");
|
||||
CurrentFloor?.CallDeferred(MethodName.QueueFree, []);
|
||||
SpawnPointCreated?.Invoke(new Transform3D(Basis.Identity, new Vector3(-999, -999, -999)));
|
||||
}
|
||||
|
||||
private void InitializeFloor(Node newFloor)
|
||||
{
|
||||
CurrentFloor = (IDungeonFloor)newFloor;
|
||||
SetupDungeonFloor();
|
||||
CurrentFloor.FloorIsLoaded = true;
|
||||
CurrentFloorNumber.OnNext(CurrentFloorNumber.Value + 1);
|
||||
FloorLoaded?.Invoke();
|
||||
CurrentFloor = (IDungeonFloor)newFloor;
|
||||
SetupDungeonFloor();
|
||||
CurrentFloor.FloorIsLoaded = true;
|
||||
CurrentFloorNumber.OnNext(CurrentFloorNumber.Value + 1);
|
||||
FloorLoaded?.Invoke();
|
||||
}
|
||||
|
||||
private async Task<Node> LoadNewFloor(string sceneName)
|
||||
{
|
||||
var sceneLoader = new SceneLoader();
|
||||
AddChild(sceneLoader);
|
||||
sceneLoader.LoadSceneRequest(sceneName);
|
||||
await ToSignal(sceneLoader, SceneLoader.SignalName.SceneLoaded);
|
||||
var result = sceneLoader.LoadedScene;
|
||||
sceneLoader.QueueFree();
|
||||
return result;
|
||||
var sceneLoader = new SceneLoader();
|
||||
AddChild(sceneLoader);
|
||||
sceneLoader.LoadSceneRequest(sceneName);
|
||||
await ToSignal(sceneLoader, SceneLoader.SignalName.SceneLoaded);
|
||||
var result = sceneLoader.LoadedScene;
|
||||
sceneLoader.QueueFree();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SetupDungeonFloor()
|
||||
{
|
||||
CurrentFloor.InitializeDungeon();
|
||||
var transform = GetPlayerSpawnPosition();
|
||||
SpawnPointCreated?.Invoke(transform);
|
||||
CurrentFloor.InitializeDungeon();
|
||||
var transform = GetPlayerSpawnPosition();
|
||||
SpawnPointCreated?.Invoke(transform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
@@ -13,6 +14,8 @@ public partial class Altar : Node3D, IDungeonFloor
|
||||
|
||||
[Dependency] protected IGame Game => this.DependOn<IGame>();
|
||||
|
||||
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||
|
||||
[Node] private Area3D Exit { get; set; } = default!;
|
||||
|
||||
[Node] private Marker3D PlayerSpawnPoint { get; set; } = default!;
|
||||
@@ -25,25 +28,29 @@ public partial class Altar : Node3D, IDungeonFloor
|
||||
|
||||
public bool FloorIsLoaded { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
public void OnResolved()
|
||||
{
|
||||
Show();
|
||||
Exit.AreaEntered += Exit_AreaEntered;
|
||||
NoExitArea.AreaEntered += NoExitArea_AreaEntered;
|
||||
FloorIsLoaded = true;
|
||||
_player.PointUpFinished += _player_PointUpFinished;
|
||||
FloorIsLoaded = true;
|
||||
}
|
||||
|
||||
private void _player_PointUpFinished()
|
||||
{
|
||||
_player.Activate();
|
||||
}
|
||||
|
||||
private void NoExitArea_AreaEntered(Area3D area)
|
||||
{
|
||||
DialogueController.ShowDialogue(Dialogue, "no_exit");
|
||||
//if (area.GetOwner() is IPlayer player)
|
||||
// player.Deactivate();
|
||||
}
|
||||
|
||||
private void Exit_AreaEntered(Area3D area)
|
||||
{
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
}
|
||||
|
||||
public void ExitReached() => Game.FloorExitReached();
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user