private void apply_commands(Commands commands) { movable.MoveTowards(commands.ship_direction.normalized, move_speed); foreach (var shield in shields) { shield.deactivate(); } // We can use shield and guns only if not overloading! if (overload_system.state != OverloadSystem.State.recovering) { if (!commands.shield_mode) { if (commands.gun_trigger.fire_north) { fire_gun(AxesDirections.north); } if (commands.gun_trigger.fire_east) { fire_gun(AxesDirections.east); } if (commands.gun_trigger.fire_south) { fire_gun(AxesDirections.south); } if (commands.gun_trigger.fire_west) { fire_gun(AxesDirections.west); } } else { if (commands.gun_trigger.fire_north) { activate_shield(AxesDirections.north); } if (commands.gun_trigger.fire_east) { activate_shield(AxesDirections.east); } if (commands.gun_trigger.fire_south) { activate_shield(AxesDirections.south); } if (commands.gun_trigger.fire_west) { activate_shield(AxesDirections.west); } } } // We can always rotate for free. rotate_guns(commands.gun_move); }
private void apply_commands(Commands commands) { movable.MoveTowards(commands.ship_direction.normalized, move_speed); // Don't get out of the screen float pos_x = Mathf.Clamp(transform.position.x, -GameCamera.SIZE_PER_HALF_SIDE, GameCamera.SIZE_PER_HALF_SIDE); float pos_y = Mathf.Clamp(transform.position.y, -GameCamera.SIZE_PER_HALF_SIDE, GameCamera.SIZE_PER_HALF_SIDE); transform.position = new Vector3(pos_x, pos_y, 0.0f); foreach (var shield in shields) { shield.deactivate(); } // We can use shield and guns only if not overloading! if (overload_system.state != OverloadSystem.State.recovering) { if (!commands.shield_mode) { if (commands.gun_trigger.fire_north) { fire_gun(AxesDirections.north); } if (commands.gun_trigger.fire_east) { fire_gun(AxesDirections.east); } if (commands.gun_trigger.fire_south) { fire_gun(AxesDirections.south); } if (commands.gun_trigger.fire_west) { fire_gun(AxesDirections.west); } } else { if (commands.gun_trigger.fire_north) { activate_shield(AxesDirections.north); } if (commands.gun_trigger.fire_east) { activate_shield(AxesDirections.east); } if (commands.gun_trigger.fire_south) { activate_shield(AxesDirections.south); } if (commands.gun_trigger.fire_west) { activate_shield(AxesDirections.west); } } } // We can always rotate for free. rotate_guns(commands.gun_move); }