Пример #1
0
        public PlayerBlob(Player owner, IGame game, IPhysics physics, IStateTracker stateTracker, Vector position, bool controlledByPlayer)
            : base(game, physics, stateTracker, position, game.Settings.MinPlayerBlobMass)
        {
            _physics = physics;
            Owner = owner;
            RecombineTicks = game.TickCount;
            ControlledByPlayer = controlledByPlayer;

            Mass = Game.Settings.MinPlayerBlobMass;

            MakeDynamic();
        }
Пример #2
0
        protected Blob(IGame game, IPhysics physics, IStateTracker stateTracker, Vector position, float mass)
        {
            _physics = physics;

            Game = game;
            StateTracker = stateTracker;
            Position = position;
            Mass = mass;

            IsStatic = false;
            _isCreated = false;

            Id = BlobIdProvider.GetId();
        }
Пример #3
0
 public MovePlayerCommand(float dx, float dy)
 {
     _direction = new Vector(dx, dy);
 }
Пример #4
0
        public void SyncWithPhysics(bool overrideAll)
        {
            if (_radiusOverride || overrideAll)
            {
                _body.Radius = _radius;
                _radiusOverride = false;
            }
            else
            {
                if (_radius != _body.Radius)
                {
                    StateTracker.UpdateBlob(this);
                }

                _radius = _body.Radius;
            }

            if (_positionOverride || overrideAll)
            {
                _body.Position = _position;
                _positionOverride = false;
            }
            else
            {
                if (_position != _body.Position)
                {
                    StateTracker.UpdateBlob(this);
                }

                _position = _body.Position;
            }

            if (_body.IsStatic)
            {
                return;
            }

            if (_velocityOverride || overrideAll)
            {
                _body.LinearVelocity = _velocity;
                _velocityOverride = false;
            }
            else
            {
                _velocity = _body.LinearVelocity;
            }

            if (_massOverride || overrideAll)
            {
                _body.Mass = _mass;
                _massOverride = false;
            }
            else
            {
                _mass = _body.Mass;
            }
        }
Пример #5
0
 public EjectedMassBlob(IGame game, IPhysics physics, IStateTracker stateTracker, Vector position)
     : base(game, physics, stateTracker, position)
 {
     MakeDynamic();
 }
Пример #6
0
 public FoodBlob(IGame game, IPhysics physics, IStateTracker stateTracker, Vector position)
     : base(game, physics, stateTracker, position, game.Settings.FoodMass)
 {
     MakeStatic();
 }
Пример #7
0
 public bool Equals(Vector other)
 {
     return Math.Abs(X - other.X) < Epsilon && Math.Abs(Y - other.Y) < Epsilon;
 }
Пример #8
0
 public float Dist(Vector other)
 {
     return (float)Math.Sqrt(Math.Pow(X - other.X, 2) + Math.Pow(Y - other.Y, 2));
 }