Exemplo n.º 1
0
 /// <summary>
 /// Thread de sleep a virer, plutot un cooldownAction qui renvoit vers MoveGroup()
 /// </summary>
 /// <param name="map"></param>
 /// <param name="groups"></param>
 static async void GenerateMobMovements(MapRecord map, List <MonsterGroup> groups)
 {
     await Task.Run(() =>
     {
         for (int i = 0; i < groups.Count; i++)
         {
             MonsterGroup group = groups[i];
             MoveGroup(map, group);
             ///  Thread.Sleep(2000);
         }
     });
 }
Exemplo n.º 2
0
        public Fight(int id, MapRecord map, FightTeam blueteam, FightTeam redteam, short fightcellid)
        {
            this.Id = id;
            this.BlueTeam = blueteam;
            this.RedTeam = redteam;
            this.BlueTeam.Fight = this;
            this.RedTeam.Fight = this;
            this.Map = map;
            this.FightCellId = fightcellid;
            this.TimeLine.OnNewRound += TimeLine_OnNewRound;
            this.Synchronizer = new ClientsSynchronizer(this);

        }
Exemplo n.º 3
0
    public bool SetRecord(string map, int difficulty, float time, int retries)
    {
        MapRecord currentRecord = records.GetRecord(map);
        MapRecord newRecord     = new MapRecord(difficulty, time, retries);

        if (newRecord.CompareTo(currentRecord) > 0)
        {
            records.SetRecord(map, newRecord);
            UFUtils.Save(recordFilePath, records);
            return(true);
        }
        return(false);
    }
Exemplo n.º 4
0
 /// <summary>
 /// Thread de sleep a virer, plutot un cooldownAction qui renvoit vers MoveGroup()
 /// </summary>
 /// <param name="map"></param>
 /// <param name="groups"></param>
 static async void GenerateMobMovements(MapRecord map, List<MonsterGroup> groups)
 {
     await Task.Run(() =>
     {
         for (int i = 0; i < groups.Count; i++)
         {
             MonsterGroup group = groups[i];
             MoveGroup(map, group);
           ///  Thread.Sleep(2000);
         }
         
     });
 }
Exemplo n.º 5
0
 public void TeleportToSpawnPoint()
 {
     if (Record.SpawnPointMapId != -1)
     {
         InteractiveRecord zaap = MapRecord.GetMap(Record.SpawnPointMapId).Zaap;
         Teleport(Record.SpawnPointMapId, (short)InteractiveRecord.GetTeleporterCellId(zaap.MapId, TeleporterTypeEnum.TELEPORTER_ZAAP));
     }
     else
     {
         Client.Character.Teleport(ConfigurationManager.Instance.StartMapId, ConfigurationManager.Instance.StartCellId);
     }
     Reply("Vous avez été téléporté.");
 }
Exemplo n.º 6
0
        public static List <Node> GetNodes(MapRecord map)
        {
            var nodes = new List <Node>();

            for (short cell = 0; cell < 560; cell++)
            {
                var node = new Node(CoordCells.GetCell(cell));
                node.Walkable = map.Walkable((ushort)cell);
                nodes.Add(node);
            }

            return(nodes);
        }
