// 运行这个效果 public void Go(Vector3 from, Vector3[] to = null, int index = 0) { Battle.BattleOver += DestorySelf; live_time_ = 0f; reach_back_index = index; if (to != null && to.Length == 0) { ClientLog.Instance.LogError("there is no TO point!"); } from_ = from; if (to == null) { crt_aim_ = new AimStruct(0, from_); } else { aimsQue_ = new Queue <AimStruct> (); for (int i = 0; i < to.Length; ++i) { aimsQue_.Enqueue(new AimStruct(i, to[i])); } crt_aim_ = aimsQue_.Dequeue(); //transform.LookAt(crt_aim_.pos_); } // 设置初始位置 SetStartPoint(); force_straight_ = false; active_ = true; }
void Update() { if (gameObject == null) { DestorySelf(); return; } // 不激活直接返回 if (!active_) { return; } //行为不是陨石的 if (eb_data_.work_type_ == EffectBehaviourData.WORKTYPE.T && eb_data_.id_ != 13) { transform.localRotation = Quaternion.identity; } // 生存时间累加 live_time_ += Time.deltaTime; if (eb_data_.dmage_hit1_ == -1) { beattack_timer_ = true; } if (beattack_timer_) { take_damage_time_ += Time.deltaTime; } // 目的地不为空才会有移动 if (crt_aim_ != null) { if (!effect_stop_move_) { // 直线行进 if (eb_data_.move_type_.Equals(EffectBehaviourData.MOVETYPE.Straight) || force_straight_) { transform.position = Vector3.Lerp(from_, crt_aim_.pos_, (lerp_time_ += Time.deltaTime) / eb_data_.move_time_); transform.LookAt(crt_aim_.pos_); } // 曲线行进 else if (eb_data_.move_type_.Equals(EffectBehaviourData.MOVETYPE.Bezier)) { transform.position = bezier_.GetPointAtTime((lerp_time_ += Time.deltaTime) / eb_data_.move_time_); } // 暂不处理 else { } } if (eb_data_.dmage_hit1_ > 0f && live_time_ > eb_data_.dmage_hit1_ && reach_call_back_1_ != null) { reach_call_back_1_(GetValidateIndex(crt_aim_.index_, reach_back_index)); reach_call_back_1_ = null; //受击计时器启动 beattack_timer_ = true; //特效停止移动 effect_stop_move_ = true; } // 如果初始点和目的地距离小于0.1f 则视为到达目的地 if (active_ && Vector3.Distance(transform.position, crt_aim_.pos_) < 0.1f) { // 调用到达回调 if (eb_data_.dmage_hit1_ == -2 && reach_call_back_1_ != null) { reach_call_back_1_(GetValidateIndex(crt_aim_.index_, reach_back_index)); reach_call_back_1_ = null; lerp_time_ = 0f; //受击计时器启动 beattack_timer_ = true; //特效停止移动 effect_stop_move_ = true; } } #region 处理自受击1开始的所有回调 if (take_damage_time_ > eb_data_.beattack_effect_ && eb_data_.beattack_effect_ != -1 && reach_call_back_eff_ != null) { reach_call_back_eff_(GetValidateIndex(crt_aim_.index_, reach_back_index)); reach_call_back_eff_ = null; } if (take_damage_time_ > eb_data_.pop_value_ && eb_data_.pop_value_ != -1 && reach_call_back_pop_ != null) { reach_call_back_pop_(GetValidateIndex(crt_aim_.index_, reach_back_index)); reach_call_back_pop_ = null; } if (take_damage_time_ > eb_data_.dmage_hit2_ && eb_data_.dmage_hit2_ != -1 && reach_call_back_2_ != null) { reach_call_back_2_(GetValidateIndex(crt_aim_.index_, reach_back_index)); reach_call_back_2_ = null; //特效继续移动 effect_stop_move_ = false; // 更新下一个目的地 if (aimsQue_ != null && aimsQue_.Count > 0 && active_) { from_ = transform.position; crt_aim_ = aimsQue_.Dequeue(); //transform.LookAt(crt_aim_.pos_); if (aimsQue_.Count == 0 && true /*feng skill*/) { transform.parent = null; force_straight_ = true; } } else { crt_aim_ = null; } } #endregion } if (eb_data_.shake_time_ != -1 && !cameraShake_ && live_time_ > eb_data_.shake_time_) { iTween.ShakePosition(Camera.main.gameObject, Vector3.one * 0.1f, 0.5f); cameraShake_ = true; } // 如果生存时间大于endTime则调用完成回调以便衔接下一个动作 if (live_time_ > eb_data_.end_time_ && finish_call_back_ != null) { DealNotExcuteHandler(); finish_call_back_(); finish_call_back_ = null; } // 生存时间大于销毁时间则销毁实例 if (eb_data_.destory_time_ > 0f && live_time_ > eb_data_.destory_time_) { DealNotExcuteHandler(); DestorySelf(); } }