Exemple #1
0
        private void SpawnMonsters()
        {
            var topLeftLocation = new Point(CurrentLocation.X - Info.EventSize, CurrentLocation.Y - Info.EventSize);

            foreach (var eventRespawn in Info.Respawns)
            {
                var respawnInfo = new RespawnInfo();

                var monster = Envir.GetMonsterInfo(eventRespawn.MonsterName);
                if (monster == null)
                {
                    SMain.EnqueueDebugging(string.Format("{0} Activating Event:{1} FAILED COULDN'T FIND MONSTER {2}", Map.Info.FileName, Info.EventName, eventRespawn.MonsterName));
                    return;
                }
                respawnInfo.Spread          = eventRespawn.MonsterCount;
                respawnInfo.Count           = eventRespawn.MonsterCount;
                respawnInfo.MonsterIndex    = monster.Index;
                respawnInfo.Delay           = 10000;
                respawnInfo.SaveRespawnTime = false;
                respawnInfo.RespawnIndex    = 0;
                respawnInfo.RespawnTicks    = 0;


                if (eventRespawn.SpreadY == 0 && eventRespawn.SpreadX == 0 && eventRespawn.MonsterCount == 1)
                {
                    respawnInfo.Location = CurrentLocation;
                }
                else
                {
                    respawnInfo.Location = new Point(topLeftLocation.X + eventRespawn.SpreadX * 2, topLeftLocation.Y + eventRespawn.SpreadY * 2);
                }

                MapRespawn mapRespawn = new MapRespawn(respawnInfo);

                RouteInfo route = new RouteInfo();
                route.Location = respawnInfo.Location;
                route.Delay    = 1000;
                mapRespawn.Route.Add(route);

                mapRespawn.Map = Map;
                mapRespawn.IsEventObjective = eventRespawn.IsObjective;
                mapRespawn.Event            = this;
                MapRespawns.Add(mapRespawn);
            }

            Map.Respawns.AddRange(MapRespawns);
        }
Exemple #2
0
        private void SpawnMonstersForInvasion(List <EventRespawn> respawns)
        {
            var topLeftLocation = new Point(CurrentLocation.X - Info.EventSize, CurrentLocation.Y - Info.EventSize);

            foreach (var eventRespawn in respawns)
            {
                var monster = Envir.GetMonsterInfo(eventRespawn.MonsterName);
                if (monster == null)
                {
                    SMain.EnqueueDebugging(string.Format("{0} Event:{1} FAILED COULDN'T FIND MONSTER {2}", Map.Info.FileName, Info.EventName, eventRespawn.MonsterName));
                    continue;
                }

                var respawnInfo = new RespawnInfo()
                {
                    Spread       = eventRespawn.MonsterCount,
                    Count        = eventRespawn.MonsterCount,
                    MonsterIndex = monster.Index,
                    Delay        = ushort.MaxValue
                };

                if (eventRespawn.SpreadY == 0 && eventRespawn.SpreadX == 0)
                {
                    respawnInfo.Location = CurrentLocation;
                }
                else
                {
                    respawnInfo.Location = new Point(topLeftLocation.X + eventRespawn.SpreadX * 2, topLeftLocation.Y + eventRespawn.SpreadY * 2);
                }

                MapRespawn mapRespawn = new MapRespawn(respawnInfo);

                RouteInfo route = new RouteInfo()
                {
                    Location = respawnInfo.Location,
                    Delay    = 1000,
                };
                mapRespawn.Route.Add(route);

                mapRespawn.Map = Map;
                mapRespawn.IsEventObjective = eventRespawn.IsObjective;
                mapRespawn.Event            = this;
                MapRespawns.Add(mapRespawn);
            }

            Map.Respawns.AddRange(MapRespawns);
        }
Exemple #3
0
        public bool Spawn(MapRespawn respawn)
        {
            Respawn = respawn;

            if (Respawn.Map == null) return false;

            for (int i = 0; i < 10; i++)
            {
                CurrentLocation = new Point(Respawn.Info.Location.X + Envir.Random.Next(-Respawn.Info.Spread, Respawn.Info.Spread + 1),
                                            Respawn.Info.Location.Y + Envir.Random.Next(-Respawn.Info.Spread, Respawn.Info.Spread + 1));

                if (!respawn.Map.ValidPoint(CurrentLocation)) continue;

                respawn.Map.AddObject(this);

                CurrentMap = respawn.Map;

                if (Respawn.Route.Count > 0)
                    Route.AddRange(Respawn.Route);

                RefreshAll();
                SetHP(MaxHP);

                Spawned();
                Respawn.Count++;
                respawn.Map.MonsterCount++;
                Envir.MonsterCount++;
                return true;
            }
            return false;
        }
