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

114 lines
2.6 KiB
GDScript

extends Node2D
signal condensedCupcake1()
#Cupcake Values
var ccVanNum: int = 0
var ccVanValue: int = 1
var ccChocNum: int = 0
#Cupcake Upgrade Prices
var ccVanPrice: int = 10
var ccVanPrice2: int = 15
var ccVanPrice3: int = 15
var ccChocPrice: int = 10
#Preloaded scenes and scripts
var upgradeUI = preload("res://Scenes/UI/upgrades.tscn")
var location = preload("res://Scenes/Locations/yard.tscn")
var horse_scene = preload("res://Scenes/horse.tscn")
var horse = preload("res://Scripts/horse.gd")
var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn")
var ccChocolate
var ccchoc
#Other
@onready var timer = get_node("Cupcake Spawn Timer")
var horseAttached = true
var horse_instance
var mouse_position = Vector2.ZERO
var ccvan = ccVanilla.instantiate()
var ccSpawnRate = 3
var ccCount = 0
var ccMaxOnScreen = 2000
func _ready():
var spawn
horse_instance = horse_scene.instantiate()
spawn = location.instantiate()
$Location.add_child(spawn)
add_child(horse_instance)
func _process(delta):
if horseAttached == true:
mouse_position = get_global_mouse_position()
horse_instance.position = mouse_position
handleInput()
func handleInput():
if Input.is_action_pressed("horseAttach"):
if horseAttached == true:
horseAttached = false
else:
horseAttached = true
func spawnCupcakes():
var randX
var randY
randomize()
if ccCount <= ccMaxOnScreen:
for i in range(ccSpawnRate):
randX = randi_range(10, 1910)
randY = randi_range(10, 1070)
ccvan.position = Vector2(randX, randY)
$Cupcakes.add_child(ccvan.duplicate())
ccCount = ccCount + ccSpawnRate
func collectCupcakes():
$InGameUI/Num/VBoxContainer/ccVanNum.text = str(ccVanNum)
func _on_timeout():
spawnCupcakes()
collectCupcakes()
timer.start
func _on_play_area_body_exited(body):
pass
func _on_cupcake_cc_van_collected():
ccVanNum += ccVanValue
ccCount -= 1
collectCupcakes()
func _on_upgrades_one_more_cupcake():
if ccVanNum >= ccVanPrice:
ccSpawnRate += 1
ccVanNum -= ccVanPrice
ccVanPrice = ccVanPrice * 1.3
$Upgrades/Control/ScrollContainer/VanGrid/VanUp1/Price.text = str(ccVanPrice)
collectCupcakes()
func _on_upgrades_faster_cupcake():
if ccVanNum >= ccVanPrice2:
ccVanNum -= ccVanPrice2
ccVanPrice2 = ccVanPrice2 * 1.3
timer.wait_time = timer.wait_time - (timer.wait_time * 0.01)
$Upgrades/Control/ScrollContainer/VanGrid/VanUp2/Price.text = str(ccVanPrice2)
collectCupcakes()
func _on_upgrades_condensed_cupcake_1():
if ccVanNum >= ccVanPrice3:
ccVanNum -= ccVanPrice3
ccVanPrice3 = ccVanPrice3 * 1.3
ccVanValue += 1
$Upgrades/Control/ScrollContainer/VanGrid/VanUp3/Price.text = str(ccVanPrice3)
collectCupcakes()