public static void Synchronize(RafManager manager)
        {
            float[] cumulativeExps = new float[]
            {
                0f,
                280f,
                660f,
                1140f,
                1720f,
                2400f,
                3180f,
                4060f,
                5040f,
                6120f,
                7300f,
                8580f,
                9960f,
                11440f,
                13020f,
                14700f,
                16480f,
                18360f,
            };
            List <ExperienceRecord> records = new List <ExperienceRecord>();

            int level = 1;

            for (int i = 0; i < cumulativeExps.Length; i++)
            {
                records.Add(new ExperienceRecord()
                {
                    Level = level, CumulativeExp = cumulativeExps[i]
                });
                level++;
            }

            foreach (var record in records)
            {
                record.AddElement();
            }

            logger.Write("Experiences synchronized");
        }
        public static void Synchronize(RafManager manager)
        {
            List <BuildingRecord> records = new List <BuildingRecord>();

            foreach (var file in manager.GetFiles("ObjectCFG.cfg"))
            {
                CFGFile cfg = new CFGFile(file.GetContent(true));

                int mapId = Helper.GetMapId(file.Path);

                foreach (var obj in cfg.Objects)
                {
                    BuildingRecord record = new BuildingRecord();

                    record.MapId             = mapId;
                    record.Name              = obj.Key;
                    record.Health            = GetFloatFromCFG(obj.Value, "mMaxHP", 0);
                    record.CollisionRadius   = GetFloatFromCFG(obj.Value, "Collision Radius", 0);
                    record.BaseStaticHpRegen = GetFloatFromCFG(obj.Value, "mBaseStaticHPRegen", 0);
                    record.CollisionHeight   = GetFloatFromCFG(obj.Value, "Collision Height", 0);
                    record.Mana              = GetFloatFromCFG(obj.Value, "mMaxMP", 0);
                    record.SelectionHeight   = GetFloatFromCFG(obj.Value, "SelectionHeight", 0);
                    record.SelectionRadius   = GetFloatFromCFG(obj.Value, "SelectionRadius", 0);
                    record.SkinId            = GetIntFromCFG(obj.Value, "skinID", 0);
                    record.SkinName1         = GetStringFromCFG(obj.Value, "SkinName1", string.Empty);
                    record.SkinName2         = GetStringFromCFG(obj.Value, "SkinName2", string.Empty);
                    record.Rot  = GetStringFromCFG(obj.Value, "Rot", string.Empty);
                    record.Move = GetStringFromCFG(obj.Value, "Move", string.Empty);
                    record.PerceptionBubbleRadius     = GetFloatFromCFG(obj.Value, "PerceptionBubbleRadius", 0);
                    record.PathfindingCollisionRadius = GetFloatFromCFG(obj.Value, "PathfindingCollisionRadius", 0);
                    records.Add(record);
                }
            }

            foreach (var record in records)
            {
                record.AddElement();
            }

            logger.Write("Buildings Synchronized");
        }
Example #3
0
        public static void Synchronize(RafManager manager)
        {
            float[] cumulativeExps = new float[]
            {
                0f,
                280f,
                660f,
                1140f,
                1720f,
                2400f,
                3180f,
                4060f,
                5040f,
                6120f,
                7300f,
                8580f,
                9960f,
                11440f,
                13020f,
                14700f,
                16480f,
                18360f,
            };
            List <ExperienceRecord> records = new List <ExperienceRecord>();

            int level = 1;

            for (int i = 0; i < cumulativeExps.Length; i++)
            {
                records.Add(new ExperienceRecord()
                {
                    Level = level, CumulativeExp = cumulativeExps[i]
                });
                level++;
            }
            DatabaseManager.Instance.CreateTable(typeof(ExperienceRecord));
            records.AddInstantElements(typeof(ExperienceRecord));

            logger.Write("Experiences synchronized");
        }
Example #4
0
        public static void Synchronize(RafManager manager)
        {
            var navGrids = manager.GetFiles("AIPath.aimesh_ngrid");

            List <MapRecord> records = new List <MapRecord>();

            List <int> ids = new List <int>();

            foreach (var navGrid in navGrids)
            {
                NavGridFile grid   = NavGridReader.ReadBinary(navGrid.GetContent(true));
                MapRecord   record = new MapRecord();
                record.Name        = navGrid.Path.Split('/')[1];
                record.Id          = Helper.GetMapId(navGrid.Path);
                record.MiddleOfMap = grid.MiddleOfMap;
                record.Width       = grid.MapWidth;
                record.Height      = grid.MapHeight;
                record.XCellCount  = grid.XCellCount;
                record.CellFlags   = grid.CellFlags;
                record.YCellCount  = grid.YCellCount;
                record.MaxGridPos  = new Vector3(grid.MaxGridPos.X, grid.MaxGridPos.Y, grid.MaxGridPos.Z);
                record.MinGridPos  = new Vector3(grid.MinGridPos.X, grid.MinGridPos.Y, grid.MinGridPos.Z);
                List <MapCellRecord> cells = new List <MapCellRecord>();

                foreach (var cell in grid.Cells)
                {
                    cells.Add(new MapCellRecord()
                    {
                        ActorList              = cell.ActorList,
                        AdditionalCost         = cell.AdditionalCost,
                        ArrivalCost            = cell.ArrivalCost,
                        AdditionalCostRefCount = cell.AdditionalCostRefCount,
                        ArrivalDirection       = cell.ArrivalDirection,
                        HintAsGoodCell         = cell.HintAsGoodCell,
                        CenterHeight           = cell.CenterHeight,
                        GoodCellSessionId      = cell.GoodCellSessionId,
                        Heuristic              = cell.Heuristic,
                        Id            = cell.Id,
                        RefHintNode   = cell.RefHintNode,
                        RefHintWeight = cell.RefHintWeight,
                        SessionId     = cell.SessionId,
                        X             = cell.X,
                        Y             = cell.Y,
                    });
                }
                record.Cells = cells.ToArray();

                var file = manager.GetUpToDateFile("LEVELS/" + record.Name + "/Scene/MapObjects.mob");

                if (file != null) // Map do not use .mob file format, we use SCO from room.dsc
                {
                    List <MapObjectRecord> objects = new List <MapObjectRecord>();
                    var mob   = new MOBFile(new MemoryStream(file.GetContent(true)));
                    int mapId = int.Parse(new string(file.Path.Split('/')[1].Skip(3).ToArray()));
                    foreach (var obj in mob.Objects)
                    {
                        objects.Add(new MapObjectRecord(obj.Name, obj.Position, obj.Type,
                                                        obj.Scale, obj.Rotation));
                    }

                    record.Objects = objects.ToArray();
                }
                else
                {
                    var room = manager.GetFiles("room.dsc").FirstOrDefault(x => x.Path.Contains(record.Name)).GetContent(true);
                    var r    = Encoding.ASCII.GetString(room);


                    record.Cells   = new MapCellRecord[0];
                    record.Objects = new MapObjectRecord[0];
                }

                if (ids.Contains(record.Id) == false)
                {
                    records.Add(record);
                    ids.Add(record.Id);
                }
            }
            DatabaseManager.Instance.CreateTable(typeof(MapRecord));
            records.AddInstantElements(typeof(MapRecord));
            logger.Write("Map synchronized");
        }