private void Move() { if (rising) { if (transform.position.y < MAXIMUM_HEIGHT) { Vector3 rise_position = transform.position; rise_position.y = MAXIMUM_HEIGHT; transform.position = Vector3.MoveTowards(transform.position, rise_position, movement_speed * EngineStrategy.GetDeltaTime()); } else { rising = false; Vector3 target_position = coordinate; target_position.y = MAXIMUM_HEIGHT; transform.position = target_position; } } else { UpdatePosition(); UpdateCoordinates(); UpdateShadow(); if ((transform.position - coordinate).magnitude > COLLISION_DISTANCE) { transform.position = Vector3.MoveTowards(transform.position, coordinate, movement_speed * EngineStrategy.GetDeltaTime()); } else { projectile_explosion.Explode(gameObject, explosion, transform.position, transform.rotation); } } }
public override void Update() { base.Update(); #endif if (!movements_locked) { platforming.DetectPlatform(); DeterminePlayerMovements(); CheckIfPlayerIsGettingCrushed(); if (!stunned) { move.Move(); rotate.Rotate(); } else { if (stun_timer > 0) { stun_timer -= EngineStrategy.GetDeltaTime(); } else { stunned = false; } } fall.Fall(); } }
private void Rotate() { if (rotation_angle > ROTATION_ANGLE_THRESHOLD) { transform.rotation = Quaternion.Slerp(transform.rotation, rotation, EngineStrategy.GetDeltaTime() * rotation_speed); } }
private void Move() { if ((transform.position - coordinate).magnitude > COLLISION_DISTANCE) { transform.position = Vector3.MoveTowards(transform.position, coordinate, movement_speed * EngineStrategy.GetDeltaTime()); } else { projectile_explosion.Explode(gameObject, explosion, transform.position, transform.rotation); } }
public void Fall() { if (is_falling == true) { CheckObstacle(); Vector3 fall_position = transform.position; fall_position.y -= 1; transform.position = Vector3.MoveTowards(transform.position, fall_position, fall_speed * EngineStrategy.GetDeltaTime()); transform.position += transform.forward * EngineStrategy.GetDeltaTime() * movement_speed_while_falling; } }
public virtual void Update() { #endif if (time_elapsed > 0) { time_elapsed -= EngineStrategy.GetDeltaTime(); } else { Rotate(); } }
private void LobProjectile() { float distance = (transform.position - coordinate).magnitude; float time = distance * movement_speed * EngineStrategy.GetDeltaTime(); if (time < PROJECTILE_LOB_MINIMUM_TIME) { time = PROJECTILE_LOB_MINIMUM_TIME; } Vector3 throwSpeed = calculateBestThrowSpeed(catapult_position, coordinate, time); body.AddForce(throwSpeed, ForceMode.VelocityChange); }
private void UpdateShadow() { foreach (Transform child in transform) { Vector3 shadow = child.position; shadow.y = SHADOW_HEIGHT_POSITION; child.position = shadow; Vector3 shadow_scale = child.localScale; shadow_scale.x += 0.5f * EngineStrategy.GetDeltaTime(); shadow_scale.z += 0.5f * EngineStrategy.GetDeltaTime(); child.localScale = shadow_scale; } }
public void MoveForwardOnIce() { CheckObstacleOnIce(); transform.position += transform.forward * EngineStrategy.GetDeltaTime() * (ice_movement_speed + extra_movement_speed) * speed_boost; if (extra_movement_speed > 0) { extra_movement_speed -= EngineStrategy.GetDeltaTime() * EXTRA_MOVEMENT_SPEED_INCREMENT * Math.Abs(extra_movement_speed); } else if (extra_movement_speed < 0) { extra_movement_speed += EngineStrategy.GetDeltaTime() * EXTRA_MOVEMENT_SPEED_INCREMENT * Math.Abs(extra_movement_speed); } }
public virtual void Update() { #endif if (time_elapsed > 0) { time_elapsed -= EngineStrategy.GetDeltaTime(); } else if (current_time_interval > 0) { current_time_interval -= EngineStrategy.GetDeltaTime(); } else { current_time_interval = time_interval; InstantiatePrefab(); } }
public void Move() { if (is_moving == true && (transform.position - move_point).magnitude > COLLISION_DISTANCE) { if (CheckObstacleCollision()) { transform.position = Vector3.MoveTowards(transform.position, move_point, movement_speed * EngineStrategy.GetDeltaTime()); } else { StopMoving(); } } else if (is_moving == true && (transform.position - move_point).magnitude <= COLLISION_DISTANCE) { StopMoving(); } }
private void Move() { if (no_rotation) { if ((transform.position - coordinates_list[move_point_index]).magnitude > COLLISION_DISTANCE) { transform.position = Vector3.MoveTowards(transform.position, coordinates_list[move_point_index], movement_speed * EngineStrategy.GetDeltaTime()); } else if (current_wait_time < 0) { current_wait_time = wait_time_between_moves; NextMovePoint(); } else { current_wait_time -= EngineStrategy.GetDeltaTime(); } } else { if (((transform.position - coordinates_list[move_point_index]).magnitude > COLLISION_DISTANCE) && (rotation_angle <= ROTATION_ANGLE_MOVE_THRESHOLD)) { transform.position = Vector3.MoveTowards(transform.position, coordinates_list[move_point_index], movement_speed * EngineStrategy.GetDeltaTime()); } else if (rotation_angle <= ROTATION_ANGLE_MOVE_THRESHOLD) { if (current_wait_time < 0) { current_wait_time = wait_time_between_moves; NextMovePoint(); CalculateRotationAngle(); } else { current_wait_time -= EngineStrategy.GetDeltaTime(); } } } }
private void Rotate() { if (rotation_angle > ROTATION_ANGLE_THRESHOLD) { CalculateRotationAngle(); transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation, EngineStrategy.GetDeltaTime() * rotation_speed); } else { if (current_wait_time <= 0) { current_wait_time = wait_time_between_rotations; NextRotationAngle(); CalculateRotationAngle(); } else { current_wait_time -= EngineStrategy.GetDeltaTime(); } } }
private bool WaitForTimers() { if (time_elapsed > 0) { time_elapsed -= EngineStrategy.GetDeltaTime(); } else if ((!random) && (current_time_interval > 0)) { current_time_interval -= EngineStrategy.GetDeltaTime(); } else if ((current_time_between_throws > 0) && ((current_throw_amount == throwing_amount) || (!random))) { current_time_between_throws -= EngineStrategy.GetDeltaTime(); } else if ((random) && (current_throw_time > 0) && (current_throw_amount < throwing_amount)) { current_throw_time -= EngineStrategy.GetDeltaTime(); } else { return(false); } return(true); }
public void RotateTorwardArrow() { if (rotating_with_arrow == true) { if (rotation_angle > ROTATION_ANGLE_THRESHOLD) { CalculateRotationAngle(); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, EngineStrategy.GetDeltaTime() * rotation_speed * STRAIGHT_ICE_ROTATION_SPEED_AMPLIFIER); } else { rotating_with_arrow = false; } } }
private void Move() { transform.position += transform.forward * EngineStrategy.GetDeltaTime() * movement_speed; }
public void Rotate() { if (is_rotating == true && rotation_angle > ROTATION_ANGLE_THRESHOLD) { CalculateRotationAngle(); if (!on_ice && !on_reverse_ice) { transform.rotation = Quaternion.Slerp(transform.rotation, rotation, EngineStrategy.GetDeltaTime() * rotation_speed); } else { if (total_degrees_rotated < degrees_to_rotate) { transform.rotation = Quaternion.Slerp(transform.rotation, rotation, EngineStrategy.GetDeltaTime() * ice_rotation_speed); } else { StopRotating(); } } total_degrees_rotated += Math.Abs(previous_angle - rotation_angle); previous_angle = rotation_angle; } else if (is_rotating == true && rotation_angle <= ROTATION_ANGLE_THRESHOLD) { StopRotating(); } }
public virtual void Update() { #endif if (trigger_on_collision) { if (current_teleport_wait_time > 0) { current_teleport_wait_time -= EngineStrategy.GetDeltaTime(); } else { if (teleporting) { if (transform.position.y > animation_y + COLLISION_DISTANCE) { Vector3 animation_position = transform.position; animation_position.y = animation_y; transform.position = Vector3.MoveTowards(transform.position, animation_position, TRIGGER_TELEPORT_ANIMATION_SPEED * EngineStrategy.GetDeltaTime()); } else { teleporting = false; Vector3 animation_position = coordinates_list[0]; animation_position.y = transform.position.y; transform.position = animation_position; move_point_index = 1; if (trigger_on_collision) { starting_wait_time = time_elapsed; triggered = false; } } } else { if (transform.position.y < default_y - COLLISION_DISTANCE) { Vector3 animation_position = transform.position; animation_position.y = default_y; transform.position = Vector3.MoveTowards(transform.position, animation_position, TRIGGER_TELEPORT_ANIMATION_SPEED * EngineStrategy.GetDeltaTime()); } else { if (triggered) { if (starting_wait_time > 0) { starting_wait_time -= EngineStrategy.GetDeltaTime(); } else { total_time_elapsed += EngineStrategy.GetDeltaTime(); Move(); if (!no_rotation) { Rotate(); } } } } } } } else { if (starting_wait_time > 0) { starting_wait_time -= EngineStrategy.GetDeltaTime(); } else { Move(); if (!no_rotation) { Rotate(); } } } }