internal CombatEngine(PhysicsEngine engine, Player player, Map map) { m_player = player; m_map = map; m_physicsEngine = engine; m_random = new Random(); }
internal static void SetupBackground(Player player, string startingBackground) { switch (startingBackground) { case "Scholar": { player.AddSkill(SkillFactory.Instance.CreateSkill("Basic Staff Proficiency")); player.AddSkill(SkillFactory.Instance.CreateSkill("Blessing Of Mana I")); player.AddSkill(SkillFactory.Instance.CreateSkill("Blessing Of Mana II")); player.Equip(ItemFactory.Instance.CreateItemOfType("Staff", 0, "Wood", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("ChestArmor", 0, "Linen Cloth", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Helm", 0, "Linen Cloth", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Gloves", 0, "Linen Cloth", "Average")); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Potion", 0)); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Potion", 0)); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Potion", 1)); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Scroll", 1)); player.SkillPoints = 15; break; } case "Scout": { player.AddSkill(SkillFactory.Instance.CreateSkill("Basic Dagger Proficiency")); player.AddSkill(SkillFactory.Instance.CreateSkill("Basic Sling Proficiency")); player.AddSkill(SkillFactory.Instance.CreateSkill("Armor Proficiency")); player.AddSkill(SkillFactory.Instance.CreateSkill("Toughness I")); player.AddSkill(SkillFactory.Instance.CreateSkill("Light")); player.Equip(ItemFactory.Instance.CreateItemOfType("Dagger", 0, "Wrought Iron", "Average")); player.EquipSecondaryWeapon((IWeapon)ItemFactory.Instance.CreateItemOfType("Sling", 0, "Jute", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("ChestArmor", 0, "Light Leather", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Helm", 0, "Light Leather", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Gloves", 0, "Light Leather", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Boots", 0, "Light Leather", "Average")); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Potion", 0)); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Scroll", 1)); player.SkillPoints = 0; break; } case "Templar": { player.AddSkill(SkillFactory.Instance.CreateSkill("Basic Sword Proficiency")); player.AddSkill(SkillFactory.Instance.CreateSkill("Armor Proficiency")); player.AddSkill(SkillFactory.Instance.CreateSkill("Heavy Armor Proficiency")); player.Equip(ItemFactory.Instance.CreateItemOfType("Sword", 0, "Bronze", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("ChestArmor", 0, "Bronze", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Helm", 0, "Bronze", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Gloves", 0, "Bronze", "Average")); player.Equip(ItemFactory.Instance.CreateItemOfType("Boots", 0, "Bronze", "Average")); player.TakeItem(ItemFactory.Instance.CreateItemOfType("Potion", 0)); player.SkillPoints = 0; break; } default: throw new InvalidOperationException("SetupBackground with invalid background - " + startingBackground); } player.SetHPMPMax(); }
internal void NewMapPlayerInfo(Player player, Map map) { m_player = player; m_map = map; m_combatEngine.NewMapPlayerInfo(player, map); // We have a new map, recalc LOS with a new map m_fovManager.UpdateNewMap(this, m_map); UpdatePlayerVisitedStatus(); }
public PhysicsEngine(Player player, Map map) { m_player = player; m_map = map; m_timingEngine = new CoreTimingEngine(); m_fovManager = new FOVManager(this, map); m_combatEngine = new CombatEngine(this, player, map); m_movableHash = new Dictionary<Point, bool>(PointEqualityComparer.Instance); m_magicEffects = new MagicEffectsEngine(this, m_combatEngine); UpdatePlayerVisitedStatus(); }
internal Character GetNextActor(Player player, Map map) { List<Character> actors = new List<Character>(); actors.Add(player as Player); foreach (Monster m in map.Monsters) { actors.Add(m); } // Until we find a winner while (true) { // Check all valid actors for ability to go now Character actorWhoCanGo = actors.FirstOrDefault(a => a.CT >= TimeConstants.CTNeededForNewTurn); if (actorWhoCanGo != null) return actorWhoCanGo; // No actors can go now, so incremenet each one's CT actors.ForEach(a => a.IncreaseCT((int)(CTPerIteration * a.CTIncreaseModifier))); } }
internal bool PlayerMoveDownStairs(Player player, Map map) { Stairs s = map.MapObjects.OfType<Stairs>().Where(x => x.Type == MapObjectType.StairsDown && x.Position == player.Position).SingleOrDefault(); if (s != null) { if (CoreGameEngine.Instance.CurrentLevel == CoreGameEngine.Instance.NumberOfLevels - 1) throw new InvalidOperationException("Win dialog should have come up instead."); // The position must come first, as changing levels checks FOV m_player.Position = StairsMapping.Instance.GetMapping(s.UniqueID); CoreGameEngine.Instance.CurrentLevel++; m_timingEngine.ActorMadeMove(m_player); return true; } return false; }
internal bool PlayerMoveUpStairs(Player player, Map map) { Stairs s = map.MapObjects.OfType<Stairs>().Where(x => x.Type == MapObjectType.StairsUp && x.Position == player.Position).SingleOrDefault(); if (s != null) { // The position must come first, as changing levels checks FOV m_player.Position = StairsMapping.Instance.GetMapping(s.UniqueID); CoreGameEngine.Instance.CurrentLevel--; m_timingEngine.ActorMadeMove(m_player); return true; } return false; }
internal bool CastSpell(Player caster, Spell spell, Point target) { bool didAnything = m_magicEffects.CastSpell(caster, spell, target); if (didAnything) m_timingEngine.ActorDidAction(caster); return didAnything; }
internal void NewMapPlayerInfo(Player player, Map map) { m_player = player; m_map = map; }
public void CreateNewWorld(string playerName, string startingBackground) { // Don't use property so we don't hit validation code m_currentLevel = 0; Stairs incommingStairs = null; Random random = new Random(); bool generateCave = false; for (int i = 0; i < 5; ++i) { generateCave = random.Chance(50); MapGeneratorBase mapGenerator = generateCave ? (MapGeneratorBase)new SimpleCaveGenerator(random) : (MapGeneratorBase)new StitchtogeatherMapGenerator(random); m_dungeon[i] = mapGenerator.GenerateMap(incommingStairs, i); incommingStairs = m_dungeon[i].MapObjects.Where(x => x.Type == MapObjectType.StairsDown).OfType<Stairs>().First(); } Point initialStairsUpPosition = m_dungeon[0].MapObjects.Where(x => x.Type == MapObjectType.StairsUp).OfType<Stairs>().First().Position; ClearMonstersFromStartingArea(initialStairsUpPosition); m_player = new Player(playerName, initialStairsUpPosition); PlayerBackgrounds.SetupBackground(m_player, startingBackground); TurnCount = 0; m_physicsEngine = new PhysicsEngine(Player, Map); m_pathFinding = new PathfindingMap(Player, Map); // If the player isn't the first actor, let others go. See archtecture note in PublicGameEngine. m_physicsEngine.AfterPlayerAction(this); }
internal bool SwapPrimarySecondaryWeapons(Player player) { bool didSomething = player.SwapPrimarySecondaryWeapons(); if (didSomething) m_timingEngine.ActorDidMinorAction(m_player); return didSomething; }
internal bool ReloadWeapon(Player player) { return m_physicsEngine.ReloadWeapon(player); }
internal bool CastSpell(Player caster, Spell spell, Point target) { return m_physicsEngine.CastSpell(caster, spell, target); }
// Due to the way XML serialization works, we grab the Instance version of this // class, not any that we could pass in. This allows us to set the map data. internal void SetWithSaveData(Player p, Dictionary<int, Map> d, int currentLevel) { m_player = p; m_dungeon = d; // Don't use property so we don't hit state changing code m_currentLevel = currentLevel; }