This commit is contained in:
joylink_fanyuhong 2024-04-30 09:14:11 +08:00
commit fb25472939
11 changed files with 228 additions and 127 deletions

View File

@ -2,7 +2,7 @@ extends Window
func _on_jjtc_click_jjtc_signal():
self.show()
$"../stationKeys".onShowWindow($"../stationKeys".WindowType.JJTC)
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.JJTC)
func _on_close_requested():
@ -12,7 +12,7 @@ func _on_close_requested():
func _on_station_keys_gui_input(event):
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
$"../stationKeys".onShowWindow($"../stationKeys".WindowType.JJTC)
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.JJTC)
func shouJJTCKey():
$JJTC_Key.show()

View File

@ -1,11 +1,14 @@
extends Window
##lcb面板
class_name LcbWindow
var currenScreenDoor:ScreenDoor=null
func _on_screen_door_click_lcb_signal(screenDoor: Variant) -> void:
var screenDoorName=String(screenDoor.name)
self.title='LCB'+screenDoorName[screenDoorName.length() - 1]
self.show()
$"../stationKeys".onShowWindow($"../stationKeys".WindowType.LCB,screenDoor.lcbKey.keyName)
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.LCB,screenDoor.lcbKey.keyName)
currenScreenDoor=screenDoor
resetState(screenDoor.lcbKey)
@ -70,7 +73,7 @@ func resetState(lcbKey):
##打开钥匙盒相关
func _on_open_key_window_gui_input(event: InputEvent) -> void:
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
$"../stationKeys".onShowWindow($"../stationKeys".WindowType.LCB,currenScreenDoor.lcbKey.keyName)
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.LCB,currenScreenDoor.lcbKey.keyName)
func _on_open_key_window_mouse_entered() -> void:

View File

@ -3,20 +3,22 @@ extends Window
func _on_psl_click_signal() -> void:
self.show()
$"../stationKeys".onShowWindow($"../stationKeys".WindowType.PSL)
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.PSL)
if !$"../stationKeys".hsjcKeyVisible() :
hideInterlockReleaseSwitchHandleKey()
if !$"../stationKeys".pslKeyVisible() :
hidePSLAllowHandleKey()
func _on_close_requested():
self.hide()
$"../stationKeys".hide()
##点击按钮或钥匙
func onHandleSignal(openLight: bool, keySwitch: Variant) -> void:
print(openLight,keySwitch,666)
func shouPSLAllowHandleKey():
$MarginContainer/GridContainer/PSLAllow.shouHandleKey()
@ -32,10 +34,6 @@ func hideInterlockReleaseSwitchHandleKey():
$MarginContainer/GridContainer/InterlockReleaseSwitch.hideHandleKey()
func onHandleSignal(openLight: bool, keySwitch: Variant) -> void:
print(openLight,keySwitch,666)
func remove_key(keyName: Variant) -> void:
var name = ''
if keyName == 'PSLAllow' :
@ -43,3 +41,17 @@ func remove_key(keyName: Variant) -> void:
elif keyName == 'InterlockReleaseSwitch' :
name = 'HSJC_Key'
$"../stationKeys".showKeyAfterRemoveKey(name)
##打开钥匙盒相关
func _on_open_key_window_gui_input(event: InputEvent) -> void:
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.PSL)
func _on_open_key_window_mouse_entered() -> void:
$openKeyWindow.set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND)
func _on_open_key_window_mouse_exited() -> void:
$openKeyWindow.set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW)

View File

