RelaxingFishGame/scenes/microgames/fishin/fishin.gd

211 lines
4.4 KiB
GDScript

extends Node2D
enum FishType {
GAR,
SALMON,
BASS,
HUMUHUMUNUKUNUKUAPUA_A,
CATFSIH,
DOGFISH,
ANGLERFISH,
MOBY_DICK,
LEAPING_SMACKEREL,
}
signal win
signal lose
signal fish_chosen(fish_sprite: Sprite2D, fish_name: String)
const IN_GAME_WAIT_TIME = 10
var pulling: Sprite2D
var mash: Label
var you: Sprite2D
var sad: Sprite2D
var happy: Sprite2D
var mouse: Sprite2D
var shake: ShakePivot
var shake2: ShakePivot
var shake3: ShakePivot
var start_game_timer: Timer
var in_game_timer: Timer
# This used to mean "success/failure" but now means "you succ, failure"
var succfail_timer: Timer
var success_timer: Timer
var gar
var salmon
var bass
var humuhumunukunukuapua_a
var catfsih
var dogfish
var pupperfish
var anglerfish
var moby_dick
var leaping_smackerel
var in_minigame = false
var num_clicks = 0
var fishes = [FishType.GAR, FishType.SALMON, FishType.BASS, FishType.HUMUHUMUNUKUNUKUAPUA_A, FishType.CATFSIH, FishType.DOGFISH, FishType.ANGLERFISH, FishType.MOBY_DICK, FishType.LEAPING_SMACKEREL]
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pulling = $ShakePivot/pulling
you = $"you!"
mash = $ShakePivot2/MASH
mouse = $ShakePivot3/Mouse
shake = $ShakePivot
shake2 = $ShakePivot2
shake3 = $ShakePivot3
sad = $SAD
happy = $Happy
start_game_timer = $StartGame
in_game_timer = $InGame
succfail_timer = $SuccessFail
success_timer = $Success
get_window().title = "Relaxing Fishing Game 🙂"
gar = $Happy/Gar
salmon = $Happy/SockeyeSalmon
bass = $Happy/LargemouthBass
humuhumunukunukuapua_a = $"Happy/Humuhumunukunukuapua'a"
catfsih = $Happy/Catfsih
dogfish = $Happy/Dogfish
pupperfish = $Happy/Pupperfish
anglerfish = $Happy/Anglerfish
moby_dick = $"Happy/Moby-Dick"
leaping_smackerel = $Happy/LeapingSmackerel
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_texture_button_button_up() -> void:
shake.shake()
shake2.shake()
shake3.shake()
if in_minigame:
num_clicks -= 1
# YOU WIN
if num_clicks == 0:
in_minigame = false
# hide non-happy cats
pulling.visible = false
mash.visible = false
mouse.visible = false
sad.visible = false
you.visible = false
# show happy cat
happy.visible = true
# show fish
var fish_choice: FishType = randi_range(0,len(fishes))
# hehe
fish_choice = FishType.GAR
match fish_choice:
FishType.GAR:
gar.visible = true
fish_chosen.emit(gar.get_node("GarSprite"), "Gar :)")
FishType.SALMON:
salmon.visible = true
FishType.BASS:
bass.visible = true
FishType.HUMUHUMUNUKUNUKUAPUA_A:
humuhumunukunukuapua_a.visible = true
FishType.CATFSIH:
catfsih.visible = true
FishType.DOGFISH:
dogfish.visible = true
FishType.ANGLERFISH:
anglerfish.visible = true
FishType.MOBY_DICK:
moby_dick.visible = true
FishType.LEAPING_SMACKEREL:
leaping_smackerel.visible = true
in_game_timer.stop()
in_game_timer.wait_time = IN_GAME_WAIT_TIME
success_timer.start()
$"Yippee!".play()
get_window().title = "Yippee!"
func _on_start_game_timeout() -> void:
if randf() < 0.2:
start_game_timer.stop()
in_game_timer.start()
in_minigame = true
# hide passive cats
you.visible = false
sad.visible = false
happy.visible = false
# show active cat
pulling.visible = true
mash.visible = true
mouse.visible = true
num_clicks = randi_range(5,10)
#num_clicks = 21
get_window().title = "MASH MASH MASH MASH MASH"
# YOU LOSE
func _on_in_game_timeout() -> void:
in_minigame = false
# hide non-sad cats
you.visible = false
happy.visible = false
pulling.visible = false
mash.visible = false
mouse.visible = false
# show sad cat
sad.visible = true
in_game_timer.stop()
succfail_timer.start()
$"Fart".play()
get_window().title = "🙂👎"
lose.emit()
func _on_success_fail_timeout() -> void:
gar.visible = false
salmon.visible = false
bass.visible = false
humuhumunukunukuapua_a.visible = false
catfsih.visible = false
dogfish.visible = false
pupperfish.visible = false
anglerfish.visible = false
moby_dick.visible = false
leaping_smackerel.visible = false
sad.visible = false
happy.visible = false
you.visible = true
succfail_timer.stop()
start_game_timer.start()
get_window().title = "Relaxing Fishing Game 🙂"
func _on_success_timeout() -> void:
win.emit()