using System;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Regions;
using Server.Items;

namespace Server.Misc
{
    class RegionMusic
    {
		public static bool isLand( Region region )
		{
			if ( ( region.IsDefault || region.Name == null || region.Name == "" ) )
				return true;

			return false;
		}

		public static void MusicRegion( Mobile from, Map map, Point3D loc, Point3D old )
		{
			Region regOld = Region.Find( old, map );
			Region regNew = Region.Find( loc, map );
			bool changeMusic = true;

			if ( regOld != regNew )
			{
				if (	( regNew is BuildingRegion && regOld is InnRegion ) ||
						( regNew is InnRegion && regOld is BuildingRegion ) )
				{ changeMusic = true; }
				else if (
						regNew is TreasureRegion || regOld is TreasureRegion || 
						regNew is UnderworldEntrance || regOld is UnderworldEntrance || 
						regNew is GardenRegion || regOld is GardenRegion || 
						regNew is BuildingRegion || regOld is BuildingRegion || 
						regNew is GateRegion || regOld is GateRegion || 
						regNew is ShrineRegion || regOld is ShrineRegion || 
						regNew is HouseRegion || regOld is HouseRegion )
				{ changeMusic = false; }
				else if (
							( regNew is OutskirtRegion && regOld is TownRegion ) || 
							( regNew is TownRegion && regOld is OutskirtRegion )
						)
				{ changeMusic = false; }

				if ( changeMusic )
				{
					MusicName toPlay = LandMusic[Utility.Random(LandMusic.Length)];

					if ( regNew is CaveRegion )
						toPlay = CaveMusic[Utility.Random(CaveMusic.Length)];
					else if ( regNew is DungeonRegion )
						toPlay = DungeonMusic[Utility.Random(DungeonMusic.Length)];
					else if ( regNew is GraveRegion )
						toPlay = DungeonMusic[Utility.Random(DungeonMusic.Length)];
					else if ( regNew is DangerRegion )
						toPlay = DungeonMusic[Utility.Random(DungeonMusic.Length)];
					else if ( regNew is PirateRegion )
						toPlay = CaveMusic[Utility.Random(CaveMusic.Length)];
					else if ( regNew is InnRegion )
						toPlay = TavernMusic[Utility.Random(TavernMusic.Length)];
					else if ( regNew is BuildingRegion )
						toPlay = VillageMusic[Utility.Random(VillageMusic.Length)];
					else if ( regNew is TownRegion )
						toPlay = VillageMusic[Utility.Random(VillageMusic.Length)];
					else if ( regNew is OutskirtRegion )
						toPlay = VillageMusic[Utility.Random(VillageMusic.Length)];

					from.Send(PlayMusic.GetInstance(toPlay));
				}
			}
        }

        public static MusicName[] TavernMusic = new MusicName[]
        {
            MusicName.Tavern01,
            MusicName.Tavern02,
            MusicName.Tavern03,
            MusicName.Tavern04,
			MusicName.Tavern05
        };

        public static MusicName[] VillageMusic = new MusicName[]
        {
			MusicName.Britain1,
			MusicName.Bucsden,
			MusicName.Jhelom,
			MusicName.Magincia,
			MusicName.Minoc,
			MusicName.Ocllo,
			MusicName.Serpents,
			MusicName.Skarabra,
			MusicName.Trinsic,
			MusicName.Vesper,
			MusicName.Wind,
			MusicName.Yew,
			MusicName.InTown01,
			MusicName.Nujelm,
			MusicName.Cove,
			MusicName.Moonglow
        };

        public static MusicName[] CaveMusic = new MusicName[]
        {
            MusicName.Create1,
            MusicName.OldUlt02,
            MusicName.OldUlt03,
            MusicName.OldUlt05,
            MusicName.OldUlt06,
            MusicName.Samlethe,
			MusicName.Cave01,
			MusicName.Jungle_a,
			MusicName.Swamp_a,
			MusicName.Jungle_a
        };

        public static MusicName[] DungeonMusic = new MusicName[]
        {
            MusicName.OldUlt03,
            MusicName.OldUlt05,
            MusicName.Samlethe,
            MusicName.Dungeon9,
            MusicName.Dungeon2,
            MusicName.Dungeon3,
			MusicName.Approach
        };

        public static MusicName[] LandMusic = new MusicName[]
        {
            MusicName.Create1,
            MusicName.OldUlt02,
            MusicName.OldUlt03,
            MusicName.Linelle,
            MusicName.Forest_a,
            MusicName.Mountn_a,
            MusicName.Plains_a,
            MusicName.Victory,
            MusicName.Travel
        };
    }
}