@ -1,16 +1,17 @@
[gd_scene load_steps=7 format=3 uid="uid://dppmr7ifqt8oa"]
[gd_scene load_steps=8 format=3 uid="uid://dppmr7ifqt8oa"]
[ext_resource type="Theme" uid="uid://bycedcl2nwwlu" path="res://ui_theme.tres" id="1_oaabl"]
[ext_resource type="FontFile" uid="uid://bkbpyidjguavf" path="res://Assets/FeiHuaSongTi-2.ttf" id="2_xva5j"]
[ext_resource type="Script" path="res://UI/psl/psl_window.gd" id="3_xodem"]
[ext_resource type="Texture2D" uid="uid://dkohhsnyl7dq8" path="res://Assets/psl/psl背景大.png" id="4_cpydh"]
[ext_resource type="PackedScene" uid="uid://ur86pfy4w0so" path="res://UI/psl/key_switch.tscn" id="6_8mvyb"]
[ext_resource type="Texture2D" uid="uid://cpmlwpev7rvbp" path="res://Assets/打开钥匙面板钥匙.png" id="7_643a1"]
[ext_resource type="PackedScene" uid="uid://c31r8s27j4dcm" path="res://UI/psl/button_light.tscn" id="7_l5iwy"]
[node name="psl" type="Window"]
title = "psl操作面板"
position = Vector2i(10, 36)
size = Vector2i(400, 720)
size = Vector2i(460, 720)
unresizable = true
transparent = true
theme = ExtResource("1_oaabl")
@ -18,15 +19,15 @@ theme_override_fonts/title_font = ExtResource("2_xva5j")
script = ExtResource("3_xodem")
[node name="Pslll" type="Sprite2D" parent="."]
position = Vector2(0.255, 0)
scale = Vector2(2.66, 2.865)
position = Vector2(220, 0)
scale = Vector2(0.43, 1.14)
texture = ExtResource("4_cpydh")
[node name="MarginContainer" type="MarginContainer" parent="."]
offset_left = 4.0
offset_left = 30.0
offset_top = 4.0
offset_right = 436.0
offset_bottom = 1459.0
offset_right = 537.0
offset_bottom = 1529.0
scale = Vector2(0.7, 0.7)
theme_override_constants/margin_left = 45
theme_override_constants/margin_top = 35
@ -109,6 +110,14 @@ layout_mode = 2
buttonHasLight = false
buttonText = "联动开门按钮"
[node name="openKeyWindow" type="TextureRect" parent="."]
offset_left = 405.0
offset_top = 50.0
offset_right = 473.0
offset_bottom = 200.0
scale = Vector2(0.64, 0.64)
texture = ExtResource("7_643a1")
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
[connection signal="clickKeySwitchSignal" from="MarginContainer/GridContainer/PSLAllow" to="." method="onHandleSignal"]
[connection signal="removeKey" from="MarginContainer/GridContainer/PSLAllow" to="." method="remove_key"]
@ -122,3 +131,6 @@ buttonText = "联动开门按钮"
[connection signal="clickButtonSignal" from="MarginContainer/GridContainer/trainDepartsButton" to="." method="onHandleSignal"]
[connection signal="clickButtonSignal" from="MarginContainer/GridContainer/interconnectedCloseButton" to="." method="onHandleSignal"]
[connection signal="clickButtonSignal" from="MarginContainer/GridContainer/interconnectedOpenButton" to="." method="onHandleSignal"]
[connection signal="gui_input" from="openKeyWindow" to="." method="_on_open_key_window_gui_input"]
[connection signal="mouse_entered" from="openKeyWindow" to="." method="_on_open_key_window_mouse_entered"]
[connection signal="mouse_exited" from="openKeyWindow" to="." method="_on_open_key_window_mouse_exited"]

View File

@ -1,5 +1,8 @@
extends Window
##钥匙面板
class_name StationKeyWindow
var current_focus: CanvasItem
## 打开的面板类型枚举

View File

