119 lines
2.8 KiB
Crystal
119 lines
2.8 KiB
Crystal
module Funfriend
|
|
enum DialogType
|
|
# Upon boot-up; random chatter
|
|
Chatter
|
|
# Upon being moved
|
|
Moved
|
|
# Upon being touched, but not moved
|
|
Touched
|
|
end
|
|
|
|
abstract class Buddy
|
|
# Used in window titles
|
|
abstract def name : String
|
|
|
|
# Given a specific `DialogType`, returns a list of possible dialogue choices
|
|
abstract def dialog(type : DialogType) : Array(Array(String))
|
|
|
|
# Returns the textures this buddy uses
|
|
abstract def textures : TextureMan::TextureBasket
|
|
|
|
# Implements the logic for the talk SFX, similar to corru.observer's `talk: () => ...`
|
|
abstract def talk_sound
|
|
end
|
|
|
|
class FunfriendBuddy < Buddy
|
|
def name : String
|
|
"FUNFRIEND"
|
|
end
|
|
|
|
def dialog(type) : Array(Array(String))
|
|
case type
|
|
when .chatter?
|
|
[
|
|
["HELLO AGAIN"],
|
|
["HI INTERLOPER"],
|
|
["HELLO!", "IS THE AUTH LAYER STILL DISSOCIATED?", "I MISS THEM"],
|
|
["INTERLOPER!", "WELCOME", "BUT ALSO PLEASE DO NOT BOTHER ME", "VERY BUSY"]
|
|
]
|
|
when .moved?
|
|
[
|
|
["OK I'LL BE HERE"]
|
|
]
|
|
when .touched?
|
|
[
|
|
["HI INTERLOPER!"],
|
|
["HELLO!"],
|
|
["HI!"]
|
|
]
|
|
else
|
|
[] of Array(String)
|
|
end
|
|
end
|
|
|
|
def textures : TextureMan::TextureBasket
|
|
TextureMan::TextureBasket.new(
|
|
(0..39).map { |i| TextureMan.load_texture("assets/buddies/funfriend_#{i.to_s.rjust(2, '0')}.png") },
|
|
10
|
|
)
|
|
end
|
|
|
|
def talk_sound
|
|
SoundMan.play_sound("assets/sfx/talk#{(1..8).sample}.ogg")
|
|
end
|
|
end
|
|
|
|
class CatfriendBuddy < FunfriendBuddy
|
|
def textures : TextureMan::TextureBasket
|
|
TextureMan::TextureBasket.new(
|
|
(0..39).map { |i| TextureMan.load_texture("assets/buddies/catfriend_#{i.to_s.rjust(2, '0')}.png") },
|
|
10
|
|
)
|
|
end
|
|
end
|
|
|
|
class GodBuddy < Buddy
|
|
def name : String
|
|
"GOD"
|
|
end
|
|
|
|
def dialog(type) : Array(Array(String))
|
|
case type
|
|
when .chatter?
|
|
[
|
|
["hello!"]
|
|
]
|
|
else
|
|
[] of Array(String)
|
|
end
|
|
end
|
|
|
|
def textures : TextureMan::TextureBasket
|
|
TextureMan::TextureBasket.new(
|
|
(0..9).map { |i| TextureMan.load_texture("assets/buddies/god_#{i.to_s.rjust(2, '0')}.png") },
|
|
10
|
|
)
|
|
end
|
|
|
|
def talk_sound
|
|
SoundMan.play_sound("assets/sfx/talk_god#{(1..8).sample}.ogg")
|
|
end
|
|
end
|
|
|
|
BUDDIES = {
|
|
"funfriend" => FunfriendBuddy,
|
|
"catfriend" => CatfriendBuddy,
|
|
"god" => GodBuddy,
|
|
}
|
|
|
|
def self.make_buddy(name : String) : Buddy
|
|
buddy_type = BUDDIES[name]?
|
|
|
|
if buddy_type
|
|
return buddy_type.new
|
|
else
|
|
raise IndexError.new(message: "Invalid buddy type \"#{name}\". Supported buddies: #{BUDDIES.keys.map { |k| "\"#{k}\""} .join(", ")}")
|
|
end
|
|
end
|
|
end
|