-
Notifications
You must be signed in to change notification settings - Fork 3
/
elixir.gd
38 lines (32 loc) · 987 Bytes
/
elixir.gd
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
extends Line2D
func _ready():
if not global.host:
$elixir_timer.queue_free()
return
func _on_elixir_timer_timeout():
if get_tree().network_peer:
if get_tree().is_network_server():
global.blue_elixir += 1
if (global.blue_elixir > 10):
global.blue_elixir = 10
global.red_elixir += 1
if (global.red_elixir > 10):
global.red_elixir = 10
return
remote func update_elixir(blue, red):
global.red_elixir = red
global.blue_elixir = blue
return
var old = 0
func _process(delta):
if get_tree().network_peer:
if get_tree().is_network_server():
if old != global.red_elixir + global.blue_elixir:
old = global.red_elixir + global.blue_elixir
rpc_unreliable("update_elixir", global.blue_elixir, global.red_elixir)
if get_tree().network_peer:
if get_tree().is_network_server():
points[0] = Vector2(range_lerp(global.blue_elixir, 0, 10, 25, 255), -3)
else:
points[0] = Vector2(range_lerp(global.red_elixir, 0, 10, 25, 255), -3)
return