@ -1,5 +1,16 @@
extends Node3D
var screenDoorALL = []
##开整体屏蔽门
func openScreenDoorALL ()-> void:
for child in screenDoorALL:
child.openScreenDoor()
##关整体屏蔽门
func closeScreenDoorALL ()-> void:
for child in screenDoorALL:
child.closeScreenDoor()
func _ready() -> void:
var screenDoor_scene = preload("res://sceen/platform/screenDoor.tscn")
@ -7,6 +18,20 @@ func _ready() -> void:
for i in range(1, 5):
var screenDoorInstance = screenDoor_scene.instantiate()
add_child(screenDoorInstance)
screenDoorALL.append(screenDoorInstance)
screenDoorInstance.position.x=(i-1)*4.385
screenDoorInstance.name = 'screenDoor{0}'.format([i])
screenDoorInstance.connect("clickLcbSignalAndSent",Callable($LCB,"_on_screen_door_click_lcb_signal"))
var count=0
func _process(delta: float) -> void:
count+=1
if count>150 and count<360:
if screenDoorALL[0].screenDoorState == ScreenDoor.ScreenDoor_State.close:
openScreenDoorALL()
elif count>540 and count<720 :
if screenDoorALL[0].screenDoorState == ScreenDoor.ScreenDoor_State.open:
closeScreenDoorALL()
elif count>2000 :
count=0

View File

