Пример #1
0
 public void addToSynchronizedAreas(Area area)
 {
     if(synchronizedAreas.Contains(area))
         return;
     if(area.getMobs().Count == 0)
         return;
     synchronizedAreas.Add(area);
     //MobThreadPool.run();
 }
Пример #2
0
 public Mob(MobController mController)
 {
     this.mController = mController;
     this.uID = WMap.Instance.mobsCount;
     this.maxHP = mController.getData().getMaxHP();
     this.curHP = maxHP;
     WMap.Instance.mobsCount++;
     this.spawnX = mController.getSpawnX();
     this.spawnY = mController.getSpawnY();
     this.area = WMap.Instance.getGrid(mController.getMap()).getAreaByRound(spawnX, spawnY);
     this.positionX = Randomizer.NextInt(this.area.getGrid().getaSize()) + this.area.getAreaStartingPosition()[0]; // cause I can.
     this.positionY = Randomizer.NextInt(this.area.getGrid().getaSize()) + this.area.getAreaStartingPosition()[1]; // cause I can.
     if(area != null)
         area.addMob(this);
     else
         Console.WriteLine("out of grid kurwa. {0} {1} {2}", mController.getMap(), spawnX, spawnY);
     this.death = false;
 }
Пример #3
0
 public Fightable getFightableNear(Area area, int uID)
 {
     for(int i = 0;i < 3;i++)
     {
         for(int u = 0;u < 3;u++)
         {
             Area nearCentral = getArea(new int[] { area.getAreaPosition()[0] - 1 + i, area.getAreaPosition()[1] - 1 + u });
             if(nearCentral == null)
                 continue;
             foreach(Fightable f in nearCentral.getMobs())
             {
                 if(f.getuID() == uID)
                     return f;
             }
             foreach(Fightable f in nearCentral.getCharacters())
             {
                 if(f.getuID() == uID)
                     return f;
             }
         }
     }
     return null;
 }
Пример #4
0
 public void removeFromSynchronizedAreas(Area area)
 {
     if(!synchronizedAreas.Contains(area))
         return;
     if(area.getCharacters().Count > 0)
         return;
     synchronizedAreas.Remove(area);
     if(synchronizedAreas.Count == 0)
     {
         // stop thread
     }
 }
Пример #5
0
 private void addArea(Area a)
 {
     if(this.areaExists(a.getaID())) return;
     this.areas.Add(a.getaID(), a);
 }
Пример #6
0
 public Boolean areaExists(Area area)
 {
     return this.areas.ContainsValue(area);
 }
Пример #7
0
 public void sendTo3x3AreaRemoveItem(Area area, int uID)
 {
     for(int i = 0;i < 3;i++)
     {
         for(int u = 0;u < 3;u++)
         {
             Area nearCentral = getArea(new int[] { area.getAreaPosition()[0] - 1 + i, area.getAreaPosition()[1] - 1 + u });
             if(nearCentral == null)
                 continue;
             foreach(Character characterAround in nearCentral.getCharacters())
             {
                 try
                 {
                     characterAround.getAccount().mClient.WriteRawPacket(ItemPackets.removeDroppedItemForCharacter(characterAround, uID));
                 }
                 catch(Exception e)
                 {
                     Console.WriteLine(e);
                 }
             }
         }
     }
 }
Пример #8
0
 public void sendTo3x3AreaSpawn(Character character, Area area, Boolean just_a_refresh_for_the_world = false)
 {
     if(!this.areaExists(area)) return;
     character.removeInnitedAreas();
     for (int i =0; i < 3; i++) {
         for (int u =0; u < 3; u++) {
             Area nearCentral = getArea(new int[] { area.getAreaPosition()[0]-1+i, area.getAreaPosition()[1]-1+u });
             if(nearCentral == null) continue;
             if(!just_a_refresh_for_the_world) nearCentral.sendAreaInit(character);
             foreach(Character characterAround in nearCentral.getCharacters()) {
                 if(characterAround == character) continue;
                 try {
                     Console.WriteLine("AreaSpawn> extCharPacket from: {0} for {1}", character.getName(), characterAround.getName());
                     characterAround.getAccount().mClient.WriteRawPacket(CharacterPackets.extCharPacket(character));
                 }
                 catch(Exception e) {
                     Console.WriteLine(e);
                 }
             }
             character.addInnitedArea(nearCentral.getaID());
             WMap.Instance.addToSynchronizedAreas(area);
         }
     }
 }
