Пример #1
0
        public override void Update(IGameTimeService gameTime)
        {
            base.Update(gameTime);

            float lifeFraction = (TimeKeeper.MsSinceInitialization - _creationTime) / Stats.Lifetime;

            float gravFraction = 1 - Stats.NonGravityFraction;

            _gravityObject.Position = Position;
            if (lifeFraction > Stats.NonGravityFraction)
            {
                _gravityObject.Gravitate(bodiesInArea);
            }

            //Check if its time to flip gravity
            if (_currentFlipPoint < flipPoints.Count)
            {
                if (lifeFraction > flipPoints[_currentFlipPoint])
                {
                    float gravVal = (Stats.FinalGravityVal - Stats.InitialGravityVal) / Stats.NumFlips * (_currentFlipPoint + 1);
                    _gravityObject.GravVal *= -1 * Math.Sign(_gravityObject.GravVal) * gravVal;
                    _currentFlipPoint++;
                }
            }
        }