Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Xna.Framework;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Terraria;
  6. using Terraria.ModLoader;
  7. using Terraria.ID;
  8.  
  9. namespace FlailOverload.Projectiles
  10. {
  11. public class Projectile : ModProjectile
  12. {
  13.  
  14.  
  15. public override void SetDefaults()
  16. {
  17. projectile.name = "MetallicFlailProjectile";
  18. projectile.width = 28;
  19. projectile.height = 28;
  20. projectile.friendly = true;
  21. projectile.penetrate = -1;
  22. projectile.melee = true;
  23.  
  24. projectile.aiStyle = 15;
  25. }
  26.  
  27.  
  28. public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color lightColor)
  29. {
  30.  
  31. Texture2D texture = ModLoader.GetTexture("FlailOverload/Projectiles/MetallicFlail_Chain");
  32.  
  33. Vector2 position = projectile.Center;
  34. Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;
  35. Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
  36. Vector2 origin = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
  37. float num1 = (float)texture.Height;
  38. Vector2 vector2_4 = mountedCenter - position;
  39. float rotation = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
  40. bool flag = true;
  41. if (float.IsNaN(position.X) && float.IsNaN(position.Y))
  42. flag = false;
  43. if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
  44. flag = false;
  45. while (flag)
  46. {
  47. if ((double)vector2_4.Length() < (double)num1 + 1.0)
  48. {
  49. flag = false;
  50. }
  51. else
  52. {
  53. Vector2 vector2_1 = vector2_4;
  54. vector2_1.Normalize();
  55. position += vector2_1 * num1;
  56. vector2_4 = mountedCenter - position;
  57. Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
  58. color2 = projectile.GetAlpha(color2);
  59. Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1.35f, SpriteEffects.None, 0.0f);
  60. }
  61. }
  62.  
  63. return true;
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement