コード例 #1
0
        public MobData(int mobId, int idParent, string monsterType, int count, int level, int chance, string location, string roomSize, bool exclude, MonsterGenerator.RegionSize minSize)
        {
            this.mobId    = mobId;
            this.idParent = idParent;
            this.count    = count;
            this.level    = level;
            this.chance   = chance;
            this.exclude  = exclude;
            this.minSize  = minSize;

            this.monsterTypeName = monsterType;

            /*try
             * {
             *      this.type = (MonsterId)Enum.Parse(typeof(MonsterId), monsterType);
             * }
             * catch (Exception)
             * {
             *      throw new Exception("neznamy typ moba " + monsterType);
             * }*/

            this.roomSize = (MapRoom.RoomType)Enum.Parse(typeof(MapRoom.RoomType), roomSize.ToUpper());

            switch (location)
            {
            case "center":
                this.location = MapRoom.DIRECTION_CENTER;
                break;

            case "left":
                this.location = MapRoom.DIRECTION_LEFT;
                break;

            case "right":
                this.location = MapRoom.DIRECTION_RIGHT;
                break;

            case "up":
                this.location = MapRoom.DIRECTION_UP;
                break;

            case "down":
                this.location = MapRoom.DIRECTION_DOWN;
                break;

            case "largest":
                this.location = MapRoom.DIRECTION_LARGEST_ROOM;
                break;
            }
        }
コード例 #2
0
        public MonsterSpawnInfo SpawnMonstersToRoom(MapRoom room, string monsterTypeName, MapRoom.RoomType type, int direction, int countRooms, int countMobsPerRoom, bool randomOffset = false, int level = 1, int chance = 100, bool exclude = true)
        {
            if (chance < 100 && !ChanceCheck(chance))
            {
                return(null);
            }

            Tile[] rooms = room.GetSubRooms(type, direction, countRooms, exclude);

            MonsterSpawnInfo info = null;

            foreach (Tile t in rooms)
            {
                if (t == null)
                {
                    break;
                }

                for (int i = 0; i < countMobsPerRoom; i++)
                {
                    info = SpawnMonsterToRoom(room, monsterTypeName, t, randomOffset, level);
                }
            }

            return(info);
        }