示例#1
0
        public override void CollisionResponse(CollisionBox thisBox, CollisionBox otherBox, int collisionResponseType)
        {
            if (Spell == 20)
            {
                var projectileObj = otherBox.AbsParent as ProjectileObj;
                if (projectileObj != null && projectileObj.CollisionTypeTag != 2 && projectileObj.CanBeFusRohDahed)
                {
                    projectileObj.RunDestroyAnimation(false);
                }
            }
            var terrainObj = otherBox.Parent as TerrainObj;

            if (CollidesWithTerrain && !(otherBox.Parent is DoorObj) && terrainObj != null &&
                ((terrainObj.CollidesTop && terrainObj.CollidesBottom && terrainObj.CollidesLeft &&
                  terrainObj.CollidesRight) || CollidesWith1Ways))
            {
                var spell = Spell;
                if (spell != 3)
                {
                    if (spell == 7)
                    {
                        base.CollisionResponse(thisBox, otherBox, collisionResponseType);
                        IsWeighted = false;
                        ActivateEffect();
                        return;
                    }
                    if (spell != 12)
                    {
                        if (DestroysWithTerrain)
                        {
                            RunDestroyAnimation(false);
                            return;
                        }
                        AccelerationY = 0f;
                        AccelerationX = 0f;
                        IsWeighted    = false;
                    }
                    else
                    {
                        var value = CollisionMath.RotatedRectIntersectsMTD(thisBox.AbsRect, thisBox.AbsRotation,
                                                                           Vector2.Zero, otherBox.AbsRect, otherBox.AbsRotation, Vector2.Zero);
                        if (value != Vector2.Zero)
                        {
                            SoundManager.Play3DSound(this, Game.ScreenManager.Player, "Spike_Bounce_01",
                                                     "Spike_Bounce_02", "Spike_Bounce_03");
                            var heading = Heading;
                            var vector  = new Vector2(value.Y, value.X * -1f);
                            var pt      = 2f * (CDGMath.DotProduct(heading, vector) / CDGMath.DotProduct(vector, vector)) *
                                          vector - heading;
                            X          += value.X;
                            Y          += value.Y;
                            Orientation = MathHelper.ToRadians(CDGMath.VectorToAngle(pt));
                        }
                    }
                }
                else if (terrainObj.CollidesBottom && terrainObj.CollidesTop && terrainObj.CollidesLeft &&
                         terrainObj.CollidesRight)
                {
                    var vector2 = CollisionMath.RotatedRectIntersectsMTD(thisBox.AbsRect, thisBox.AbsRotation,
                                                                         Vector2.Zero, otherBox.AbsRect, otherBox.AbsRotation, Vector2.Zero);
                    base.CollisionResponse(thisBox, otherBox, collisionResponseType);
                    if ((vector2.Y <= 0f && vector2.X == 0f) || otherBox.AbsRotation != 0f)
                    {
                        AccelerationY = 0f;
                        AccelerationX = 0f;
                        IsWeighted    = false;
                    }
                }
                else if (!terrainObj.CollidesBottom && terrainObj.CollidesTop && !terrainObj.CollidesLeft &&
                         !terrainObj.CollidesRight)
                {
                    var vector3 = CollisionMath.RotatedRectIntersectsMTD(thisBox.AbsRect,
                                                                         thisBox.AbsRotation, Vector2.Zero, otherBox.AbsRect, otherBox.AbsRotation, Vector2.Zero);
                    if (vector3.Y <= 0f && AccelerationY > 0f)
                    {
                        base.CollisionResponse(thisBox, otherBox, collisionResponseType);
                        if ((vector3.Y <= 0f && vector3.X == 0f) || otherBox.AbsRotation != 0f)
                        {
                            AccelerationY = 0f;
                            AccelerationX = 0f;
                            IsWeighted    = false;
                        }
                    }
                }
            }
            else if (otherBox.Type != 0)
            {
                var spell2 = Spell;
                if (spell2 == 5)
                {
                    if (otherBox.AbsParent == Target)
                    {
                        CollisionTypeTag = 2;
                    }
                }
                else
                {
                    base.CollisionResponse(thisBox, otherBox, collisionResponseType);
                }
            }
        }