using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Trelamium.Projectiles;
namespace Trelamium.NPCs.IceEye
{
public class FrozenThing : ModNPC
{
public override void SetDefaults()
{
npc.name = "Frozen Thing";
npc.displayName = "Frozen Thing";
npc.npcSlots = 0.1f;
npc.aiStyle = -1;
aiType = -1;
npc.damage = 0;
npc.width = 56;
npc.height = 48;
npc.defense = 0;
npc.lifeMax = 1800;
npc.knockBackResist = 0f;
Main.npcFrameCount[npc.type] = 4;
npc.value = Item.buyPrice(0, 0, 0, 0);
npc.noGravity = true;
npc.chaseable = false;
npc.HitSound = SoundID.NPCHit1;
npc.rarity = 2;
}
public override void FindFrame(int frameHeight)
{
npc.frameCounter += 0.15f;
npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)npc.frameCounter;
npc.frame.Y = frame * frameHeight;
}
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return spawnInfo.player.ZoneSnow &&
!spawnInfo.player.ZoneTowerStardust &&
!spawnInfo.player.ZoneTowerSolar &&
!spawnInfo.player.ZoneTowerVortex &&
!spawnInfo.player.ZoneTowerNebula &&
!NPC.AnyNPCs(mod.NPCType("FrozenThing")) &&
!NPC.AnyNPCs(mod.NPCType("Glacier")) &&
!NPC.AnyNPCs(mod.NPCType("GlacierRun1")) &&
!Main.snowMoon && !Main.pumpkinMoon && NPC.downedMechBossAny ? 0f : 0.140f;
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = 1800;
npc.damage = 0;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 67, hitDirection, -1f, 0, default(Color), 1f);
}
if (npc.life <= 0)
{
for (int k = 0; k < 20; k++)
{
Dust.NewDust(npc.position, npc.width, npc.height, 67, hitDirection, -1f, 0, default(Color), 1f);
}
Vector2 spawnAt = npc.Center + new Vector2(0f, (float)npc.height / 2f);
NPC.NewNPC((int)spawnAt.X, (int)spawnAt.Y, mod.NPCType("Glacier"));
}
}
}
}