-
Notifications
You must be signed in to change notification settings - Fork 1
/
Goal.gd
124 lines (111 loc) · 3.55 KB
/
Goal.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
extends ActorBase
class_name Goal
var gamelogic = null;
var actorname = ""
var pos = Vector2.ZERO
var dinged = false;
#locked is for time crystals, locked2 is for crates
var locked = false;
var locked2 = false;
var animations = [];
var scalify_target = 0.1;
var scalify_current = 0.1;
var rotate_magnitude = 1;
var particle_timer = 1;
var particle_timer_max = 1;
var last_particle_angle = 0;
var facing_left = false; #dummied out
var is_crystal = false; #dummied out
func lock2() -> void:
if (!locked2):
locked2 = true;
modulate.a = 0.4;
gamelogic.add_to_animation_server(self, [2]);
func unlock2() -> void:
if (locked2):
locked2 = false;
modulate.a = 0.8;
gamelogic.add_to_animation_server(self, [2]);
func lock() -> void:
if (!locked):
locked = true;
modulate.r = 0.4;
modulate.g = 0.4;
modulate.b = 0.4;
gamelogic.add_to_animation_server(self, [2]);
func unlock() -> void:
if (locked):
locked = false;
modulate.r = 1.0;
modulate.g = 1.0;
modulate.b = 1.0;
gamelogic.add_to_animation_server(self, [2]);
func update_scalify_target() -> void:
scalify_target = 0.1;
if (actorname == Actor.Name.HeavyGoal):
scalify_target *= 1.7;
if (dinged and !locked and !locked2):
scalify_target *= 2;
func instantly_reach_scalify() -> void:
update_scalify_target();
scalify_current = scalify_target;
scale = Vector2(scalify_current, scalify_current);
func update_graphics() -> void:
update_scalify_target();
func get_next_texture() -> Texture:
return texture
func set_next_texture(tex: Texture) -> void:
pass
func _process(delta: float) -> void:
particle_timer += delta;
if (particle_timer > particle_timer_max):
var underactorsparticles = gamelogic.underactorsparticles;
particle_timer -= particle_timer_max;
var sprite = Sprite.new();
sprite.set_script(preload("res://GoalParticle.gd"));
sprite.texture = self.texture;
# use parent's position if we're a joke, our own otherwise
if (self.get_parent() is Actor):
sprite.position = self.get_parent().position + self.position;
else:
sprite.position = self.position;
sprite.centered = true;
sprite.rotation = gamelogic.rng.randf_range(0, 2*PI);
sprite.rotate_magnitude = self.rotate_magnitude*4;
sprite.alpha_max = 0.4;
sprite.modulate = Color(modulate.r, modulate.g, modulate.b, 0);
var next_particle_angle = last_particle_angle + 2*PI/6 + gamelogic.rng.randf_range(0, 2*PI*4/6)
last_particle_angle = next_particle_angle;
if (dinged):
sprite.scale = scale / 3;
particle_timer_max = 0.5;
sprite.fadeout_timer_max = 2;
sprite.velocity = Vector2(0, 18).rotated(next_particle_angle);
else:
sprite.scale = scale / 2.2;
particle_timer_max = 1;
sprite.fadeout_timer_max = 4;
sprite.velocity = Vector2(0, 6).rotated(next_particle_angle);
sprite.position -= sprite.velocity*sprite.fadeout_timer_max;
underactorsparticles.add_child(sprite);
# by cosmological coincidence this is roughly what I wanted!
self.rotation += rotate_magnitude*delta;
# scale
if (scalify_target != scalify_current):
if (scalify_current < scalify_target):
# again by cosmological coincidence it's perfect
scalify_current += delta;
if (scalify_current > scalify_target):
scalify_current = scalify_target;
else:
scalify_current -= delta;
if (scalify_current < scalify_target):
scalify_current = scalify_target;
scale = Vector2(scalify_current, scalify_current);
if (animations.size() > 0):
var current_animation = animations[0];
var is_done = true;
if (current_animation[0] == 2): #set_next_texture
update_graphics();
if (is_done):
animations.pop_front();