-
Notifications
You must be signed in to change notification settings - Fork 0
/
lines_manager.verse
152 lines (121 loc) · 5.97 KB
/
lines_manager.verse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Assets }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/UI }
# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.
duration := enum{Short, Long}
line := struct:
Character : texture
Sentence : texture
Duration : duration
# A Verse-authored creative device that can be placed in a level
lines_manager := class(creative_device):
@editable Scene1Trigger : mutator_zone_device = mutator_zone_device{}
@editable Scene2Trigger : mutator_zone_device = mutator_zone_device{}
@editable Scene3Trigger : mutator_zone_device = mutator_zone_device{}
@editable Scene4Trigger : mutator_zone_device = mutator_zone_device{}
@editable CardKeyButtons: []conditional_button_device = array{}
@editable FrontAttackTrigger: trigger_device = trigger_device{}
var MaybeMyUIPerPlayer : [player]?canvas = map{}
var IsStarted: logic = false
var LinesProvider: lines_provider = english_lines_provider{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Scene1Trigger.AgentEntersEvent.Subscribe(OnScene1)
Scene2Trigger.AgentEntersEvent.Subscribe(OnScene2)
Scene3Trigger.AgentEntersEvent.Subscribe(OnScene3)
Scene4Trigger.AgentEntersEvent.Subscribe(OnScene4)
FrontAttackTrigger.TriggeredEvent.Subscribe(OnFrontAttack)
for(Index : int = 0..CardKeyButtons.Length - 1 ):
if(CardKeyButton := CardKeyButtons[Index]):
CardKeyButton.NotEnoughItemsEvent.Subscribe(OnCardKey)
SetLinesProvider(Language: language):void =
if (Language = language.Japanese):
set LinesProvider = japanese_lines_provider{}
else:
set LinesProvider = english_lines_provider{}
OnFrontAttack(MaybeAgent: ?agent):void =
if (Agent := MaybeAgent?):
spawn{StartLines(Agent, LinesProvider.WeakspotLinesList())}
OnCardKey(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.CardKeyLinesList())}
OnPlayerDead(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.PlayerDeadLinesList())}
OnScene1(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene1LinesList())}
OnScene2(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene2LinesList())}
OnScene3(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene3LinesList())}
OnScene4(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene4LinesList())}
OnScene5(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene5LinesList())}
OnScene6(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene6LinesList())}
OnScene7(Agent: agent):void =
spawn{StartLines(Agent, LinesProvider.Scene7LinesList())}
StartLines(Agent: agent, Lines: []line)<suspends>:void =
if (IsStarted = true):
return
set IsStarted = true
# player_uiを取得
if (Player := player[Agent], PlayerUI := GetPlayerUI[Player]):
for(Index : int = 0..Lines.Length - 1 ):
if (Line := Lines[Index]):
NewUI := CreateMyUI(Line)
PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.None})
Sleep(GetDuration(Line.Duration))
PlayerUI.RemoveWidget(NewUI)
set IsStarted = false
GetDuration<private>(Duration: duration):float =
if (Duration = duration.Short):
return 4.0
else:
return 8.0
GetScene7Duration(): float =
return GetTotalDuration(LinesProvider.Scene7LinesList())
GetScene6Duration(): float =
return GetTotalDuration(LinesProvider.Scene6LinesList())
GetScene5Duration(): float =
return GetTotalDuration(LinesProvider.Scene5LinesList())
GetTotalDuration<private>(Lines: []line): float =
var TotalDuration:float = 0.0
for(Index : int = 0..Lines.Length - 1 ):
if (Line := Lines[Index]):
set TotalDuration += GetDuration(Line.Duration)
return TotalDuration
# UI作成
CreateMyUI(Line: line): canvas=
# キャンバスウィジェット
MyCanvas : canvas = canvas:
Slots := array:
canvas_slot: #Character
Anchors := anchors{Minimum := vector2{X := 0.1, Y := 0.3}, Maximum := vector2{X := 0.1, Y := 0.3} }
Offsets := margin{Top := 50.0, Left := 10.0, Bottom := 0.0, Right := 0.0}
Alignment := vector2{X := 0.5, Y := 0.5}
ZOrder := 0
SizeToContent := true
Widget := texture_block:
DefaultImage := Line.Character
DefaultDesiredSize := vector2{X := 200.0, Y := 200.0}
canvas_slot: #Sentence
Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.35}, Maximum := vector2{X := 0.5, Y := 0.35} }
Offsets := margin{Top := 0.0, Left := 20.0, Right := 0.0, Bottom := 0.0}
Alignment := vector2{X := 0.5, Y := 0.5}
SizeToContent := true
Widget := texture_block:
DefaultImage := Line.Sentence
DefaultDesiredSize := vector2{X := 1280.0, Y := 170.4}
return MyCanvas
DeleteMyUI(Message : widget_message) : void=
if:
PlayerUI := GetPlayerUI[Message.Player]
MyUI := MaybeMyUIPerPlayer[Message.Player]?
then:
# プレイヤー画面から作成したUIを削除
PlayerUI.RemoveWidget(MyUI)
# データ上のプレイヤーに紐づくUIを削除(false)
if (set MaybeMyUIPerPlayer[Message.Player] = false){}