Beispiel #1
0
        internal void SpawnPotion(Room rooms)
        {
            //Todo: add sql
            //throw new NotImplementedException();
            int rndCount = rnd.Next(0, maxPotionCount);

            if (rooms.GetArea() < 60)
            {
                rndCount = rnd.Next(0, 1);
            }

            for (int i = 0; i < rndCount; i++)
            {
                int rndType  = rnd.Next(0, Enum.GetNames(typeof(PotionType)).Length);
                int rndValue = rnd.Next(minPotionValue, MaxPotionValue + 1);
                if ((PotionType)rndType == PotionType.Atack || (PotionType)rndType == PotionType.Defense)
                {
                    rndValue = 1;
                }


                ArrayElementsStruct coord = GetRandomCoord(rooms);
                if (coord.x != -1 && coord.y != -1)
                {
                    rooms.AddReplaceObject(new Potion(coord.x, coord.y, rndValue, (PotionType)rndType));
                }
            }
        }
Beispiel #2
0
        internal void SpawnDoorToNextLvl(Room rooms)
        {
            //throw new NotImplementedException();


            ArrayElementsStruct coord = GetRandomCoord(rooms);

            if (coord.x != -1 && coord.y != -1)
            {
                rooms.AddReplaceObject(new Door(coord.x, coord.y));
            }
        }
Beispiel #3
0
        private ArrayElementsStruct GetRandomCoord(Room rooms)
        {
            int x                     = rnd.Next(2, rooms.Width - 2);
            int y                     = rnd.Next(2, rooms.Height - 2);
            int exitCounter           = 20;
            ArrayElementsStruct coord = rooms.ArrayElementsToXY(x, y);

            while (rooms.GetFirstObject(coord.x, coord.y) != null || exitCounter <= 0)
            {
                x     = rnd.Next(2, rooms.Width - 2);
                y     = rnd.Next(2, rooms.Height - 2);
                coord = rooms.ArrayElementsToXY(x, y);
                exitCounter--;
            }
            if (exitCounter <= 0)
            {
                return(new ArrayElementsStruct(-1, -1));
            }
            return(coord);
        }
Beispiel #4
0
        internal void SpawnEquipment(Room rooms)
        {
            //Todo: add sql
            //throw new NotImplementedException();
            int rndEquipmentCount = rnd.Next(0, maxEquipmentCount);

            if (rooms.GetArea() < 60)
            {
                rndEquipmentCount = rnd.Next(0, 1);
            }

            for (int i = 0; i < rndEquipmentCount; i++)
            {
                int rndEquipment          = rnd.Next(0, defaultEquipment.Count);
                ArrayElementsStruct coord = GetRandomCoord(rooms);
                if (coord.x != -1 && coord.y != -1)
                {
                    rooms.AddReplaceObject(new Equipment(coord.x, coord.y, defaultEquipment[rndEquipment].Equipmenttype, defaultEquipment[rndEquipment].Damage, defaultEquipment[rndEquipment].Defense, defaultEquipment[rndEquipment].renderChar, defaultEquipment[rndEquipment].Name));
                }
            }
        }
Beispiel #5
0
        internal void SpawnGold(Room rooms)
        {
            //Todo: add sql
            //throw new NotImplementedException();
            int rndCount = rnd.Next(0, maxGoldCount);

            if (rooms.GetArea() < 60)
            {
                rndCount = rnd.Next(0, 1);
            }

            for (int i = 0; i < rndCount; i++)
            {
                int rndGoldValue          = rnd.Next(0, MaxGoldValue);
                ArrayElementsStruct coord = GetRandomCoord(rooms);
                if (coord.x != -1 && coord.y != -1)
                {
                    rooms.AddReplaceObject(new Gold(coord.x, coord.y, rndGoldValue));
                }
            }
        }
Beispiel #6
0
        internal void SpawnEnemy(Room rooms)
        {
            //Todo: add sql

            //spawner when sql not working
            int rndEnemyCount = rnd.Next(0, maxEnemyCount);
            int rndExpCount   = rnd.Next(1, 10);

            for (int i = 0; i < rndEnemyCount; i++)
            {
                int rndEnemyAtack         = rnd.Next(EnemyMinAtack + (lvl * 3), EnemyMaxAtack + 1 + (lvl * 3));
                int rndEnemyHp            = rnd.Next(EnemyMinhp + (lvl * 3), EnemyMaxhp + 1 + (lvl * 3));
                int rndEnemy              = rnd.Next(0, defaultEnemys.Count);
                ArrayElementsStruct coord = GetRandomCoord(rooms);
                if (coord.x != -1 && coord.y != -1)
                {
                    rooms.AddReplaceObject(new Enemy(coord.x, coord.y, defaultEnemys[rndEnemy].renderChar, rndEnemyHp, rndEnemyAtack, rndExpCount));
                }
            }


            //throw new NotImplementedException();
        }