public void LoadGame() { RLGame loadedGame = ioService.LoadGame(); this.map = loadedGame.map; this.levelGenerator = loadedGame.levelGenerator; this.messages = loadedGame.messages; this.renderer = loadedGame.renderer; this.ioService = loadedGame.ioService; this.monsters = loadedGame.monsters; this.messages = loadedGame.messages; this.playerActionsService = loadedGame.playerActionsService; this.aiService = loadedGame.aiService; this.hero = loadedGame.hero; this.dice = loadedGame.dice; }
public RLGame(Interfaces.IRLRenderer renderer = null, Interfaces.IRLLevelGenerator levelGenerator = null, IJsonGameIOService jsonService = null, RLMap map = null, List<RLMonster> monsters = null, Stack<Tuple<ConsoleColor, string>> messages = null, RLPlayerActionsService playerActionsService = null, RLAIService aiService = null, RLHero hero = null, RLDice injectedDice = null) { this.renderer = renderer != null ? renderer : new RLRenderer(); this.levelGenerator = levelGenerator != null ? levelGenerator : new RLLevelGenerator(); this.ioService = jsonService != null ? jsonService : new JsonGameIOService(); this.map = map; this.monsters = monsters != null ? monsters : new List<RLMonster>(); this.messages = messages != null ? messages : new Stack<Tuple<ConsoleColor, string>>(); this.playerActionsService = playerActionsService != null ? playerActionsService : new RLPlayerActionsService(); this.dice = injectedDice != null ? injectedDice : new RLDice(); this.aiService = aiService != null ? aiService : new RLAIService(dice); this.hero = hero != null ? hero : this.levelGenerator.GetDefaultHero(); }
public Tuple<int, int> moveAway(RLMonster monster, RLHero hero) { //work out differences to find the axis with the greatest difference. We'll move along that axis. int x = monster.locationX, y = monster.locationY; int xDiff = monster.locationX - hero.locationX; int yDiff = monster.locationY - hero.locationY; if (xDiff < 0) { xDiff = xDiff * -1; } if (yDiff < 0) { yDiff = yDiff * -1; } if (xDiff >= yDiff) { if (hero.locationX > monster.locationX) { x--; } else { x++; } } else { if (hero.locationY > monster.locationY) { y--; } else { y++; } } return new Tuple<int, int>(x, y); }