Ejemplo n.º 1
0
        public override void HandleCollision(Sprite collidedWith, Rectangle overlap)
        {
            if (collidedWith is IHandHeld)
            {
                HandHeld hh = (HandHeld)collidedWith;
                if (hh.inCombat)
                {
                    harvesting = true;
                }

                // hit from what direction
                if (!animateHarvest)
                {
                    animateLeft = animateRight = false;

                    if (collidedWith.GetBoundingBox().Left < GetBoundingBox().Left)  //left side collision
                    {
                        animateRight = true;
                    }
                    else if (collidedWith.GetBoundingBox().Right > GetBoundingBox().Right) // right side collision
                    {
                        animateLeft = true;
                    }

                    // one or the other
                    animateLeft = !animateRight;
                }
            }
        }
Ejemplo n.º 2
0
        // Ship collision handler
        public override void HandleCollision(Sprite collidedWith, Rectangle overlap)
        {
            if (collidedWith is IWeapon) // weapons don't stop ship movement - its own weapons have already been filtered out
            {
                colliding = false;
            }

            if (collidedWith is IAmmo)
            {
                showHealthBar = true;
                Ammo ball = (Ammo)collidedWith;
                if (!ball.exploded)
                {
                    health -= ball.structureDamage;
                }
                return;
            }

            if (collidedWith.GetType().BaseType == typeof(Gusto.Models.Animated.HandHeld))
            {
                HandHeld handHeld = (HandHeld)collidedWith;
                showHealthBar = true;
                health       -= handHeld.damage;
            }

            if (collidedWith.bbKey.Equals("landTile"))
            {
                colliding   = false;
                hittingLand = true;
                if (!anchored)
                {
                    showHealthBar = true;
                    health       -= 1;
                }
                anchored = true;
                return;
            }

            if (collidedWith.bbKey.Equals("playerPirate") || collidedWith is INPC)
            {
                colliding = false;
                return;
            }

            if (collidedWith is IShip)
            {
                colliding = false;
                anchored  = true;

                Ship sh = (Ship)collidedWith;
                if (sh.teamType != teamType)
                {
                    boardingShipInteriorId = sh.shipInterior.interiorId;
                }
            }
        }
Ejemplo n.º 3
0
        public override void HandleCollision(Sprite collidedWith, Rectangle overlap)
        {
            if (collidedWith.GetType().BaseType == typeof(Gusto.Models.Animated.HandHeld))
            {
                HandHeld handHeld = (HandHeld)collidedWith;
                showHealthBar = true;
                health       -= handHeld.damage;
            }
            else if (collidedWith.bbKey.Equals("landTile") || collidedWith.bbKey.Equals("interiorTile"))
            {
                TilePiece tp = (TilePiece)collidedWith;

                colliding    = false;
                mapCordPoint = tp.mapCordPoint;

                // narrow the collision to just the feet (appears more realistic)
                Rectangle footSpace = new Rectangle(GetBoundingBox().Left, GetBoundingBox().Bottom - (GetBoundingBox().Height / 3), GetBoundingBox().Width, GetBoundingBox().Height / 3);
                if (footSpace.Intersects(collidedWith.GetBoundingBox()))
                {
                    swimming = false;
                }
            }

            else if (collidedWith is IGroundObject)
            {
                colliding = false;
            }

            else if (collidedWith.bbKey.Equals("interiorTileWall"))
            {
                colliding = false;
            }

            else if (collidedWith is IWalks || collidedWith is IShip || collidedWith is IPlaceable || collidedWith is IInventoryItem || collidedWith is IStructure)
            {
                colliding = false;
            }
            else if (collidedWith is IAmmo)
            {
                showHealthBar = true;
                Ammo ball = (Ammo)collidedWith;   // TODO: bug NPC gets hit here by its own ships cannonballs
                if (!ball.exploded && ball.teamType != teamType)
                {
                    health -= ball.groundDamage;
                }
                return;
            }
        }
Ejemplo n.º 4
0
 public override void HandleCollision(Sprite collidedWith, Rectangle overlap)
 {
     // grass walk through animation
     if (collidedWith is IWalks && collidedWith.moving && !animateWalkThrough)
     {
         animateWalkThrough = true;
     }
     if (collidedWith is IHandHeld)
     {
         HandHeld hh = (HandHeld)collidedWith;
         if (hh.inCombat)
         {
             harvesting = true;
         }
     }
 }