Initial commit
This commit is contained in:
47
scripts/_G.gd
Normal file
47
scripts/_G.gd
Normal file
@ -0,0 +1,47 @@
|
||||
extends Node
|
||||
|
||||
func exit():
|
||||
get_tree().quit()
|
||||
|
||||
func loadScene(scene):
|
||||
#warning-ignore:return_value_discarded
|
||||
var path = "res://scenes/"+scene+".tscn"
|
||||
get_tree().change_scene(path)
|
||||
|
||||
func loadLevel(lvl):
|
||||
var l = load("res://scenes/"+lvl+".tscn").instance()
|
||||
get_tree().get_root().add_child(l)
|
||||
|
||||
func unloadLevel(lvl):
|
||||
var rootnode = get_tree().get_root().get_children()
|
||||
for v in rootnode:
|
||||
if v.get_name() == lvl:
|
||||
get_tree().get_root().remove_child(v)
|
||||
|
||||
func hideMenuButts():
|
||||
PlayBtn.hide()
|
||||
AuthorsBtn.hide()
|
||||
ExitBtn.hide()
|
||||
|
||||
func showMenuButts():
|
||||
PlayBtn.show()
|
||||
AuthorsBtn.show()
|
||||
ExitBtn.show()
|
||||
|
||||
var PlayBtn
|
||||
var AuthorsBtn
|
||||
var ExitBtn
|
||||
var cans
|
||||
var currentTrashType = 'none'
|
||||
var score = 0
|
||||
var dogLevel = 0
|
||||
|
||||
func updateScore(v):
|
||||
score = int(v)
|
||||
|
||||
var trash = {
|
||||
1: ['res://sprites/trash/plasticbottle.png', 'plastic'],
|
||||
2: ['res://sprites/trash/glassbottle.png', 'glass'],
|
||||
3: ['res://sprites/trash/metalcan.png', 'other'],
|
||||
4: ['res://sprites/trash/newspaper.png', 'paper']
|
||||
}
|
11
scripts/animatedAuthorsTextAnim.gd
Normal file
11
scripts/animatedAuthorsTextAnim.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
|
||||
|
||||
func _ready():
|
||||
$anim.play("idle")
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
_G.unloadLevel("Authors")
|
||||
_G.showMenuButts()
|
4
scripts/authorsAnim.gd
Normal file
4
scripts/authorsAnim.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
$anim.play("onLoad")
|
8
scripts/authorsBtn.gd
Normal file
8
scripts/authorsBtn.gd
Normal file
@ -0,0 +1,8 @@
|
||||
extends Button
|
||||
|
||||
func _ready():
|
||||
_G.AuthorsBtn = self
|
||||
|
||||
func _pressed():
|
||||
_G.loadLevel("Authors")
|
||||
_G.hideMenuButts()
|
5
scripts/dog.gd
Normal file
5
scripts/dog.gd
Normal file
@ -0,0 +1,5 @@
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
get_node('./cloud/tail').play()
|
||||
$anim.play('idle')
|
7
scripts/dogBtn.gd
Normal file
7
scripts/dogBtn.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Node
|
||||
|
||||
func _pressed():
|
||||
_G.dogLevel += 1
|
||||
if _G.dogLevel == 3:
|
||||
_G.dogLevel = 0
|
||||
_G.loadScene("dog")
|
10
scripts/dogLoadout.gd
Normal file
10
scripts/dogLoadout.gd
Normal file
@ -0,0 +1,10 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
$sound.stream = load("res://sounds/dogMusic.ogg")
|
||||
$sound.play()
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
_G.loadScene("MainMenu")
|
7
scripts/exitBtn.gd
Normal file
7
scripts/exitBtn.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Button
|
||||
|
||||
func _ready():
|
||||
_G.ExitBtn = self
|
||||
|
||||
func _pressed():
|
||||
_G.exit()
|
4
scripts/fallingTrashcans.gd
Normal file
4
scripts/fallingTrashcans.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Particles2D
|
||||
|
||||
func _ready():
|
||||
_G.cans = self
|
5
scripts/mainMenuLoadout.gd
Normal file
5
scripts/mainMenuLoadout.gd
Normal file
@ -0,0 +1,5 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
$sound.stream = load("res://sounds/menuMusic.ogg")
|
||||
$sound.play()
|
20
scripts/onCardLoad.gd
Normal file
20
scripts/onCardLoad.gd
Normal file
@ -0,0 +1,20 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
nextCard()
|
||||
|
||||
func nextCard():
|
||||
if !$winloseAnim.is_playing():
|
||||
if _G.currentTrashType == 'none':
|
||||
randomize()
|
||||
var i = randi() % len(_G.trash) + 1
|
||||
$sprite.texture = load(_G.trash[i][0])
|
||||
_G.currentTrashType = _G.trash[i][1]
|
||||
$anim.queue("onLoad")
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _physics_process(delta):
|
||||
nextCard()
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
_G.currentTrashType = 'none'
|
||||
_G.loadScene("MainMenu")
|
7
scripts/playBtn.gd
Normal file
7
scripts/playBtn.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Button
|
||||
|
||||
func _ready():
|
||||
_G.PlayBtn = self
|
||||
|
||||
func _pressed():
|
||||
_G.loadScene('Playground')
|
5
scripts/scorePlayground.gd
Normal file
5
scripts/scorePlayground.gd
Normal file
@ -0,0 +1,5 @@
|
||||
extends Label
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _physics_process(delta):
|
||||
text = "Ваш счет: " + str(_G.score)
|
4
scripts/sunAnim.gd
Normal file
4
scripts/sunAnim.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
$anim.play("idle")
|
23
scripts/trashcanBtns/glass.gd
Normal file
23
scripts/trashcanBtns/glass.gd
Normal file
@ -0,0 +1,23 @@
|
||||
extends TextureButton
|
||||
|
||||
onready var anim = get_node('../../anim')
|
||||
onready var animWinLose = get_node('../../winloseAnim')
|
||||
onready var game = get_node('../../../Playground')
|
||||
onready var sound = get_node('../../sound')
|
||||
|
||||
func _pressed():
|
||||
if _G.currentTrashType == 'glass' && _G.currentTrashType != 'none':
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("win")
|
||||
_G.updateScore(_G.score+1)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/win.wav")
|
||||
sound.play()
|
||||
else:
|
||||
if(_G.currentTrashType != 'none'):
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("lose")
|
||||
_G.updateScore(0)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/lose.wav")
|
||||
sound.play()
|
23
scripts/trashcanBtns/other.gd
Normal file
23
scripts/trashcanBtns/other.gd
Normal file
@ -0,0 +1,23 @@
|
||||
extends TextureButton
|
||||
|
||||
onready var anim = get_node('../../anim')
|
||||
onready var animWinLose = get_node('../../winloseAnim')
|
||||
onready var game = get_node('../../../Playground')
|
||||
onready var sound = get_node('../../sound')
|
||||
|
||||
func _pressed():
|
||||
if _G.currentTrashType == 'other' && _G.currentTrashType != 'none':
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("win")
|
||||
_G.updateScore(_G.score+1)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/win.wav")
|
||||
sound.play()
|
||||
else:
|
||||
if(_G.currentTrashType != 'none'):
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("lose")
|
||||
_G.updateScore(0)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/lose.wav")
|
||||
sound.play()
|
23
scripts/trashcanBtns/paper.gd
Normal file
23
scripts/trashcanBtns/paper.gd
Normal file
@ -0,0 +1,23 @@
|
||||
extends TextureButton
|
||||
|
||||
onready var anim = get_node('../../anim')
|
||||
onready var animWinLose = get_node('../../winloseAnim')
|
||||
onready var game = get_node('../../../Playground')
|
||||
onready var sound = get_node('../../sound')
|
||||
|
||||
func _pressed():
|
||||
if _G.currentTrashType == 'paper' && _G.currentTrashType != 'none':
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("win")
|
||||
_G.updateScore(_G.score+1)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/win.wav")
|
||||
sound.play()
|
||||
else:
|
||||
if(_G.currentTrashType != 'none'):
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("lose")
|
||||
_G.updateScore(0)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/lose.wav")
|
||||
sound.play()
|
23
scripts/trashcanBtns/plastic.gd
Normal file
23
scripts/trashcanBtns/plastic.gd
Normal file
@ -0,0 +1,23 @@
|
||||
extends TextureButton
|
||||
|
||||
onready var anim = get_node('../../anim')
|
||||
onready var animWinLose = get_node('../../winloseAnim')
|
||||
onready var game = get_node('../../../Playground')
|
||||
onready var sound = get_node('../../sound')
|
||||
|
||||
func _pressed():
|
||||
if _G.currentTrashType == 'plastic' && _G.currentTrashType != 'none':
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("win")
|
||||
_G.updateScore(_G.score+1)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/win.wav")
|
||||
sound.play()
|
||||
else:
|
||||
if(_G.currentTrashType != 'none'):
|
||||
anim.play('onUnload')
|
||||
animWinLose.play("lose")
|
||||
_G.updateScore(0)
|
||||
_G.currentTrashType = 'none'
|
||||
sound.stream = load("res://sounds/lose.wav")
|
||||
sound.play()
|
Reference in New Issue
Block a user