-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLauncher.sh
150 lines (125 loc) · 4.74 KB
/
Launcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# Store our directory name so we can launch from anywhere
script_dir="$(dirname "$0")"
# MARK - Variables
# Character information initialized with defaults
name=""
chapter=-1
# Using an int intead of bool here, because I just think they work better in Bash.
newgame=0
# Ensure we have the right resolution for cutscenes to work.
sh $script_dir/utils/CheckResolution.sh
# MARK - Cutscene
# Allow the cutscene to be skipped, for testing and for veteran players
if [[ "$1" != "skip" ]]; then
# Play the intro cutscene. This is a separate script to keep things tidy.
bash $script_dir/utils/animation/IntroCutscene.sh
fi
# MARK - Menu
# Load the menu, and hang out on it until we get a name from loading or new game
while [ "$name" == "" ]
do
bash $script_dir/utils/MainMenu.sh
case $? in
# MARK - New Game
1)
# Case 1 is new game. Here we ask for a name, and create a save file
echo
echo "New Game!"
echo
echo "What do you want your name to be?"
echo
read name
# If we already have a save with that name, as about overwriting
if [ -f "$script_dir/gamesaves/$name/chapter" ]; then
echo "A game with that name already exists. Overwrite? [y/n]"
echo
read yn
if [[ "$yn" == "y" || "$yn" == "Y" ]]; then
echo "Erasing save..."
else
# Setting name back to blank ensures we go through the menu again
name=""
fi
fi
# Set all our character information and create the save file
chapter=1
newgame=1
# Make the save directory
mkdir "$script_dir/gamesaves/$name"
# Make the save files
echo "1" > "$script_dir/gamesaves/$name/chapter"
echo "paws" > "$script_dir/gamesaves/$name/inventory"
# Make a note of what saves we have
saves=$(ls -1 $script_dir/gamesaves | wc -l)
;;
# MARK - Load Game
2)
# Check if any gamesaves exist. If they do not, inform and break early.
if [[ -z $(find "$script_dir/gamesaves" -mindepth 1 -type f -not -name ".*") ]]; then
echo "Sorry. No gamesaves found. Returning to main menu."
sleep 1.5
continue
fi
# If we are loading a game save, list out the save files and ask which one to choose
echo
echo "What game save would you like to load? Type the name exactly."
echo "Existing saves:"
echo
ls -1 $script_dir/gamesaves
echo
read savename
# Check to be sure a save with that name actually exists. If it doesn't, back to main menu.
if [ -f "$script_dir/gamesaves/$savename/chapter" ]; then
echo "Loading $savename..."
name=$savename
# Get the current chapter to load
chapter=$(bash $script_dir/utils/inventory/CheckChapter.sh "$name")
else
echo
echo "Sorry, no save with that name exists."
echo
echo "Try again."
sleep 1.5
fi
;;
# MARK - Content Warning
3)
bash $script_dir/utils/animation/animate.sh $script_dir/utils/animation/dialogue/triggerwarn.dia 1 print
;;
# MARK - Credits
4)
# Play the credits
bash $script_dir/utils/animation/animate.sh $script_dir/utils/animation/cutscenes/credits.anim .1 scroll
echo
printf "%s" "Press enter to return to Main Menu."
read
;;
# MARK - Exit game
*)
# Technically this only happens on a 5, but doing it as a default helps us justincase.
echo "See you again soon!"
exit 0
;;
esac
done
# If it's a new game, play the opening dialogue
if [[ "$newgame" == "1" ]]; then
bash $script_dir/utils/animation/StoryOpenCutscene.sh
sleep 1
fi
# MARK - Game Start
# At this point, we should have all the information we require to dive into the game.
# Clear the screen
for i in {1..24}; do
echo
done
echo "Hello $name. You are in chapter $chapter."
echo
echo -e "Hint: If you're ever lost, you can try to \`\e[32mlook \e[34maround\e[0m\` for clues, or"
echo -e "check your \`\e[32mquestlog\e[0m\` for help."
echo
echo -e "Use the \`\e[32mhelp\e[0m\` command for more information about what you can do."
echo
echo "You find yourself in the barnyard which you call home. What do you want to do?"
bash $script_dir/areas/barnyard.area "$name"