예제 #1
0
        public void Update(float aDeltaTime, float aTimeScale)
        {
            _delta = _particle.CurrentLifeTime / _particle.LifeTime;
            if (Preset.colour.animateColor)
            {
                _curColor   = (_useChild) ? _childSprite.color : _sprite.color;
                _curColor.r = AntMath.Lerp(_curColor.r, _endColor.r, _curve.Evaluate(_delta));
                _curColor.g = AntMath.Lerp(_curColor.g, _endColor.g, _curve.Evaluate(_delta));
                _curColor.b = AntMath.Lerp(_curColor.b, _endColor.b, _curve.Evaluate(_delta));
                _curColor.a = AntMath.Lerp(_curColor.a, _endColor.a, _curve.Evaluate(_delta));

                if (_useChild)
                {
                    _childSprite.color = _curColor;
                }
                else
                {
                    _sprite.color = _curColor;
                }
            }
            else if (_gradientColor)
            {
                if (_useChild)
                {
                    _childSprite.color = _gradient.Evaluate(_delta);
                }
                else
                {
                    _sprite.color = _gradient.Evaluate(_delta);
                }
            }
        }
예제 #2
0
        public void Reset(AntEmitter aEmitter)
        {
            _curColor      = Preset.colour.startColor;
            _endColor      = Preset.colour.endColor;
            _gradient      = Preset.colour.gradient;
            _curve         = Preset.colour.curveColor;
            _useChild      = Preset.colour.useChildSprite;
            _gradientColor = Preset.colour.gradientColor;
            IsActive       = (Preset.colour.animateColor || Preset.colour.gradientColor);

            if (Preset.colour.effectLifeTime)
            {
                _delta      = _particle.Effect.Duration / _particle.Effect.TotalDuration;
                _delta      = AntMath.TrimToRange(_delta, 0.0f, 1.0f);
                _curColor.r = AntMath.Lerp(_curColor.r, _endColor.r, _curve.Evaluate(_delta));
                _curColor.g = AntMath.Lerp(_curColor.g, _endColor.g, _curve.Evaluate(_delta));
                _curColor.b = AntMath.Lerp(_curColor.b, _endColor.b, _curve.Evaluate(_delta));
                _curColor.a = AntMath.Lerp(_curColor.a, _endColor.a, _curve.Evaluate(_delta));
            }

            if (_useChild)
            {
                _childSprite.color = _curColor;
            }
            else
            {
                _sprite.color = _curColor;
            }
        }
예제 #3
0
        public void Update(float aDeltaTime, float aTimeScale)
        {
            _delta = _particle.CurrentLifeTime / _particle.LifeTime;
            _dx    = AntMath.Lerp(_startScale.x, _endScale.x, _curveX.Evaluate(_delta));
            _dy    = AntMath.Lerp(_startScale.y, _endScale.y, _curveY.Evaluate(_delta));

            if (_useChild)
            {
                _childTransform.localScale = new Vector3(
                    _dx,
                    (_proportional)
                                                ? _dx
                                                : _dy,
                    1.0f
                    );
            }
            else
            {
                _transform.localScale = new Vector3(
                    _dx,
                    (_proportional)
                                                ? _dx
                                                : _dy,
                    1.0f
                    );
            }
        }
        public void Update(float aDeltaTime, float aTimeScale)
        {
            if (_movement.gravity)
            {
                _velocity.x += _movement.gravityFactor.x * aDeltaTime * aTimeScale;
                _velocity.y += _movement.gravityFactor.y * aDeltaTime * aTimeScale;

                if (_movement.rotate)
                {
                    Angle = AntMath.AngleDeg(_velocity);
                }
            }
            else
            {
                _delta      = _particle.CurrentLifeTime / _particle.LifeTime;
                _angle      = Angle * AntMath.RADIANS;
                _velocity.x = _speed * Mathf.Cos(_angle);
                _velocity.y = _speed * Mathf.Sin(_angle);

                if (_movement.animateSpeed)
                {
                    _speed = AntMath.Lerp(_startSpeed, _endSpeed, _movement.speedCurve.Evaluate(_delta));
                }
                else
                {
                    _speed += _movement.accel * aDeltaTime * aTimeScale;
                    _speed *= _movement.drag;
                }
            }

            _position           = _transform.position;
            _position.x        += _velocity.x * aDeltaTime * aTimeScale;
            _position.y        += _velocity.y * aDeltaTime * aTimeScale;
            _transform.position = _position;
        }
        public void Update(float aDeltaTime, float aTimeScale)
        {
            if (_needToInit)
            {
                _needToInit             = false;
                _trail.sortingLayerName = _particle.SortingLayer;
                _trail.sortingOrder     = _particle.SortingOrder;
                IsActive    = _preset.animateTime;
                _needToInit = false;
            }

            if (_preset.animateTime)
            {
                _delta      = _particle.CurrentLifeTime / _particle.LifeTime;
                _trail.time = AntMath.Lerp(_startTime, _preset.endTime, _preset.timeCurve.Evaluate(_delta));
            }
        }
