mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:55:35 +00:00
Player spawning and isometric in menu
This commit is contained in:
parent
a11f25e19d
commit
1229613def
10 changed files with 286 additions and 43 deletions
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=57 format=3 uid="uid://ec4m3geediis"]
|
||||
[gd_scene load_steps=59 format=3 uid="uid://ec4m3geediis"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cvisn0b641od4" path="res://addons/cyclops_level_builder/nodes/cyclops_block.gd" id="1_18fbr"]
|
||||
[ext_resource type="Script" uid="uid://ba0tf7ihw4hpp" path="res://Scripts/Misc/CameraController3D.cs" id="1_g4gcm"]
|
||||
[ext_resource type="Script" uid="uid://b8g8mflgsr5dc" path="res://Scripts/GameController.cs" id="1_joeuf"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkwi1hu1bixoe" path="res://Scenes/HUD/HUD.tscn" id="2_itd0i"]
|
||||
[ext_resource type="Script" uid="uid://djeq3sxhsep3c" path="res://addons/cyclops_level_builder/resources/data_vector_byte.gd" id="2_kler0"]
|
||||
[ext_resource type="Resource" uid="uid://bq2o78engsuyt" path="res://Resources/Maps/IsoMapTest2.tres" id="2_l7bgk"]
|
||||
[ext_resource type="Script" uid="uid://c5nxsq3tyxcx6" path="res://Scripts/InventoryManager.cs" id="3_itd0i"]
|
||||
[ext_resource type="Script" uid="uid://civ3w78ahacnu" path="res://addons/cyclops_level_builder/resources/data_vector_int.gd" id="3_k6bah"]
|
||||
[ext_resource type="Script" uid="uid://db41w3h28c2la" path="res://addons/cyclops_level_builder/resources/data_vector_float.gd" id="4_01bfr"]
|
||||
|
|
@ -16,6 +17,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://du8xcvbnf30o2" path="res://ExternalMaterial/Barrel/Barrels.png" id="11_id3mo"]
|
||||
[ext_resource type="PackedScene" uid="uid://rimplblbptcd" path="res://Scenes/Actors/IsoPlayer_FSM.tscn" id="12_g4gcm"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8gtrjf2xeue7" path="res://3D/MapScenes/TestLevel.tscn" id="12_g83w3"]
|
||||
[ext_resource type="Script" uid="uid://dnslcy71dgea" path="res://Scripts/Misc/CameraTarget3D.cs" id="16_e2nai"]
|
||||
[ext_resource type="PackedScene" uid="uid://cupulrjeeivxm" path="res://3D/MapScenes/TestLevel2.tscn" id="18_e2nai"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_id3mo"]
|
||||
|
|
@ -413,8 +415,15 @@ face_vertex_data = {
|
|||
|
||||
[node name="IsoMapTest2" type="Node3D"]
|
||||
|
||||
[node name="GameController" type="Node" parent="."]
|
||||
[node name="GameController" type="Node" parent="." node_paths=PackedStringArray("_cameraTarget", "PlayerParentNode")]
|
||||
script = ExtResource("1_joeuf")
|
||||
_cameraTarget = NodePath("../CameraTarget")
|
||||
MapResource = ExtResource("2_l7bgk")
|
||||
PlayerTemplate = ExtResource("12_g4gcm")
|
||||
SpawnMarkers = Dictionary[int, NodePath]({
|
||||
0: NodePath("../StartPosition")
|
||||
})
|
||||
PlayerParentNode = NodePath("..")
|
||||
|
||||
[node name="HUD" parent="GameController" instance=ExtResource("2_itd0i")]
|
||||
|
||||
|
|
@ -473,9 +482,13 @@ hframes = 4
|
|||
[node name="TestLevel" parent="." instance=ExtResource("12_g83w3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.84862, 0, -4.8932)
|
||||
|
||||
[node name="IsoPlayerFsm" parent="." instance=ExtResource("12_g4gcm")]
|
||||
[node name="StartPosition" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19.8843, 1.57535, 3.5485)
|
||||
|
||||
[node name="CameraTarget" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.0389, 2.33215, 3.16925)
|
||||
script = ExtResource("16_e2nai")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 26.5146, 7.935, 10.4923)
|
||||
projection = 1
|
||||
|
|
@ -483,7 +496,7 @@ size = 7.537
|
|||
script = ExtResource("1_g4gcm")
|
||||
MaxAimOffsetDistance = 16.0
|
||||
CameraOffset = Vector3(8, 12, 8)
|
||||
TargetPath = NodePath("../IsoPlayerFsm")
|
||||
TargetPath = NodePath("../CameraTarget")
|
||||
|
||||
[node name="TestLevel2" parent="." instance=ExtResource("18_e2nai")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 69.0028, 0, -23.3622)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Resource" script_class="DebugMapSelectData" load_steps=42 format=3 uid="uid://d1lc8lhq1b05p"]
|
||||
[gd_resource type="Resource" script_class="DebugMapSelectData" load_steps=44 format=3 uid="uid://d1lc8lhq1b05p"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://durmwwyw3dnm6" path="res://Scripts/Resources/DebugMenu/DebugMapSelectData.cs" id="1_6kwth"]
|
||||
[ext_resource type="Script" uid="uid://mja0rk7n2kln" path="res://Scripts/Resources/MapStartDataResource.cs" id="1_ov731"]
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
[ext_resource type="Resource" uid="uid://6ek4lmtuij4t" path="res://Resources/Maps/Roguelite.tres" id="9_ognca"]
|
||||
[ext_resource type="Resource" uid="uid://cn8tu4jct04rp" path="res://Resources/StartData/Pistol_Start.tres" id="10_olpjo"]
|
||||
[ext_resource type="Resource" uid="uid://d1rd3eep3b0jj" path="res://Resources/Maps/ReimuTest.tres" id="11_olpjo"]
|
||||
[ext_resource type="Resource" uid="uid://bq2o78engsuyt" path="res://Resources/Maps/IsoMapTest2.tres" id="12_nbnej"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qnbi6"]
|
||||
script = ExtResource("2_tnajf")
|
||||
|
|
@ -209,6 +210,14 @@ Path = ""
|
|||
_name = "Reimu Test"
|
||||
metadata/_custom_type_script = "uid://dnthdjrx78u6m"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rmbs0"]
|
||||
script = ExtResource("2_tnajf")
|
||||
Enabled = true
|
||||
Map = ExtResource("12_nbnej")
|
||||
Path = ""
|
||||
_name = "Isometric Test"
|
||||
metadata/_custom_type_script = "uid://dnthdjrx78u6m"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_6kwth")
|
||||
Maps = Array[Object]([SubResource("Resource_qnbi6"), SubResource("Resource_0k62o"), SubResource("Resource_edoov"), SubResource("Resource_47bot"), SubResource("Resource_mgdm6"), SubResource("Resource_v2as6"), SubResource("Resource_pein5"), SubResource("Resource_6wrc7"), SubResource("Resource_x3w7w"), SubResource("Resource_ajht5"), SubResource("Resource_7vmdn"), SubResource("Resource_6ijnv"), SubResource("Resource_bkci5"), SubResource("Resource_ognca"), SubResource("Resource_nbnej"), SubResource("Resource_w7lsm"), SubResource("Resource_vq1um"), SubResource("Resource_hougo"), SubResource("Resource_xhgge"), SubResource("Resource_gkp3t"), SubResource("Resource_c3ldk")])
|
||||
Maps = Array[Object]([SubResource("Resource_qnbi6"), SubResource("Resource_0k62o"), SubResource("Resource_edoov"), SubResource("Resource_47bot"), SubResource("Resource_mgdm6"), SubResource("Resource_v2as6"), SubResource("Resource_pein5"), SubResource("Resource_6wrc7"), SubResource("Resource_x3w7w"), SubResource("Resource_ajht5"), SubResource("Resource_7vmdn"), SubResource("Resource_6ijnv"), SubResource("Resource_bkci5"), SubResource("Resource_ognca"), SubResource("Resource_nbnej"), SubResource("Resource_w7lsm"), SubResource("Resource_vq1um"), SubResource("Resource_hougo"), SubResource("Resource_xhgge"), SubResource("Resource_gkp3t"), SubResource("Resource_c3ldk"), SubResource("Resource_rmbs0")])
|
||||
|
|
|
|||
14
Resources/Maps/IsoMapTest2.tres
Normal file
14
Resources/Maps/IsoMapTest2.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_resource type="Resource" script_class="MapResource" load_steps=3 format=3 uid="uid://bq2o78engsuyt"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://cn8tu4jct04rp" path="res://Resources/StartData/Pistol_Start.tres" id="1_ns0cf"]
|
||||
[ext_resource type="Script" uid="uid://quy4d4tgvqfy" path="res://Scripts/Resources/MapResource.cs" id="2_p6a7h"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_p6a7h")
|
||||
LevelId = 0
|
||||
MapName = &"iso Test"
|
||||
MapDescription = null
|
||||
ScenePath = &"uid://ec4m3geediis"
|
||||
WeaponsAllowed = true
|
||||
StartData = ExtResource("1_ns0cf")
|
||||
metadata/_custom_type_script = "uid://quy4d4tgvqfy"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=22 format=3 uid="uid://rimplblbptcd"]
|
||||
[gd_scene load_steps=23 format=3 uid="uid://rimplblbptcd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://88smibkin17p" path="res://Scripts/Components/FSM/3DPlayer/IsoPlayerFSMProxy.cs" id="1_cc7e7"]
|
||||
[ext_resource type="Texture2D" uid="uid://ddwhrlrgj6i00" path="res://Sprites/Actors/Cirno.png" id="1_vex34"]
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
[ext_resource type="AudioStream" uid="uid://myr6n2c1u503" path="res://SFX/581602__samsterbirdies__beep-error.mp3" id="13_2ffwi"]
|
||||
[ext_resource type="Script" uid="uid://d2psafx4f3f58" path="res://Scripts/Components/FSM/3DPlayer/PlayerWeaponModule3D.cs" id="15_el8as"]
|
||||
[ext_resource type="Script" uid="uid://by0x0qmbmkoak" path="res://Scripts/Components/FSM/3DPlayer/PlayerWeaponProvider3D.cs" id="16_olwak"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfgc6ik8vb08c" path="res://Scenes/Weapons/BaseWeapon_3D.tscn" id="17_olwak"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_fg04g"]
|
||||
radius = 0.349554
|
||||
|
|
@ -133,6 +134,12 @@ WeaponProvider = NodePath("WeaponProvider")
|
|||
InputProvider = NodePath("../InputProvider")
|
||||
Storage = NodePath("../Storage")
|
||||
|
||||
[node name="WeaponProvider" type="Node" parent="WeaponModule" node_paths=PackedStringArray("StorageModule")]
|
||||
[node name="WeaponProvider" type="Node" parent="WeaponModule" node_paths=PackedStringArray("StorageModule", "WeaponRightOffset", "WeaponLeftOffset")]
|
||||
script = ExtResource("16_olwak")
|
||||
StorageModule = NodePath("../../Storage")
|
||||
WeaponTemplate = ExtResource("17_olwak")
|
||||
WeaponRightOffset = NodePath("../Marker3D")
|
||||
WeaponLeftOffset = NodePath("../Marker3D")
|
||||
|
||||
[node name="Marker3D" type="Marker3D" parent="WeaponModule"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.267617, 0, -0.24769)
|
||||
|
|
|
|||
24
Scenes/Weapons/BaseWeapon_3D.tscn
Normal file
24
Scenes/Weapons/BaseWeapon_3D.tscn
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cfgc6ik8vb08c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dutroqc0grqyv" path="res://Scripts/Weapons/Weapon3D.cs" id="1_gdxml"]
|
||||
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="2_s6td3"]
|
||||
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="3_6jcxd"]
|
||||
|
||||
[node name="Weapon" type="Node3D" node_paths=PackedStringArray("Muzzle", "Pivot", "Sprite")]
|
||||
script = ExtResource("1_gdxml")
|
||||
WeaponData = ExtResource("2_s6td3")
|
||||
Muzzle = NodePath("Muzzle")
|
||||
Pivot = NodePath("Pivot")
|
||||
Sprite = NodePath("Sprite3D")
|
||||
|
||||
[node name="Muzzle" type="Marker3D" parent="."]
|
||||
|
||||
[node name="Pivot" type="Marker3D" parent="."]
|
||||
|
||||
[node name="ShootTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
billboard = 1
|
||||
texture_filter = 0
|
||||
texture = ExtResource("3_6jcxd")
|
||||
|
|
@ -1,24 +1,54 @@
|
|||
using Cirno.Scripts.Enums;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Misc;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts;
|
||||
|
||||
public partial class GameController : Node
|
||||
{
|
||||
public static GameController Instance { get; private set; }
|
||||
|
||||
|
||||
private Hud _hud;
|
||||
private IsoPlayerFSMProxy _player;
|
||||
public IsoPlayerStateMachine Player => _player.PlayerFSM;
|
||||
|
||||
[Export] private Marker3D _cameraTarget;
|
||||
public Vector3? PlayerPosition => _player?.GlobalPosition ?? null;
|
||||
public Vector3? PlayerVelocity => _player?.Velocity ?? null;
|
||||
public GameState GameState { get; private set; }
|
||||
|
||||
[Signal] public delegate void GameStateChangeEventHandler(GameState state);
|
||||
|
||||
[Signal] public delegate void ManagerReadyEventHandler();
|
||||
|
||||
|
||||
[Signal]
|
||||
public delegate void GameStateChangeEventHandler(GameState state);
|
||||
|
||||
[Signal]
|
||||
public delegate void ManagerReadyEventHandler();
|
||||
|
||||
[Export] public StringName PauseActionName { get; private set; } = "pause";
|
||||
|
||||
[Export] public MapResource MapResource { get; private set; }
|
||||
|
||||
[Export] public PackedScene PlayerTemplate { get; set; }
|
||||
|
||||
[Export] public Dictionary<int, NodePath> SpawnMarkers { get; private set; } = new();
|
||||
|
||||
[Export]
|
||||
public int EggStartIndex = 0;
|
||||
|
||||
[Export] public Node3D PlayerParentNode { get; set; }
|
||||
private InventoryManager _inventoryManager { get; set; }
|
||||
|
||||
private Vector3 _lastCheckPointPosition;
|
||||
|
||||
public Vector3 LastCheckPointPosition
|
||||
{
|
||||
get => _lastCheckPointPosition;
|
||||
set => _lastCheckPointPosition = value;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
|
@ -35,28 +65,27 @@ public partial class GameController : Node
|
|||
{
|
||||
//GlobalState.Session.LevelNumber = MapResource.LevelId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GlobalState.Instance.ChangeCursor(false);
|
||||
|
||||
|
||||
if (GlobalState.Instance.SessionSettings.AllowSaving)
|
||||
{
|
||||
GlobalState.Instance.SaveGame();
|
||||
}
|
||||
|
||||
|
||||
//_audioManager = new AudioManager();
|
||||
// this.AddChild(_audioManager);
|
||||
|
||||
// this.AddChild(_audioManager);
|
||||
|
||||
_hud = GetNodeOrNull<Hud>("HUD");
|
||||
if (_hud == null) GD.Print("No HUD in scene.");
|
||||
|
||||
//_cameraTarget = GetNodeOrNull<Node2D>("CameraTarget");
|
||||
//if (_cameraTarget == null) GD.Print("No camera target in scene.");
|
||||
|
||||
// _inventoryManager = GetNodeOrNull<InventoryManager>("InventoryManager");
|
||||
//if (_inventoryManager == null) GD.Print("No inventory manager in scene.");
|
||||
_inventoryManager = GetNodeOrNull<InventoryManager>("InventoryManager");
|
||||
if (_inventoryManager == null) GD.Print("No inventory manager in scene.");
|
||||
|
||||
|
||||
//SpawnBulletsContainer();
|
||||
|
||||
if (_hud != null)
|
||||
|
|
@ -64,28 +93,26 @@ public partial class GameController : Node
|
|||
this.GameStateChange += _hud.OnGameStateChanged;
|
||||
}
|
||||
|
||||
// if (_inventoryManager != null && _hud != null)
|
||||
// {
|
||||
//
|
||||
// _inventoryManager.WeaponUpdate += key => _hud.EquipWeapon(key);
|
||||
// }
|
||||
if (_inventoryManager != null && _hud != null)
|
||||
{
|
||||
_inventoryManager.WeaponUpdate += key => _hud.EquipWeapon(key);
|
||||
}
|
||||
|
||||
//PlayerRespawned += OnPlayerRespawned;
|
||||
|
||||
GameState = GameState.Playing;
|
||||
|
||||
|
||||
|
||||
//CallDeferred(MethodName.DelayPlayerSpawn);
|
||||
CallDeferred(MethodName.DelayPlayerSpawn);
|
||||
|
||||
CallDeferred(MethodName.OnFinished);
|
||||
}
|
||||
|
||||
|
||||
private void OnFinished()
|
||||
{
|
||||
EmitSignalManagerReady();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (GameState is GameState.Paused && Input.IsActionJustPressed(PauseActionName))
|
||||
|
|
@ -93,7 +120,7 @@ public partial class GameController : Node
|
|||
Unpause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (GameState == GameState.Playing)
|
||||
|
|
@ -139,7 +166,7 @@ public partial class GameController : Node
|
|||
case GameState.Shop:
|
||||
case GameState.Inventory:
|
||||
GlobalState.Instance.ChangeCursor(true);
|
||||
|
||||
|
||||
GetTree().SetPause(true);
|
||||
//Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
break;
|
||||
|
|
@ -165,4 +192,123 @@ public partial class GameController : Node
|
|||
{
|
||||
GetTree().SetPause(false);
|
||||
}
|
||||
|
||||
private void DelayPlayerSpawn()
|
||||
{
|
||||
if (SpawnMarkers.Any())
|
||||
{
|
||||
SpawnPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("No player spawn marker in scene.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player != null && _hud != null)
|
||||
{
|
||||
// _player.HealthChanged += (newHealth, maxHealth) => _hud.UpdateHealth(newHealth, maxHealth);
|
||||
//
|
||||
// _player.ShieldChanged += (newShield, maxShield) => _hud.UpdateShield(newShield, maxShield);
|
||||
//
|
||||
// _player.InteractableAreaEntered += (interactable) => _hud.UpdateInteractable(interactable);
|
||||
//
|
||||
// _player.Death += () =>
|
||||
// {
|
||||
// // Show Game Over
|
||||
// _hud.ShowGameOver();
|
||||
// };
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("No player and hud in scene");
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait before the player is fully initialized before spawning weapons on it
|
||||
CallDeferred(MethodName.SpawnWeapons);
|
||||
}
|
||||
|
||||
private void SpawnWeapons()
|
||||
{
|
||||
foreach (var startingItem in MapResource.StartData.StartingEquipment)
|
||||
{
|
||||
_inventoryManager.AddItem(startingItem);
|
||||
}
|
||||
|
||||
foreach (var item in MapResource.StartData.RemoveEquipment)
|
||||
{
|
||||
_inventoryManager.RemoveItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void SpawnPlayer()
|
||||
{
|
||||
if (_player != null) return;
|
||||
|
||||
//_player = this.CreateChild<PlayerMovement>(PlayerTemplate, PlayerSpawnMarker.Position );
|
||||
_player = PlayerTemplate.Instantiate<IsoPlayerFSMProxy>();
|
||||
|
||||
if (PlayerParentNode is not null)
|
||||
{
|
||||
PlayerParentNode.AddChild(_player);
|
||||
_player.Owner = PlayerParentNode;
|
||||
_player.Transform = PlayerParentNode.GlobalTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AddChild(_player);
|
||||
_player.Owner = this;
|
||||
}
|
||||
|
||||
_player.GlobalPosition = GetStartPosition();
|
||||
|
||||
LastCheckPointPosition = _player.GlobalPosition;
|
||||
|
||||
//_player.GlobalPosition = PlayerSpawnMarker.Position;
|
||||
|
||||
CameraTargetPlayer();
|
||||
|
||||
//
|
||||
// if (_cameraTarget != null)
|
||||
// {
|
||||
// _cameraTarget.Reparent(_player, true);
|
||||
// _cameraTarget.GlobalPosition = _player.Position;
|
||||
// }
|
||||
}
|
||||
|
||||
public void CameraTargetPlayer()
|
||||
{
|
||||
if (_player is null) return;
|
||||
CameraTargetObject(_player);
|
||||
}
|
||||
|
||||
public void CameraTargetObject(Node3D target, Vector3? offset = null)
|
||||
{
|
||||
if (_cameraTarget is null) return;
|
||||
_cameraTarget.Reparent(target, true);
|
||||
_cameraTarget.GlobalPosition = target.GlobalPosition;
|
||||
|
||||
if (offset.HasValue)
|
||||
{
|
||||
_cameraTarget.Position += offset.Value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Vector3 GetStartPosition()
|
||||
{
|
||||
if (MapResource != null)
|
||||
{
|
||||
if (SpawnMarkers.TryGetValue(EggStartIndex, out var spawnMarker))
|
||||
{
|
||||
var marker = GetNode<Node3D>(spawnMarker);
|
||||
|
||||
return marker.Position; // Why position and not globalposition? I have no idea
|
||||
}
|
||||
}
|
||||
|
||||
var m = GetNode<Node3D>(SpawnMarkers.First().Value);
|
||||
return m.GlobalPosition;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,14 +23,18 @@ public partial class CameraController3D : Camera3D
|
|||
|
||||
[Export] public NodePath TargetPath;
|
||||
|
||||
private Node3D _target;
|
||||
private CameraTarget3D _target;
|
||||
private Vector3 _currentPosition = Vector3.Zero;
|
||||
private Vector3 _currentAimOffset = Vector3.Zero;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
_target = GetNode<Node3D>(TargetPath);
|
||||
|
||||
RotationDegrees = new Vector3(-45f, 45f, 0f);
|
||||
Projection = ProjectionType.Orthogonal;
|
||||
|
||||
_target = GetNode<CameraTarget3D>(TargetPath);
|
||||
if (_target == null)
|
||||
{
|
||||
GD.PushError("Camera target not found.");
|
||||
|
|
@ -40,13 +44,22 @@ public partial class CameraController3D : Camera3D
|
|||
_currentPosition = GlobalPosition;
|
||||
|
||||
// Set fixed isometric angle once: -45° X tilt, 45° Y pan
|
||||
RotationDegrees = new Vector3(-45f, 45f, 0f);
|
||||
Projection = ProjectionType.Orthogonal;
|
||||
|
||||
}
|
||||
|
||||
public void RegisterTarget(CameraTarget3D target, bool jump = true)
|
||||
{
|
||||
// assert(not _active_target)
|
||||
_target = target;
|
||||
if (jump)
|
||||
{
|
||||
//_currentPosition = _activeTarget.GlobalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_target == null) return;
|
||||
if (_target is null) return;
|
||||
|
||||
float dt = (float)delta;
|
||||
Vector3 targetPos = _target.GlobalTransform.Origin;
|
||||
|
|
|
|||
16
Scripts/Misc/CameraTarget3D.cs
Normal file
16
Scripts/Misc/CameraTarget3D.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Misc;
|
||||
|
||||
public partial class CameraTarget3D : Marker3D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
// register with the controller
|
||||
var res = GetTree().GetFirstNodeInGroup("camera_controllers");
|
||||
if (res is CameraController3D cameraController)
|
||||
{
|
||||
cameraController.RegisterTarget(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/Misc/CameraTarget3D.cs.uid
Normal file
1
Scripts/Misc/CameraTarget3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dnslcy71dgea
|
||||
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
namespace Cirno.Scripts.Weapons;
|
||||
|
||||
public partial class WeaponSoundModule : Node2D
|
||||
public partial class WeaponSoundModule : Node
|
||||
{
|
||||
[Export]
|
||||
public Weapon Weapon { get; private set; }
|
||||
|
||||
[Export]
|
||||
public AudioStreamPlayer2D ShootSound { get; private set; }
|
||||
public AudioStreamPlayer ShootSound { get; private set; }
|
||||
[Export]
|
||||
public AudioStreamPlayer2D ReloadSound { get; private set; }
|
||||
public AudioStreamPlayer ReloadSound { get; private set; }
|
||||
[Export]
|
||||
public AudioStreamPlayer2D EmptySound { get; private set; }
|
||||
public AudioStreamPlayer EmptySound { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue