Exemplo n.º 1
0
        void Update()
        {
            //Update periodically
            if (Time.frameCount % updateInterval == 0)
            {
                cachedEnemies = FindObjectsOfType <EntityEnemy>();
                cachedAnimals = FindObjectsOfType <EntityAnimal>();
                cachedNPCs    = FindObjectsOfType <EntityNPC>();
            }

            if (Input.GetKeyDown(KeyCode.Insert))
            {
                //Change the boolean to it's counterpart state - i.e. from false to true and vice versa
                toggleWindow = !toggleWindow;
            }

            if (Input.GetKey(KeyCode.LeftAlt))
            {
                EntityEnemy targetEnemy = GetClosestEnemy(cachedEnemies);
                if (targetEnemy == null)
                {
                    EntityAnimal targetAnimal = GetClosestAnimal(cachedAnimals);
                    AutoAim(targetAnimal);
                }
                AutoAim(targetEnemy);
            }
        }
Exemplo n.º 2
0
        private void AutoAim(EntityEnemy target)
        {
            if (target != null)
            {
                Vector3 targetHead = target.emodel.GetHeadTransform().position;
                if (target.IsAlive() && Vector3.Distance(cam.transform.position, targetHead) <= espRange && Vector3.Angle(cam.transform.forward, targetHead - cam.transform.position) < cam.fieldOfView)
                {
                    Vector3 targetHeadPOS_w2s = cam.WorldToScreenPoint(targetHead);
                    if (new Regex("7 Days").IsMatch(Win32.GetActiveWindowTitle()))
                    {
                        MoveMouse((int)Math.Round(targetHeadPOS_w2s.x), (int)(Screen.height - Math.Round(targetHeadPOS_w2s.y)));

                        /*float yaw = CalculateYaw(target);
                         * float pitch = CalculatePitch(target);
                         * fpCam.Yaw = yaw;
                         * fpCam.Pitch = pitch;
                         * debugMsg = String.Format(
                         *  "N:{0}\nMe:{1}\nD:{2}\neX:{3}\neY:{4}\nT:{5}",
                         *  target.EntityName,
                         *  fpCam.transform.position.ToString(),
                         *  Math.Round(Vector3.Distance(cam.transform.position, targetHead)),
                         *  Math.Round(fpCam.Pitch),
                         *  Math.Round(fpCam.Yaw),
                         *  targetHead.ToString());*/
                    }
                }
            }
        }
Exemplo n.º 3
0
            static void Postfix(EntityEnemy _zombie)
            {
                var zombieGameObj = _zombie.gameObject;

                asset.GetNormalShader(zombieGameObj);
                asset.ApplyWallhackShader(zombieGameObj);
            }
Exemplo n.º 4
0
        public static List <Item> GenereateLoot(EntityEnemy enemy)
        {
            List <Item> loot      = new List <Item>();
            int         lootItems = GameStorage.Random.Next(3);

            for (int i = 0; i < lootItems; i++)
            {
                double itemRandom = GameStorage.Random.NextDouble();

                if (itemRandom <= 0.1)
                {
                    loot.Add(new Item()
                    {
                        Rarity = ItemRarity.Rare, Name = "A Rare Item", GoldValue = 0
                    });
                }
                else if (itemRandom <= 0.11)
                {
                    loot.Add(new Item()
                    {
                        Rarity = ItemRarity.Special, Name = "A Special Item", GoldValue = 0
                    });
                }
                else if (itemRandom <= 0.51)
                {
                    loot.Add(NormalItems.GetRandomNormalItem());
                }
                else
                {
                    loot.Add(JunkItems.GetRandomJunkItem());
                }
            }

            return(loot);
        }
Exemplo n.º 5
0
 public void Loot(EntityEnemy toLoot)
 {
     AddGold(toLoot.GoldValue);
     foreach (Item i in toLoot.Loot)
     {
         Backpack.Add(i);
     }
 }
Exemplo n.º 6
0
    public BaseStateAction(Entity owner, bool seperateUpdate = false)
    {
        this.owner = owner;
        RunUpdate  = seperateUpdate;

        if (owner is EntityEnemy)
        {
            EntityEnemy enemy = owner as EntityEnemy;
            brain = enemy.Brain;
        }
    }
