Example #1
0
 public static Microsoft.Xna.Framework.Rectangle ShrinkRectangle(Microsoft.Xna.Framework.Rectangle rectToShrink)
 {
     rectToShrink.Inflate(
         Math.Min(0, (1920 - rectToShrink.Width) / 2),
         Math.Min(0, (1200 - rectToShrink.Height) / 2));
     return(rectToShrink);
 }
        public static Rectangle Deflated(this Rectangle rect, int width, int height)
        {
            Rectangle copy = rect;

            copy.Inflate(-width, -height);

            return(copy);
        }
        public static Rectangle Deflated(this Rectangle rect, Size size)
        {
            Rectangle copy = rect;

            copy.Inflate(-size.Width, -size.Height);

            return(copy);
        }
        public override bool PreAI(Projectile projectile)
        {
            if (hasTeleported && teleportWhoAmI != -1)
            {
                Microsoft.Xna.Framework.Rectangle otherBox = Main.projectile[teleportWhoAmI].Hitbox;
                otherBox.Inflate(10, 10);

                if (!projectile.Hitbox.Intersects(otherBox))
                {
                    hasTeleported  = false;
                    teleportWhoAmI = -1;
                }
            }
            return(true);
        }
Example #5
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            player.jumpBoost = true;
            player.autoJump  = true;
            player.noFallDmg = true;

            if (!player.mount.Active && player.velocity.Y > 0f)
            {
                Microsoft.Xna.Framework.Rectangle checkDamagePlayer = player.getRect();
                checkDamagePlayer.Offset(0, player.height - 1);
                checkDamagePlayer.Height = 2;
                checkDamagePlayer.Inflate(12, 6);
                for (int i = 0; i < 200; i++)
                {
                    NPC npc = Main.npc[i];
                    if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[player.whoAmI] == 0)
                    {
                        Microsoft.Xna.Framework.Rectangle checkDamageNPC = npc.getRect();
                        if (checkDamagePlayer.Intersects(checkDamageNPC) && (npc.noTileCollide || Collision.CanHit(player.position, player.width, player.height, npc.position, npc.width, npc.height)))
                        {
                            var   damage    = 20f * player.meleeDamage;
                            float knockBack = 5f;
                            int   direction = npc.direction;
                            if (npc.velocity.X < 0f)
                            {
                                direction = -1;
                            }
                            if (npc.velocity.X > 0f)
                            {
                                direction = 1;
                            }
                            npc.StrikeNPC((int)damage, knockBack, direction, Main.rand.Next(2) == 0 ? true : false, false, false);
                            if (Main.netMode != NetmodeID.SinglePlayer)
                            {
                                NetMessage.SendData(MessageID.StrikeNPC, -1, -1, NetworkText.FromLiteral(""), npc.whoAmI, 1, knockBack, direction, (int)damage);
                            }
                            npc.immune[player.whoAmI] = 10;
                            player.velocity.Y         = -10f;
                            player.immune             = true;
                            break;
                        }
                    }
                }
            }
        }
Example #6
0
 public override void Update(Player player, ref int buffIndex)
 {
     player.mount.SetMount(ModContent.MountType <EmeraldSlime>(), player);
     player.buffTime[buffIndex]   = 10;
     player.armorEffectDrawShadow = true;
     if (player.wet)
     {
         player.wetSlime = 30;
         if (player.velocity.Y > 2f)
         {
             player.velocity.Y = player.velocity.Y * 0.9f;
         }
         player.velocity.Y = player.velocity.Y - 1f;
         if (player.velocity.Y < -5f)
         {
             player.velocity.Y = -5f;
         }
         if (player.controlJump)
         {
             player.velocity.Y = -20f;
         }
     }
     Microsoft.Xna.Framework.Rectangle checkDamagePlayer = player.getRect();
     checkDamagePlayer.Offset(0, player.height - 1);
     checkDamagePlayer.Height = 2;
     checkDamagePlayer.Inflate(12, 6);
     for (int i = 0; i < 200; i++)
     {
         NPC npc = Main.npc[i];
         if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[player.whoAmI] == 0)
         {
             Microsoft.Xna.Framework.Rectangle checkDamageNPC = npc.getRect();
             if (checkDamagePlayer.Intersects(checkDamageNPC) && (npc.noTileCollide || Collision.CanHit(player.position, player.width, player.height, npc.position, npc.width, npc.height)))
             {
                 var   damage    = 60f * player.meleeDamage;
                 float knockBack = 5f;
                 int   direction = player.direction;
                 if (player.velocity.X < 0f)
                 {
                     direction = -1;
                 }
                 if (player.velocity.X > 0f)
                 {
                     direction = 1;
                 }
                 if (player.whoAmI == Main.myPlayer)
                 {
                     npc.StrikeNPC((int)damage, knockBack, direction, false, false, false);
                     if (Main.netMode != NetmodeID.SinglePlayer)
                     {
                         NetMessage.SendData(MessageID.StrikeNPC, -1, -1, NetworkText.FromLiteral(""), npc.whoAmI, 1, knockBack, direction, (int)damage);
                     }
                 }
                 npc.immune[player.whoAmI] = 10;
                 player.velocity.Y         = -20f;
                 player.immune             = true;
                 break;
             }
         }
     }
 }