public class Jukebox_Tile : ModTile
{
public static bool inUse = false;
public static bool alreadyPlaying = false;
public override void SetDefaults()
{
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX);
TileObjectData.newTile.Width = 2;
TileObjectData.newTile.Height = 3;
TileObjectData.newTile.StyleHorizontal = true;
TileObjectData.newTile.CoordinateHeights = new int[] {16,16,16};
TileObjectData.newTile.CoordinateWidth = 16;
TileObjectData.newTile.CoordinatePadding = 0;
TileObjectData.addTile(Type);
AddMapEntry(new Color(255, 71, 19), "Jukebox");
animationFrameHeight = 48;
}
public override void AnimateTile(ref int frame, ref int frameCounter)
{
if (!inUse)
{
frame = 0;
return;
}
if (++frameCounter == 12)
{
if (frame == 9) frame = 1; else frame++;
frameCounter = 0;
}
}
public override void RightClick(int i, int j)
{
inUse = !inUse;
if (alreadyPlaying) alreadyPlaying = !alreadyPlaying;
}
public override void NearbyEffects(int i, int j, bool closer)
{
Player player = Main.player[Main.myPlayer];
if (closer) {
((Jukebox_ModPlayer)player.GetModPlayer(mod, "Jukebox_ModPlayer")).closeToJukebox = true;
if (inUse)
((Jukebox_ModPlayer)player.GetModPlayer(mod, "Jukebox_ModPlayer")).setJukebox(true,JukeboxMod.randomNumber);
}
else
((Jukebox_ModPlayer)player.GetModPlayer(mod, "Jukebox_ModPlayer")).closeToJukebox = false;
}
}