public virtual void SpawnTrap() { Map map = this.Map; if ( map == null ) return; BaseTrap trap = null; int random = Utility.Random( 100 ); if ( 22 > random ) trap = new SawTrap( Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor ); else if ( 44 > random ) trap = new SpikeTrap( Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor ); else if ( 66 > random ) trap = new GasTrap( Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall ); else if ( 88 > random ) trap = new FireColumnTrap(); else trap = new MushroomTrap(); if ( trap == null ) return; if ( trap is FireColumnTrap || trap is MushroomTrap ) trap.Hue = 0x451; // try 10 times to find a valid location for ( int i = 0; i < 10; ++i ) { int x = Utility.Random( m_RegionBounds.X, m_RegionBounds.Width ); int y = Utility.Random( m_RegionBounds.Y, m_RegionBounds.Height ); int z = this.Z; if ( !map.CanFit( x, y, z, 16, false, false ) ) z = map.GetAverageZ( x, y ); if ( !map.CanFit( x, y, z, 16, false, false ) ) continue; trap.MoveToWorld( new Point3D( x, y, z ), map ); m_Traps.Add( trap ); return; } trap.Delete(); }
public virtual void SpawnTraps( Field Handeling ) { if ( Handeling.AllowTraps == false ) return; int numberOfTraps = Handeling.NumberOfTraps; int kindOfTrap = 0; Item trap = null; int randomValueX = 0; int randomValueY = 0; int negative = 0; for ( int i = 0; i < numberOfTraps; i++ ) { kindOfTrap = Utility.Random( 5 ); randomValueX = Utility.Random( 20 ); negative = Utility.Random( 2 ); if ( negative > 0 ) randomValueX *= -1; negative = Utility.Random( 2 ); randomValueY = Utility.Random( 20 ); if ( negative > 0 ) randomValueY *= -1; switch ( kindOfTrap ) { case 0: { trap = new FireColumnTrap(); break; } case 1: { trap = new GasTrap(); break; } case 2: { trap = new GiantSpikeTrap(); break; } case 3: { trap = new SawTrap(); break; } case 4: { trap = new SpikeTrap(); break; } } trap.Movable = false; trap.Location = new Point3D((spawnpoint.X + randomValueX), (spawnpoint.Y + randomValueY), (spawnpoint.Z)); trap.Map = spawnmap; Traps.Add(trap); } }