/// <summary> /// /// </summary> public MonsterFight(MapInstance map, long id, CharacterEntity character, MonsterGroupEntity monsterGroup) : base(FightTypeEnum.TYPE_PVM, map, id, character.Id, -1, character.CellId, monsterGroup.Id, -1, monsterGroup.CellId, WorldConfig.PVM_START_TIMEOUT, WorldConfig.PVM_TURN_TIME, false, false, new LootMonsterBehavior()) { Character = character; MonsterGroup = monsterGroup; JoinFight(Character, Team0); foreach(var monster in monsterGroup.Monsters) JoinFight(monster, Team1); foreach (var challenge in ChallengeManager.Instance.Generate(WorldConfig.PVM_CHALLENGE_COUNT)) Team0.AddChallenge(challenge); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> public PaddockDoor(MapInstance map, int cellId) : base(map, cellId) { m_paddock = map.Paddock; if (m_paddock == null) Logger.Info("null paddock on map " + map.Id); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <param name="walkThrough"></param> public HarvestableResource(MapInstance map, int cellId, int generatedTemplateId, int minRespawnTime, int maxRespawnTime, int experience, bool walkThrough = false) : base(map, cellId, walkThrough) { GeneratedTemplateId = generatedTemplateId; MinRespawnTime = minRespawnTime; MaxRespawnTime = maxRespawnTime; Experience = experience; }
/// <summary> /// /// </summary> public FightManager(MapInstance map) { m_map = map; m_map.AddUpdatable(this); m_map.SubArea.AddHandler(base.Dispatch); m_fightList = new Dictionary<long, AbstractFight>(); m_fightActions = new List<FightActionDAO>(FightActionRepository.Instance.GetById(ZoneTypeEnum.TYPE_MAP, m_map.Id)); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="id"></param> /// <param name="aggressor"></param> /// <param name="victim"></param> public AlignmentFight(MapInstance map, long id, AbstractFighter aggressor, CharacterEntity victim) : base(FightTypeEnum.TYPE_AGGRESSION, map, id, aggressor.Id, aggressor.AlignmentId, aggressor.CellId, victim.Id, victim.AlignmentId, victim.CellId, WorldConfig.AGGRESSION_START_TIMEOUT, WorldConfig.AGGRESSION_TURN_TIME, false, true, new HonorGainBehavior()) { IsNeutralAgression = victim.AlignmentId == (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL; JoinFight(aggressor, Team0); JoinFight(victim, Team1); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="currentCell"></param> /// <param name="radius"></param> /// <returns></returns> public static IEnumerable<int> GetCircleCells(MapInstance map, int currentCell, int radius) { var cells = new List<int>() { currentCell }; for (int i = 0; i < radius; i++) { var copy = cells.ToArray(); foreach (var cell in copy) cells.AddRange(GetAdjacentCells(map, cell).Where(x => !cells.Contains(x))); } return cells; }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="id"></param> /// <param name="monsters"></param> /// <param name="victim"></param> public AlignmentFight(MapInstance map, long id, MonsterGroupEntity monsters, CharacterEntity victim) : base(FightTypeEnum.TYPE_AGGRESSION, map, id, monsters.Id, monsters.AlignmentId, monsters.CellId, victim.Id, victim.AlignmentId, victim.CellId, WorldConfig.AGGRESSION_START_TIMEOUT, WorldConfig.AGGRESSION_TURN_TIME, false, true) { IsNeutralAgression = victim.AlignmentId == (int)AlignmentTypeEnum.ALIGNMENT_NEUTRAL; Monsters = monsters; foreach (var monster in monsters.Monsters) JoinFight(monster, Team0); JoinFight(victim, Team1); }
/// <summary> /// /// </summary> public TaxCollectorFight(MapInstance map, long id, CharacterEntity attacker, TaxCollectorEntity taxCollector) : base(FightTypeEnum.TYPE_PVT, map, id, attacker.Id, 0, attacker.CellId, taxCollector.Id, 0, taxCollector.CellId, WorldConfig.PVT_START_TIMEOUT, WorldConfig.PVT_TURN_TIME) { CanDefend = true; Attacker = attacker; TaxCollector = taxCollector; JoinFight(Attacker, Team0); JoinFight(TaxCollector, Team1); AddTimer(WorldConfig.PVT_TELEPORT_DEFENDERS_TIMEOUT, TeleportDefenders, true); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="id"></param> /// <param name="data"></param> /// <param name="trigger"></param> public MapCell(MapInstance map, int id, byte[] data, MapTriggerDAO trigger = null) { Id = id; Trigger = trigger; m_walkable = ((data[2] & 56) >> 3) > 0; if (!m_walkable && ((data[2] & 56) >> 3) != 0) return; LineOfSight = (data[0] & 1) == 1; if ((data[7] & 2) >> 1 == 1) { InteractiveObjectId = ((data[0] & 2) << 12) + ((data[1] & 1) << 12) + (data[8] << 6) + data[9]; if (InteractiveObjectManager.Instance.Exists(InteractiveObjectId)) InteractiveObject = InteractiveObjectManager.Instance.Generate(InteractiveObjectId, map, Id); } }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <param name="currentCell"></param> /// <param name="range"></param> /// <returns></returns> public static IEnumerable<int> GetCells(MapInstance map, int cellId, int currentCell, string range) { switch (range[0]) { case 'C': if (range[1] == '_') { foreach (var cell in map.Cells) yield return cell.Id; yield break; } else { foreach (var cell in GetCircleCells(map, cellId, Util.HASH.IndexOf(range[1]))) yield return cell; } break; case 'X': foreach (var cell in GetCrossCells(map, cellId, Util.HASH.IndexOf(range[1]))) yield return cell; break; case 'T': foreach (var cell in GetTLineCells(map, cellId, Pathfinding.GetDirection(map, currentCell, cellId), Util.HASH.IndexOf(range[1]))) yield return cell; break; case 'L': foreach (var cell in GetLineCells(map, cellId, Pathfinding.GetDirection(map, currentCell, cellId), Util.HASH.IndexOf(range[1]))) yield return cell; break; default: yield return cellId; break; } }
/// <summary> /// /// </summary> public ChallengerFight(MapInstance map, long id, CharacterEntity attacker, CharacterEntity defender) : base(FightTypeEnum.TYPE_CHALLENGE, map, id, attacker.Id, 0, attacker.CellId, defender.Id, 0, defender.CellId, WorldConfig.PVP_START_TIMEOUT, WorldConfig.PVP_TURN_TIME, true, false, new RegenerateLosersBehavior(), new RegenerateWinnersBehavior()) { Attacker = attacker; Defender = defender; JoinFight(Attacker, Team0); JoinFight(Defender, Team1); }
/// <summary> /// /// </summary> public CraftPlan(MapInstance map, int cellId) : base(map, cellId) { }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> public TrashCan(MapInstance map, int cellId) : base(map, cellId) { m_storage = new StorageInventory(); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <param name="canWalkThrough"></param> public Chest(MapInstance map, int cellId, bool canWalkThrough = false) : base(map, cellId, canWalkThrough) { //Logger.Debug(string.Format("chest on mapId: {0}, cellId: {1}", map.Id, cellId)); }
/// <summary> /// /// </summary> /// <param name="map"></param> public void SetMap(MapInstance map) { m_map = map; }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="currentCell"></param> /// <param name="radius"></param> /// <returns></returns> public static IEnumerable<int> GetCrossCells(MapInstance map, int currentCell, int radius) { foreach (var cell in GetCircleCells(map, currentCell, radius)) if (Pathfinding.InLine(map, currentCell, cell)) yield return cell; }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> public Pheonix(MapInstance map, int cellId) : base(map, cellId) { }
/// <summary> /// /// </summary> /// <param name="cellId"></param> public Waypoint(MapInstance map, int cellId) : base(map, cellId) { WaypointManager.Instance.AddWaypoint(Map.Id, this); }
/// <summary> /// /// </summary> public override void Dispose() { CurrentAction = null; if (Statistics != null) { Statistics.Dispose(); Statistics = null; } if (SpellBook != null) { SpellBook.Dispose(); SpellBook = null; } if (Inventory != null) { Inventory.Dispose(); Inventory = null; } m_listeners.Clear(); m_listeners = null; m_chatByChannel.Clear(); m_chatByChannel = null; m_map = null; base.Dispose(); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <param name="canWalkThrough"></param> public HouseDoor(MapInstance map, int cellId, bool canWalkThrough = false) : base(map, cellId, canWalkThrough) { // TODO: implement houses //Logger.Debug(string.Format("house door on mapId: {0}, cellId: {1}", map.Id, cellId)); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <param name="direction"></param> /// <param name="length"></param> /// <returns></returns> public static IEnumerable<int> GetTLineCells(MapInstance map, int cellId, int direction, int length) { var lineDirection = direction <= 5 ? direction + 2 : direction - 6; yield return cellId; foreach (var cell in GetLineCells(map, cellId, lineDirection, length)) yield return cell; foreach(var cell in (GetLineCells(map, cellId, Pathfinding.OppositeDirection(lineDirection), length))) yield return cell; }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="cellId"></param> public InteractiveObject(MapInstance map, int cellId, bool canWalkThrough = false) { CanWalkThrough = canWalkThrough; Map = map; CellId = cellId; // STARTS ON ACTIVE STATE ? YA NIGGAE IsActive = true; m_frameId = 0; }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <returns></returns> public static IEnumerable<int> GetAdjacentCells(MapInstance map, int cellId) { for (int i = 1; i < 8; i += 2) yield return Pathfinding.NextCell(map, cellId, i); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> /// <param name="direction"></param> /// <param name="length"></param> /// <returns></returns> public static IEnumerable<int> GetLineCells(MapInstance map, int cellId, int direction, int length) { yield return cellId; for (int i = 1; i < length + 1; i++) yield return Pathfinding.NextCell(map, cellId, direction, i); }
protected AbstractFight(FightTypeEnum type, MapInstance mapInstance, long id, long team0LeaderId, int team0Alignment, int team0FlagCell, long team1LeaderId, int team1Alignment, int team1FlagCell, long startTimeout, long turnTime, bool cancelButton = false, bool canWinHonor = false, params AbstractEndingBehavior[] endingBehaviors) { m_endingBehaviors = new Queue<AbstractEndingBehavior>(endingBehaviors); m_activableObjects = new Dictionary<AbstractFighter, List<AbstractActivableObject>>(); m_processingTargets = new LinkedList<CastInfos>(); m_currentApCost = -1; Type = type; Id = id; Map = mapInstance; State = FightStateEnum.STATE_PLACEMENT; LoopState = FightLoopStateEnum.STATE_INIT; CancelButton = cancelButton; TurnTime = turnTime; StartTime = startTimeout; NextLoopTimeout = startTimeout; Result = new FightEndResult(Id, canWinHonor); Cells = new Dictionary<int, FightCell>(); TurnProcessor = new FightTurnProcessor(); foreach (var cell in mapInstance.Cells) Cells.Add(cell.Id, new FightCell(cell.Id, cell.Walkable , cell.LineOfSight)); SpectatorTeam = new SpectatorTeam(this); Team0 = new FightTeam(0, team0LeaderId, team0Alignment, team0FlagCell, this, new List<FightCell>(Cells.Values.Where(cell => mapInstance.FightTeam0Cells.Contains(cell.Id)))); Team1 = new FightTeam(1, team1LeaderId, team1Alignment, team1FlagCell, this, new List<FightCell>(Cells.Values.Where(cell => mapInstance.FightTeam1Cells.Contains(cell.Id)))); Team0.OpponentTeam = Team1; Team1.OpponentTeam = Team0; AddUpdatable(SpectatorTeam); AddUpdatable(Team0); AddUpdatable(Team1); AddHandler(SpectatorTeam.Dispatch); AddHandler(Team0.Dispatch); AddHandler(Team1.Dispatch); }