public void AddMonster(int monsterID, int chanceOfEncountering) { if (MonsterHere.Exists(m => m.MonsterID == monsterID)) { MonsterHere.First(m => m.MonsterID == monsterID) .ChanceOfEncountering = chanceOfEncountering; } else { MonsterHere.Add(new MonsterEncounter(monsterID, chanceOfEncountering)); } }
public void AddMonster(int monsterID, int chanceOfEncountering) { if (MonsterHere.Exists(m => m.MonsterID == monsterID)) { //Hvis monster er her, reset gammel værdi med ny værdi. MonsterHere.First(m => m.MonsterID == monsterID).ChanceOfEncountering = chanceOfEncountering; } else { //Hvis der ikke er noget monster, tilføj monster. MonsterHere.Add(new MonsterEncounter(monsterID, chanceOfEncountering)); } }
public void AddMonster(int monsterID, int chanceOfEncounter) { if (MonsterHere.Exists(m => m.MonsterID == monsterID)) { // This monster has already been loaded in this location // so, overwrite the ChanceOfEncounter with the new number MonsterHere.First(m => m.MonsterID == monsterID) .ChanceOfEncounter = chanceOfEncounter; } else { // This monster is not already at this location, so add it. MonsterHere.Add(new MonsterEncounter(monsterID, chanceOfEncounter)); } }