mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:45:33 +00:00
Level Teleporters
This commit is contained in:
parent
5e357e1a96
commit
7a8bb4311b
26 changed files with 581 additions and 410 deletions
BIN
3D/MapModels/actor_level_teleporter.glb
Normal file
BIN
3D/MapModels/actor_level_teleporter.glb
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -2452,21 +2452,9 @@
|
|||
}
|
||||
// entity 193
|
||||
{
|
||||
"classname" "trigger_area"
|
||||
"targetname" ""
|
||||
"target" "tube_emitter_intro"
|
||||
"activationtype" "Toggle"
|
||||
"minactivations" "1"
|
||||
"maxactivations" "2"
|
||||
// brush 0
|
||||
{
|
||||
( -40 -60 16 ) ( -40 -59 16 ) ( -40 -60 17 ) special/trigger [ 0 -1 0 24 ] [ 0 0 -1 0 ] 270 1 1
|
||||
( -40 -32 16 ) ( -40 -32 17 ) ( -39 -32 16 ) special/trigger [ 1 0 0 8 ] [ 0 0 -1 0 ] 90 1 1
|
||||
( -40 -60 16 ) ( -39 -60 16 ) ( -40 -59 16 ) special/trigger [ -1 0 0 -8 ] [ 0 -1 0 24 ] 270 1 1
|
||||
( 12 -32 24 ) ( 12 -31 24 ) ( 13 -32 24 ) special/trigger [ 1 0 0 8 ] [ 0 -1 0 24 ] 180 1 1
|
||||
( 12 -16 20 ) ( 13 -16 20 ) ( 12 -16 21 ) special/trigger [ -1 0 0 -8 ] [ 0 0 -1 0 ] 180 1 1
|
||||
( -16 -32 20 ) ( -16 -32 21 ) ( -16 -31 20 ) special/trigger [ 0 1 0 -24 ] [ 0 0 -1 0 ] 180 1 1
|
||||
}
|
||||
"classname" "actor_level_teleporter"
|
||||
"origin" "-8 -40 17"
|
||||
"enabled" "1"
|
||||
}
|
||||
// entity 194
|
||||
{
|
||||
|
|
|
|||
31
3D/Scenes/Props/Level_Teleporter_3D.tscn
Normal file
31
3D/Scenes/Props/Level_Teleporter_3D.tscn
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bn7hkgapi5oka"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c4e21ceehvqap" path="res://Scripts/Activables/3D/LevelTeleporter3D.cs" id="1_cbs4u"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnofvejpr6lvx" path="res://3D/BlockbenchModels/Teleporter/Teleporter.gltf" id="2_b3mo2"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_jvaa5"]
|
||||
size = Vector3(0.855408, 0.0617218, 0.878296)
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_5c8o5"]
|
||||
height = 0.949707
|
||||
radius = 0.257813
|
||||
|
||||
[node name="LevelTeleporter" type="StaticBody3D"]
|
||||
script = ExtResource("1_cbs4u")
|
||||
TeleportOffset = Vector3(0, 0.4, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00344848, -0.0301591, 0.000671387)
|
||||
shape = SubResource("BoxShape3D_jvaa5")
|
||||
|
||||
[node name="blockbench_export" parent="." instance=ExtResource("2_b3mo2")]
|
||||
|
||||
[node name="TeleporterTrigger" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TeleporterTrigger"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.525146, 0)
|
||||
shape = SubResource("CylinderShape3D_5c8o5")
|
||||
|
||||
[connection signal="body_entered" from="TeleporterTrigger" to="." method="_on_body_entered"]
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
[gd_resource type="Resource" script_class="FuncGodotFGDModelPointClass" load_steps=4 format=3 uid="uid://dvpi4kx2visc0"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://5bc1qysixhmh" path="res://3D/TrenchBroom/EntityDefinitions/base/actor_base.tres" id="1_klaoa"]
|
||||
[ext_resource type="PackedScene" uid="uid://bn7hkgapi5oka" path="res://3D/Scenes/Props/Level_Teleporter_3D.tscn" id="2_atmpw"]
|
||||
[ext_resource type="Script" uid="uid://dkmyelig23ub5" path="res://addons/func_godot/src/fgd/func_godot_fgd_model_point_class.gd" id="5_7bpmd"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("5_7bpmd")
|
||||
target_map_editor = 1
|
||||
rotation_offset = Vector3(0, 180, 0)
|
||||
scene_file = ExtResource("2_atmpw")
|
||||
apply_scale_on_map_build = false
|
||||
classname = "actor_level_teleporter"
|
||||
description = "Teleporter to the next level"
|
||||
base_classes = Array[Resource]([ExtResource("1_klaoa")])
|
||||
class_properties = {
|
||||
"enabled": false
|
||||
}
|
||||
class_property_descriptions = {
|
||||
"enabled": "Enabled or disabled"
|
||||
}
|
||||
meta_properties = {
|
||||
"model": "\"3D/MapModels/actor_level_teleporter.glb\"",
|
||||
"size": AABB(-8, -8, -1, 8, 8, 1)
|
||||
}
|
||||
metadata/_custom_type_script = "uid://c83r7t467hm4m"
|
||||
|
|
@ -120,7 +120,8 @@ public partial class TriggerArea : Area3D, ITargetable, ITargeting, IActivationT
|
|||
|
||||
private void ToggleCollision(bool toggle)
|
||||
{
|
||||
Monitoring = toggle;
|
||||
SetDeferred(nameof(Monitoring), toggle);
|
||||
//Monitoring = toggle;
|
||||
}
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Resource" script_class="FuncGodotFGDFile" load_steps=48 format=3 uid="uid://b700sa4be6dfa"]
|
||||
[gd_resource type="Resource" script_class="FuncGodotFGDFile" load_steps=49 format=3 uid="uid://b700sa4be6dfa"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://ia1t5p4mhom3" path="res://3D/TrenchBroom/EntityDefinitions/point/lights/light_omni.tres" id="1_7vcj1"]
|
||||
[ext_resource type="Script" uid="uid://cknmd0lgmorx2" path="res://addons/func_godot/src/fgd/func_godot_fgd_file.gd" id="1_lykim"]
|
||||
|
|
@ -47,8 +47,9 @@
|
|||
[ext_resource type="Resource" uid="uid://dd7haabidbq5s" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/actor_tank_standalone.tres" id="44_k6g2u"]
|
||||
[ext_resource type="Resource" uid="uid://b4cf1i0x46ej4" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/Actor_Emitter_Floor.tres" id="45_b4ckg"]
|
||||
[ext_resource type="Resource" uid="uid://chytq0646of5n" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/Actor_Locker.tres" id="46_dyoc0"]
|
||||
[ext_resource type="Resource" uid="uid://dvpi4kx2visc0" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/Actor_Level_Teleporter.tres" id="47_pa845"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_lykim")
|
||||
entity_definitions = Array[Resource]([ExtResource("1_7vcj1"), ExtResource("2_u7uvb"), ExtResource("3_u7uvb"), ExtResource("4_1nmxk"), ExtResource("5_ljb2x"), ExtResource("6_seuvu"), ExtResource("7_fmwex"), ExtResource("8_c8m8m"), ExtResource("9_14sjf"), ExtResource("10_xik3w"), ExtResource("11_dgiqm"), ExtResource("12_1teik"), ExtResource("13_f0hti"), ExtResource("14_6ld6e"), ExtResource("15_g8j5j"), ExtResource("16_7h4of"), ExtResource("17_m3sbm"), ExtResource("18_m3sbm"), ExtResource("19_hvhb8"), ExtResource("20_3v5us"), ExtResource("21_g67cj"), ExtResource("22_iy67w"), ExtResource("23_b5lmu"), ExtResource("24_ndas4"), ExtResource("25_n7wsi"), ExtResource("26_v48k5"), ExtResource("27_ombvk"), ExtResource("28_31lma"), ExtResource("29_louv0"), ExtResource("30_wfgfu"), ExtResource("31_elv2e"), ExtResource("32_elv2e"), ExtResource("33_aawmv"), ExtResource("34_wy0ht"), ExtResource("35_3jqmy"), ExtResource("36_p5b6l"), ExtResource("37_53o7h"), ExtResource("38_mdgca"), ExtResource("39_d6b4f"), ExtResource("40_l3pck"), ExtResource("41_q8hab"), ExtResource("42_ekplg"), ExtResource("43_d7qk0"), ExtResource("44_k6g2u"), ExtResource("45_b4ckg"), ExtResource("46_dyoc0")])
|
||||
entity_definitions = Array[Resource]([ExtResource("1_7vcj1"), ExtResource("2_u7uvb"), ExtResource("3_u7uvb"), ExtResource("4_1nmxk"), ExtResource("5_ljb2x"), ExtResource("6_seuvu"), ExtResource("7_fmwex"), ExtResource("8_c8m8m"), ExtResource("9_14sjf"), ExtResource("10_xik3w"), ExtResource("11_dgiqm"), ExtResource("12_1teik"), ExtResource("13_f0hti"), ExtResource("14_6ld6e"), ExtResource("15_g8j5j"), ExtResource("16_7h4of"), ExtResource("17_m3sbm"), ExtResource("18_m3sbm"), ExtResource("19_hvhb8"), ExtResource("20_3v5us"), ExtResource("21_g67cj"), ExtResource("22_iy67w"), ExtResource("23_b5lmu"), ExtResource("24_ndas4"), ExtResource("25_n7wsi"), ExtResource("26_v48k5"), ExtResource("27_ombvk"), ExtResource("28_31lma"), ExtResource("29_louv0"), ExtResource("30_wfgfu"), ExtResource("31_elv2e"), ExtResource("32_elv2e"), ExtResource("33_aawmv"), ExtResource("34_wy0ht"), ExtResource("35_3jqmy"), ExtResource("36_p5b6l"), ExtResource("37_53o7h"), ExtResource("38_mdgca"), ExtResource("39_d6b4f"), ExtResource("40_l3pck"), ExtResource("41_q8hab"), ExtResource("42_ekplg"), ExtResource("43_d7qk0"), ExtResource("44_k6g2u"), ExtResource("45_b4ckg"), ExtResource("46_dyoc0"), ExtResource("47_pa845")])
|
||||
metadata/_custom_type_script = "uid://cknmd0lgmorx2"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
[resource]
|
||||
script = ExtResource("2_p6a7h")
|
||||
MapId = &"Factory2"
|
||||
MapName = &"iso Test"
|
||||
MapDescription = null
|
||||
ScenePath = &"uid://ec4m3geediis"
|
||||
NextMap = &"Factory3"
|
||||
WeaponsAllowed = true
|
||||
StartData = ExtResource("1_ns0cf")
|
||||
MapType = 1
|
||||
metadata/_custom_type_script = "uid://quy4d4tgvqfy"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
[resource]
|
||||
script = ExtResource("2_7gq3v")
|
||||
MapId = &"Factory3"
|
||||
MapName = &"iso Test 3"
|
||||
MapDescription = null
|
||||
ScenePath = &"D:/Maddo/cirnogodot/IsoTest/IsoMapTest3.tscn"
|
||||
NextMap = &"Factory2"
|
||||
WeaponsAllowed = true
|
||||
StartData = ExtResource("1_5tghs")
|
||||
MapType = 1
|
||||
metadata/_custom_type_script = "uid://quy4d4tgvqfy"
|
||||
|
|
|
|||
11
Resources/Maps/3D/MapsDatabase_3D.tres
Normal file
11
Resources/Maps/3D/MapsDatabase_3D.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_resource type="Resource" script_class="MapsDatabase" load_steps=5 format=3 uid="uid://de87ukaq3jbi4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://denacldr388km" path="res://Scripts/Resources/MapsDatabase.cs" id="1_fisvv"]
|
||||
[ext_resource type="Resource" uid="uid://bq2o78engsuyt" path="res://Resources/Maps/3D/IsoMapTest2.tres" id="1_k7j74"]
|
||||
[ext_resource type="Resource" uid="uid://bxju78og0t8ca" path="res://Resources/Maps/3D/IsoMapTest3.tres" id="2_eecr0"]
|
||||
[ext_resource type="Resource" uid="uid://b32mqmglcdo64" path="res://Resources/Maps/3D/Tutorial_3D.tres" id="3_3qbig"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_fisvv")
|
||||
Maps = Array[Object]([ExtResource("3_3qbig"), ExtResource("1_k7j74"), ExtResource("2_eecr0")])
|
||||
metadata/_custom_type_script = "uid://denacldr388km"
|
||||
|
|
@ -11,9 +11,12 @@ metadata/_custom_type_script = "uid://mja0rk7n2kln"
|
|||
|
||||
[resource]
|
||||
script = ExtResource("2_kgbmv")
|
||||
MapId = &"Tutorial"
|
||||
MapName = &"Tutorial"
|
||||
MapDescription = null
|
||||
ScenePath = &"uid://dorx2l3svs58g"
|
||||
NextMap = &"Factory3"
|
||||
WeaponsAllowed = true
|
||||
StartData = SubResource("Resource_kgbmv")
|
||||
MapType = 1
|
||||
metadata/_custom_type_script = "uid://quy4d4tgvqfy"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ metadata/_custom_type_script = "uid://mja0rk7n2kln"
|
|||
[resource]
|
||||
script = ExtResource("1_x864d")
|
||||
LevelId = -1
|
||||
MapId = null
|
||||
MapName = &"Briefing"
|
||||
MapDescription = null
|
||||
ScenePath = &"uid://dcn2o6hllas78"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Resource" script_class="MapsDatabase" load_steps=10 format=3 uid="uid://blf2ii0j3fqil"]
|
||||
[gd_resource type="Resource" script_class="MapsDatabase" load_steps=13 format=3 uid="uid://blf2ii0j3fqil"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://dsvcyd0f5br85" path="res://Resources/Maps/Briefing_1.tres" id="1_axa7o"]
|
||||
[ext_resource type="Resource" uid="uid://b4u3cs6ietmow" path="res://Resources/Maps/Tutorial.tres" id="1_jm16h"]
|
||||
|
|
@ -9,8 +9,11 @@
|
|||
[ext_resource type="Resource" uid="uid://mx860r8t37g1" path="res://Resources/Maps/Level2.tres" id="4_axa7o"]
|
||||
[ext_resource type="Resource" uid="uid://b0xtpdb4by8mm" path="res://Resources/Maps/Level3.tres" id="5_8yujj"]
|
||||
[ext_resource type="Resource" uid="uid://b6per1p85bqpn" path="res://Resources/Maps/Level4.tres" id="6_2lffu"]
|
||||
[ext_resource type="Resource" uid="uid://bq2o78engsuyt" path="res://Resources/Maps/3D/IsoMapTest2.tres" id="9_8jebd"]
|
||||
[ext_resource type="Resource" uid="uid://bxju78og0t8ca" path="res://Resources/Maps/3D/IsoMapTest3.tres" id="10_2s8ya"]
|
||||
[ext_resource type="Resource" uid="uid://b32mqmglcdo64" path="res://Resources/Maps/3D/Tutorial_3D.tres" id="11_ejvbj"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_p3u82")
|
||||
Maps = Array[Object]([ExtResource("1_axa7o"), ExtResource("1_jm16h"), ExtResource("2_2lffu"), ExtResource("4_8yujj"), ExtResource("3_b8vvn"), ExtResource("4_axa7o"), ExtResource("5_8yujj"), ExtResource("6_2lffu")])
|
||||
Maps = Array[Object]([ExtResource("1_axa7o"), ExtResource("1_jm16h"), ExtResource("2_2lffu"), ExtResource("4_8yujj"), ExtResource("3_b8vvn"), ExtResource("4_axa7o"), ExtResource("5_8yujj"), ExtResource("6_2lffu"), ExtResource("9_8jebd"), ExtResource("10_2s8ya"), ExtResource("11_ejvbj")])
|
||||
metadata/_custom_type_script = "uid://denacldr388km"
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@
|
|||
|
||||
[sub_resource type="Resource" id="Resource_dpitu"]
|
||||
script = ExtResource("1_3bwtp")
|
||||
EggIndex = 0
|
||||
StartingEquipment = []
|
||||
RemoveEquipment = []
|
||||
metadata/_custom_type_script = "uid://mja0rk7n2kln"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_5stb7")
|
||||
LevelId = 0
|
||||
MapId = null
|
||||
MapName = &"Tutorial"
|
||||
MapDescription = &"A VR simulation for training"
|
||||
ScenePath = &"uid://bpnahwxmjgb6t"
|
||||
|
|
|
|||
8
Scenes/Utils/GlobalMapsDatabase.tscn
Normal file
8
Scenes/Utils/GlobalMapsDatabase.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://do44hif0la2ds"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cegjwc0h7qenj" path="res://Scripts/Utils/GlobalMapDatabase.cs" id="1_6tu8k"]
|
||||
[ext_resource type="Resource" uid="uid://blf2ii0j3fqil" path="res://Resources/Maps/MapsDatabase.tres" id="2_i6q1f"]
|
||||
|
||||
[node name="GlobalMapsDatabase" type="Node"]
|
||||
script = ExtResource("1_6tu8k")
|
||||
Maps = ExtResource("2_i6q1f")
|
||||
48
Scripts/Activables/3D/LevelTeleporter3D.cs
Normal file
48
Scripts/Activables/3D/LevelTeleporter3D.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Activables._3D;
|
||||
|
||||
[Tool]
|
||||
public partial class LevelTeleporter3D : Teleporter3D
|
||||
{
|
||||
[Export] public bool SaveInventory { get; set; }
|
||||
|
||||
public override void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
// TargetGroup = props["target"].AsString();
|
||||
//
|
||||
// TargetName = props["targetname"].AsString();
|
||||
IsEnabled = props["enabled"].AsBool();
|
||||
}
|
||||
|
||||
protected override async Task Teleport(IsoPlayerStateMachine player)
|
||||
{
|
||||
player.SetState(PlayerState.Cutscene);
|
||||
await TweenPlayer(player.MainObject);
|
||||
|
||||
PlayTeleportStartSound();
|
||||
FireParticles();
|
||||
|
||||
player.SetState(PlayerState.Teleporting);
|
||||
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
||||
|
||||
if (SaveInventory)
|
||||
{
|
||||
// Save inventory
|
||||
GlobalState.Instance.SessionSettings.Items = InventoryManager.Instance.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalState.Instance.SessionSettings.EquippedWeaponId = string.Empty;
|
||||
}
|
||||
|
||||
var nextMap = GlobalState.Instance.MapsDatabase.FindNextMap(GlobalState.Instance.SessionSettings.MapId);
|
||||
GlobalState.Instance.GotoScene(nextMap);
|
||||
}
|
||||
}
|
||||
1
Scripts/Activables/3D/LevelTeleporter3D.cs.uid
Normal file
1
Scripts/Activables/3D/LevelTeleporter3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c4e21ceehvqap
|
||||
|
|
@ -35,7 +35,7 @@ public partial class Teleporter3D : StaticBody3D, IActivable, ITargetable
|
|||
|
||||
[Export] public StringName DefaultAnimationName { get; private set; } = "Default";
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
public virtual void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
TargetGroup = props["target"].AsString();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Cirno.Scripts.Activables;
|
|||
public partial class LevelTeleporter : Teleporter
|
||||
{
|
||||
[Export] public string LevelPath { get; set; }
|
||||
[Export] public MapResource Map { get; private set; }
|
||||
[Export] public MapResource Map { get; private set; }
|
||||
|
||||
[Export] public bool SaveInventory { get; set; }
|
||||
|
||||
|
|
@ -47,13 +47,12 @@ public partial class LevelTeleporter : Teleporter
|
|||
{
|
||||
GlobalState.Instance.SessionSettings.LevelNumber += 1;
|
||||
}
|
||||
|
||||
|
||||
GlobalState.Instance.GotoScene(LevelPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalState.Instance.GotoScene(Map);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,8 @@ public partial class GameController : Node
|
|||
}
|
||||
else
|
||||
{
|
||||
//GlobalState.Session.LevelNumber = MapResource.LevelId;
|
||||
GlobalState.Session.LevelNumber = MapResource.LevelId;
|
||||
GlobalState.Session.MapId = MapResource.MapId;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public partial class GlobalState : Node
|
|||
private readonly StringName _mapsDatabaseResource = "uid://blf2ii0j3fqil";
|
||||
|
||||
private MapsDatabase _mapsDatabase;
|
||||
|
||||
public MapsDatabase MapsDatabase => _mapsDatabase;
|
||||
|
||||
private Texture2D _menuMouseTexture;
|
||||
private Image _menuMouseImage;
|
||||
|
|
@ -35,7 +37,7 @@ public partial class GlobalState : Node
|
|||
private Image _reticuleMouseImage;
|
||||
|
||||
public bool UseMenuCursor { get; set; } = true;
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
|
@ -52,7 +54,7 @@ public partial class GlobalState : Node
|
|||
|
||||
_menuMouseTexture = ResourceLoader.Load<Texture2D>(_menuMouseTexturePath);
|
||||
_menuMouseImage = _menuMouseTexture.GetImage();
|
||||
|
||||
|
||||
_reticuleMouseTexture = ResourceLoader.Load<Texture2D>(_reticuleMouseTexturePath);
|
||||
_reticuleMouseImage = _reticuleMouseTexture.GetImage();
|
||||
|
||||
|
|
@ -222,6 +224,7 @@ public partial class GlobalState : Node
|
|||
{
|
||||
{ "Items", items },
|
||||
{ "Level", SessionSettings.LevelNumber },
|
||||
{ "MapId", SessionSettings.MapId },
|
||||
{ "Difficulty", (int)SessionSettings.Difficulty }
|
||||
};
|
||||
|
||||
|
|
@ -259,9 +262,10 @@ public partial class GlobalState : Node
|
|||
|
||||
DifficultyLevel difficulty = (DifficultyLevel)deserializedSaveData["Difficulty"].AsInt32();
|
||||
|
||||
int levelNumber = (int)deserializedSaveData["Level"];
|
||||
int levelNumber = deserializedSaveData["Level"].AsInt32();
|
||||
StringName mapId = deserializedSaveData["MapId"].AsStringName();
|
||||
|
||||
var levelData = _mapsDatabase.Maps.FirstOrDefault(x => x.LevelId == levelNumber);
|
||||
var levelData = _mapsDatabase.FindMap(mapId);
|
||||
if (levelData is null)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -269,6 +273,7 @@ public partial class GlobalState : Node
|
|||
|
||||
this.SessionSettings.NewSession();
|
||||
SessionSettings.LevelNumber = levelNumber;
|
||||
SessionSettings.MapId = mapId;
|
||||
SessionSettings.Items = items;
|
||||
SessionSettings.Difficulty = difficulty;
|
||||
|
||||
|
|
@ -283,9 +288,8 @@ public partial class GlobalState : Node
|
|||
Vector2I size;
|
||||
if (useMenuCursor)
|
||||
{
|
||||
scaled = (Image)_menuMouseImage.Duplicate();
|
||||
size = (Vector2I)(scale * _menuMouseTexture.GetSize());
|
||||
|
||||
scaled = (Image)_menuMouseImage.Duplicate();
|
||||
size = (Vector2I)(scale * _menuMouseTexture.GetSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -295,8 +299,9 @@ public partial class GlobalState : Node
|
|||
|
||||
scaled.Resize(size.X, size.Y, Image.Interpolation.Nearest);
|
||||
|
||||
Input.SetCustomMouseCursor(scaled, Input.CursorShape.Arrow, useMenuCursor ? Vector2.Zero : new Vector2(size.X / 2,size.Y / 2));
|
||||
|
||||
Input.SetCustomMouseCursor(scaled, Input.CursorShape.Arrow,
|
||||
useMenuCursor ? Vector2.Zero : new Vector2(size.X / 2, size.Y / 2));
|
||||
|
||||
//DisplayServer.CursorSetCustomImage(scaled);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,19 @@ namespace Cirno.Scripts.Resources;
|
|||
public partial class MapResource : Resource
|
||||
{
|
||||
[Export] public int LevelId { get; set; }
|
||||
[Export] public StringName MapId { get; set; }
|
||||
[Export] public StringName MapName { get; set; }
|
||||
[Export] public StringName MapDescription { get; set; }
|
||||
[Export] public StringName ScenePath { get; set; }
|
||||
[Export] public StringName NextMap { get; set; }
|
||||
[Export] public bool WeaponsAllowed { get; set; }
|
||||
[Export] public MapStartDataResource StartData { get; set; }
|
||||
|
||||
[Export] public MapType MapType { get; set; }
|
||||
}
|
||||
|
||||
public enum MapType
|
||||
{
|
||||
Map2D,
|
||||
Map3D
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
|
@ -7,4 +8,14 @@ namespace Cirno.Scripts.Resources;
|
|||
public partial class MapsDatabase : Resource
|
||||
{
|
||||
[Export] public Array<MapResource> Maps { get; set; }
|
||||
|
||||
public MapResource FindMap(StringName mapId)
|
||||
{
|
||||
return Maps.FirstOrDefault(x => x.MapId is not null && x.MapId.Equals(mapId));
|
||||
}
|
||||
|
||||
public MapResource FindNextMap(StringName mapId)
|
||||
{
|
||||
return FindMap(FindMap(mapId).NextMap);
|
||||
}
|
||||
}
|
||||
27
Scripts/Utils/GlobalMapDatabase.cs
Normal file
27
Scripts/Utils/GlobalMapDatabase.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Utils;
|
||||
|
||||
public partial class GlobalMapDatabase : Node
|
||||
{
|
||||
|
||||
public static GlobalMapDatabase Instance { get; private set; }
|
||||
|
||||
[Export] public MapsDatabase Maps { get; private set; }
|
||||
|
||||
public MapResource FindMap(StringName mapId)
|
||||
{
|
||||
return Maps.FindMap(mapId);
|
||||
}
|
||||
|
||||
public MapResource FindNextMap(StringName mapId)
|
||||
{
|
||||
return Maps.FindNextMap(mapId); //FindMap(Maps.FindMap(mapId).NextMap);
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
1
Scripts/Utils/GlobalMapDatabase.cs.uid
Normal file
1
Scripts/Utils/GlobalMapDatabase.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cegjwc0h7qenj
|
||||
|
|
@ -17,6 +17,7 @@ public class SessionSettings
|
|||
public Godot.Collections.Dictionary<string, int> Items { get; set; } = new();
|
||||
|
||||
public int LevelNumber { get; set; } = 0;
|
||||
public StringName MapId { get; set; }
|
||||
|
||||
public float Health { get; set; }
|
||||
public float Shield { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue