/// <summary>
        /// Checks for collisions within its monitored objects.  Games CollisionManager's automatically have their Update functions called at the beginning of each update loop.
        /// </summary>
        /// <param name="gameTime">The current game time object.</param>
        public void Update(GameTime gameTime)
        {
            if (_enabled)
            {
                DrainAddQueue();
                DrainRemoveQueue();

                List<Collidable> collidables = _collidables.Values.ToList();
                Collidable first, second;

                for (var i = 0; i < collidables.Count; i++)
                {
                    first = collidables[i];

                    for (var j = i + 1; j < collidables.Count; j++)
                    {
                        second = collidables[j];

                        if (first.IsCollidingWith(second))
                        {
                            first.Collided(new CollisionData(second));
                            second.Collided(new CollisionData(first));
                            OnCollision(first, second);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initiates a new game object.
        /// </summary>
        public Game()
        {
            _gameTime = new GameTime();
            ID = Interlocked.Increment(ref GameIDs);
            CollisionManager = new CollisionManager();

            Configuration = new GameConfiguration(GameRunner.Instance.Register(this));
        }
 /// <summary>
 /// The Update function is triggered roughly 60 times per second by default (can be configured) and should be where all the game logic runs.
 /// </summary>
 /// <param name="gameTime">Represents the overall game time and how much time has passed since the last time the game updated.</param>
 public override void Update(GameTime gameTime)
 {
     // Iterate over each user and update them (this allows all of the players to move).
     foreach (var user in UserManager.Users)
     {
         user.Update(gameTime);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Triggered on a regular interval defined by the <see cref="GameConfiguration"/>.  Should be overridden to run game logic.
 /// </summary>
 /// <param name="gameTime">The global game time object.  Used to represent total time running and used to track update interval elapsed speeds.</param>
 public virtual void Update(GameTime gameTime)
 {
 }
Exemplo n.º 5
0
        public void Update(GameTime gameTime)
        {
            if (!this._isPlaying)
            {
                return;
            }

            this.Elapsed = this.Elapsed.Add(gameTime.Elapsed);

            if (this.Elapsed.TotalMilliseconds >= this.Duration.TotalMilliseconds)
            {
                this.Elapsed = this.Duration;
                this.Current = this.To.Clone();
                this._isPlaying = false;

                this.Changed(this.Current.Clone());
                this.Completed(this);
            }
            else
            {
                this.UpdateTween();
                this.Changed(this.Current.Clone());
            }

            foreach (var moveable in this.Moveables)
            {
                moveable.Position = this.Current.Clone();
                moveable.Rotation = Rotation;
            }
        }
 /// <summary>
 /// Updated by the MMO game object
 /// </summary>
 /// <param name="gameTime">Represents the overall game time and how much time has passed since the last time the game updated.</param>
 public void Update(GameTime gameTime)
 {
     // We update the MovementController so that it can move our player in the desired direction.
     MovementController.Update(gameTime);
 }