public override void update(float dt, double update_time, float flow_speed) { if (alive_) { if (destroy_start_ <= 0f) { if (!lock_target_.alive_) { destroy_start_ = update_time; rigidbody_.setVelocity(0f, 0f, flow_speed); } else { if (arrival_time_ < 1.5f) { var diff = lock_target_.updated_position_ - rigidbody_.transform_.position_; var accel = (diff / arrival_time_ - rigidbody_.velocity_) * 2f / arrival_time_; rigidbody_.setAcceleration(ref accel); } arrival_time_ -= dt; if (arrival_time_ <= 0f) { lock_target_.hit(); destroy_start_ = update_time; } } } else { rigidbody_.setVelocity(0f, 0f, 0f); if (update_time - destroy_start_ > 0.25f) { destroy(); return; } } rigidbody_.update(dt); if (trail_id_ >= 0) { var pos = rigidbody_.transform_.transformPosition(ref trail_locator_); if (destroy_start_ <= 0f) { flow_speed *= 0.25f; } else { flow_speed = 0f; } Trail.Instance.update(trail_id_, ref pos, dt, flow_speed * 0.25f, update_time); } } }
public override void update(float dt, float update_time) { if (alive_) { float flow_z = -20f * dt; if (destroy_start_ <= 0f) { if (!lock_target_.alive_) { destroy_start_ = update_time; rigidbody_.setVelocity(0f, 0f, flow_z); } else { if (arrival_time_ < 0.9f) { var diff = lock_target_.updated_position_ - rigidbody_.transform_.position_; var accel = (diff / arrival_time_ - rigidbody_.velocity_) * 2f / arrival_time_; rigidbody_.setAcceleration(ref accel); } // if (arrival_time_ > 0.5f && MyRandom.Probability(0.5f)) { // var theta = MyRandom.Range(0, Mathf.PI*2f); // rigidbody_.addForceX(Mathf.Sin(theta)*100f); // rigidbody_.addForceY(Mathf.Cos(theta)*100f); // } arrival_time_ -= dt; if (arrival_time_ < 0f) { lock_target_.hit(); destroy_start_ = update_time; } } } else { rigidbody_.setVelocity(0f, 0f, 0f); if (update_time - destroy_start_ > 0.25f) { destroy(); return; } } rigidbody_.update(dt); if (trail_id_ >= 0) { var pos = rigidbody_.transform_.transformPosition(ref trail_locator_); Trail.Instance.update(trail_id_, ref pos, flow_z, update_time); } } }