mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-07-22 15:47:00 +00:00
Update 6.8
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
class FusionQuizAppScene < PokeNavAppScene
|
||||
attr_accessor :playing
|
||||
attr_accessor :difficulty
|
||||
|
||||
def initialize
|
||||
super
|
||||
@playing = false
|
||||
end
|
||||
|
||||
def y_gap
|
||||
return 64;
|
||||
end
|
||||
|
||||
def start_x
|
||||
return Graphics.width-200;
|
||||
end
|
||||
|
||||
def pbStartScene(buttons = nil)
|
||||
$game_system.bgm_memorize
|
||||
super(buttons)
|
||||
pbBGMPlay("game_corner")
|
||||
displayTextElements
|
||||
end
|
||||
|
||||
def bg_path
|
||||
if @playing
|
||||
if @difficulty == :ADVANCED
|
||||
return "Graphics/Pictures/Pokegear/FusionQuiz/bg_play_advanced"
|
||||
else
|
||||
return "Graphics/Pictures/Pokegear/FusionQuiz/bg_play"
|
||||
end
|
||||
else
|
||||
return "Graphics/Pictures/Pokegear/FusionQuiz/bg_menu"
|
||||
end
|
||||
end
|
||||
|
||||
def cursor_path
|
||||
return "Graphics/Pictures/Pokegear/FusionQuiz/cursor"
|
||||
end
|
||||
|
||||
def header_name
|
||||
return _INTL("Who's That Fusion!")
|
||||
end
|
||||
|
||||
def header_path
|
||||
return "Graphics/Pictures/Pokegear/FusionQuiz/bg_header_quiz"
|
||||
end
|
||||
|
||||
def click(button_id)
|
||||
case button_id
|
||||
when "play"
|
||||
@selected = :play
|
||||
@exiting = true
|
||||
when "score"
|
||||
@selected = :score
|
||||
@exiting = true
|
||||
else
|
||||
pbPlayCloseMenuSE
|
||||
@selected = :exit
|
||||
@exiting = true
|
||||
end
|
||||
end
|
||||
|
||||
def updateInput
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
@selected = :exit
|
||||
@exiting = true
|
||||
return
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def selected_action
|
||||
return @selected
|
||||
end
|
||||
|
||||
def updateBackground
|
||||
echoln bg_path
|
||||
@sprites["bg"].setBitmap(bg_path) unless @sprites["bg"].disposed?
|
||||
end
|
||||
|
||||
def pbEndSceneKeepBg
|
||||
@exiting = true
|
||||
sprites_without_bg = @sprites.reject { |k, _| ["bg", "background", "header"].include?(k) }
|
||||
pbFadeOutAndHide(sprites_without_bg) { pbUpdate }
|
||||
pbDisposeSpriteHash(sprites_without_bg)
|
||||
@buttons.each(&:dispose)
|
||||
Kernel.pbClearText
|
||||
showHeaderName
|
||||
end
|
||||
|
||||
def disposeBg
|
||||
@sprites["bg"]&.dispose
|
||||
@sprites["background"]&.dispose
|
||||
@sprites["header"]&.dispose
|
||||
@viewport&.dispose
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
echoln "ENDING"
|
||||
$game_system.bgm_stop
|
||||
$game_system.bgm_restore
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,183 @@
|
||||
class FusionQuizAppScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
POINTS_TO_UNLOCK_MODES = {
|
||||
:regular_3_rounds => 0,
|
||||
:regular_5_rounds => 2000,
|
||||
:regular_10_rounds => 4000,
|
||||
:advanced_3_rounds => 5000,
|
||||
:advanced_5_rounds => 12000,
|
||||
:advanced_10_rounds => 16000,
|
||||
}
|
||||
|
||||
def pbStartScreen(main_menu_scene, screen)
|
||||
@main_menu_scene = main_menu_scene
|
||||
@screen = screen
|
||||
#Possible modes:
|
||||
# :regular_3_rounds
|
||||
# :regular_5_rounds
|
||||
# :regular_10_rounds
|
||||
# :advanced_3_rounds
|
||||
# :advanced_5_rounds
|
||||
# :advanced_10_rounds
|
||||
$Trainer&.pokenav&.fusion_quiz_unlocked_modes = [:regular_3_rounds] unless $Trainer&.pokenav&.fusion_quiz_unlocked_modes
|
||||
loop do
|
||||
btn_play = FusionQuizMenuButton.new("play", nil, _INTL("Play"))
|
||||
btn_score = FusionQuizMenuButton.new("score", nil, _INTL("Score"))
|
||||
btn_close = FusionQuizMenuButton.new("exit", nil, _INTL("Exit"))
|
||||
|
||||
@scene.pbStartScene([btn_play, btn_score, btn_close])
|
||||
@scene.pbScene
|
||||
|
||||
case @scene.selected_action
|
||||
when :play
|
||||
@scene.pbEndSceneKeepBg
|
||||
launch_quiz
|
||||
@scene.playing = false
|
||||
@scene.disposeBg
|
||||
when :score
|
||||
@scene.pbEndSceneKeepBg
|
||||
show_high_score
|
||||
@scene.disposeBg
|
||||
when :exit, nil
|
||||
@scene.pbEndScene
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def launch_quiz
|
||||
difficulty = prompt_difficulty
|
||||
high_score = pbGet(VAR_STAT_FUSION_QUIZ_HIGHEST_SCORE)
|
||||
@scene.difficulty = difficulty
|
||||
if difficulty
|
||||
nb_rounds = prompt_nb_rounds(difficulty)
|
||||
if nb_rounds > 0
|
||||
@scene.playing = true
|
||||
@scene.updateBackground
|
||||
quiz = FusionQuiz.new(difficulty)
|
||||
quiz.silhouette_color = Color.new(0, 0, 0, 200)
|
||||
quiz.windowed = false
|
||||
if difficulty == :ADVANCED
|
||||
quiz.picture_offset_x = -30
|
||||
quiz.picture_offset_y = 32
|
||||
else
|
||||
quiz.picture_offset_x = -40
|
||||
quiz.picture_offset_y = 32
|
||||
end
|
||||
quiz.start_quiz(nb_rounds)
|
||||
unless quiz.player_abandonned
|
||||
score = quiz.get_score
|
||||
if score > high_score
|
||||
pbMEPlay("Level Up")
|
||||
pbMessage(_INTL("You beat your previous high score!", score))
|
||||
end
|
||||
unlock_new_modes(score)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_mode_name(mode_id)
|
||||
case mode_id
|
||||
when :regular_3_rounds
|
||||
return _INTL("Regular (3 Rounds)")
|
||||
when :regular_5_rounds
|
||||
return _INTL("Regular (5 Rounds)")
|
||||
when :regular_10_rounds
|
||||
return _INTL("Regular (10 Rounds)")
|
||||
when :advanced_3_rounds
|
||||
return _INTL("Advanced (3 Rounds)")
|
||||
when :advanced_5_rounds
|
||||
return _INTL("Advanced (5 Rounds)")
|
||||
when :advanced_10_rounds
|
||||
return _INTL("Advanced (10 Rounds)")
|
||||
end
|
||||
end
|
||||
|
||||
def unlock_new_modes(score)
|
||||
POINTS_TO_UNLOCK_MODES.keys.each do |mode_id|
|
||||
points_to_unlock = POINTS_TO_UNLOCK_MODES[mode_id]
|
||||
next if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(mode_id)
|
||||
if score >= points_to_unlock
|
||||
$Trainer&.pokenav&.fusion_quiz_unlocked_modes = [:regular_3_rounds] unless $Trainer&.pokenav&.fusion_quiz_unlocked_modes
|
||||
$Trainer&.pokenav&.fusion_quiz_unlocked_modes << mode_id
|
||||
pbSEPlay("itemlevel", 80)
|
||||
pbMessage(_INTL("Unlocked a new difficulty: \\C[3]{1}",get_mode_name(mode_id)))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def prompt_difficulty
|
||||
advanced_difficulties = [:advanced_3_rounds, :advanced_5_rounds, :advanced_10_rounds]
|
||||
echoln $Trainer&.pokenav&.fusion_quiz_unlocked_modes
|
||||
cmd_regular = _INTL("Regular")
|
||||
cmd_advanced = _INTL("Advanced")
|
||||
cmd_cancel = _INTL("Cancel")
|
||||
options = []
|
||||
options << cmd_regular
|
||||
options << cmd_advanced if ($Trainer&.pokenav&.fusion_quiz_unlocked_modes & advanced_difficulties)&.any?
|
||||
options << cmd_cancel
|
||||
choice = pbMessage(
|
||||
_INTL("Choose a difficulty:"),
|
||||
options,3
|
||||
)
|
||||
|
||||
case options[choice]
|
||||
when cmd_regular
|
||||
return :REGULAR
|
||||
when cmd_advanced
|
||||
return :ADVANCED
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def prompt_nb_rounds(difficulty)
|
||||
options = []
|
||||
|
||||
cmd_3_rounds = _INTL("3 Rounds")
|
||||
cmd_5_rounds = _INTL("5 Rounds")
|
||||
cmd_10_rounds = _INTL("10 Rounds")
|
||||
cmd_cancel = _INTL("Cancel")
|
||||
|
||||
case difficulty
|
||||
when :ADVANCED
|
||||
options << cmd_3_rounds if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(:advanced_3_rounds)
|
||||
options << cmd_5_rounds if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(:advanced_5_rounds)
|
||||
options << cmd_10_rounds if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(:advanced_10_rounds)
|
||||
when :REGULAR
|
||||
options << cmd_3_rounds if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(:regular_3_rounds)
|
||||
options << cmd_5_rounds if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(:regular_5_rounds)
|
||||
options << cmd_10_rounds if $Trainer&.pokenav&.fusion_quiz_unlocked_modes&.include?(:regular_10_rounds)
|
||||
end
|
||||
options << cmd_cancel
|
||||
choice = pbMessage(
|
||||
_INTL("Choose the number of rounds:"),
|
||||
options,4
|
||||
)
|
||||
|
||||
case options[choice]
|
||||
when cmd_3_rounds
|
||||
nb_rounds = 3
|
||||
when cmd_5_rounds
|
||||
nb_rounds = 5
|
||||
when cmd_10_rounds
|
||||
nb_rounds = 10
|
||||
else
|
||||
nb_rounds = 0
|
||||
end
|
||||
return nb_rounds
|
||||
end
|
||||
|
||||
def show_high_score
|
||||
high = pbGet(VAR_STAT_FUSION_QUIZ_HIGHEST_SCORE)
|
||||
total = pbGet(VAR_STAT_FUSION_QUIZ_TOTAL_PTS)
|
||||
times = pbGet(VAR_STAT_FUSION_QUIZ_NB_TIMES)
|
||||
pbMessage(_INTL("High Score: {1} pts", high))
|
||||
pbMessage(_INTL("Total Points: {1}\\nGames Played: {2}", total, times))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
class FusionQuizMenuButton < PokenavButton
|
||||
|
||||
IMAGE_TEXT_GAP = 128
|
||||
DEFAULT_SPRITE_PATH = "000"
|
||||
IMAGE_X_OFFSET = 32
|
||||
SOURCE_IMAGE_Y_CROP = 24
|
||||
|
||||
ICON_SIZE = 24
|
||||
ICON_X_MARGIN = 8
|
||||
ICON_GAP = 4
|
||||
|
||||
def initialize(id, icon = nil, text = nil, viewport = nil)
|
||||
super
|
||||
@text_color = pbColor(:LIGHT_TEXT_MAIN_COLOR)
|
||||
@shadow_color = pbColor(:LIGHT_TEXT_SHADOW_COLOR)
|
||||
end
|
||||
def get_width
|
||||
return 180
|
||||
end
|
||||
|
||||
def get_height
|
||||
return 52
|
||||
end
|
||||
|
||||
def text_padding
|
||||
return 40
|
||||
end
|
||||
|
||||
def text_alignment
|
||||
return 1 #Centered
|
||||
end
|
||||
def background_image
|
||||
return "Graphics/Pictures/Pokegear/FusionQuiz/icon_button"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user