Exemplo n.º 7
0
        static bool HandleModifyPhaseCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            uint phaseId      = args.NextUInt32();
            uint visibleMapId = args.NextUInt32();

            if (phaseId != 0 && !CliDB.PhaseStorage.ContainsKey(phaseId))
            {
                handler.SendSysMessage(CypherStrings.PhaseNotfound);
                return(false);
            }

            Unit target = handler.GetSelectedUnit();

            if (visibleMapId != 0)
            {
                MapRecord visibleMap = CliDB.MapStorage.LookupByKey(visibleMapId);
                if (visibleMap == null || visibleMap.ParentMapID != target.GetMapId())
                {
                    handler.SendSysMessage(CypherStrings.PhaseNotfound);
                    return(false);
                }

                if (!target.GetPhaseShift().HasVisibleMapId(visibleMapId))
                {
                    PhasingHandler.AddVisibleMapId(target, visibleMapId);
                }
                else
                {
                    PhasingHandler.RemoveVisibleMapId(target, visibleMapId);
                }
            }

            if (phaseId != 0)
            {
                if (!target.GetPhaseShift().HasPhase(phaseId))
                {
                    PhasingHandler.AddPhase(target, phaseId, true);
                }
                else
                {
                    PhasingHandler.RemovePhase(target, phaseId, true);
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        public async Task MaskingService_DecrementOccurrencesAsync_OccurrencesDecremented(string hash, string actual, int originalOccurrences)
        {
            MapRecord record = new MapRecord(hash, actual, originalOccurrences);

            await _mapDAO.CreateAsync(record).ConfigureAwait(false);

            await _maskingService.DecrementOccurrencesAsync(hash).ConfigureAwait(false);

            MapObject obj = (MapObject)await _mapDAO.ReadByIdAsync(hash).ConfigureAwait(false);

            Assert.IsTrue(obj.Occurrences.Equals(originalOccurrences - 1));

            await _mapDAO.DeleteByIdsAsync(new List <string>() { hash }).ConfigureAwait(false);
        }
        private static void StartFighting()
        {
            var guilds = GuildArenaRecord.GuildsArena.Take(GuildArenaRecord.GuildsArena.Count / 2);

            MapRecord mapTarget = MapRecord.GetMap(GVG_MAPS.Random());

            foreach (var guildArena in guilds)
            {
                var fight = FightProvider.Instance.CreateFightGvG(mapTarget);

                List <Character> blueTeam = new List <Character>();
                List <Character> redTeam  = new List <Character>();
                foreach (var character in HubMapRecord.Instance.GetEntities <Character>())
                {
                    if (character.Guild.Id == guildArena.FirstGuildId)
                    {
                        blueTeam.Add(character);
                    }
                    else if (character.Guild.Id == guildArena.SecondGuildId)
                    {
                        redTeam.Add(character);
                    }
                }

                if (blueTeam.Count == 0 || redTeam.Count == 0)
                {
                    foreach (var character in HubMapRecord.Instance.GetEntities <Character>())
                    {
                        character.Reply("Le match opposant les deux guildes n'aura pas lieu car, il n'ya pas assez de membre pour combattre");
                    }

                    continue;
                }

                foreach (var character in blueTeam)
                {
                    character.Teleport(mapTarget.Id);
                    fight.BlueTeam.AddFighter(character.CreateFighter(fight.BlueTeam));
                }

                foreach (var character in redTeam)
                {
                    character.Teleport(mapTarget.Id);
                    fight.RedTeam.AddFighter(character.CreateFighter(fight.RedTeam));
                }

                guildArena.RemoveElement();
                fight.StartPlacement();
            }
        }
Exemplo n.º 10
0
        public static void HandleMapGetInformation(MapInformationsRequestMessage message, WorldClient client)
        {
            client.Character.Map = MapRecord.GetMap(message.mapId);

            if (client.Character.Map == null)
            {
                client.Character.SpawnPoint();
                client.Character.Reply("Unknown Map...(" + message.mapId + ")");
                return;
            }

            client.Character.Map.Instance.AddEntity(client.Character);
            client.Character.Map.Instance.MapComplementary(client, message.mapId, client.Character.Map.SubAreaId);
        }
Exemplo n.º 11
0
        public long GetResetTimeForDB()
        {
            // only save the reset time for normal instances
            MapRecord entry = CliDB.MapStorage.LookupByKey(GetMapId());

            if (entry == null || entry.InstanceType == MapTypes.Raid || GetDifficultyID() == Difficulty.Heroic)
            {
                return(0);
            }
            else
            {
                return(GetResetTime());
            }
        }
Exemplo n.º 12
0
        void HandleQueryCorpseLocation(QueryCorpseLocationFromClient queryCorpseLocation)
        {
            CorpseLocation packet = new CorpseLocation();
            Player         player = Global.ObjAccessor.FindConnectedPlayer(queryCorpseLocation.Player);

            if (!player || !player.HasCorpse() || !_player.IsInSameRaidWith(player))
            {
                packet.Valid  = false;                              // corpse not found
                packet.Player = queryCorpseLocation.Player;
                SendPacket(packet);
                return;
            }

            WorldLocation corpseLocation = player.GetCorpseLocation();
            uint          corpseMapID    = corpseLocation.GetMapId();
            uint          mapID          = corpseLocation.GetMapId();
            float         x = corpseLocation.GetPositionX();
            float         y = corpseLocation.GetPositionY();
            float         z = corpseLocation.GetPositionZ();

            // if corpse at different map
            if (mapID != player.GetMapId())
            {
                // search entrance map for proper show entrance
                MapRecord corpseMapEntry = CliDB.MapStorage.LookupByKey(mapID);
                if (corpseMapEntry != null)
                {
                    if (corpseMapEntry.IsDungeon() && corpseMapEntry.CorpseMapID >= 0)
                    {
                        // if corpse map have entrance
                        Map entranceMap = Global.MapMgr.CreateBaseMap((uint)corpseMapEntry.CorpseMapID);
                        if (entranceMap != null)
                        {
                            mapID = (uint)corpseMapEntry.CorpseMapID;
                            x     = corpseMapEntry.Corpse.X;
                            y     = corpseMapEntry.Corpse.Y;
                            z     = entranceMap.GetHeight(player.GetPhaseShift(), x, y, MapConst.MaxHeight);
                        }
                    }
                }
            }

            packet.Valid       = true;
            packet.Player      = queryCorpseLocation.Player;
            packet.MapID       = (int)corpseMapID;
            packet.ActualMapID = (int)mapID;
            packet.Position    = new Vector3(x, y, z);
            packet.Transport   = ObjectGuid.Empty;
            SendPacket(packet);
        }
        public static List <MonsterSpawnMapRecord> GetSpawns(int mapid)
        {
            var spawn = MonsterSpawnMapRecord.GetSpawn(mapid);

            if (spawn.Count() > 0)
            {
                return(spawn);
            }
            else
            {
                var subId = MapRecord.GetSubAreaId(mapid);
                var sub   = MonstersSpawnsSub.FindAll(x => x.SubAreaId == subId);
                return(sub.ConvertAll <MonsterSpawnMapRecord>(x => new MonsterSpawnMapRecord(0, x.MonsterId, mapid, x.Probability)));
            }
        }
Exemplo n.º 14
0
    /* Returns a list of any exteriors within or adjacent to given coordinates. */
    public List <Cell> FindExteriors(int x, int y)
    {
        MapRecord   map   = null; //Session.session.map;
        List <Cell> cells = new List <Cell>();

        for (int i = 0; i < map.exteriors.Count; i++)
        {
            Cell c = map.exteriors[i];
            if (Adjacent(c.x, c.y, x, y))
            {
                cells.Add(c);
            }
        }
        return(cells);
    }
Exemplo n.º 15
0
 public Fight(MapRecord map, FightTeam blueTeam, FightTeam redTeam, short cellId)
 {
     this.Id               = FightProvider.Instance.PopId();
     this.Map              = map;
     this.BlueTeam         = blueTeam;
     this.RedTeam          = redTeam;
     this.BlueTeam.Fight   = this;
     this.RedTeam.Fight    = this;
     this.TimeLine         = new TimeLine(this);
     this.SequencesManager = new SequenceManager(this);
     this.CellId           = cellId;
     this.Started          = false;
     this.CreationTime     = DateTime.Now;
     this.Marks            = new List <Mark>();
 }
Exemplo n.º 16
0
        public bool IsValidMAP(uint mapid, bool startUp)
        {
            MapRecord mEntry = CliDB.MapStorage.LookupByKey(mapid);

            if (startUp)
            {
                return(mEntry != null);
            }
            else
            {
                return(mEntry != null && (!mEntry.IsDungeon() || Global.ObjectMgr.GetInstanceTemplate(mapid) != null));
            }

            // TODO: add check for Battlegroundtemplate
        }
Exemplo n.º 17
0
        InstanceMap CreateInstance(uint InstanceId, InstanceSave save, Difficulty difficulty, int teamId)
        {
            // make sure we have a valid map id
            MapRecord entry = CliDB.MapStorage.LookupByKey(GetId());

            if (entry == null)
            {
                Log.outError(LogFilter.Maps, "CreateInstance: no record for map {0}", GetId());
                Contract.Assert(false);
            }
            InstanceTemplate iTemplate = Global.ObjectMgr.GetInstanceTemplate(GetId());

            if (iTemplate == null)
            {
                Log.outError(LogFilter.Maps, "CreateInstance: no instance template for map {0}", GetId());
                Contract.Assert(false);
            }

            // some instances only have one difficulty
            Global.DB2Mgr.GetDownscaledMapDifficultyData(GetId(), ref difficulty);

            Log.outDebug(LogFilter.Maps, "MapInstanced.CreateInstance: {0} map instance {1} for {2} created with difficulty {3}", save != null ? "" : "new ", InstanceId, GetId(), difficulty);

            InstanceMap map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);

            Contract.Assert(map.IsDungeon());

            map.LoadRespawnTimes();
            map.LoadCorpseData();

            bool load_data = save != null;

            map.CreateInstanceData(load_data);
            InstanceScenario instanceScenario = Global.ScenarioMgr.CreateInstanceScenario(map, teamId);

            if (instanceScenario != null)
            {
                map.SetInstanceScenario(instanceScenario);
            }

            if (WorldConfig.GetBoolValue(WorldCfg.InstancemapLoadGrids))
            {
                map.LoadAllCells();
            }

            m_InstancedMaps[InstanceId] = map;
            return(map);
        }
Exemplo n.º 18
0
        public static void HandleMapGetInformation(MapInformationsRequestMessage message, WorldClient client)
        {
            if (client.Character.Record.MapId == message.mapId)
            {
                client.Character.Map = MapRecord.GetMap(message.mapId);

                if (client.Character.Map == null)
                {
                    client.Character.SpawnPoint();
                    client.Character.Reply("Unknown Map...(" + message.mapId + ")");
                    return;
                }

                client.Character.OnEnterMap();
            }
        }
Exemplo n.º 19
0
        public void StartFighting()
        {
            Clients.ForEach(x => x.UpdateRegistrationStatus(false, PvpArenaStepEnum.ARENA_STEP_STARTING_FIGHT));

            int arenaMapId = ArenaProvider.Instance.RandomArenaMap();

            BlueTeam.ForEach(x => MapsHandler.SendCurrentMapMessage(x.WorldClient, arenaMapId));
            RedTeam.ForEach(x => MapsHandler.SendCurrentMapMessage(x.WorldClient, arenaMapId));

            var fight = FightProvider.Instance.CreateArenaFight(MapRecord.GetMap(arenaMapId), this);

            BlueTeam.ForEach(x => fight.BlueTeam.AddFighter(x.WorldClient.Character.CreateFighter(fight.BlueTeam)));
            RedTeam.ForEach(x => fight.RedTeam.AddFighter(x.WorldClient.Character.CreateFighter(fight.RedTeam)));
            fight.StartPlacement();
            Clients.Clear();
            ArenaProvider.Instance.m_arena_groups.Remove(this);
        }
Exemplo n.º 20
0
        public override void Teleport(MapRecord map)
        {
            if (this.Maps.Contains(map.Id))
            {
                int    cost = Costs[Maps.ToList().IndexOf(map.Id)];
                ushort cellId;

                var zaap = map.Zaap;
                cellId = zaap != null?GetTeleporterCell(map, zaap) : map.RandomWalkableCell();

                if (this.Character.RemoveKamas(cost))
                {
                    this.Close();
                    this.Character.Teleport(map.Id, cellId);
                }
            }
        }
Exemplo n.º 21
0
        public override void Teleport(MapRecord map)
        {
            if (this.Maps.Contains(map.Id))
            {
                int cost = Costs[Maps.ToList().IndexOf(map.Id)];

                var zaapi = map.GetInteractiveByElementType(106); // IT Type Enum

                ushort cellId = zaapi != null?GetTeleporterCell(map, zaapi) : map.RandomWalkableCell();

                if (this.Character.RemoveKamas(cost))
                {
                    this.Close();
                    this.Character.Teleport(map.Id, cellId);
                }
            }
        }
Exemplo n.º 22
0
        private static Cell[] GetCellsCircle(Cell centerCell, MapRecord map, int radius, int minradius)
        {
            var centerPoint = new MapPoint(centerCell);
            var result      = new List <Cell>();

            if (radius == 0)
            {
                if (minradius == 0)
                {
                    result.Add(centerCell);
                }

                return(result.ToArray());
            }

            int x = (int)(centerPoint.X - radius);
            int y = 0;
            int i = 0;
            int j = 1;

            while (x <= centerPoint.X + radius)
            {
                y = -i;

                while (y <= i)
                {
                    if (minradius == 0 || Math.Abs(centerPoint.X - x) + Math.Abs(y) >= minradius)
                    {
                        AddCellIfValid(x, y + centerPoint.Y, map, result);
                    }

                    y++;
                }

                if (i == radius)
                {
                    j = -j;
                }

                i = i + j;
                x++;
            }

            return(result.ToArray());
        }
Exemplo n.º 23
0
        public static void EndFightCommand(string value, WorldClient client)
        {
            var split = value.Split(' ');

            int       map    = int.Parse(split[0]);
            MapRecord record = MapRecord.GetMap(map);

            ushort randomWalkableCell = split.Length > 1 ? ushort.Parse(split[1]) : record.RandomWalkableCell();

            EndFightActionRecord endFight = new EndFightActionRecord(EndFightActionRecord.EndFightActions.DynamicPop(x => x.Id),
                                                                     client.Character.Map.Id,
                                                                     map,
                                                                     randomWalkableCell);

            endFight.AddInstantElement();

            client.Character.Reply("EndFightAction has been added");
        }
Exemplo n.º 24
0
    public void Save()
    {
        MapRecord record = new MapRecord(_row, _column);

        for (int i = 0; i < _row; i++)
        {
            for (int j = 0; j < _column; j++)
            {
                MapGrid mapGrid = _mapGridArray[GetIndex(i, j, _column)];
                record.SetSelect(i, j, mapGrid.Select ? MapDefine.SELECT : MapDefine.UNSELECT);
            }
        }

        using (StreamWriter sw = new StreamWriter(MapDefine.MAP_DATA_PATH))
        {
            sw.Write(JsonMapper.ToJson(record));
        }
    }
Exemplo n.º 25
0
        public short[] GetCells(short centerCell, MapRecord map)
        {
            MapPoint     mapPoint = new MapPoint(centerCell);
            List <short> list     = new List <short>();

            for (int i = (int)this.MinRadius; i <= (int)this.Radius; i++)
            {
                switch (this.Direction)
                {
                case DirectionsEnum.DIRECTION_EAST:
                    MapPoint.AddCellIfValid(mapPoint.X + i, mapPoint.Y + i, map, list);
                    break;

                case DirectionsEnum.DIRECTION_SOUTH_EAST:
                    MapPoint.AddCellIfValid(mapPoint.X + i, mapPoint.Y, map, list);
                    break;

                case DirectionsEnum.DIRECTION_SOUTH:
                    MapPoint.AddCellIfValid(mapPoint.X + i, mapPoint.Y - i, map, list);
                    break;

                case DirectionsEnum.DIRECTION_SOUTH_WEST:
                    MapPoint.AddCellIfValid(mapPoint.X, mapPoint.Y - i, map, list);
                    break;

                case DirectionsEnum.DIRECTION_WEST:
                    MapPoint.AddCellIfValid(mapPoint.X - i, mapPoint.Y - i, map, list);
                    break;

                case DirectionsEnum.DIRECTION_NORTH_WEST:
                    MapPoint.AddCellIfValid(mapPoint.X - i, mapPoint.Y, map, list);
                    break;

                case DirectionsEnum.DIRECTION_NORTH:
                    MapPoint.AddCellIfValid(mapPoint.X - i, mapPoint.Y + i, map, list);
                    break;

                case DirectionsEnum.DIRECTION_NORTH_EAST:
                    MapPoint.AddCellIfValid(mapPoint.X, mapPoint.Y + i, map, list);
                    break;
                }
            }
            return(list.ToArray());
        }
 public static void HandleAdminQuietCommand(AdminQuietCommandMessage message, WorldClient client)
 {
     if (message.content.StartsWith("moveto") && !client.Character.IsFighting && client.Account.Role >= ServerRoleEnum.ADMINISTRATOR)
     {
         int mapid;
         if (int.TryParse(message.content.Split(null).Last(), out mapid))
         {
             var map = MapRecord.GetMap(mapid);
             if (map.WalkableCells.Contains(client.Character.Record.CellId))
             {
                 client.Character.Teleport(mapid);
             }
             else
             {
                 client.Character.Teleport(mapid, map.RandomWalkableCell());
             }
         }
     }
 }
Exemplo n.º 27
0
        public static GameRolePlayGroupMonsterInformations GetActorInformations(MapRecord map, MonsterGroup group)
        {
            var random               = new AsyncRandom();
            var firstMonster         = group.Monsters[0];
            var firstMonsterTemplate = MonsterRecord.GetMonster(firstMonster.MonsterId);
            var light = new MonsterInGroupLightInformations(firstMonsterTemplate.Id, (sbyte)random.Next(1, 6));
            List <MonsterInGroupInformations> monstersinGroup = new List <MonsterInGroupInformations>();

            for (int i = 1; i < group.Monsters.Count; i++)
            {
                var mob      = group.Monsters[i];
                var template = MonsterRecord.GetMonster(mob.MonsterId);
                monstersinGroup.Add(new MonsterInGroupInformations(mob.MonsterId, mob.ActualGrade, template.RealLook.ToEntityLook()));
            }
            var staticInfos = new GroupMonsterStaticInformations(light, monstersinGroup);

            return(new GameRolePlayGroupMonsterInformations(group.MonsterGroupId, firstMonsterTemplate.RealLook.ToEntityLook(),
                                                            new EntityDispositionInformations((short)group.CellId, 3), false, false, false, staticInfos, group.AgeBonus, 0, 0));
        }
Exemplo n.º 28
0
        public static void HandleTeleportRequest(TeleportRequestMessage message, WorldClient client)
        {
            switch ((TeleporterTypeEnum)message.teleporterType)
            {
            case TeleporterTypeEnum.TELEPORTER_ZAAP:
                if (client.Character.GetDialog <ZaapDialog>() != null)
                {
                    client.Character.GetDialog <ZaapDialog>().Teleport(MapRecord.GetMap(message.mapId));
                }
                break;

            case TeleporterTypeEnum.TELEPORTER_SUBWAY:
                if (client.Character.GetDialog <ZaapiDialog>() != null)
                {
                    client.Character.GetDialog <ZaapiDialog>().Teleport(MapRecord.GetMap(message.mapId));
                }
                break;
            }
        }
        public static void SpawnPortal(DelayedAction action)
        {
            int portalId = int.Parse(action.Record.Value1);

            PortalRecord record = PortalRecord.GetPortal(portalId);

            MapRecord targetedMap = null;

            if (action.Value != null)
            {
                ((MapRecord)action.Value).Instance.RemoveEntity(((MapRecord)action.Value).Instance.GetEntities <Portal>().FirstOrDefault(x => x.Template.Id == int.Parse(action.Record.Value1)));
            }

            if (action.Record.Value2 != string.Empty)
            {
                List <MapRecord> subAreaMaps = MapRecord.GetSubAreaMaps(int.Parse(action.Record.Value2))
                                               .ConvertAll <MapRecord>(x => MapRecord.GetMap(x))
                                               .FindAll(x => x.Instance.GetEntities <Portal>().FirstOrDefault(w => w.Template.Id == portalId) == null);

                if (subAreaMaps.Count > 0)
                {
                    targetedMap = subAreaMaps.Random();

                    targetedMap.Instance.AddEntity(new Portal(record, targetedMap.Instance));

                    action.Value = targetedMap;
                }
            }
            else
            {
                List <MapRecord> maps = MapRecord.Maps.FindAll(x => x.Instance.GetEntities <Portal>().FirstOrDefault(w => w.Template.Id == portalId) == null).FindAll(x => x.Position.Outdoor);

                if (maps.Count > 0)
                {
                    targetedMap = maps.Random();

                    targetedMap.Instance.AddEntity(new Portal(record, targetedMap.Instance));

                    action.Value = targetedMap;
                }
            }
        }
        private void createCommand(CommandLineApplication command)
        {
            command.OnExecute(() =>
            {
                var id     = Guid.NewGuid();
                var record = new MapRecord()
                {
                    Id           = id,
                    Description  = id.ToString(),
                    IsBrowseable = false,
                    Entries      = new List <MapEntryRecord>()
                };

                _mapService.InsertOneAsync(record).Wait();

                command.Out.WriteLine($"New map id: {id}");

                return(0);
            });
        }
Exemplo n.º 31
0
    public void Load()
    {
        string str;

        using (StreamReader sr = new StreamReader(MapDefine.MAP_DATA_PATH))
        {
            str = sr.ReadToEnd();
        }

        MapRecord mapRecord = JsonMapper.ToObject <MapRecord>(str);

        for (int i = 0; i < mapRecord.Row; i++)
        {
            for (int j = 0; j < mapRecord.Column; j++)
            {
                MapGrid mapGrid = _mapGridArray[GetIndex(i, j, mapRecord.Column)];
                mapGrid.Select = mapRecord.GetSelect(i, j) == MapDefine.SELECT;
            }
        }
    }
Exemplo n.º 32
0
        static void MoveGroup(MapRecord map,MonsterGroup group)
        {

            var random = new AsyncRandom();
            var info = MonsterGroup.GetActorInformations(map, group);
            List<short> cells = Pathfinding.GetCircleCells(info.disposition.cellId, MoveCellsCount);
            cells.Remove(info.disposition.cellId);
            cells.RemoveAll(x => !map.WalkableCells.Contains(x));
            cells.RemoveAll(x => PathHelper.GetDistanceBetween(info.disposition.cellId, x) <= MoveCellsCount);
            if (cells.Count == 0)
                return;
            var newCell = cells[random.Next(0, cells.Count())];
            var path = new Pathfinder(map, info.disposition.cellId, newCell).FindPath();
            if (path != null)
            {
                path.Insert(0, info.disposition.cellId);
                map.Instance.Send(new GameMapMovementMessage(path, info.contextualId));
                group.CellId = (ushort)newCell;
            }
            else
                Logger.Error("Unable to move group" + group.MonsterGroupId + " on map " + map.Id + ", wrong path");

        }
Exemplo n.º 33
0
 public FightArena(int id, MapRecord map, FightTeam blueTeam, FightTeam redTeam, short fightCellId)
     : base(id, map, blueTeam, redTeam, fightCellId)
 {
 }