Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Removed unnecessary helpers (Deg/Rad conversion)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jofairden committed Jul 11, 2017
1 parent 613aa4c commit 9705091
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 332 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,4 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
*.sln
30 changes: 6 additions & 24 deletions Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ namespace Tremor
public delegate void ExtraAction();
public static class Helper
{
/// <summary>
/// *Используется для перевода градусов в радианы*
/// </summary>
/// <param name="Grad">Градусов</param>
/// <returns>Возвращяет радианы</returns>
public static float GradtoRad(float Grad)
{
return Grad * (float)Math.PI / 180.0f;
}

public static Vector2 RandomPositin(Vector2 pos1, Vector2 pos2)
{
Random rnd = new Random();
Expand Down Expand Up @@ -48,16 +38,6 @@ public static Vector2 VelocityFPTP(Vector2 pos1, Vector2 pos2, float speed)
return move * (speed / (float)Math.Sqrt(move.X * move.X + move.Y * move.Y));
}

/// <summary>
/// *Используется для перевода радиан в градусы*
/// </summary>
/// <param name="Rad">Радианов</param>
/// <returns>Возвращяет градусы</returns>
public static float RadtoGrad(float Rad)
{
return Rad * 180.0f / (float)Math.PI;
}

/// <summary>
/// *Используется для нахождения ID ближайшего NPC к точке*
/// </summary>
Expand Down Expand Up @@ -176,10 +156,12 @@ public static Vector2 CenterPoint(Vector2 A, Vector2 B)
/// <returns>Возвращяет точку смещённую по заданым параметрам</returns>
public static Vector2 PolarPos(Vector2 Point, float Distance, float Angle, int XOffset = 0, int YOffset = 0)
{
Vector2 ReturnedValue = new Vector2();
ReturnedValue.X = (Distance * (float)Math.Sin(RadtoGrad(Angle)) + Point.X) + XOffset;
ReturnedValue.Y = (Distance * (float)Math.Cos(RadtoGrad(Angle)) + Point.Y) + YOffset;
return ReturnedValue;
Vector2 returnedValue = new Vector2
{
X = (Distance * (float)Math.Sin(MathHelper.ToDegrees(Angle)) + Point.X) + XOffset,
Y = (Distance * (float)Math.Cos(MathHelper.ToDegrees(Angle)) + Point.Y) + YOffset
};
return returnedValue;
}

/// <summary>*Вычисления того, произойдёт ли событие с заданым шансом в этот раз, или нет*</summary>
Expand Down
9 changes: 3 additions & 6 deletions Projectiles/BallChainPro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ public override void SetDefaults()
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ball n Chain");

}


public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - Helper.GradtoRad(90);
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override bool? CanHitNPC(NPC target)
Expand All @@ -56,9 +55,7 @@ public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
float num1 = texture.Height;
Vector2 vector2_4 = mountedCenter - position;
float rotation = (float)Math.Atan2(vector2_4.Y, vector2_4.X) - 1.57f;
bool flag = true;
if (float.IsNaN(position.X) && float.IsNaN(position.Y))
flag = false;
bool flag = !(float.IsNaN(position.X) && float.IsNaN(position.Y));
if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
flag = false;
while (flag)
Expand Down
9 changes: 4 additions & 5 deletions Projectiles/BerserkerPro.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terraria;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace Tremor.Projectiles
Expand All @@ -12,7 +13,6 @@ public class BerserkerPro : ModProjectile

public override void SetDefaults()
{

projectile.width = 18;
projectile.height = 34;
projectile.timeLeft = 6;
Expand All @@ -26,15 +26,14 @@ public override void SetDefaults()
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Berserker Sword");

}


