Пример #1
0
        private void OnPlayerCollision(object sender, Physic2DCollisionEventArgs args)
        {
            RigidBody2D other = args.Body2DA == RigidBody ? args.Body2DB : args.Body2DA;

            if (other.Owner.Tag == Game.TAG_EYE)
            {
                EyeController eye = other.Owner.FindComponent <EyeController>();
                if (eye.IsHot && !IsProtected)
                {
                    Die();
                }
                else if (eye.IsCool && !HasEye())
                {
                    AttachEye(other.Owner);
                    Animation.CurrentAnimation = Game.PLAYER_SHRINKING;
                    Animation.Play();
                    animationRemaining = AnimationTransition;
                    playerAnimState    = PlayerAnimationState.Shrinking;
                }
            }
            else if (args.PointA.HasValue && args.PointB.HasValue &&
                     args.PointA.Value.Y == args.PointB.Value.Y &&
                     args.PointA.Value.X != args.PointB.Value.X)
            {
                ;//this.soundManager.PlaySound(SoundType.Contact);
                collidingBodies.Add(other);
            }
        }
Пример #2
0
        /// <summary>
        /// Handles Circle OnPhysicsCollision.
        /// </summary>
        /// <param name="sender">Sender Object.</param>
        /// <param name="args">Collision Arguments.</param>
        private void CircleRigidBody_OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
        {
            // Gets angle, updates Textblocks and Draws information marks
            float angle = (float)Math.Atan2(args.Normal.X, args.Normal.Y);

            this.circleTextBlock.Text = string.Format("Normal : {0}\nNormal Angle: {1}\nPointA : {2}\nPointB : {3}", args.Normal, MathHelper.ToDegrees(angle), args.PointA, args.PointB);
            this.CreateVolatileMark(args.PointA.Value.X, args.PointA.Value.Y, angle);
        }
Пример #3
0
        private void OnCrateCollision(object sender, Physic2DCollisionEventArgs args)
        {
            var   velocity = args.Body2DB.LinearVelocity;
            float length   = velocity.Length();
            float volume   = Math.Min(1, length / 5);

            var instance = this.soundManager.PlaySound(SoundType.CrateDrop, volume);
        }
Пример #4
0
 private void OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
 {
     // Gets angle, updates Textblocks and Draws information marks
     float angle = (float)Math.Atan2(args.Normal.X, args.Normal.Y);
     Labels.Add("Normal", args.Normal);
     Labels.Add("Angle", MathHelper.ToDegrees(angle));
     Labels.Add("PointA", args.PointA);
     Labels.Add("PointB", args.PointB);
     this.CreateVolatileMark(args.PointA.Value.X, args.PointA.Value.Y, angle);
 }
Пример #5
0
        private void OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
        {
            // Gets angle, updates Textblocks and Draws information marks
            float angle = (float)Math.Atan2(args.Normal.X, args.Normal.Y);

            Labels.Add("Normal", args.Normal);
            Labels.Add("Angle", MathHelper.ToDegrees(angle));
            Labels.Add("PointA", args.PointA);
            Labels.Add("PointB", args.PointB);
            this.CreateVolatileMark(args.PointA.Value.X, args.PointA.Value.Y, angle);
        }
