Esempio n. 1
0
        public void OnNewCollision(object sender, ICollisionInput args)
        {
            Guid entity1 = args.GetEntityKeys()[0];
            Guid entity2 = args.GetEntityKeys()[1];

            if (entity1 == _guid || entity2 == _guid)
            {
                _components.OfType <Move>().First().Velocity *= -1;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Receives collision event data, used to drive ball bounce behaviour
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void OnNewCollision(object sender, ICollisionInput args)
        {
            // SET 'entity1' to the first collider entity
            Guid entity1 = args.GetEntityKeys()[0];

            // SET 'entity2' to the second collider entity
            Guid entity2 = args.GetEntityKeys()[1];

            // IF one of the collider entities is the ball
            if (entity1 == _guid || entity2 == _guid)
            {
                // Flip the balls direction
                _facingDirectionX *= -1;

                // Increment the balls speed by 2
                _components.OfType <Move>().First().Speed = new Vector2(_components.OfType <Move>().First().Speed.X + 2, _components.OfType <Move>().First().Speed.Y);
            }
        }