public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.player[(int)projectile.ai[0]].Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.player[(int)projectile.ai[0]].Center, projectile.Center) - Helper.GradtoRad(90);
projectile.Center = Helper.PolarPos(Main.player[(int)projectile.ai[0]].Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.player[(int)projectile.ai[0]].Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override bool? CanHitNPC(NPC target)
Expand Down
11 changes: 3 additions & 8 deletions Projectiles/BrainSmasherPro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class BrainSmasherPro : ModProjectile

public override void SetDefaults()
{

projectile.width = 48;
projectile.height = 48;
projectile.timeLeft = 6;
Expand All @@ -29,15 +28,13 @@ public override void SetDefaults()
public override void SetStaticDefaults()
{
DisplayName.SetDefault("BrainSmasher");

}


public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.player[(int)projectile.ai[0]].Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.player[(int)projectile.ai[0]].Center, projectile.Center) - Helper.GradtoRad(90);
projectile.Center = Helper.PolarPos(Main.player[(int)projectile.ai[0]].Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.player[(int)projectile.ai[0]].Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override bool? CanHitNPC(NPC target)
Expand All @@ -56,9 +53,7 @@ public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
float num1 = texture.Height;
Vector2 vector2_4 = mountedCenter - position;
float rotation = (float)Math.Atan2(vector2_4.Y, vector2_4.X) - 1.57f;
bool flag = true;
if (float.IsNaN(position.X) && float.IsNaN(position.Y))
flag = false;
bool flag = !(float.IsNaN(position.X) && float.IsNaN(position.Y));
if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
flag = false;
while (flag)
Expand Down
9 changes: 3 additions & 6 deletions Projectiles/FungusBlueSword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class FungusBlueSword : ModProjectile

public override void SetDefaults()
{

projectile.width = 18;
projectile.height = 44;
projectile.timeLeft = 6;
Expand All @@ -27,28 +26,26 @@ public override void SetDefaults()
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Fungus Blue Sword");

}


public override Color? GetAlpha(Color lightColor)
{
return Color.White;
}


public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
if (Main.rand.Next(3) == 0)
{
target.AddBuff(31, 180, false);
}
}

public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - Helper.GradtoRad(90);
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override bool? CanHitNPC(NPC target)
Expand Down
4 changes: 2 additions & 2 deletions Projectiles/FungusYellowSword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public override void SetStaticDefaults()
public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - Helper.GradtoRad(90);
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
Expand Down
85 changes: 41 additions & 44 deletions Projectiles/PaladinHammerPro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,56 @@
namespace Tremor.Projectiles
{
public class PaladinHammerPro : ModProjectile
{
const float RotationSpeed = 0.05f;
const float Distanse = 48;
{
const float RotationSpeed = 0.05f;
const float Distanse = 48;

float Rotation;
float Rotation;

public override void SetDefaults()
{

projectile.width = 18;
projectile.height = 34;
projectile.timeLeft = 6;
projectile.melee = true;
projectile.aiStyle = -1;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ignoreWater = true;
}

public override void SetStaticDefaults()
{
DisplayName.SetDefault("PaladinHammerPro");

}
public override void SetDefaults()
{
projectile.width = 18;
projectile.height = 34;
projectile.timeLeft = 6;
projectile.melee = true;
projectile.aiStyle = -1;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ignoreWater = true;
}

public override void SetStaticDefaults()
{
DisplayName.SetDefault("PaladinHammerPro");
}

public override Color? GetAlpha(Color lightColor)
{
return Color.White;
}

public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - Helper.GradtoRad(90);
}
public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override bool? CanHitNPC(NPC target)
{
return !target.friendly;
}
public override bool? CanHitNPC(NPC target)
{
return !target.friendly;
}

public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);
for(int k = 0; k < projectile.oldPos.Length; k++)
{
Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
}
return true;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);
for (int k = 0; k < projectile.oldPos.Length; k++)
{
Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
Color color = projectile.GetAlpha(lightColor) * ((projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
}
return true;
}
}
}
65 changes: 31 additions & 34 deletions Projectiles/TrueBladeOne.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,45 @@

namespace Tremor.Projectiles
{
public class TrueBladeOne : ModProjectile
{
const float RotationSpeed = 0.05f;
const float Distanse = 50;
public class TrueBladeOne : ModProjectile
{
const float RotationSpeed = 0.05f;
const float Distanse = 50;

float Rotation;
float Rotation;

public override void SetDefaults()
{

projectile.width = 22;
projectile.height = 44;
projectile.timeLeft = 6;
projectile.melee = true;
projectile.aiStyle = -1;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ignoreWater = true;
}

public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Blade");

}
public override void SetDefaults()
{
projectile.width = 22;
projectile.height = 44;
projectile.timeLeft = 6;
projectile.melee = true;
projectile.aiStyle = -1;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ignoreWater = true;
}

public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Blade");
}

public override Color? GetAlpha(Color lightColor)
{
return Color.White;
}

public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, Helper.GradtoRad(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - Helper.GradtoRad(90);
}
public override void AI()
{
Rotation += RotationSpeed;
projectile.Center = Helper.PolarPos(Main.LocalPlayer.Center, Distanse, MathHelper.ToRadians(Rotation));
projectile.rotation = Helper.rotateBetween2Points(Main.LocalPlayer.Center, projectile.Center) - MathHelper.ToRadians(90);
}

public override bool? CanHitNPC(NPC target)
{
return !target.friendly;
}
}
public override bool? CanHitNPC(NPC target)
{
return !target.friendly;
}
}
}
Loading

0 comments on commit 9705091

Please sign in to comment.