private Vector3 Move(GameObject obj, Vector3 speed_vect, Vector3 accel_vect, float time) { m_StartTransform.transform.position = obj.transform.position; m_StartTransform.transform.rotation = obj.transform.rotation; Vector3 local_motion = speed_vect * time + accel_vect * time * time / 2; Vector3 word_target_pos; while (local_motion.magnitude > m_MaxMoveStep) { Vector3 child = Vector3.ClampMagnitude(local_motion, m_MaxMoveStep); local_motion = local_motion - child; word_target_pos = m_StartTransform.transform.TransformPoint(child); if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, word_target_pos)) { TriggerUtil.MoveObjTo(obj, word_target_pos); } else { word_target_pos = TriggerUtil.GetGroundPos(word_target_pos); TriggerUtil.MoveObjTo(obj, word_target_pos); } } else { TriggerUtil.MoveObjTo(obj, word_target_pos); } m_StartTransform.transform.position = obj.transform.position; } word_target_pos = m_StartTransform.transform.TransformPoint(local_motion); if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, word_target_pos)) { TriggerUtil.MoveObjTo(obj, word_target_pos); } else { word_target_pos = TriggerUtil.GetGroundPos(word_target_pos); TriggerUtil.MoveObjTo(obj, word_target_pos); } } else { TriggerUtil.MoveObjTo(obj, word_target_pos); } return(speed_vect + accel_vect * time); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } GameObject obj = senderObj.GfxObj; if (null == obj) { return(false); } GameObject target = senderObj.TargetGfxObj; if (null != senderObj.TrackEffectObj) { obj = senderObj.TrackEffectObj; target = senderObj.GfxObj; } if (curSectionTime < StartTime) { return(true); } switch (m_RelativeType) { case "RelativeSelf": SetTransformRelativeSelf(obj); break; case "RelativeTarget": SetTransformRelativeTarget(obj, target); break; case "RelativeWorld": obj.transform.position = m_Postion; obj.transform.rotation = Quaternion.Euler(m_Rotate); break; } if (m_IsUseTerrainHeight) { Vector3 terrain_pos = TriggerUtil.GetGroundPos(obj.transform.position); obj.transform.position = terrain_pos; } return(false); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } EntityInfo obj = senderObj.GfxObj; if (null == obj) { return(false); } if (curSectionTime < StartTime) { return(true); } switch (m_RelativeType) { case "RelativeSelf": SetTransformRelativeSelf(obj); break; case "RelativeTarget": SetTransformRelativeTarget(obj, senderObj.TargetGfxObj); break; case "RelativeWorld": obj.GetMovementStateInfo().SetPosition(m_Postion); obj.GetMovementStateInfo().SetFaceDir(Geometry.DegreeToRadian(m_Rotate.Y)); break; } if (m_IsUseTerrainHeight) { Vector3 terrain_pos = TriggerUtil.GetGroundPos(obj.GetMovementStateInfo().GetPosition3D()); obj.GetMovementStateInfo().SetPosition(terrain_pos); } return(false); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } GameObject obj = senderObj.GfxObj; if (null == obj) { return(false); } GameObject targetObj = senderObj.TargetGfxObj; if (null != senderObj.TrackEffectObj) { obj = senderObj.TrackEffectObj; targetObj = senderObj.GfxObj; } if (curSectionTime < StartTime) { return(true); } else if (curSectionTime <= StartTime + m_RealDuration) { if (!Prepare(senderObj, instance, obj, targetObj)) { return(false); } if (null != m_Curve && m_Curve.keys.Length >= 2) { float time = Mathf.Clamp01((curSectionTime - StartTime) * 1.0f / m_RealDuration); float val = m_Curve.Evaluate(time); Vector3 targetPos = Vector3.SlerpUnclamped(new Vector3(m_StartPos.x, m_StartPos.y, m_StartPos.z), new Vector3(m_TargetPos.x, m_StartPos.y, m_StartPos.z), val); if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos)) { TriggerUtil.MoveObjTo(obj, targetPos); } else { targetPos = TriggerUtil.GetGroundPos(targetPos); TriggerUtil.MoveObjTo(obj, targetPos); } } else { TriggerUtil.MoveObjTo(obj, targetPos); } } else { float dist = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity; Vector3 targetPos = obj.transform.position + m_Forward * dist; if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos)) { TriggerUtil.MoveObjTo(obj, targetPos); } else { targetPos = TriggerUtil.GetGroundPos(targetPos); TriggerUtil.MoveObjTo(obj, targetPos); } } else { TriggerUtil.MoveObjTo(obj, targetPos); } } return(true); } else { Vector3 diff = m_TargetPos - obj.transform.position; if (diff.sqrMagnitude > 0.01f) { Vector3 targetPos = m_TargetPos; if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos)) { TriggerUtil.MoveObjTo(obj, targetPos); } else { targetPos = TriggerUtil.GetGroundPos(targetPos); TriggerUtil.MoveObjTo(obj, targetPos); } } else { TriggerUtil.MoveObjTo(obj, targetPos); } } return(false); } }