Exemple #4
0
        public bool Load()
        {
            try
            {
                string fileName = Path.Combine(Settings.MapPath, Info.FileName + ".map");
                if (File.Exists(fileName))
                {
                    byte[] fileBytes = File.ReadAllBytes(fileName);
                    switch(FindType(fileBytes))
                    {
                        case 0:
                            LoadMapCellsv0(fileBytes);
                            break;
                        case 1:
                            LoadMapCellsv1(fileBytes);
                            break;
                        case 2:
                            LoadMapCellsv2(fileBytes);
                            break;
                        case 3:
                            LoadMapCellsv3(fileBytes);
                            break;
                        case 4:
                            LoadMapCellsv4(fileBytes);
                            break;
                        case 5:
                            LoadMapCellsv5(fileBytes);
                            break;
                        case 6:
                            LoadMapCellsv6(fileBytes);
                            break;
                        case 7:
                            LoadMapCellsv7(fileBytes);
                            break;
                        case 100:
                            LoadMapCellsV100(fileBytes);
                            break;
                    }

                    for (int i = 0; i < Info.Respawns.Count; i++)
                    {
                        MapRespawn info = new MapRespawn(Info.Respawns[i]);
                        if (info.Monster == null) continue;
                        info.Map = this;
                        Respawns.Add(info);
                    }

                    for (int i = 0; i < Info.NPCs.Count; i++)
                    {
                        NPCInfo info = Info.NPCs[i];
                        if (!ValidPoint(info.Location)) continue;

                        AddObject(new NPCObject(info) {CurrentMap = this});
                    }

                    for (int i = 0; i < Info.SafeZones.Count; i++)
                        CreateSafeZone(Info.SafeZones[i]);
                    CreateMine();
                    return true;
                }
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }

            SMain.Enqueue("Failed to Load Map: " + Info.FileName);
            return false;
        }
Exemple #5
0
        public bool Load()
        {
            try
            {
                string fileName = Path.Combine(Settings.MapPath, Info.FileName + ".map");
                if (File.Exists(fileName))
                {
                    byte[] fileBytes = File.ReadAllBytes(fileName);

                    int offSet = 21;

                    int w = BitConverter.ToInt16(fileBytes, offSet);
                    offSet += 2;
                    int xor = BitConverter.ToInt16(fileBytes, offSet);
                    offSet += 2;
                    int h = BitConverter.ToInt16(fileBytes, offSet);
                    Width = w ^ xor;
                    Height = h ^ xor;
                    Cells = new Cell[Width, Height];

                    offSet = 54;

                            for (int x = 0; x < Width; x++)
                        for (int y = 0; y < Height; y++)
                            {
                                if (((BitConverter.ToInt32(fileBytes, offSet) ^ 0xAA38AA38) & 0x20000000) != 0)
                                    Cells[x, y] = Cell.HighWall; //Can Fire Over.

                                offSet += 6;
                                if (((BitConverter.ToInt16(fileBytes, offSet) ^ xor) & 0x8000) != 0)
                                    Cells[x, y] = Cell.LowWall; //Can't Fire Over.

                                if (Cells[x, y] == null) Cells[x, y] = new Cell {Attribute = CellAttribute.Walk};

                                offSet += 9;
                            }

                    for (int i = 0; i < Info.Respawns.Count; i++)
                    {
                        MapRespawn info = new MapRespawn(Info.Respawns[i]);
                        if (info.Monster == null) continue;
                        info.Map = this;
                        Respawns.Add(info);
                    }

                    for (int i = 0; i < Info.NPCs.Count; i++)
                    {
                        NPCInfo info = Info.NPCs[i];
                        if (!ValidPoint(info.Location)) continue;

                        AddObject(new NPCObject(info) {CurrentMap = this});
                    }

                    for (int i = 0; i < Info.SafeZones.Count; i++)
                        CreateSafeZone(Info.SafeZones[i]);

                    return true;
                }
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }

            SMain.Enqueue("Failed to Load Map: " + Info.FileName);
            return false;
        }
Exemple #6
0
        public bool Spawn(MapRespawn respawn)
        {
            Respawn = respawn;
            if (uniqueAI != null && uniqueAI.UseKillTimer)
            {
                DateTime timeKilled = new DateTime(uniqueAI.LastKillYear, uniqueAI.LastKillMonth, uniqueAI.LastKillDay, uniqueAI.LastKillHour, uniqueAI.LastKillMinute, 0, 0);
                DateTime timeNow = DateTime.Now;
                if (timeNow.CompareTo(timeKilled) < 0)
                    return false;
            }
            if (Respawn.Map == null) return false;

            for (int i = 0; i < 10; i++)
            {
                CurrentLocation = new Point(Respawn.Info.Location.X + Envir.Random.Next(-Respawn.Info.Spread, Respawn.Info.Spread + 1),
                                            Respawn.Info.Location.Y + Envir.Random.Next(-Respawn.Info.Spread, Respawn.Info.Spread + 1));

                if (!respawn.Map.ValidPoint(CurrentLocation)) continue;

                respawn.Map.AddObject(this);

                CurrentMap = respawn.Map;

                if (Respawn.Route.Count > 0)
                    Route.AddRange(Respawn.Route);

                RefreshAll();
                SetHP(MaxHP);

                Spawned();
                Respawn.Count++;
                respawn.Map.MonsterCount++;
                Envir.MonsterCount++;
                return true;
            }
            return false;
        }