Пример #9
0
 public void sendTo3x3AreaMovement(Character character, Area area, byte[] packet)
 {
     if(!this.areaExists(area)) return;
     List<int> relistInnitedAreas = new List<int>();
     for (int i =0; i < 3; i++) {
         for (int u =0; u < 3; u++) {
             Area nearCentral = getArea(new int[] { area.getAreaPosition()[0]-1+i, area.getAreaPosition()[1]-1+u });
             if(nearCentral == null) continue;
             foreach(Character characterAround in nearCentral.getCharacters()) {
                 if(characterAround == character)
                     continue;
                 if(!character.getInnitedAreas().Contains(nearCentral.getaID()))
                 {
                     characterAround.getAccount().mClient.WriteRawPacket(CharacterPackets.extCharPacket(character));
                 }
                 try {
                     Console.WriteLine("AreaMove> Packet sent for {0} from {1}", characterAround.getName(), character.getName());
                     characterAround.getAccount().mClient.WriteRawPacket(packet);
                 }
                 catch(Exception e) {
                     Console.WriteLine(e);
                 }
             }
             if(character.getInnitedAreas().Contains(nearCentral.getaID()))
             {
                 relistInnitedAreas.Add(nearCentral.getaID());
                 continue;
             }
             nearCentral.sendAreaInit(character);
             relistInnitedAreas.Add(nearCentral.getaID());
         }
     }
     character.removeInnitedAreas();
     character.setInnitedAreas(relistInnitedAreas);
 }
Пример #10
0
 public void sendTo3x3AreaLeave(Character character, Area area)
 {
     if(!this.areaExists(area)) return;
     for (int i =0; i < 3; i++) {
         for (int u =0; u < 3; u++) {
             Area nearCentral = getArea(new int[] { area.getAreaPosition()[0]-1+i, area.getAreaPosition()[1]-1+u });
             if(nearCentral == null) continue;
             foreach(Character characterAround in nearCentral.getCharacters()) {
                 if(characterAround == character) continue;
                 try {
                     Console.WriteLine("AreaLeave> vanPacket from: {0} for {1}", character.getName(), characterAround.getName());
                     characterAround.getAccount().mClient.WriteRawPacket(CharacterPackets.vanCharPacket(character));
                 } catch (Exception e) { Console.WriteLine(e); }
             }
         }
     }
     character.getArea().removeCharacter(character);
     character.removeInnitedAreas();
     WMap.Instance.removeFromSynchronizedAreas(area);
 }
Пример #11
0
 public void sendTo3x3Area(Character character, Area area, byte[] packet)
 {
     if(!this.areaExists(area)) return;
     for (int i =0; i < 3; i++) {
         for (int u =0; u < 3; u++) {
             Area nearCentral = getArea(new int[] { area.getAreaPosition()[0]-1+i, area.getAreaPosition()[1]-1+u });
             if(nearCentral == null) continue;
             foreach(Character characterAround in nearCentral.getCharacters()) {
                 if(characterAround == character) continue;
                 try {
                     Console.WriteLine("Area> Packet sent for {0} from {1}", characterAround.getName(), character.getName());
                     characterAround.getAccount().mClient.WriteRawPacket(packet);
                 } catch (Exception e) { Console.WriteLine(e); }
             }
         }
     }
 }
Пример #12
0
 public void initGrid()
 {
     for(int i = 0;i < this.gSize[1];i++) {
         for(int u = 0;u < this.gSize[0];u++) {
             Area area = new Area((u * this.getrGSize()) + i, new int[] { u, i }, this);
             this.addArea(area);
         }
     }
 }
Пример #13
0
 public void setArea(Area area)
 {
     this.area = area;
 }