@ -5,68 +5,80 @@ class_name ScreenDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
signal clickLcbSignalAndSent(screenDoor,hasKey)
## Lcb旋钮的状态枚举
enum KNOB_STATE{
ISOLATE,# 隔离
AUTO,# 自动
OPEN,# 开门
CLOSE,# 关门
}
class LcbKeyWindow :
var keyName: String
var keyState:KNOB_STATE
func _init(keyName: String, keyState: KNOB_STATE):
self.keyName = keyName
self.keyState = keyState
var lcbKey = LcbKeyWindow.new('',KNOB_STATE.AUTO)
func _on_lcb_click() -> void:
self.clickLcbSignalAndSent.emit(self)
## 屏蔽门的状态枚举
enum Screen_Door_STATE{
idle = 0,
open = 1,# 开门
close = 2,# 关门
enum ScreenDoor_State{
opening,# 正在开门
open,#开到位
closeing,#正在关门
close,# 关到位
}
##屏蔽门的状态
@onready var screenDoorState : Screen_Door_STATE = Screen_Door_STATE.idle :
@onready var screenDoorState : ScreenDoor_State = ScreenDoor_State.close :
set(value):
if screenDoorState != value:
screenDoorState = value
if screenDoorState == Screen_Door_STATE.open :
if screenDoorState == ScreenDoor_State.opening :
left_animation_player.play("leftOpen")
right_animation_player.play("rightOpen")
elif screenDoorState == Screen_Door_STATE.close :
elif screenDoorState == ScreenDoor_State.closeing :
left_animation_player.play("leftClose")
right_animation_player.play("rightClose")
##打开屏蔽门
func openScreenDoor ()-> void:
screenDoorState=Screen_Door_STATE.open
if screenDoorState == ScreenDoor_State.close :
screenDoorState=ScreenDoor_State.opening
##关闭屏蔽门
func closeScreenDoor ()-> void:
screenDoorState=Screen_Door_STATE.close
if screenDoorState == ScreenDoor_State.open :
screenDoorState=ScreenDoor_State.closeing
var count=0
func _process(delta: float) -> void:
count+=1
if count>150 and count<360:
screenDoorState=Screen_Door_STATE.open
elif count>540 and count<720 :
if self.name != "screenDoor2" and self.name != "screenDoor4":
screenDoorState=Screen_Door_STATE.close
elif count>720 and count<1000 :
if self.name == "screenDoor2":
screenDoorState=Screen_Door_STATE.close
elif count>2000 :
count=0
func _on_left_animation_player_animation_finished(anim_name: StringName) -> void:
if anim_name == 'leftOpen':
screenDoorState = ScreenDoor_State.open
elif anim_name == 'leftClose':
screenDoorState = ScreenDoor_State.close
## 屏蔽门的故障枚举
enum ScreenDoor_Fault_State{
noFault,#无故障
openFault,# 开门故障
closeFault,# 关门故障
pinchPeople,#夹人
glassBreakage,#玻璃破碎
}
##屏蔽门的故障状态
@onready var screenDoorFaultState : ScreenDoor_Fault_State = ScreenDoor_Fault_State.noFault :
set(value):
if screenDoorFaultState != value:
screenDoorFaultState = value
##设置故障
func setScreenDoorFault (faultType:ScreenDoor_Fault_State)-> void:
screenDoorFaultState = faultType
##恢复故障
func removeScreenDoorFault ()-> void:
screenDoorFaultState = ScreenDoor_Fault_State.noFault
##以下是lcb相关
class LcbKeyWindow :
var keyName: String
var keyState:LcbWindow.KNOB_STATE
func _init(keyName: String, keyState: LcbWindow.KNOB_STATE):
self.keyName = keyName
self.keyState = keyState
var lcbKey = LcbKeyWindow.new('',LcbWindow.KNOB_STATE.AUTO)
signal clickLcbSignalAndSent(screenDoor)
func _on_lcb_click() -> void:
self.clickLcbSignalAndSent.emit(self)

View File

@ -258,3 +258,4 @@ libraries = {
}
[connection signal="clickLcbSignal" from="LCB" to="." method="_on_lcb_click"]
[connection signal="animation_finished" from="LeftAnimationPlayer" to="." method="_on_left_animation_player_animation_finished"]

View File

@ -68,6 +68,7 @@ _data = {
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.004, 1.768, 6.38)
visible = false
current = true
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_ux83q")
@ -80,3 +81,5 @@ root_node = NodePath("../WorldEnvironment")
libraries = {
"": SubResource("AnimationLibrary_lf7ox")
}
[connection signal="animation_finished" from="trainAnimationPlayer" to="train" method="_on_train_animation_player_animation_finished"]

View File

@ -1,51 +1,26 @@
extends Node3D
##左边的门
class_name train
##
class_name Train
@onready var train_animation_player: AnimationPlayer = $"../trainAnimationPlayer"
## 车的类型枚举
enum TrainType{
four = 4,# 4编组
six = 6,#6编组
four = 2,# 4编组
six = 4,#6编组
}
@export var trainType:TrainType = TrainType.four
func _ready() -> void:
var trainDoor_scene = preload("res://sceen/train/trainDoor.tscn")
var lasttrainDoorPosX = -4.385
for i in range(1, (trainType+2)*4+1):
##有动画的屏蔽门
var trainDoorInstance = trainDoor_scene.instantiate()
add_child(trainDoorInstance)
if i % 4 ==1 and i != 1:
trainDoorInstance.position.x=lasttrainDoorPosX+6.104
else:
trainDoorInstance.position.x=lasttrainDoorPosX+4.385
##无动画的屏蔽门
if i>1:
var copyNoMoveDoor = $NoMoveDoor.duplicate()
$".".add_child(copyNoMoveDoor)
copyNoMoveDoor.position.x = lasttrainDoorPosX
lasttrainDoorPosX = trainDoorInstance.position.x
trainDoorInstance.name = 'trainDoor{0}'.format([i])
print(trainType)
for i in range(1, trainType):
var copyTrainBody = $TrainBody.duplicate()
$".".add_child(copyTrainBody)
copyTrainBody.position.x=19.259*(i+1)
$TrainHeadH.position.x += 19.259*(trainType-1)
## 门的状态枚举
## 车的状态枚举
enum Train_STATE{
idle = 0,
come = 1,# 车来
leave = 2,# 车走
come,# 进站
comeAndStop,# 进站且停稳
leave,# 出站
}
##门是否移动
@onready var trainState : Train_STATE = Train_STATE.idle :
##车的状态
@onready var trainState : Train_STATE = Train_STATE.leave :
set(value):
if trainState != value:
trainState = value
@ -54,13 +29,74 @@ enum Train_STATE{
elif trainState == Train_STATE.leave :
train_animation_player.play("trainLeave")
##进站停车
func trainCome ()-> void:
trainState=Train_STATE.come
##出站
func trainLeave ()-> void:
trainState=Train_STATE.leave
func _on_train_animation_player_animation_finished(anim_name: StringName) -> void:
if anim_name == 'trainCome' :
trainState = Train_STATE.comeAndStop
var leftTrainDoorALL = []
##开左侧车门
func openLeftTrainDoorALL ()-> void:
for child in leftTrainDoorALL:
child.openTrainDoor()
##关左侧车门
func closeLeftTrainDoorALL ()-> void:
for child in leftTrainDoorALL:
child.closeTrainDoor()
func _ready() -> void:
var trainDoor_scene = preload("res://sceen/train/trainDoor.tscn")
var lasttrainDoorPosX = -4.385
for i in range(1, (trainType+2)*4+1):
##左侧有动画的车门
var trainDoorInstance = trainDoor_scene.instantiate()
add_child(trainDoorInstance)
leftTrainDoorALL.append(trainDoorInstance)
if i % 4 ==1 and i != 1:
trainDoorInstance.position.x=lasttrainDoorPosX+6.104
else:
trainDoorInstance.position.x=lasttrainDoorPosX+4.385
##右侧无动画的车门
if i>1:
var copyNoMoveDoor = $NoMoveDoor.duplicate()
add_child(copyNoMoveDoor)
copyNoMoveDoor.position.x = lasttrainDoorPosX
lasttrainDoorPosX = trainDoorInstance.position.x
trainDoorInstance.name = 'trainDoor{0}'.format([i])
for i in range(1, trainType):
var copyTrainBody = $TrainBody.duplicate()
$".".add_child(copyTrainBody)
copyTrainBody.position.x=19.259*(i+1)
$TrainHeadH.position.x += 19.259*(trainType-1)
var count=0
func _process(delta: float) -> void:
count+=1
if count<180:
trainState=Train_STATE.come
if trainState == Train_STATE.leave :
trainCome()
elif count>180 and count<360:
if leftTrainDoorALL[0].trainDoorState == TrainDoor.Train_Door_STATE.close:
openLeftTrainDoorALL()
elif count>540 and count<720 :
if leftTrainDoorALL[0].trainDoorState == TrainDoor.Train_Door_STATE.open :
closeLeftTrainDoorALL()
elif count>1000 and count<2000:
trainState=Train_STATE.leave
if trainState == Train_STATE.comeAndStop :
trainLeave()
elif count>2000:
count=0

View File

@ -1,20 +1,19 @@
extends Node3D
##左边的
class_name trainDoor
##
class_name TrainDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
## 门的状态枚举
## 门的状态枚举
enum Train_Door_STATE{
idle = 0,
open = 1,# 开门
close = 2,# 关门
open,# 开门
close,# 关门
}
##门是否移动
@onready var trainDoorState : Train_Door_STATE = Train_Door_STATE.idle :
##车门的状态
@onready var trainDoorState : Train_Door_STATE = Train_Door_STATE.close :
set(value):
if trainDoorState != value:
trainDoorState = value
@ -25,17 +24,12 @@ enum Train_Door_STATE{
left_animation_player.play("leftClose")
right_animation_player.play("rightClose")
var count=0
func _process(delta: float) -> void:
count+=1
if count>180 and count<360:
trainDoorState=Train_Door_STATE.open
elif count>540 and count<720 :
if self.name != "trainDoor2":
trainDoorState=Train_Door_STATE.close
elif count>720 and count<1000 :
if self.name == "trainDoor2":
trainDoorState=Train_Door_STATE.close
elif count>2000 :
count=0
##打开车门
func openTrainDoor ()-> void:
trainDoorState=Train_Door_STATE.open
##关闭车门
func closeTrainDoor ()-> void:
trainDoorState=Train_Door_STATE.close