RotatedRelativePoint() public method

public RotatedRelativePoint ( Vector2 pos, bool rotateForward = true ) : Vector2
pos Vector2
rotateForward bool
return Vector2
Exemplo n.º 1
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 relativeCenter = player.RotatedRelativePoint(player.MountedCenter, true);

            float num5 = player.inventory[player.selectedItem].shootSpeed * item.scale;
            Vector2 vector2_3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - relativeCenter;
            if ((double)player.gravDir == -1.0)
                vector2_3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - relativeCenter.Y;
            Vector2 vector2_4 = Vector2.Normalize(vector2_3);
            if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                vector2_4 = -Vector2.UnitY;
            vector2_4 *= num5;
            item.velocity = vector2_4;

            float rotationOffset = 8;
            Vector2 projectilePos = player.Center;
            Vector2 spinningpoint = Vector2.Normalize(item.velocity) * rotationOffset;
            for (int i = 0; i < 2; ++i)
            {
                spinningpoint = Utils.RotatedBy(spinningpoint, Main.rand.NextDouble() * 0.25F, new Vector2());
                if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
                    spinningpoint = -Vector2.UnitY;

                float angle = (float)Math.Atan(speedY / speedX);
                Vector2 vector2 = new Vector2(projectilePos.X + 30 * (float)Math.Cos(angle), projectilePos.Y + 30 * (float)Math.Sin(angle));
                float mouseX = Main.mouseX + Main.screenPosition.X;
                if (mouseX < projectilePos.X)
                {
                    vector2 = new Vector2(projectilePos.X - 30 * (float)Math.Cos(angle), projectilePos.Y - 30 * (float)Math.Sin(angle));
                }

                Projectile.NewProjectile(vector2.X, vector2.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockBack, Main.myPlayer);
            }
            return false;
        }
Exemplo n.º 2
0
        public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 relativeCenter = player.RotatedRelativePoint(player.MountedCenter, true);

            float num5 = player.inventory[player.selectedItem].shootSpeed * item.scale;
            Vector2 vector2_3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - relativeCenter;
            if ((double)player.gravDir == -1.0)
                vector2_3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - relativeCenter.Y;
            Vector2 vector2_4 = Vector2.Normalize(vector2_3);
            if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                vector2_4 = -Vector2.UnitY;
            vector2_4 *= num5;
            item.velocity = vector2_4;

            float rotationOffset = 8;
            int positionOffset = 2;
            Vector2 projectilePos = player.Center + new Vector2(0, Main.rand.Next(-positionOffset, positionOffset + 1));
            Vector2 spinningpoint = Vector2.Normalize(item.velocity) * rotationOffset;
            spinningpoint = Utils.RotatedBy(spinningpoint, Main.rand.NextDouble() * 0.196349546313286 - 0.0981747731566429, new Vector2());
            if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
                spinningpoint = -Vector2.UnitY;

            float angle = (float)Math.Atan(speedY / speedX);
            Vector2 vector2 = new Vector2(projectilePos.X + 80F * (float)Math.Cos(angle), projectilePos.Y + 80F * (float)Math.Sin(angle));
            float mouseX = Main.mouseX + Main.screenPosition.X;
            if (mouseX < projectilePos.X)
            {
                vector2 = new Vector2(projectilePos.X - 80F * (float)Math.Cos(angle), projectilePos.Y - 80F * (float)Math.Sin(angle));
            }

            position = vector2;
            speedX = spinningpoint.X * 3; // * 3 for faster bullet speed.
            speedY = spinningpoint.Y * 3; // * 3 for faster bullet speed.
            return true; // Spawn the bullet with the changed position and rotation.
        }
Exemplo n.º 3
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 relativeCenter = player.RotatedRelativePoint(player.MountedCenter, true);

            float num5 = player.inventory[player.selectedItem].shootSpeed * item.scale;
            Vector2 vector2_3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - relativeCenter;
            if ((double)player.gravDir == -1.0)
                vector2_3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - relativeCenter.Y;
            Vector2 vector2_4 = Vector2.Normalize(vector2_3);
            if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                vector2_4 = -Vector2.UnitY;
            vector2_4 *= num5;
            item.velocity = vector2_4;

            float rotationOffset = 8;
            Vector2 spinningpoint = Vector2.Normalize(item.velocity) * rotationOffset;
            spinningpoint = Utils.RotatedBy(spinningpoint, Main.rand.NextDouble() * 0.196349546313286 - 0.0981747731566429, new Vector2());
            if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
                spinningpoint = -Vector2.UnitY;

            Projectile.NewProjectile(position.X, position.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockBack, item.owner);

            spinningpoint = Vector2.Normalize(item.velocity) * rotationOffset;
            spinningpoint = Utils.RotatedBy(spinningpoint, Main.rand.NextDouble() * 0.196349546313286 - 0.0981747731566429, new Vector2());
            if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
                spinningpoint = -Vector2.UnitY;
            Projectile.NewProjectile(position.X, position.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockBack, item.owner);
            return false;//return base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
        }
Exemplo n.º 4
0
 public override void HoldItem(Player player)
 {
     if (Main.rand.Next(player.itemAnimation > 0 ? 40 : 80) == 0)
     {
     }
     Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true);
     Lighting.AddLight(position, 1f, 1f, 1f);
 }
Exemplo n.º 5
0
		public override void HoldItem(Player player)
		{
			if (Main.rand.Next(player.itemAnimation > 0 ? 40 : 80) == 0)
			{
				Dust.NewDust(new Vector2(player.itemLocation.X + 16f * player.direction, player.itemLocation.Y - 14f * player.gravDir), 4, 4, mod.DustType("Sparkle"));
			}
			Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true);
			Lighting.AddLight(position, 1f, 1f, 1f);
		}