Beispiel #1
0
 public Level(string name, Map map)
 {
     Name              = name;
     Map               = map;
     Map.CellChange   += (x, y, creature) => CellChange?.Invoke(x, y, creature);
     Map.Die          += (x, y, creature) => Die?.Invoke(x, y, creature);
     Map.Damaged      += (x, y, creature, damage) => Damaged?.Invoke(x, y, creature, damage);
     Map.DoingStarted += (x, y, character, doing) => DoingStarted?.Invoke(x, y, character, doing);
     Map.DoingEnd     += (x, y, character, doing) => DoingEnd?.Invoke(x, y, character, doing);
     Map.Die          += (x, y, creature) =>
     {
         if (creature is Base _base)
         {
             EndWin?.Invoke(!_base.IsPlayerCreature);
             IsEnd = true;
         }
     };
 }
Beispiel #2
0
 public Level(string name)
 {
     Name              = name;
     Map               = new Map(File.ReadAllLines(GetFolderName() + "\\map.txt"));
     Map.CellChange   += (x, y, creature) => CellChange?.Invoke(x, y, creature);
     Map.Die          += (x, y, creature) => Die?.Invoke(x, y, creature);
     Map.Damaged      += (x, y, creature, damage) => Damaged?.Invoke(x, y, creature, damage);
     Map.DoingStarted += (x, y, character, doing) => DoingStarted?.Invoke(x, y, character, doing);
     Map.DoingEnd     += (x, y, character, doing) => DoingEnd?.Invoke(x, y, character, doing);
     Map.Die          += (x, y, creature) =>
     {
         if (creature is Base _base)
         {
             EndWin?.Invoke(!_base.IsPlayerCreature);
             IsEnd = true;
         }
     };
 }
Beispiel #3
0
 public void AddCharacter(Character character)
 {
     if (character.IsPlayerCreature && PlayerCharactersQueue.Count < 50)
     {
         PlayerCharactersQueue.Enqueue(character);
     }
     else if (EnemyCharactersQueue.Count < 50)
     {
         EnemyCharactersQueue.Enqueue(character);
     }
     character.Die += (x, y, creature) =>
     {
         if (this[x, y] == null)
         {
             return;
         }
         this[x, y] = null;
         Die?.Invoke(x, y, creature);
     };
     character.Damaged    += (x, y, creature, damage) => Damaged?.Invoke(x, y, creature, damage);
     character.StartDoing += (x, y, creature, doing) => DoingStarted?.Invoke(x, y, creature, doing);
     character.EndDoing   += (x, y, creature, doing) => DoingEnd?.Invoke(x, y, creature, doing);
     SpawnCharactersInQueue();
 }