Explorar el Código

大厅游戏模式切换

LTCatt hace 6 años
padre
commit
e8f086ff11

+ 1 - 0
data/ltw/functions/clock/tick20.mcfunction

@@ -2,6 +2,7 @@
 schedule function ltw:clock/tick20 20t replace
 
 # 调用其他模块
+execute if score $state mem matches 0 run function ltw:state/0/tick20
 execute if score $state mem matches 3 run function ltw:state/3/tick20
 execute if score $state mem matches 4 run function ltw:state/4/tick20
 execute if score $state mem matches 5 run function ltw:state/5/tick20

+ 2 - 1
data/ltw/functions/init.mcfunction

@@ -44,9 +44,10 @@ scoreboard objectives remove game_id
 scoreboard objectives add game_id dummy "游戏编号"
 scoreboard players set $ game_id 0
 
-# 常量
+# 常量与变量初始化
 scoreboard players set $c_mini_total mem 5
 scoreboard players set $c_10 mem 10
+scoreboard players set $game_type mem 1
 
 # 队伍
 team remove player

+ 4 - 0
data/ltw/functions/state/0/change_classic.mcfunction

@@ -0,0 +1,4 @@
+# 切换为经典模式
+execute if score $game_type mem matches 1 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"text": "已切换为经典模式!","color":"aqua"}]
+scoreboard players set $game_type mem 0
+function ltw:state/0/refresh_state

+ 4 - 0
data/ltw/functions/state/0/change_gameparty.mcfunction

@@ -0,0 +1,4 @@
+# 切换为小游戏模式
+execute if score $game_type mem matches 0 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"text": "已切换为小游戏模式!","color":"aqua"}]
+scoreboard players set $game_type mem 1
+function ltw:state/0/refresh_state

+ 3 - 0
data/ltw/functions/state/0/refresh_state.mcfunction

@@ -0,0 +1,3 @@
+# 更新当前选择的小游戏状态
+execute if score $game_type mem matches 0 run fill 14 15 1 19 11 6 minecraft:crimson_hyphae replace minecraft:warped_hyphae
+execute if score $game_type mem matches 1 run fill 14 15 1 19 11 6 minecraft:warped_hyphae replace minecraft:crimson_hyphae

+ 1 - 1
data/ltw/functions/state/0/start_gameparty.mcfunction

@@ -2,7 +2,7 @@
 
 # 设置旁观
 tag @a remove watcher
-tag @a[tag=!hub_gameparty] add watcher
+tag @a[tag=hub_watch] add watcher
 
 # 设置数据
 scoreboard players reset * total_score

+ 7 - 1
data/ltw/functions/state/0/state_enter.mcfunction

@@ -14,4 +14,10 @@ team modify player collisionRule never
 gamerule fallDamage false
 
 # 清理加载区域
-forceload remove all
+forceload remove all
+
+# 重置开始倒计时
+scoreboard players set $countdown mem 0
+
+# 重置当前状态
+function ltw:state/0/refresh_state

+ 0 - 0
data/ltw/functions/state/0/tick20.mcfunction


+ 7 - 8
data/ltw/functions/state/0/tick5.mcfunction

@@ -1,9 +1,8 @@
-# 将玩家分类:经典、小游戏、旁观
-tag @a remove hub_classic
-tag @a remove hub_gameparty
+# 判断玩家是否处于准备状态
+tag @a remove hub_ready
 tag @a remove hub_watch
-execute as @a at @s if block ~ ~-1 ~ crimson_hyphae run tag @s add hub_classic
-execute as @a at @s if block ~ ~-2 ~ crimson_hyphae run tag @s add hub_classic
-execute as @a at @s if block ~ ~-1 ~ warped_hyphae run tag @s add hub_gameparty
-execute as @a at @s if block ~ ~-2 ~ warped_hyphae run tag @s add hub_gameparty
-tag @a[tag=!hub_classic,tag=!hub_gameparty] add hub_watch
+execute as @a at @s if block ~ ~-1 ~ crimson_hyphae run tag @s add hub_ready
+execute as @a at @s if block ~ ~-2 ~ crimson_hyphae run tag @s add hub_ready
+execute as @a at @s if block ~ ~-1 ~ warped_hyphae run tag @s add hub_ready
+execute as @a at @s if block ~ ~-2 ~ warped_hyphae run tag @s add hub_ready
+tag @a[tag=!hub_ready] add hub_watch

+ 2 - 1
data/ltw/functions/state/0/try_start_classic.mcfunction

@@ -1,2 +1,3 @@
 # 尝试开始经典模式
-tellraw @a[tag=hub_classic] {"text": "经典模式尚未完成, 请开始小游戏模式!","color":"red"}
+tellraw @a[tag=hub_ready] {"text": "经典模式尚未完成, 请开始小游戏模式!","color":"red"}
+execute as @a[tag=hub_ready] at @s run function lib:sounds/error

+ 1 - 1
data/ltw/functions/state/0/try_start_gameparty.mcfunction

@@ -1,7 +1,7 @@
 # 尝试开始小游戏模式
 
 # 计算玩家数量
-execute store result score $count mem if entity @a[tag=hub_gameparty]
+execute store result score $count mem if entity @a[tag=hub_ready]
 
 # 根据玩家数量判定
 execute if score $count mem matches ..1 as @a at @s run function lib:sounds/error

+ 1 - 1
data/test/functions/mini/colormatch.mcfunction

@@ -1,5 +1,5 @@
 # 测试用:快速开始 Color Match
-tag @a add hub_gameparty
+tag @a add hub_ready
 tag @a remove hub_watch
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 1 - 1
data/test/functions/mini/hotpm.mcfunction

@@ -1,5 +1,5 @@
 # 测试用:快速开始 Hot Potato
-tag @a add hub_gameparty
+tag @a add hub_ready
 tag @a remove hub_watch
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 1 - 1
data/test/functions/mini/parkour.mcfunction

@@ -1,5 +1,5 @@
 # 测试用:快速开始跑酷
-tag @a add hub_gameparty
+tag @a add hub_ready
 tag @a remove hub_watch
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 1 - 1
data/test/functions/mini/tntrun.mcfunction

@@ -1,5 +1,5 @@
 # 测试用:快速开始 TNT Run
-tag @a add hub_gameparty
+tag @a add hub_ready
 tag @a remove hub_watch
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 1 - 1
data/test/functions/mini/zombie.mcfunction

@@ -1,5 +1,5 @@
 # 测试用:快速开始僵尸
-tag @a add hub_gameparty
+tag @a add hub_ready
 tag @a remove hub_watch
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6