Jelajahi Sumber

灭火;游戏结束判断

LTCatt 6 tahun lalu
induk
melakukan
7c71c0225a

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

@@ -4,6 +4,7 @@ schedule function ltw:clock/tick20 20t replace
 # 调用其他模块
 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 6 run function ltw:state/6/tick20
 
 # 全局倒计时
 scoreboard players remove $countdown mem 1

+ 5 - 1
data/ltw/functions/state/3/player_enter.mcfunction

@@ -1,9 +1,13 @@
 # 对单个玩家的处理(如果玩家中途加入就会执行此函数)
+gamemode creative
 title @s clear
-gamemode spectator @s
 
 # 状态效果
 effect clear @s
 effect give @s saturation 1000000 0 true
 effect give @s instant_health 10 0 true
 effect give @s blindness 1000000 0 true
+
+# 自由旁观
+gamemode spectator @s
+spectate

+ 5 - 1
data/ltw/functions/state/4/player_enter.mcfunction

@@ -1,6 +1,6 @@
 # 对单个玩家的处理(如果玩家中途加入就会执行此函数)
+gamemode creative
 title @s clear
-gamemode spectator @s
 
 # 状态效果
 effect clear @s
@@ -10,3 +10,7 @@ effect give @s night_vision 1000000 0 true
 
 # 显示小游戏介绍
 function mini:main/player_intro
+
+# 自由旁观
+gamemode spectator @s
+spectate

+ 1 - 2
data/ltw/functions/state/5/player_enter.mcfunction

@@ -1,6 +1,5 @@
 # 对单个玩家的处理(如果玩家中途加入就会执行此函数)
-
-# 重置 HUD
+gamemode creative
 title @s clear
 
 # 使用小游戏的其他项目

+ 16 - 0
data/ltw/functions/state/6/player_enter.mcfunction

@@ -0,0 +1,16 @@
+# 对单个玩家的处理(如果玩家中途加入就会执行此函数)
+gamemode creative
+title @s clear
+
+# 状态效果
+effect clear @s
+effect give @s saturation 1000000 0 true
+effect give @s instant_health 10 0 true
+effect give @s night_vision 1000000 0 true
+
+# 显示小游戏结果
+function mini:main/show_result
+
+# 自由旁观
+gamemode spectator
+spectate

+ 6 - 0
data/ltw/functions/state/6/state_enter.mcfunction

@@ -0,0 +1,6 @@
+# 要求系统进入状态 6(小游戏结束)
+scoreboard players set $state mem 6
+execute as @a run function ltw:state/6/player_enter
+
+# 初始化倒计时
+scoreboard players set $countdown mem 5

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

@@ -0,0 +1,7 @@
+# 显示倒计时
+title @a times 3 14 2
+title @a subtitle {"score":{"name":"$countdown","objective":"mem"}}
+title @a title [""]
+
+# 退出状态
+execute if score $countdown mem matches 0 run function ltw:state/7/state_enter

+ 12 - 0
data/ltw/functions/state/7/player_enter.mcfunction

@@ -0,0 +1,12 @@
+# 对单个玩家的处理(如果玩家中途加入就会执行此函数)
+gamemode creative
+title @s clear
+
+# 状态效果
+effect clear @s
+effect give @s saturation 1000000 0 true
+effect give @s instant_health 10 0 true
+effect give @s night_vision 1000000 0 true
+
+# UNDONE
+gamemode creative

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

@@ -0,0 +1,5 @@
+# 要求系统进入状态 7(选择奖励)
+scoreboard players set $state mem 7
+execute as @a run function ltw:state/7/player_enter
+
+# UNDONE

+ 5 - 0
data/mini/functions/main/game_end.mcfunction

@@ -0,0 +1,5 @@
+# 小游戏结束
+execute if score $mini_type mem matches 2 run function mini:tntrun/game_end
+
+# 进入状态 6
+function ltw:state/6/state_enter

+ 1 - 1
data/mini/functions/main/game_init.mcfunction

@@ -1,2 +1,2 @@
-# 初始化单个小游戏
+# 小游戏初始化
 execute if score $mini_type mem matches 2 run function mini:tntrun/game_init

+ 10 - 4
data/mini/functions/main/player_failed.mcfunction

@@ -2,10 +2,16 @@
 
 # 失败提示与计数
 tag @s remove mini_running
-scoreboard players set $temp mem 0
-execute as @a[tag=mini_running] run scoreboard players add $temp mem 1
-tellraw @a [{"selector": "@s","color":"red"}," 已失败! 剩余 ",{"score": {"name": "$temp","objective": "mem"}}," 人!"]
+scoreboard players set $alive mem 0
+execute as @a[tag=mini_running] run scoreboard players add $alive mem 1
+tellraw @a [{"selector": "@s","color":"red"}," 已失败! 剩余 ",{"score": {"name": "$alive","objective": "mem"}}," 人!"]
+
+# 记录名次
+# UNDONE
 
 # 进入旁观
 gamemode spectator @s
-spectate @r[tag=mini_running]
+spectate @r[tag=mini_running]
+
+# 如果只有一个玩家没有失败,则游戏结束
+execute if score $alive mem matches ..1 run function mini:main/game_end

+ 4 - 0
data/mini/functions/main/show_result.mcfunction

@@ -0,0 +1,4 @@
+# 显示小游戏排名
+
+# UNDONE
+say 游戏结束了!排名记录还没做!

+ 9 - 0
data/mini/functions/tntrun/game_end.mcfunction

@@ -0,0 +1,9 @@
+# 结束 TNT Run
+forceload remove 1000 2000 1050 2050
+
+# 清理残余实体
+kill @e[tag=tntrun_block]
+
+# 开启伤害
+gamerule fallDamage true
+gamerule fireDamage true

+ 2 - 2
data/test/functions/start_random_game.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始随机小游戏
 
-say 已开始随机小游戏!
 function ltw:state/3/state_enter
 function ltw:state/4/state_enter
-scoreboard players set $countdown mem 5
+scoreboard players set $countdown mem 5
+say 已开始随机小游戏!