public override bool InArea(ViVector3 pos, float range) { ViDebuger.AssertWarning(_dirLeftAngle <= _dirRightAngle); float deltaX = pos.x - _center.x; float deltaY = pos.y - _center.y; float dir = ViMath2D.GetAngle(deltaX, deltaY); return((ViMath2D.Length2(_center.x, _center.y, pos.x, pos.y) < (_radius2 + range * range)) && (_dirLeftAngle <= dir && dir < _dirRightAngle)); }
public override void Start(float duration) { ViDebuger.AssertWarning(Target); if (Target == null) { Target = new ViSimpleProvider <ViVector3>(); } _velocity = ViVector3.ZERO; _duration = ViMathDefine.Max(0.01f, duration); ViVector3 targetPos = Target.Value; float distanceH = ViMath2D.Length(targetPos.x, targetPos.y, Translate.x, Translate.y); float distanceV = targetPos.z - Translate.z; float time = distanceV / m_GravityAcc / _duration; float preDeltaTime = _duration * 0.5f + time; float aftDeltaTime = _duration * 0.5f - time; _velocity.z = preDeltaTime * m_GravityAcc; }
public override void _Update(float deltaTime, ViVector3 target) { ViDebuger.AssertWarning(deltaTime > 0.0f); ViDebuger.AssertWarning(_speed > 0.0f); // // ViVector3 targetPos = Target.Value; float distanceH = ViMath2D.Length(targetPos.x, targetPos.y, Translate.x, Translate.y); float distanceV = targetPos.z - Translate.z; float time = distanceH / _speed; m_GravityAcc = -2.0f * (distanceV / (time * time) - _velocity.z / time); m_GravityAcc = ViMathDefine.Clamp(m_GravityAcc, -GRAVITY, 5.0f * GRAVITY); ViVector3 kDir = targetPos - Translate; kDir.z = 0.0f; kDir.Normalize(); _velocity.x = kDir.x * _speed; _velocity.y = kDir.y * _speed; _velocity.z -= m_GravityAcc * deltaTime; _direction = _velocity; _direction.Normalize(); }
public static void GetRotate(float angle, ref float x, ref float y) { ViMath2D.Rotate(ViMath2D.FRONT_X, ViMath2D.FRONT_Y, angle, ref x, ref y); }
public static float GetDirection(float x, float y) { return(ViMath2D.GetRotateAngle(ViMath2D.FRONT_X, ViMath2D.FRONT_Y, x, y)); }
public override bool InArea(ViVector3 pos, float range) { return(ViMath2D.Length2(_center.x, _center.y, pos.x, pos.y) < (_radius2 + range * range)); }
public override bool InArea(ViVector3 pos) { return(ViMath2D.Length2(_center.x, _center.y, pos.x, pos.y) < _radius2); }
public void Init(float front, float halfWidth) { _rotRect.Len = front; _rotRect.HalfWidth = halfWidth; _range = ViMath2D.Length(front, halfWidth); }