using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using TAPI;
using Terraria;
namespace MPT.Projectiles
{
public class GuideRay : ModProjectile
{
public override void AI()
{
projectile.light = 0.9f;
projectile.localAI[0] += 1f;
if (projectile.localAI[0] > 3f)
{
projectile.alpha = 255;
for (int thickness = 0; thickness < 1; thickness++)
{
int DustID1 = MPTDust.CreateGuideDust(new Vector2(projectile.position.X, projectile.position.Y - projectile.height/4), projectile.width, projectile.height);
}
}
}
//When it collides on a tile, produces Guide Gore!
public override bool OnTileCollide(ref Vector2 velocityChange)
{
if (projectile.velocity.X != velocityChange.X)
{
projectile.velocity.X = -velocityChange.X;
}
if (projectile.velocity.Y != velocityChange.Y)
{
projectile.velocity.Y = -velocityChange.Y;
}
int rand = Main.rand.Next(4);
if (rand == 0)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore1"], 1f);
else if (rand == 1)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 2)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 3)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
else
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
Main.PlaySound(4, (int)projectile.position.X, (int)projectile.position.Y, 1);
return false;
}
//When it hits things, spawn gore!
public override void DealtNPC(NPC n, int hitDir, int dmgDealt, float knockback, bool crit)
{
int rand = Main.rand.Next(4);
if (rand == 0)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore1"], 1f);
else if (rand == 1)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 2)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 3)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
else
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
Main.PlaySound(4, (int)projectile.position.X, (int)projectile.position.Y, 1);
}
public override void DealtPlayer(Player p, int hitDir, int dmgDealt, bool crit)
{
int rand = Main.rand.Next(4);
if (rand == 0)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore1"], 1f);
else if (rand == 1)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 2)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 3)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
else
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
Main.PlaySound(4, (int)projectile.position.X, (int)projectile.position.Y, 1);
}
//When the projectile dies, spawn gore!
public override void PostKill()
{
int rand = Main.rand.Next(4);
if (rand == 0)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore1"], 1f);
else if (rand == 1)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 2)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore2"], 1f);
else if (rand == 3)
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
else
Gore.NewGore(projectile.position, new Vector2(MathHelper.Lerp(-4f, 4f, (float)Main.rand.NextDouble()), -2), GoreDef.gores["MPT:GuideGore3"], 1f);
Main.PlaySound(4, (int)projectile.position.X, (int)projectile.position.Y, 1);
}
}
}