Пример #6
0
        private void OnEyeCollision(object sender, Physic2DCollisionEventArgs args)
        {
            RigidBody2D other = args.Body2DA == RigidBody ? args.Body2DB : args.Body2DA;

            if (other.Owner.Tag == Game.TAG_EYE)
            {
                EyeController eye = other.Owner.FindComponent <EyeController>();
                if (eye.IsHot && IsAttached)
                {
                    player.Die();
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Handles Box On PhysicsCollision.
        /// </summary>
        /// <param name="sender">Sender Object.</param>
        /// <param name="args">Collision Arguments.</param>
        private void BoxRigidBody_OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
        {
            /// gets normal angle, updates textblocks and draws information marks
            float angle = (float)Math.Atan2(args.Normal.X, args.Normal.Y);

            this.boxTextBlock.Text = string.Format("Normal : {0}\nNormal Angle: {1}\nPointA : {2}\nPointB : {3}", args.Normal, MathHelper.ToDegrees(angle), args.PointA, args.PointB);
            this.CreateVolatileMark(args.PointA.Value.X, args.PointA.Value.Y, angle);

            // We could retrieve a second contact points on Collision. A circle only can get ONE contact point.
            if (args.PointB != Vector2.Zero)
            {
                this.CreateVolatileMark(args.PointB.Value.X, args.PointB.Value.Y, angle);
            }
        }
Пример #8
0
        /// <summary>
        /// Called when [on physic2 d collision].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="Physic2DCollisionEventArgs" /> instance containing the event data.</param>
        private void OnOnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
        {
            var controller = args.Body2DB.Owner.FindComponent <FallingBodyController>();

            if (controller == null)
            {
                return;
            }

            // Calculates the Damage by pad velocity
            var velocityMagnitude = args.Body2DB.LinearVelocity.Length();

            controller.Damage(velocityMagnitude / 100.0f);
        }
Пример #9
0
 private void OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
 {
     this.collisionCounter++;
     this.soundManager.PlaySound(SoundType.Contact);
 }
Пример #10
0
 private void OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
 {
     this.collisionCounter++;
     this.soundManager.PlaySound(SoundType.Contact);
 }
Пример #11
0
 /// <summary>
 /// Handles Circle OnPhysicsCollision.
 /// </summary>
 /// <param name="sender">Sender Object.</param>
 /// <param name="args">Collision Arguments.</param>
 private void CircleRigidBody_OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
 {
     // Gets angle, updates Textblocks and Draws information marks
     float angle = (float)Math.Atan2(args.Normal.X, args.Normal.Y);
     this.circleTextBlock.Text = string.Format("Normal : {0}\nNormal Angle: {1}\nPointA : {2}\nPointB : {3}", args.Normal, MathHelper.ToDegrees(angle), args.PointA, args.PointB);
     this.CreateVolatileMark(args.PointA.Value.X, args.PointA.Value.Y, angle);
 }
Пример #12
0
        /// <summary>
        /// Handles Box On PhysicsCollision.
        /// </summary>
        /// <param name="sender">Sender Object.</param>
        /// <param name="args">Collision Arguments.</param>
        private void BoxRigidBody_OnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
        {
            /// gets normal angle, updates textblocks and draws information marks
            float angle = (float)Math.Atan2(args.Normal.X, args.Normal.Y);
            this.boxTextBlock.Text = string.Format("Normal : {0}\nNormal Angle: {1}\nPointA : {2}\nPointB : {3}", args.Normal, MathHelper.ToDegrees(angle), args.PointA, args.PointB);
            this.CreateVolatileMark(args.PointA.Value.X, args.PointA.Value.Y, angle);

            // We could retrieve a second contact points on Collision. A circle only can get ONE contact point.
            if (args.PointB != Vector2.Zero)
            {
                this.CreateVolatileMark(args.PointB.Value.X, args.PointB.Value.Y, angle);
            }
        }
Пример #13
0
        private void OnCrateCollision(object sender, Physic2DCollisionEventArgs args)
        {
            var velocity = args.Body2DB.LinearVelocity;
            float length = velocity.Length();
            float volume = Math.Min(1, length/ 5);
            Labels.Add("Volume", volume);

            var instance = this.soundManager.PlaySound(SoundType.CrateDrop, volume);
        }
Пример #14
0
        /// <summary>
        /// Called when [on physic2 d collision].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="Physic2DCollisionEventArgs" /> instance containing the event data.</param>
        private void OnOnPhysic2DCollision(object sender, Physic2DCollisionEventArgs args)
        {
            var controller = args.Body2DB.Owner.FindComponent<FallingBodyController>();
            if (controller == null)
            {
                return;
            }

            // Calculates the Damage by pad velocity
            var velocityMagnitude = args.Body2DB.LinearVelocity.Length();
            controller.Damage(velocityMagnitude / 100.0f);
        }