Exemplo n.º 7
0
 /// <summary>
 /// Erstellt anhand der in den DungeonGenArgs angegebenen Zahl pro Raum Gegner und platziert sie zufällig
 /// </summary>
 private void SpawnEnemies()
 {
     foreach (Room r in d.Rooms)
     {
         int enemyCount = (int)Math.Round((rnd.NextFloatGaussian(0.5f) + 0.5) * d.Args.EnemiesPerRoom);
         for (int i = 0; i < enemyCount; i++)
         {
             EntityEnemy enem = (EntityEnemy)rnd.PickElements(enemyTypes, 1)[0].GetConstructors()[0].Invoke(new object[] { d.Bounds }); // sucht einen Gegnertyp zufällig aus und erstellt ein Objekt dessen
             enem.Position = (new Vector(r.X, r.Y) + new Vector(r.SizeX * rnd.NextFloatGaussian(), r.SizeY * rnd.NextFloatGaussian()) / 2) * 16;
             entities.Add(enem);
         }
     }
 }
Exemplo n.º 8
0
        bool IsRunning(EntityEnemy enemy)
        {
            EnemyIcon iconNum;

            if (enemy.IsRunning)
            {
                return(true);
            }
            iconNum = GetIconNum(enemy);
            if (iconNum == EnemyIcon.Dog || iconNum == EnemyIcon.Bear)
            {
                return(true);
            }
            return(false);
        }
        public void Init( Game game )
        {
            _game = game;

            _isDone = false;

            _selectedEnemy = new EntityEnemyZombee();

            _swarms.Clear();
            _swarms.Add( new Swarm() );
            _currentSwarm = 0;

            if( _font == null )
                _font = game.Content.Load<SpriteFont>( "fonts/MenuItem" );

            _lastWheelValue = Mouse.GetState().ScrollWheelValue;
        }
Exemplo n.º 10
0
        public void Init(Game game)
        {
            _game = game;

            _isDone = false;

            _selectedEnemy = new EntityEnemyZombee();

            _swarms.Clear();
            _swarms.Add(new Swarm());
            _currentSwarm = 0;

            if (_font == null)
            {
                _font = game.Content.Load <SpriteFont>("fonts/MenuItem");
            }

            _lastWheelValue = Mouse.GetState().ScrollWheelValue;
        }
Exemplo n.º 11
0
 EnemyIcon GetIconNum(EntityEnemy enemy)
 {
     if (enemy is EntityFlying)
     {
         return(EnemyIcon.Flying);
     }
     if (enemy is EntityZombieDog || NameContains(enemy.EntityName, "wolf"))
     {
         return(EnemyIcon.Dog);
     }
     if (NameContains(enemy.EntityName, "bear"))
     {
         return(EnemyIcon.Bear);
     }
     if (enemy is EntityEnemyAnimal || NameContains(enemy.EntityName, "snake"))
     {
         return(EnemyIcon.Animal);
     }
     return(EnemyIcon.Zombie);
 }