예제 #6
0
        public void Reset(AntEmitter aEmitter)
        {
            IsActive      = Preset.scale.animateScale;
            _endScale     = Preset.scale.endScale;
            _startScale   = Vector2.zero;
            _startScale.x = Preset.scale.startScale.x + AntMath.RandomRangeFloat(Preset.scale.rndToScaleX);
            _startScale.y = Preset.scale.startScale.y + AntMath.RandomRangeFloat(Preset.scale.rndToScaleY);
            _curveX       = Preset.scale.scaleCurveX;
            _curveY       = Preset.scale.scaleCurveY;
            _useChild     = Preset.scale.useChildSprite;
            _proportional = Preset.scale.proportional;

            if (Preset.scale.effectLifeTime && !AntMath.Equal(_particle.Effect.lifeTime, 0.0f))
            {
                _delta        = _particle.Effect.Duration / _particle.Effect.TotalDuration;
                _delta        = AntMath.TrimToRange(_delta, 0.0f, 1.0f);
                _startScale.x = AntMath.Lerp(_startScale.x, Preset.scale.endScale.x, _curveX.Evaluate(_delta));
                _startScale.y = AntMath.Lerp(_startScale.y, Preset.scale.endScale.y, _curveY.Evaluate(_delta));
            }

            if (Preset.scale.useChildSprite)
            {
                _childTransform.localScale = new Vector3(
                    _startScale.x,
                    (Preset.scale.proportional)
                                                ? _startScale.x
                                                : _startScale.y,
                    1.0f
                    );
            }
            else
            {
                _transform.localScale = new Vector3(
                    _startScale.x,
                    (Preset.scale.proportional)
                                                ? _startScale.x
                                                : _startScale.y,
                    1.0f
                    );
            }
        }
        private void UpdateMovement()
        {
            if (AntMath.Distance(_currentPoint, (Vector2)_t.position) < 0.5f)
            {
                // Arrived to the current way point.
                _pointIndex++;
                if (_pointIndex < _route.Count)
                {
                    // Move to next one.
                    _currentPoint = _route[_pointIndex];
                }
                else
                {
                    // This is end of the way.
                    float dist = AntMath.Distance(_currentPoint, (Vector2)_t.position);
                    if (dist < 0.5f)
                    {
                        // Enable break.
                        _speed   = AntMath.Lerp(_speed, 0.0f, 1.0f - breakCurve.Evaluate(dist / 0.5f));
                        _isBrake = true;
                    }

                    if (AntMath.Equal(_speed, 0.0f, 0.1f))
                    {
                        // Absolutely arrived.
                        StopMove();
                        if (EventArrived != null)
                        {
                            EventArrived(this);
                        }
                    }
                }

                _steeringTime = 0.0f;
                _isSteering   = false;
            }

            float targetAngle = AntMath.Angle(AntMath.AngleDeg(_t.position, _currentPoint));

            _debugTargetAngle = targetAngle * AntMath.RADIANS;
            float angleDiff = AntMath.AngleDifference(Angle, targetAngle) * AntMath.DEGREES;

            // If our direction incorrect.
            if (!AntMath.Equal(angleDiff, 0.0f, 0.01f) && !_isSteering)
            {
                // Correct our angle to the current way point.
                _isSteering        = true;
                _steeringTime      = 0.0f;
                _totalSteeringTime = totalSteeringTime * (1.0f - Mathf.Abs(angleDiff / 360.0f));
            }

            // Acceleration!
            if (!_isBrake && _accelerationTime < totalAccelTime)
            {
                _accelerationTime += Time.deltaTime;
                _speed             = AntMath.Lerp(_speed, moveSpeed, accelCurve.Evaluate(_accelerationTime / totalAccelTime));
            }

            // Correction of the angle.
            if (_isSteering)
            {
                _steeringTime += Time.deltaTime;
                Angle          = AntMath.LerpAngleDeg(Angle, targetAngle, steeringCurve.Evaluate(_steeringTime / _totalSteeringTime));
                if (AntMath.Equal(angleDiff, 0.0f, 0.01f))
                {
                    _isSteering   = false;
                    _steeringTime = 0.0f;
                }
            }

            // Movement.
            float ang = Angle * AntMath.RADIANS;

            Velocity = new Vector2(_speed * Mathf.Cos(ang), _speed * Mathf.Sin(ang));
        }