You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CupcakeRevolution/Scripts/game_world.gd

506 lines
16 KiB
GDScript

extends Node2D
#Cupcake Values
var ccValues = {
"van": [0, 1],
"choc": [0, 1],
"straw": [0, 1],
"rvel": [0, 1],
"cin": [0, 1],
"hon": [0, 1],
"night": [0, 1]
}
#Cupcake Upgrade Prices
var ccPrices = {
"van": [10, 15, 15, 25000],
"choc": [10, 15, 15, 50000, 150, null],
"straw": [10, 15, 15, 75000, 2000, 50, 150, 200, 50000],
"rvel": [10, 15, 15, 100000],
"cin": [10, 15, 15, 125000],
"hon": [10, 15, 15, 150000],
"night": [10, 15, 15, 175000]
}
var UpNum = {
"van": [0, 0, 0, 0],
"choc": [0, 0, 0, 0, 0, 0],
"straw": [0, 0, 0, 0, 0, 0, 0],
"rvel": [0, 0, 0, 0],
"cin": [0, 0, 0, 0],
"hon": [0, 0, 0, 0],
"night": [0, 0, 0, 0]
}
###Preloaded scenes and scripts
var upgradeUI = preload("res://Scenes/UI/upgrades.tscn")
var horse_scene = preload("res://Scenes/horse.tscn")
var horse = preload("res://Scripts/horse.gd")
#Cupcakes
var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn")
var ccChocolate = preload("res://Scenes/Cupcakes/chocCupcake.tscn")
var ccStrawberry = preload("res://Scenes/Cupcakes/strawCupcake.tscn")
var ccRedVelvet = preload("res://Scenes/Cupcakes/rvelCupcake.tscn")
var ccCinnamon = preload("res://Scenes/Cupcakes/cinCupcake.tscn")
var ccHonest = preload("res://Scenes/Cupcakes/honCupcake.tscn")
var ccNightmare = preload("res://Scenes/Cupcakes/nightCupcake.tscn")
var ccRock
var ccRuby
var ccSapphire
var ccEmerald
var ccDiamond
var ccLoyal
var ccChaos
#Areas
var location = null
const AREA_PATHS = [
"res://Scenes/Locations/yard.tscn",
"res://Scenes/Locations/neighYard.tscn",
"res://Scenes/Locations/dungeonHon.tscn",
"res://Scenes/Locations/dungeonNight.tscn"
]
var areaScenes = []
#Area Locks
var neighYardLocked = true
#Instantiations
var ccVan = ccVanilla.instantiate()
var ccChoc = ccChocolate.instantiate()
var ccStraw = ccStrawberry.instantiate()
var ccRVel = ccRedVelvet.instantiate()
var ccCin = ccCinnamon.instantiate()
var ccHon = ccHonest.instantiate()
var ccNight = ccNightmare.instantiate()
var ccRoc = ccRock
var ccRub = ccRuby
var ccSap = ccSapphire
var ccEme = ccEmerald
var ccDia = ccDiamond
var ccLoy = ccLoyal
var ccCha = ccChaos
#Cupcake Locks
var ccChocLocked = true
var ccStrawLocked = true
var ccRVelLocked = true
var ccCinLocked = true
var ccHonLocked = true
var ccNightLocked = true
var ccRocLocked = true
var ccRubLocked = true
var ccSapLocked = true
var ccEmeLocked = true
var ccDiaLocked = true
var ccChaLocked = true
#Spawnrates
var ccSpawnRates = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
var ccVanSpawnRate = 3
var ccChocSpawnRate = 3
var ccStrawSpawnRate = 3
var ccRVelSpawnRate = 3
var ccCinSpawnRate = 3
var ccHonSpawnRate = 3
var ccNightSpawnRate = 3
var ccRocSpawnRate = 3
var ccRubSpawnRate = 3
var ccSapSpawnRate = 3
var ccEmeSpawnRate = 3
var ccDiaSpawnRate = 3
var ccChaSpawnRate = 3
#Combo
var comboLocked = true
var combo = 1.00
var comboMultiplier
#Tools
var tool = null
const TOOL_PATHS = [
"res://Scenes/Tools/hooves.tscn",
"res://Scenes/Tools/bakingTray.tscn"
]
var toolScenes = []
#Other
@onready var timer = get_node("Cupcake Spawn Timer")
var horseAttached = true
var horse_instance
var horseScene
var mouse_position = Vector2.ZERO
var ccCount = 0
var ccMaxOnScreen = 3000
#General
func _ready():
for path in AREA_PATHS:
var scene = load(path)
var instance = scene.instantiate()
areaScenes.append(instance)
horse_instance = horse_scene.instantiate()
add_child(horse_instance)
location = areaScenes[0]
spawnHorse()
for path in TOOL_PATHS:
var scene = load(path)
var instance = scene.instantiate()
toolScenes.append(instance)
tool = toolScenes[0]
add_child(tool)
func _process(delta):
if horseAttached == true:
mouse_position = get_global_mouse_position()
horse_instance.position = mouse_position
if $"Tool":
tool.position = mouse_position
func _input(event):
if event is InputEventMouseButton and event.pressed:
if Input.is_action_pressed("horseAttach"):
if horseAttached == true:
horseAttached = false
else:
horseAttached = true
#AreaTeleporter
func spawnHorse():
if $Location.get_child_count() >= 1:
$Location.remove_child(location)
$Location.add_child(location)
#Update Count
func collectCupcakes():
$InGameUI/Num/NumGrid/ccVanNum.text = str(ccValues["van"][0])
$InGameUI/Num/NumGrid/ccChocNum.text = str(ccValues["choc"][0])
$InGameUI/Num/NumGrid/ccStrawNum.text = str(ccValues["straw"][0])
$InGameUI/Num/NumGrid/ccRVelNum.text = str(ccValues["rvel"][0])
$InGameUI/Num/NumGrid/ccCinNum.text = str(ccValues["cin"][0])
$InGameUI/Num/NumGrid/ccHonNum.text = str(ccValues["hon"][0])
$InGameUI/Num/NumGrid/ccNightNum.text = str(ccValues["night"][0])
#Cupcake Timer
func _on_timeout():
spawnCupcakes(ccVan, ccSpawnRates[0])
if not ccChocLocked:
spawnCupcakes(ccChoc, ccSpawnRates[1])
if not ccStrawLocked:
spawnCupcakes(ccStraw, ccSpawnRates[2])
if not ccRVelLocked:
spawnCupcakes(ccRVel, ccSpawnRates[3])
if not ccCinLocked:
spawnCupcakes(ccCin, ccSpawnRates[4])
collectCupcakes()
timer.start()
#Spawn
func spawnCupcakes(cupcake: Node2D, spawn_rate: int):
var randX
var randY
randomize()
if ccCount <= ccMaxOnScreen:
for i in range(spawn_rate):
randX = randi_range(50, 1870)
randY = randi_range(50, 1030)
cupcake.position = Vector2(randX, randY)
$Cupcakes.add_child(cupcake.duplicate())
ccCount += spawn_rate
###Upgrades###
#Vanilla
func _on_upgrades_one_more_cupcake():
if ccValues["van"][0] >= ccPrices["van"][0]:
ccSpawnRates[0] += 1
ccValues["van"][0] -= ccPrices["van"][0]
ccPrices = ccPrices["van"][0] * 1.3
UpNum["van"][0] += 1
$Upgrades/Control/VanScroll/VanGrid/VanUp1/Price.text = str(ccPrices["van"][0])
collectCupcakes()
func _on_upgrades_faster_cupcake():
if ccValues["van"][0] >= ccPrices["van"][1]:
ccValues["van"][0] -= ccPrices["van"][1]
ccPrices["van"][1] = ccPrices["van"][1] * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
UpNum["van"][1] += 1
$Upgrades/Control/VanScroll/VanGrid/VanUp2/Price.text = str(ccPrices["van"][1])
collectCupcakes()
func _on_upgrades_condensed_cupcake_1():
if ccValues["van"][0] >= ccPrices["van"][2]:
ccValues["van"][0] -= ccPrices["van"][2]
ccPrices["van"][2] = ccPrices["van"][2] * 1.3
ccValues["van"][1] += 1
UpNum["van"][2] += 1
$Upgrades/Control/VanScroll/VanGrid/VanUp3/Price.text = str(ccPrices["van"][2])
collectCupcakes()
#Chocolate
func _on_upgrades_one_more_cupcake_2():
if ccValues["choc"][0] >= ccPrices["choc"][0]:
ccSpawnRates[1] += 1
ccValues["choc"][0] -= ccPrices["choc"][0]
ccPrices["choc"][0] = ccPrices["choc"][0] * 1.3
UpNum["choc"][0] += 1
$Upgrades/Control/ChocScroll/ChocGrid/ChocUp1/Price.text = str(ccPrices["choc"][0])
collectCupcakes()
func _on_upgrades_faster_cupcake_2():
if ccValues["choc"][0] >= ccPrices["choc"][1]:
ccValues["choc"][0] -= ccPrices["choc"][1]
ccPrices["choc"][1] = ccPrices["choc"][1] * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
UpNum["choc"][1] += 1
$Upgrades/Control/ChocScroll/ChocGrid/ChocUp2/Price.text = str(ccPrices["choc"][1])
collectCupcakes()
func _on_upgrades_condensed_cupcake_2():
if ccValues["choc"][0] >= ccPrices["choc"][2]:
ccValues["choc"][0] -= ccPrices["choc"][2]
ccPrices["choc"][2] = ccPrices["choc"][2] * 1.3
ccValues["choc"][1] += 1
UpNum["choc"][2] += 1
$Upgrades/Control/ChocScroll/ChocGrid/ChocUp3/Price.text = str(ccPrices["choc"][2])
collectCupcakes()
#Strawberry
func _on_upgrades_one_more_cupcake_3():
if ccValues["straw"][0] >= ccPrices["straw"][0]:
ccSpawnRates[2] += 1
ccValues["straw"][0] -= ccPrices["straw"][0]
ccPrices = ccPrices * 1.3
UpNum["straw"][0] += 1
$Upgrades/Control/StrawScroll/StrawGrid/StrawUp1/Price.text = str(ccPrices)
collectCupcakes()
func _on_upgrades_faster_cupcake_3():
if ccValues["straw"][0] >= ccPrices["straw"][1]:
ccValues["straw"][0] -= ccPrices["straw"][1]
ccPrices["straw"][1] = ccPrices["straw"][1] * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
UpNum["straw"][1] += 1
$Upgrades/Control/StrawScroll/StrawGrid/StrawUp2/Price.text = str(ccPrices["straw"][1])
collectCupcakes()
func _on_upgrades_condensed_cupcake_3():
if ccValues["straw"][0] >= ccPrices["straw"][2]:
ccValues["straw"][0] -= ccPrices["straw"][2]
ccPrices["straw"][2] = ccPrices["straw"][2] * 1.3
ccValues["straw"][1] += 1
UpNum["straw"][2] += 1
$Upgrades/Control/StrawScroll/StrawGrid/StrawUp3/Price.text = str(ccPrices["straw"][2])
collectCupcakes()
#Red Velvet
func _on_upgrades_one_more_cupcake_4():
if ccValues["rvel"][0] >= ccPrices["rvel"][0]:
ccSpawnRates[3] += 1
ccValues["rvel"][0] -= ccPrices["rvel"][0]
ccPrices["rvel"][0] = ccPrices["rvel"][0] * 1.3
$Upgrades/Control/RVelScroll/RVelGrid/RVelUp1/Price.text = str(ccPrices["rvel"][0])
collectCupcakes()
func _on_upgrades_faster_cupcake_4():
if ccValues["rvel"][0] >= ccPrices["rvel"][1]:
ccValues["rvel"][0] -= ccPrices["rvel"][1]
ccPrices["rvel"][1] = ccPrices["rvel"][1] * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
$Upgrades/Control/RVelScroll/RVelGrid/RVelUp2/Price.text = str(ccPrices["rvel"][1])
collectCupcakes()
func _on_upgrades_condensed_cupcake_4():
if ccValues["rvel"][0] >= ccPrices["rvel"][2]:
ccValues["rvel"][0] -= ccPrices["rvel"][2]
ccPrices["rvel"][2] = ccPrices["rvel"][2] * 1.3
ccValues["rvel"][1] += 1
$Upgrades/Control/RVelScroll/RVelGrid/RVelUp3/Price.text = str(ccPrices["rvel"][2])
collectCupcakes()
#Cinnamon
func _on_upgrades_one_more_cupcake_5():
if ccValues["cin"][0] >= ccPrices["cin"][0]:
ccSpawnRates[4] += 1
ccValues["cin"][0] -= ccPrices["cin"][0]
ccPrices["cin"][0] = ccPrices["cin"][0] * 1.3
$Upgrades/Control/CinScroll/CinGrid/CinUp1/Price.text = str(ccPrices["cin"][0])
collectCupcakes()
func _on_upgrades_faster_cupcake_5():
if ccValues["cin"][0] >= ccPrices["cin"][1]:
ccValues["cin"][0] -= ccPrices["cin"][1]
ccPrices["cin"][1] = ccPrices["cin"][1] * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
$Upgrades/Control/CinScroll/CinGrid/CinUp2/Price.text = str(ccPrices["cin"][1])
collectCupcakes()
func _on_upgrades_condensed_cupcake_5():
if ccValues["cin"][0] >= ccPrices["cin"][2]:
ccValues["cin"][0] -= ccPrices["cin"][2]
ccPrices["cin"][2] = ccPrices["cin"][2] * 1.3
ccValues["cin"][1] += 1
$Upgrades/Control/CinScroll/CinGrid/CinUp3/Price.text = str(ccPrices["cin"][2])
collectCupcakes()
#Honest
func _on_upgrades_one_more_cupcake_6():
if ccValues["hon"][0] >= ccPrices["hon"][0]:
ccHonSpawnRate += 1
ccValues["hon"][0] -= ccPrices["hon"][0]
ccPrices["hon"][0] = ccPrices["hon"][0] * 1.3
$Upgrades/Control/HonScroll/HonGrid/HonUp1/Price.text = str(ccPrices["hon"][0])
collectCupcakes()
func _on_upgrades_faster_cupcake_6():
if ccValues["hon"][0] >= ccPrices["hon"][1]:
ccValues["hon"][0] -= ccPrices["hon"][1]
ccPrices["hon"][1] = ccPrices["hon"][1] * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
$Upgrades/Control/HonScroll/HonGrid/HonUp2/Price.text = str(ccPrices["hon"][1])
collectCupcakes()
func _on_upgrades_condensed_cupcake_6():
if ccValues["hon"][0] >= ccPrices["hon"][2]:
ccValues["hon"][0] -= ccPrices["hon"][2]
ccPrices["hon"][2] = ccPrices["hon"][2] * 1.3
ccValues["hon"][1] += 1
$Upgrades/Control/HonScroll/HonGrid/HonUp3/Price.text = str(ccPrices["hon"][2])
collectCupcakes()
func _on_upgrades_cupcake_damage():
pass
func _on_upgrades_horse_health():
pass
func _on_upgrades_sweetie_damage():
pass
#Nightmare
#Unlock
func _on_upgrades_unlock_choc():
if ccValues["van"][0] >= ccPrices["van"][3]:
ccValues -= ccPrices["van"][3]
ccChocLocked = false
$"InGameUI/Main/HBoxContainer/Choc".visible = true
$"InGameUI/Num/NumGrid/chocIcon".visible = true
$"InGameUI/Num/NumGrid/ccValues".visible = true
$"Upgrades/Control/VanScroll/VanGrid/VanUp4/Buy".visible = false
func _on_upgrades_unlock_straw():
if ccValues["choc"][0] >= ccPrices["choc"][3]:
ccValues["choc"][0] -= ccPrices["choc"][3]
ccStrawLocked = false
$"InGameUI/Main/HBoxContainer/Straw".visible = true
$"InGameUI/Num/NumGrid/strawIcon".visible = true
$"InGameUI/Num/NumGrid/ccValues".visible = true
$"Upgrades/Control/ChocScroll/ChocGrid/ChocUp4/Buy".visible = false
func _on_upgrades_unlock_r_vel():
if ccValues >= ccPrices["straw"][8]:
ccValues["straw"][0] -= ccPrices["straw"][8]
ccRVelLocked = false
$"InGameUI/Main/HBoxContainer/RVel".visible = true
$"InGameUI/Num/NumGrid/rvelIcon".visible = true
$"InGameUI/Num/NumGrid/ccValues".visible = true
$"Upgrades/Control/StrawScroll/StrawGrid/StrawUp4/Buy".visible = false
func _on_upgrades_unlock_cin():
if ccValues["rvel"][0] >= ccPrices["rvel"][3]:
ccValues["rvel"][0] -= ccPrices["rvel"][3]
ccCinLocked = false
$"InGameUI/Main/HBoxContainer/Cin".visible = true
$"InGameUI/Num/NumGrid/cinIcon".visible = true
$"InGameUI/Num/NumGrid/ccValues".visible = true
$"Upgrades/Control/RVelScroll/RVelGrid/RVelUp4/Buy".visible = false
func _on_upgrades_unlock_hon():
if ccValues >= ccPrices["cin"][3]:
ccValues["cin"][0] -= ccPrices["cin"][3]
ccHonLocked = false
$"InGameUI/Main/HBoxContainer/Honest".visible = true
$"InGameUI/Num/NumGrid/honIcon".visible = true
$"InGameUI/Num/NumGrid/ccValues".visible = true
$"Upgrades/Control/CinScroll/CinGrid/CinUp4/Buy".visible = false
func _on_upgrades_unlock_nightmare():
if ccValues["hon"][0] >= ccPrices["hon"][3]:
ccValues -= ccPrices["hon"][3]
ccNightLocked = false
$"InGameUI/Main/HBoxContainer/Night".visible = true
$"InGameUI/Num/NumGrid/nightIcon".visible = true
$"InGameUI/Num/NumGrid/ccNightNum".visible = true
$"Upgrades/Control/HonScroll/HonGrid/HonUp4/Buy".visible = false
#Collect
func _on_van_cupcake_cc_van_collected():
ccValues["van"][0] += ccValues["van"][1]
ccCount -= 1
collectCupcakes()
func _on_choc_cupcake_cc_choc_collected():
ccValues["choc"][0] += ccValues["choc"][1]
ccCount -= 1
collectCupcakes()
func _on_straw_cupcake_cc_straw_collected():
ccValues["straw"][0] += ccValues["straw"][1]
ccCount -= 1
collectCupcakes()
func _on_rvel_cupcake_cc_rvel_collected():
ccValues["rvel"][0] += ccValues["rvel"][1]
ccCount -= 1
collectCupcakes()
func _on_cin_cupcake_cc_cin_collected():
ccValues["cin"][0] += ccValues["cin"][1]
ccCount -= 1
collectCupcakes()
func _on_honest_cupcake_cc_hon_collected():
ccValues["hon"][0] += ccValues["hon"][1]
ccCount -= 1
collectCupcakes()
func _on_night_cupcake_cc_night_collected():
ccValues["night"][0] += ccValues["night"][1]
ccCount -= 1
collectCupcakes()
#Areas
func _on_upgrades_your_yard():
if $Upgrades/Control/AreaScroll/AreaGrid/Area1/Buy.disabled == false:
location = areaScenes[0]
$Upgrades/Control/AreaScroll/AreaGrid/Area2/Buy.disabled = false
$Upgrades/Control/AreaScroll/AreaGrid/Area1/Buy.disabled = true
$Upgrades/Control/AreaScroll/AreaGrid/Area1/Buy.text = str("Teleport (You're here)")
$Upgrades/Control/AreaScroll/AreaGrid/Area2/Buy.text = str("Teleport")
spawnHorse()
func _on_upgrades_neigh_yard():
if neighYardLocked == true:
if ccValues["straw"][0] >= ccPrices["straw"][6]:
ccValues["straw"][0] -= ccPrices["straw"][6]
neighYardLocked = false
$Upgrades/Control/AreaScroll/AreaGrid/Area1/Buy.text = str("Teleport")
if neighYardLocked == false and $Upgrades/Control/AreaScroll/AreaGrid/Area2/Buy.disabled == false:
location = areaScenes[1]
$Upgrades/Control/AreaScroll/AreaGrid/Area2/Buy.disabled = true
$Upgrades/Control/AreaScroll/AreaGrid/Area1/Buy.disabled = false
$Upgrades/Control/AreaScroll/AreaGrid/Area1/Buy.text = str("Teleport")
$Upgrades/Control/AreaScroll/AreaGrid/Area2/Buy.text = str("Teleport (You're here)")
spawnHorse()
func _on_upgrades_honest_dungeon():
pass # Replace with function body.
func _on_upgrades_abandoned_castle():
pass # Replace with function body.
#Tools
func _on_upgrades_tool_1():
remove_child(tool)
tool = toolScenes[0]
add_child(tool)
func _on_upgrades_tool_2():
remove_child(tool)
tool = toolScenes[1]
add_child(tool)