Exemplo n.º 12
0
        /*public Single CalculateYaw(EntityEnemy target)
         * {
         *  Vector3 targetHead = target.emodel.GetHeadPosition();
         *  Vector3 targetToFace = targetHead - fpCam.transform.position;
         *  float yaw = Quaternion.LookRotation(targetToFace, fpCam.transform.up).eulerAngles.y;
         *
         *  if (yaw > 180f)
         *  {
         *      yaw -= 360f;
         *  }
         *  return yaw;
         * }*/

        /*public Single CalculatePitch(EntityEnemy target)
         * {
         *  Vector3 targetHead = target.emodel.GetHeadPosition();
         *  Vector3 targetToFace = targetHead - fpCam.transform.position;
         *  float pitch = Quaternion.LookRotation(targetToFace, fpCam.transform.up).eulerAngles.x;
         *
         *  if (pitch > 180f)
         *  {
         *      pitch -= 360f;
         *  }
         *  return pitch;
         * }*/

        // Get closest enemy
        private EntityEnemy GetClosestEnemy(EntityEnemy[] entities)
        {
            EntityEnemy targetA         = null;
            float       targetADistance = 0;

            if (entities != null)
            {
                if (entities.Length == 1)
                {
                    return(entities[0]);
                }

                foreach (EntityEnemy entity in entities)
                {
                    if (entity != null)
                    {
                        float entityDistanceToPlayer = Vector3.Distance(cam.transform.position, entity.transform.position);
                        if (targetA == null && entity.IsAlive() && entityDistanceToPlayer <= aimRange)
                        {
                            targetA         = entity;
                            targetADistance = entityDistanceToPlayer;
                            continue;
                        }
                        else if (entity.IsAlive() && entityDistanceToPlayer <= aimRange)
                        {
                            if (entityDistanceToPlayer < targetADistance)
                            {
                                targetA         = entity;
                                targetADistance = entityDistanceToPlayer;
                            }
                        }
                    }
                }
                return(targetA);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     entity = this.GetComponentInChildren<EntityEnemy>();
     CalculatePath();
 }
 public ManagedZombie(EntityEnemy _zombie, EntityPlayer _player)
 {
     zombie = _zombie;
     player = _player;
 }
Exemplo n.º 15
0
 public void OnKill(EntityEnemy enemy)
 {
     Loot(enemy);
     IncreaseXp(10);
 }
Exemplo n.º 16
0
 public void Initialize(EntityEnemy owner, AISensor sensor)
 {
     this.Owner  = owner;
     this.sensor = sensor;
 }
Exemplo n.º 17
0
    private bool HandleActivationConditions(Constants.AbilityActivationCondition[] conditions)
    {
        //Debug.Log("handeling activation conditions");
        bool result = false;



        if (RecoveryManager.HasRecovery == false)
        {
            result = true;
        }

        bool freeActivation = conditions.Contains(Constants.AbilityActivationCondition.IgnoreCost) && conditions.Contains(Constants.AbilityActivationCondition.IgnoreRecovery);

        if (freeActivation)
        {
            result = true;
        }

        if (conditions.Contains(Constants.AbilityActivationCondition.Normal) || conditions.Length < 1)
        {
            //Check For Resource
            result = RecoveryManager.HasCharges;

            //Debug.Log(abilityName + " has charges to spend " + result);
            //Debug.Log(RecoveryManager.Charges + " charges left on " + abilityName);

            if (result == true)
            {
                RecoveryManager.SpendCharge();
                //Spend Resource
            }

            //BufferMe(result);
            //re result;
        }

        if (conditions.Contains(Constants.AbilityActivationCondition.IgnoreRecovery))
        {
            //Check For Resource
            //Spend Resource
        }

        if (conditions.Contains(Constants.AbilityActivationCondition.IgnoreCost))
        {
            result = RecoveryManager.HasCharges;

            if (result == true)
            {
                RecoveryManager.SpendCharge();
            }

            BufferMe(result);
            return(result);
        }

        if (Source.Entity() is EntityEnemy)
        {
            EntityEnemy baddie = Source.Entity() as EntityEnemy;

            if (MeetsRequiredConditions(baddie.AISensor.ClosestTarget) == false)
            {
                result = false;
            }
        }
        else
        {
            //Debug.Log("Checking conditions for " + abilityName + " at the ability level");

            if (MeetsRequiredConditions(null) == false)
            {
                //Debug.Log(abilityName + " failed to meet requirements");
                result = false;
            }
        }

        if (ParentAbility != null)
        {
            result = IsSequenceRight();
        }

        //Debug.Log("Result for handle activatons is " + result);

        BufferMe(result);
        return(result);
    }
Exemplo n.º 18
0
 public void Initialize(EntityEnemy owner)
 {
     this.owner     = owner;
     circleCollider = GetComponent <CircleCollider2D>();
 }
Exemplo n.º 19
0
 bool IsInvestigating(EntityEnemy zombie)
 {
     return(zombie.HasInvestigatePosition);
 }
Exemplo n.º 20
0
        public void Update(GameTime gameTime)
        {
            MouseState mouseState = Mouse.GetState();

            _selectedEnemy.Position = new Vector2(mouseState.X, mouseState.Y);

            // Make sure that the mouse is inside the window!
            if (_game.Window.ClientBounds.Contains(mouseState.X + _game.Window.ClientBounds.X, mouseState.Y + _game.Window.ClientBounds.Y))
            {
                // The user wishes to place an enemy at the position of the mouse
                if (mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                {
                    _swarms.ElementAt(_currentSwarm).Add(_selectedEnemy.Clone(_selectedEnemy.Position));
                }
                // The user wishes to remove an enemy at the position of the mouse
                else if (mouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                {
                    _swarms.ElementAt(_currentSwarm).Remove(new Vector2(mouseState.X, mouseState.Y));
                }
                // The player wants to change the selected enemy
                else if (mouseState.ScrollWheelValue < _lastWheelValue)
                {
                    _lastWheelValue = mouseState.ScrollWheelValue;
                    _selectedEnemy  = new EntityEnemyZombee();
                }
                else if (mouseState.ScrollWheelValue > _lastWheelValue)
                {
                    _lastWheelValue = mouseState.ScrollWheelValue;
                    _selectedEnemy  = new EntityEnemyBeeHive();
                }
            }

            KeyboardState keyboardState = Keyboard.GetState();

            // Update the previous state of the keys
            if (!keyboardState.IsKeyDown(PREVIOUS_KEY))
            {
                _previousKeyHasBeenDown = false;
            }
            if (!keyboardState.IsKeyDown(DELETE_KEY))
            {
                _deleteKeyHasBeenDown = false;
            }
            if (!keyboardState.IsKeyDown(NEXT_KEY))
            {
                _nextKeyHasBeenDown = false;
            }
            if (!keyboardState.IsKeyDown(SAVE_KEY))
            {
                _saveKeyHasBeenDown = false;
            }

            // Handle the keyboard input accordingly

            // Previous wave
            if (keyboardState.IsKeyDown(PREVIOUS_KEY) && !_previousKeyHasBeenDown)
            {
                _previousKeyHasBeenDown = true;

                if (_currentSwarm != 0)
                {
                    --_currentSwarm;
                }
            }
            // Delete the current wave
            else if (keyboardState.IsKeyDown(DELETE_KEY) && !_deleteKeyHasBeenDown)
            {
                _deleteKeyHasBeenDown = true;

                _swarms.RemoveAt(_currentSwarm);

                if (_currentSwarm != 0)
                {
                    --_currentSwarm;
                }

                if (_swarms.Count == 0)
                {
                    _swarms.Add(new Swarm());
                }
            }
            // Next wave
            else if (keyboardState.IsKeyDown(NEXT_KEY) && !_nextKeyHasBeenDown)
            {
                _nextKeyHasBeenDown = true;

                if (++_currentSwarm == _swarms.Count)
                {
                    _swarms.Add(new Swarm());
                }
            }
            // Save the current map
            else if (keyboardState.IsKeyDown(SAVE_KEY) && !_saveKeyHasBeenDown)
            {
                _saveKeyHasBeenDown = true;

                Map    map      = new Map();
                string fileName = "editor.map";

                map.Swarms = _swarms;

                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                using (XmlWriter writer = XmlWriter.Create("Content/maps/" + fileName, settings))
                    IntermediateSerializer.Serialize(writer, map, null);
            }
            // Go back to the menu
            else if (keyboardState.IsKeyDown(MENU_KEY))
            {
                _isDone    = true;
                _nextState = "MainMenu";
            }
        }
Exemplo n.º 21
0
 bool IsAttacking(EntityEnemy zombie)
 {
     return(zombie.GetAttackTarget() == player);
 }
Exemplo n.º 22
0
    private bool HandleActivationConditions(Constants.AbilityActivationCondition[] conditions)
    {
        bool result = false;

        if (RecoveryManager.HasRecovery == false)
        {
            return(true);
        }

        bool freeActivation = conditions.Contains(Constants.AbilityActivationCondition.IgnoreCost) && conditions.Contains(Constants.AbilityActivationCondition.IgnoreRecovery);

        if (freeActivation)
        {
            return(true);
        }

        if (conditions.Contains(Constants.AbilityActivationCondition.Normal) || conditions.Length < 1)
        {
            //Check For Resource
            result = RecoveryManager.HasCharges;

            //Debug.Log(abilityName + " has charges to spend " + result);
            //Debug.Log(RecoveryManager.Charges + " charges left on " + abilityName);

            if (result == true)
            {
                RecoveryManager.SpendCharge();
                //Spend Resource
            }

            BufferMe(result);
            return(result);
        }

        if (conditions.Contains(Constants.AbilityActivationCondition.IgnoreRecovery))
        {
            //Check For Resource
            //Spend Resource
        }

        if (conditions.Contains(Constants.AbilityActivationCondition.IgnoreCost))
        {
            result = RecoveryManager.HasCharges;

            if (result == true)
            {
                RecoveryManager.SpendCharge();
            }

            BufferMe(result);
            return(result);
        }

        if (Source.Entity() is EntityEnemy)
        {
            EntityEnemy baddie = Source.Entity() as EntityEnemy;

            if (MeetsRequiredConditions(baddie.AISensor.ClosestTarget) == false)
            {
                result = false;
            }
        }
        else
        {
            if (MeetsRequiredConditions(null) == false)
            {
                //Debug.Log(abilityName + " failed to meet requirements");
                result = false;
            }
        }


        BufferMe(result);
        return(result);
    }
        public void Update( GameTime gameTime )
        {
            MouseState mouseState = Mouse.GetState();

            _selectedEnemy.Position = new Vector2( mouseState.X, mouseState.Y );

            // Make sure that the mouse is inside the window!
            if( _game.Window.ClientBounds.Contains( mouseState.X + _game.Window.ClientBounds.X, mouseState.Y + _game.Window.ClientBounds.Y ) )
            {
                // The user wishes to place an enemy at the position of the mouse
                if( mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed )
                    _swarms.ElementAt( _currentSwarm ).Add( _selectedEnemy.Clone( _selectedEnemy.Position ) );
                // The user wishes to remove an enemy at the position of the mouse
                else if( mouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed )
                    _swarms.ElementAt( _currentSwarm ).Remove( new Vector2( mouseState.X, mouseState.Y ) );
                // The player wants to change the selected enemy
                else if( mouseState.ScrollWheelValue < _lastWheelValue )
                {
                    _lastWheelValue = mouseState.ScrollWheelValue;
                    _selectedEnemy = new EntityEnemyZombee();
                }
                else if( mouseState.ScrollWheelValue > _lastWheelValue )
                {
                    _lastWheelValue = mouseState.ScrollWheelValue;
                    _selectedEnemy = new EntityEnemyBeeHive();
                }
            }

            KeyboardState keyboardState = Keyboard.GetState();

            // Update the previous state of the keys
            if( !keyboardState.IsKeyDown( PREVIOUS_KEY ) )
                _previousKeyHasBeenDown = false;
            if( !keyboardState.IsKeyDown( DELETE_KEY ) )
                _deleteKeyHasBeenDown = false;
            if( !keyboardState.IsKeyDown( NEXT_KEY ) )
                _nextKeyHasBeenDown = false;
            if( !keyboardState.IsKeyDown( SAVE_KEY ) )
                _saveKeyHasBeenDown = false;

            // Handle the keyboard input accordingly

            // Previous wave
            if( keyboardState.IsKeyDown( PREVIOUS_KEY ) && !_previousKeyHasBeenDown )
            {
                _previousKeyHasBeenDown = true;

                if( _currentSwarm != 0 )
                    --_currentSwarm;
            }
            // Delete the current wave
            else if( keyboardState.IsKeyDown( DELETE_KEY ) && !_deleteKeyHasBeenDown )
            {
                _deleteKeyHasBeenDown = true;

                _swarms.RemoveAt( _currentSwarm );

                if( _currentSwarm != 0 )
                    --_currentSwarm;

                if( _swarms.Count == 0 )
                    _swarms.Add( new Swarm() );
            }
            // Next wave
            else if( keyboardState.IsKeyDown( NEXT_KEY ) && !_nextKeyHasBeenDown )
            {
                _nextKeyHasBeenDown = true;

                if( ++_currentSwarm == _swarms.Count )
                    _swarms.Add( new Swarm() );
            }
            // Save the current map
            else if( keyboardState.IsKeyDown( SAVE_KEY ) && !_saveKeyHasBeenDown )
            {
                _saveKeyHasBeenDown = true;

                Map map = new Map();
                string fileName = "editor.map";

                map.Swarms = _swarms;

                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                using( XmlWriter writer = XmlWriter.Create( "Content/maps/" + fileName, settings ) )
                    IntermediateSerializer.Serialize( writer, map, null );
            }
            // Go back to the menu
            else if( keyboardState.IsKeyDown( MENU_KEY ) )
            {
                _isDone = true;
                _nextState = "MainMenu";
            }
        }
 public ManagedZombie(EntityEnemy _zombie, EntityPlayer _player)
 {
     this.zombie = _zombie;
     this.player = _player;
 }
Exemplo n.º 25
0
 bool IsSleeping(EntityEnemy zombie)
 {
     return(zombie.IsSleeping);
 }
Exemplo n.º 26
0
 private static void ProcessEntityEnemy(EntityEnemy entity)
 {
     Log.Out($"{Config.ModPrefix} Spawn Detected:{GetClassName(entity)}[{entity.entityId}]({entity.GetType()})@{(int)entity.position.x} {(int)entity.position.y} {(int)entity.position.z}");
 }
Exemplo n.º 27
0
 bool IsFlying(EntityEnemy enemy)
 {
     return(enemy is EntityFlying);
 }
Exemplo n.º 28
0
    private IEnumerator BuildDungeon()
    {
        SetStatus("building");

        GameObject dungeon = new GameObject("Dungeon");

        for (int level = 0; level < numOfLevels; level++)
        {
            GameObject lvl = new GameObject(level.ToString());
            lvl.transform.SetParent(dungeon.transform);
            foreach (DungeonRoom room in levels[level])
            {
                room.Generate(room.position.Value.x, room.position.Value.y, room.position.Value.z).transform.SetParent(lvl.transform);
            }
        }

        SetStatus("spawning.player");

        Vector3 playerSpawn;

        {
            SpawnPoint[] playerSpawns     = dungeon.transform.Find("0").GetComponentsInChildren <SpawnPoint>();
            SpawnPoint   playerSpawnPoint = random.NextFrom(playerSpawns);
            playerSpawn = playerSpawnPoint.transform.position + playerSpawnPoint.offset;

            foreach (SpawnPoint spawn in playerSpawnPoint.transform.parent.GetComponentsInChildren <SpawnPoint>())
            {
                DestroyImmediate(spawn);
            }
        }

        SetStatus("spawning.teleporters");

        exitsCache = new Vector2[levels.Length];

        for (int level = 0; level < levels.Length - 1; level++)
        {
            SpawnPoint[] lowerSpawns = dungeon.transform.Find(level.ToString()).GetComponentsInChildren <SpawnPoint>();
            SpawnPoint[] upperSpawns = dungeon.transform.Find((level + 1).ToString()).GetComponentsInChildren <SpawnPoint>();

            SpawnPoint lowerSpawn = random.NextFrom(lowerSpawns);
            SpawnPoint upperSpawn = random.NextFrom(upperSpawns);

            DungeonZoner template = zoners.NextWithReplacement();

            GameObject lowerZonerObject = Instantiate(template.gameObject, lowerSpawn.transform.parent, false);
            GameObject upperZonerObject = Instantiate(template.gameObject, upperSpawn.transform.parent, false);

            lowerZonerObject.transform.position = lowerSpawn.transform.position + lowerSpawn.offset;
            upperZonerObject.transform.position = upperSpawn.transform.position + upperSpawn.offset;

            DungeonZoner lowerZoner = lowerZonerObject.GetComponent <DungeonZoner>();
            DungeonZoner upperZoner = upperZonerObject.GetComponent <DungeonZoner>();

            lowerZoner.zonerLink = upperZoner.transform.position;
            upperZoner.zonerLink = lowerZoner.transform.position;

            foreach (SpawnPoint spawn in upperSpawn.transform.parent.GetComponentsInChildren <SpawnPoint>())
            {
                DestroyImmediate(spawn);
            }

            exitsCache[level] = new Vector2(lowerZoner.transform.position.x, lowerZoner.transform.position.z);

            print(level + ": " + lowerZoner.transform.position);
        }

        SetStatus("spawning.enemies");

        Transform enemiesParent = new GameObject("enemies").transform;

        for (int pass = 0; pass < enemyGenPasses; pass++)
        {
            for (int pass2 = 0; pass2 < roomsPerLevel * numOfLevels - random.Next(2, roomsPerLevel); pass2++)
            {
                SpawnPoint spawn = random.NextFrom(dungeon.transform.GetComponentsInChildren <SpawnPoint>());

                if (!spawn)
                {
                    break;
                }

                EntityEnemy enemy = enemies.NextWithReplacement();

                GameObject enemyInst = Instantiate(enemy.gameObject, enemiesParent);
                enemyInst.transform.position = spawn.transform.position + spawn.offset;

                enemyInst.GetComponent <EntityEnemy>().OnSpawn();

                Destroy(spawn);
            }
        }

        SetStatus("spawning.treasure");

        Transform treasureParent = new GameObject("treasure").transform;

        for (int pass = 0; pass < treasureGenPasses; pass++)
        {
            SpawnPoint spawn = random.NextFrom(dungeon.transform.GetComponentsInChildren <SpawnPoint>());

            if (!spawn)
            {
                break;
            }

            DungeonTile component = components.NextWithReplacement();

            GameObject compInst = Instantiate(component.gameObject, treasureParent);
            compInst.transform.position = spawn.transform.position + spawn.offset;

            compInst.GetComponent <EntityTreasure>().OnSpawn();

            Destroy(spawn);
        }

        SetStatus("spawning.exit");

        SpawnPoint exitSpawn       = random.NextFrom(dungeon.transform.Find((levels.Length - 1).ToString()).GetComponentsInChildren <SpawnPoint>());
        GameObject exitZonerObject = Instantiate(zoners.NextWithReplacement().gameObject, exitSpawn.transform.parent, false);

        exitZonerObject.transform.position = exitSpawn.transform.position + exitSpawn.offset;

        DungeonZoner exitZoner = exitZonerObject.GetComponent <DungeonZoner>();

        exitZoner.isZonerExit = true;

        Destroy(exitSpawn.gameObject);

        print("EXIT: " + exitZoner.transform.position);

        SetStatus("wait");

        if (isDedicated)
        {
            yield return(new WaitForSeconds(4F)); // Wait a bit because we're too fast to see my loading animation :/
        }
        Destroy(this.dungeon.gameObject);
        Destroy(gameObject);


        if (playerOverride)
        {
            Instantiate(playerOverride, playerSpawn, Quaternion.identity);
        }
        else
        {
            if (PlayerData.Instance == null)
            {
                PlayerData.Instance = new PlayerData("#ns Debug Player", PlayerData.PlayerClass.MAGE);
            }

            Instantiate(Resources.Load <GameObject>(PlayerData.prefabs[PlayerData.Instance.playerClass]), playerSpawn, Quaternion.identity);
        }
        if (isDedicated)
        {
            GameObject mods = new GameObject("modules");
            foreach (GameObject ob in Resources.LoadAll <GameObject>("Modules/"))
            {
                GameObject mod = Instantiate(ob);

                if (mod.GetComponent <ModuleDisable>() && mod.GetComponent <ModuleDisable>().isActiveAndEnabled)
                {
                    Destroy(mod);
                    continue;
                }

                mod.transform.SetParent(mods.transform);
            }

            GameObject gl          = new GameObject("Global Light");
            Light      globalLight = gl.AddComponent <Light>();
            globalLight.type         = LightType.Directional;
            gl.transform.eulerAngles = new Vector3(50, -30, 0); // TODO proper lighting
        }
    }