Initial Commit
This commit is contained in:
parent
6d0191e863
commit
beb2b93613
10 changed files with 516 additions and 0 deletions
58
scripts/computer.gd
Normal file
58
scripts/computer.gd
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
extends StaticBody3D
|
||||
|
||||
const TARGET = 100
|
||||
var current = 0
|
||||
|
||||
var pc_occupied = [0, 0, 0,]
|
||||
|
||||
var pc_body = [0, 0, 0]
|
||||
|
||||
func _ready():
|
||||
Game.computers += 1
|
||||
|
||||
func _on_computer_tick_timeout():
|
||||
current += (pc_occupied[0] + pc_occupied[1] + pc_occupied[2])
|
||||
if current >= TARGET:
|
||||
current = "Complete"
|
||||
$computer_tick.stop()
|
||||
Game.computers -= 1
|
||||
$pc_1/Label3D.text = str(current)
|
||||
$pc_2/Label3D.text = str(current)
|
||||
$pc_3/Label3D.text = str(current)
|
||||
|
||||
|
||||
func _on_pc_1_area_body_entered(body):
|
||||
if pc_occupied[0] == 0:
|
||||
body.has_method("_input")
|
||||
pc_occupied[0] = 1
|
||||
pc_body[0] = body
|
||||
|
||||
|
||||
func _on_pc_2_area_body_entered(body):
|
||||
if pc_occupied[1] == 0:
|
||||
pc_occupied[1] = 1
|
||||
pc_body[1] = body
|
||||
|
||||
|
||||
func _on_pc_3_area_body_entered(body):
|
||||
if pc_occupied[2] == 0:
|
||||
pc_occupied[2] = 1
|
||||
pc_body[2] = body
|
||||
|
||||
|
||||
func _on_pc_1_area_body_exited(body):
|
||||
if pc_occupied[0] == 1 and body == pc_body[0]:
|
||||
pc_occupied[0] = 0
|
||||
pc_body[0] = 0
|
||||
|
||||
|
||||
func _on_pc_2_area_body_exited(body):
|
||||
if pc_occupied[1] == 1 and body == pc_body[1]:
|
||||
pc_occupied[1] = 0
|
||||
pc_body[1] = 0
|
||||
|
||||
|
||||
func _on_pc_3_area_body_exited(body):
|
||||
if pc_occupied[2] == 1 and body == pc_body[2]:
|
||||
pc_occupied[2] = 0
|
||||
pc_body[2] = 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue