| 1 |
if (live_call()) |
| 2 |
return global.live_result; |
| 3 |
if (destroy_self == true) |
| 4 |
{ |
| 5 |
draw_alpha = lerp(draw_alpha, 0, 0.2); |
| 6 |
if (draw_alpha == 0) |
| 7 |
{ |
| 8 |
global.sworks_robot_count = instance_number(obj_robot_build_item); |
| 9 |
var x_origin = 60; |
| 10 |
var y_origin = 140; |
| 11 |
var i = 0; |
| 12 |
with (obj_robot_build_item) |
| 13 |
{ |
| 14 |
global.sworks_robot_sprite[i] = sprite_index; |
| 15 |
global.sworks_robot_x[i] = x_origin - x; |
| 16 |
global.sworks_robot_y[i] = y_origin - y; |
| 17 |
global.sworks_robot_depth[i] = depth; |
| 18 |
global.sworks_robot_angle[i] = image_angle; |
| 19 |
global.sworks_robot_scale[i] = image_xscale; |
| 20 |
i += 1; |
| 21 |
} |
| 22 |
instance_destroy(); |
| 23 |
instance_destroy(obj_robot_build_cursor); |
| 24 |
instance_destroy(obj_robot_build_item); |
| 25 |
} |
| 26 |
exit; |
| 27 |
} |
| 28 |
if (global.dialogue_open) |
| 29 |
exit; |
| 30 |
draw_alpha = lerp(draw_alpha, 1, 0.2); |
| 31 |
var confirm_key = keyboard_multicheck_pressed(0); |
| 32 |
var cancel_key = keyboard_multicheck_pressed(1); |
| 33 |
var cursor_x = obj_robot_build_cursor.x; |
| 34 |
var cursor_y = obj_robot_build_cursor.y; |
| 35 |
if (point_in_rectangle(cursor_x, cursor_y, 360, 20, 470, 150)) |
| 36 |
robot_item_selected = 0; |
| 37 |
else if (point_in_rectangle(cursor_x, cursor_y, 470, 20, 580, 150)) |
| 38 |
robot_item_selected = 1; |
| 39 |
else if (point_in_rectangle(cursor_x, cursor_y, 360, 150, 470, 280)) |
| 40 |
robot_item_selected = 2; |
| 41 |
else if (point_in_rectangle(cursor_x, cursor_y, 470, 150, 580, 280)) |
| 42 |
robot_item_selected = 3; |
| 43 |
else |
| 44 |
robot_item_selected = -1; |
| 45 |
if (point_in_rectangle(cursor_x, cursor_y, 500, 320, 580, 370)) |
| 46 |
gui_button_selected = 0; |
| 47 |
else if (point_in_rectangle(cursor_x, cursor_y, 500, 398, 580, 448)) |
| 48 |
gui_button_selected = 1; |
| 49 |
else |
| 50 |
gui_button_selected = -1; |
| 51 |
if (confirm_key) |
| 52 |
{ |
| 53 |
if (robot_item_selected != -1) |
| 54 |
{ |
| 55 |
var robot_item_number = instance_number(obj_robot_build_item); |
| 56 |
if (robot_item_number >= item_number_max) |
| 57 |
{ |
| 58 |
audio_play_sound(snd_fail, 1, 0); |
| 59 |
} |
| 60 |
else |
| 61 |
{ |
| 62 |
robot_move_to_position = true; |
| 63 |
obj_robot_build_cursor.soul_can_move = false; |
| 64 |
obj_robot_build_cursor.image_alpha_base = 0.5; |
| 65 |
robot_item_placed[item_number] = instance_create(obj_robot_build_cursor.x, obj_robot_build_cursor.y, obj_robot_build_item); |
| 66 |
with (robot_item_placed[item_number]) |
| 67 |
sprite_index = other.robot_item[other.robot_item_selected]; |
| 68 |
item_number += 1; |
| 69 |
audio_play_sound(snd_mainmenu_select, 1, 0); |
| 70 |
} |
| 71 |
} |
| 72 |
if (gui_button_selected != -1) |
| 73 |
{ |
| 74 |
if (gui_button_selected == 0 && item_number > 0) |
| 75 |
{ |
| 76 |
instance_destroy(robot_item_placed[item_number - 1]); |
| 77 |
item_number -= 1; |
| 78 |
audio_play_sound(snd_confirm, 1, 0); |
| 79 |
} |
| 80 |
else if (gui_button_selected == 1) |
| 81 |
{ |
| 82 |
audio_play_sound(snd_confirm, 1, 0); |
| 83 |
if (!instance_exists(obj_robot_build_dialogue_confirm)) |
| 84 |
instance_create(0, 0, obj_robot_build_dialogue_confirm); |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
if (robot_item_selected != -1) |
| 89 |
robot_item_scale[robot_item_selected] = lerp(robot_item_scale[robot_item_selected], 1.3, 0.15); |
| 90 |
for (var i = 0; i < array_length_1d(robot_item_scale); i++) |
| 91 |
{ |
| 92 |
if (i != robot_item_selected) |
| 93 |
robot_item_scale[i] = lerp(robot_item_scale[i], 1, 0.25); |
| 94 |
} |
| 95 |
if (robot_move_to_position == true) |
| 96 |
{ |
| 97 |
obj_robot_build_cursor.x = lerp(obj_robot_build_cursor.x, 170, 0.3); |
| 98 |
obj_robot_build_cursor.y = lerp(obj_robot_build_cursor.y, 150, 0.3); |
| 99 |
if (round(obj_robot_build_cursor.x) == 170 && round(obj_robot_build_cursor.y) == 150) |
| 100 |
{ |
| 101 |
robot_move_to_position = false; |
| 102 |
obj_robot_build_cursor.soul_can_move = true; |
| 103 |
obj_robot_build_cursor.image_alpha_base = 1; |
| 104 |
} |
| 105 |
} |