Пример #1
0
        public static void Update()
        {
            if (!BasicSpriteRegistry.HigherLevel)
            {
                BasicSpriteRegistry.HigherLevel = false;
            }
            foreach (ISpriteInstance instance in BasicSpriteRegistry.Instances.Values)
            {
                int update = _advancedInstance.SpriteBase.Update(_advancedInstance);
                _advancedInstance = instance as IAdvancedSpriteInstance;
                if (_advancedInstance != null)
                {
                    if (_advancedInstance.Updating)
                    {
                        if (update == 0)
                        {
                            if (_advancedInstance.Speed <= 0)
                            {
                                throw new Exception("Instance: " + _advancedInstance.InstanceName + "'s speed must be greater than 0");
                            }
                            else
                            {
                                _gameFramePerAnimFrame = (1 / _advancedInstance.Speed) * (1 / _advancedInstance.Animation.BaseSpeed);
                            }

                            if (_gameFramePerAnimFrame < 0)
                            {
                                throw new Exception("Animation: " + _advancedInstance.Animation.AnimationName + " from Sprite:" + _advancedInstance.SpriteBase.SpriteID + " must have a speed greater than 0");
                            }
                            else if (_gameFramePerAnimFrame > 1)
                            {
                                if (_advancedInstance.InternalFrame >= _gameFramePerAnimFrame)
                                {
                                    _advancedInstance.InternalFrame = 0;
                                    _advancedInstance.Frame++;
                                }
                                else
                                {
                                    _advancedInstance.InternalFrame++;
                                }
                            }
                            else
                            {
                                _gameFramePerAnimFrame   = 1 / _gameFramePerAnimFrame;
                                _advancedInstance.Frame += (int)_gameFramePerAnimFrame;
                            }
                        }

                        _movinstance = instance as IMovingSpriteInstance;
                        if (_movinstance != null)
                        {
                            if (update == 0)
                            {
                                _movinstance.Location += _movinstance.Velocity;
                                _tempvect              = _movinstance.Velocity;
                                if (_movinstance.Velocity.X > 0)
                                {
                                    if (_movinstance.Velocity.X >= _movinstance.Deceleration.X)
                                    {
                                        _tempvect.X -= _movinstance.Deceleration.X;
                                    }
                                    else
                                    {
                                        _tempvect.X = 0;
                                    }
                                }
                                if (_movinstance.Velocity.X < 0)
                                {
                                    if (_movinstance.Velocity.X <= -_movinstance.Deceleration.X)
                                    {
                                        _tempvect.X += _movinstance.Deceleration.X;
                                    }
                                    else
                                    {
                                        _tempvect.X = 0;
                                    }
                                }
                                if (_movinstance.Velocity.Y > 0)
                                {
                                    if (_movinstance.Velocity.Y >= _movinstance.Deceleration.X)
                                    {
                                        _tempvect.Y -= _movinstance.Deceleration.Y;
                                    }
                                    else
                                    {
                                        _tempvect.Y = 0;
                                    }
                                }
                                if (_movinstance.Velocity.Y < 0)
                                {
                                    if (_movinstance.Velocity.Y <= -_movinstance.Deceleration.Y)
                                    {
                                        _tempvect.Y += _movinstance.Deceleration.Y;
                                    }
                                    else
                                    {
                                        _tempvect.Y = 0;
                                    }
                                }

                                _movinstance.Velocity = _tempvect;
                            }
                        }
                    }
                }
            }

            foreach (IMultiSpriteInstance _mulInstance in _multiInstances)
            {
                foreach (IMovingSpriteInstance inst in _mulInstance.Sprites)
                {
                    int update = _advancedInstance.SpriteBase.Update(inst);

                    if (_advancedInstance.Updating)
                    {
                        if (update == 0)
                        {
                            if (_advancedInstance.Speed <= 0)
                            {
                                throw new Exception("Instance: " + _advancedInstance.InstanceName + "'s speed must be greater than 0");
                            }
                            else
                            {
                                _gameFramePerAnimFrame = (1 / _advancedInstance.Speed) * (1 / _advancedInstance.Animation.BaseSpeed);
                            }

                            if (_gameFramePerAnimFrame < 0)
                            {
                                throw new Exception("Animation: " + _advancedInstance.Animation.AnimationName + " from Sprite:" + _advancedInstance.SpriteBase.SpriteID + " must have a speed greater than 0");
                            }
                            else if (_gameFramePerAnimFrame > 1)
                            {
                                if (_advancedInstance.InternalFrame >= _gameFramePerAnimFrame)
                                {
                                    _advancedInstance.InternalFrame = 0;
                                    _advancedInstance.Frame++;
                                }
                                else
                                {
                                    _advancedInstance.InternalFrame++;
                                }
                                if (_advancedInstance.Frame >= _advancedInstance.Animation.FrameCount)
                                {
                                    _advancedInstance.Frame = 0;
                                }
                            }
                            else
                            {
                                _gameFramePerAnimFrame   = 1 / _gameFramePerAnimFrame;
                                _advancedInstance.Frame += (int)_gameFramePerAnimFrame;
                                if (_advancedInstance.Frame >= _advancedInstance.Animation.FrameCount)
                                {
                                    _advancedInstance.Frame = 0;
                                }
                            }
                        }

                        if (update == 0)
                        {
                            _movinstance.Location += _movinstance.Velocity;
                            _tempvect              = _movinstance.Velocity;
                            if (_movinstance.Velocity.X > 0)
                            {
                                if (_movinstance.Velocity.X >= _movinstance.Deceleration.X)
                                {
                                    _tempvect.X -= _movinstance.Deceleration.X;
                                }
                                else
                                {
                                    _tempvect.X = 0;
                                }
                            }
                            if (_movinstance.Velocity.X < 0)
                            {
                                if (_movinstance.Velocity.X <= -_movinstance.Deceleration.X)
                                {
                                    _tempvect.X += _movinstance.Deceleration.X;
                                }
                                else
                                {
                                    _tempvect.X = 0;
                                }
                            }
                            if (_movinstance.Velocity.Y > 0)
                            {
                                if (_movinstance.Velocity.Y >= _movinstance.Deceleration.X)
                                {
                                    _tempvect.Y -= _movinstance.Deceleration.Y;
                                }
                                else
                                {
                                    _tempvect.Y = 0;
                                }
                            }
                            if (_movinstance.Velocity.Y < 0)
                            {
                                if (_movinstance.Velocity.Y <= -_movinstance.Deceleration.Y)
                                {
                                    _tempvect.Y += _movinstance.Deceleration.Y;
                                }
                                else
                                {
                                    _tempvect.Y = 0;
                                }
                            }

                            _movinstance.Velocity = _tempvect;
                        }
                    }
                }
            }
        }
Пример #2
0
 public void Move(Vector2 VelocityMod, IMovingSpriteInstance instance)
 {
 }
Пример #3
0
 public void MoveTo(Vector2 Location, int FramesToMove, IMovingSpriteInstance instance)
 {
 }
Пример #4
0
 public void Move(Vector2 Direction, int speed, IMovingSpriteInstance instance)
 {
 }
Пример #5
0
 public void AllStop(IMovingSpriteInstance instance)
 {
 }