3D Switches

This commit is contained in:
Marco 2025-06-13 17:46:44 +02:00
commit cb60226ced
20 changed files with 267 additions and 14 deletions

View file

@ -117,3 +117,6 @@ script = ExtResource("11_4cdxq")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="ActivationProvider"]
stream = ExtResource("13_2ffwi")
bus = &"Effects"
[node name="AudioListener3D" type="AudioListener3D" parent="."]
current = true

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=37 format=3 uid="uid://dkwi1hu1bixoe"]
[gd_scene load_steps=38 format=3 uid="uid://dkwi1hu1bixoe"]
[ext_resource type="Script" uid="uid://baf6pxbvhqmjk" path="res://Scripts/Hud.cs" id="1_m0hb0"]
[ext_resource type="PackedScene" uid="uid://dsaj5dx82brsg" path="res://Scenes/HUD/UiSelector.tscn" id="2_jidad"]
[ext_resource type="PackedScene" uid="uid://cd3ee1adstcrw" path="res://Scenes/HUD/HudItemContainer.tscn" id="2_mattb"]
[ext_resource type="LabelSettings" uid="uid://buk3e7bbwmnv1" path="res://Resources/Styles/Hud_Text_Style.tres" id="2_x7kl7"]
[ext_resource type="Texture2D" uid="uid://dde36pgb8fbwc" path="res://Sprites/selector_big.png" id="3_hee3i"]
@ -90,6 +91,7 @@ font_color = Color(0, 0.737255, 0.113725, 1)
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_healthLabel", "_healthBar", "_shieldLabel", "_shieldBar", "_motivationLabel", "_itemsContainer", "_gameOverPanel", "_fairyTerminatedPanel", "_hudInfoPanel", "NotificationsContainer", "WeaponContainer", "PauseMenuContainer", "DebugMenuHolder")]
process_mode = 3
script = ExtResource("1_m0hb0")
SelectorScene = ExtResource("2_jidad")
WeaponContainerTemplate = ExtResource("2_mattb")
ItemNotificationTemplate = ExtResource("3_mw35l")
_healthLabel = NodePath("HudInfo/HealthBarContainer/HealthLabel")

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=6 format=3 uid="uid://dsaj5dx82brsg"]
[ext_resource type="Texture2D" uid="uid://dde36pgb8fbwc" path="res://Sprites/selector_big.png" id="1_undfg"]
[ext_resource type="Script" uid="uid://w85hem1ec8cq" path="res://Scripts/Tools/AnimatedTextureRect.gd" id="2_cjotf"]
[sub_resource type="AtlasTexture" id="AtlasTexture_vxp1j"]
atlas = ExtResource("1_undfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_bnh43"]
atlas = ExtResource("1_undfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_0vbph"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_vxp1j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bnh43")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="UiSelector" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 0
offset_left = -8.0
offset_top = -8.0
offset_right = 8.0
offset_bottom = 8.0
texture = SubResource("AtlasTexture_vxp1j")
stretch_mode = 2
script = ExtResource("2_cjotf")
Frames = SubResource("SpriteFrames_0vbph")

View file

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Linq;
using Cirno.Scripts;
using Cirno.Scripts.Interactables;
using Cirno.Scripts.Misc;
using Cirno.Scripts.Resources;
using Godot.Collections;
@ -53,4 +54,20 @@ public partial class Interactable : Area2D, IInteractable
{
return true;
}
public Vector2 GetScreenPosition()
{
if (CameraController.Instance is null)
{
return this.GlobalPosition;
}
return this.GlobalPosition - CameraController.Instance.GlobalPosition +
(GetViewport().GetVisibleRect().Size / 2);
}
public Vector2 GetGlobalPosition2D()
{
return GetGlobalPosition();
}
}