public void SpawnFigureToPoint(int figureIndex) { GameFigure figureBufer = spawnBufer.figureOnThisPoint; GameFigure spawnFigureBufer = Instantiate(figureBufer.army == Army.White ? whiteSpawnFigure[figureIndex] : blackSpawnFigure[figureIndex], figureBufer.transform.position, figureBufer.transform.rotation); spawnFigureBufer.currentPosition = figureBufer.currentPosition; spawnFigureBufer.moveSpeed = figureBufer.moveSpeed; spawnFigureBufer.Initialize(this); spawnFigureBufer.SetRelationsMaterial(relationsMaterials[1]); if (spawnFigureBufer.army == Army.White) { whiteArmyBufer[figureIndex]--; } else { blackArmyBufer[figureIndex]--; } figures.Add(spawnFigureBufer); RemoveFigure(figureBufer); ClearBoardDrawing(); chooseFigurePanel.SetActive(false); GameFieldSettingsPack.IsMenu = false; CheckArmy(); CheckDefeat(); ComputerStep(); }
public void ChoseFirstTurn() { switch (_lastGameResult) { case GameResult.Lose: PlayerFigure = GameFigure.Circle; StateController.Instance.AITurnState(); break; case GameResult.Draw: if (PlayerFigure == GameFigure.Circle) { PlayerFigure = GameFigure.Cross; StateController.Instance.UserTurnState(); } else { PlayerFigure = GameFigure.Circle; StateController.Instance.AITurnState(); } break; case GameResult.Win: PlayerFigure = GameFigure.Cross; StateController.Instance.UserTurnState(); break; case GameResult.None: PlayerFigure = GameFigure.Cross; StateController.Instance.UserTurnState(); break; } }
public void SetUnderSwordState(GameFigure figure) //помечает фигуру как возможную для сруба (Метка "Под ударом") { currentEnemy = figure; enemyLink.SetActive(true); if (GetSupportFigures().Count > 0 && GameFieldSettingsPack.DrawShields) { shields.SetActive(true); } figure.OnChoosenTargetEnemy += ClearFigureUnderAttackLink; }
public void RemoveFigure(GameFigure figure) { if (figure.type == FigureType.King) { FinalGame(figure.army); } figure.RemoveEventLinks(this); figures.Remove(figure); Destroy(figure.gameObject); ClearBoardDrawing(); ClearAllAttackLinks(); }
public bool Attack(GameFigure target) { if (target != null && UseMeleeAttack && _data.MainHero.TargetObjectId == target.ObjectId && !_data.PlayerIsCasting && _data.MainHero.RangeTo(target) >= MinimumAttackDistance && _data.MainHero.RangeTo(target) <= MaximumAttackDistance + 150) { _actionsController.Attack(); return(true); } return(false); }
/// <summary> /// Маппер фигр и их изображений. /// </summary> public Image GetPieceImage(GameFigure figure, GameSide side) { if (side == GameSide.White) { switch (figure) { case GameFigure.Rook: return(PeiceImages[0, 2]); case GameFigure.King: return(PeiceImages[0, 0]); case GameFigure.Bishop: return(PeiceImages[0, 3]); case GameFigure.Knight: return(PeiceImages[0, 4]); case GameFigure.Queen: return(PeiceImages[0, 1]); case GameFigure.Pawn: return(PeiceImages[0, 5]); } } if (side == GameSide.Black) { switch (figure) { case GameFigure.Rook: return(PeiceImages[1, 2]); case GameFigure.King: return(PeiceImages[1, 0]); case GameFigure.Bishop: return(PeiceImages[1, 3]); case GameFigure.Knight: return(PeiceImages[1, 4]); case GameFigure.Queen: return(PeiceImages[1, 1]); case GameFigure.Pawn: return(PeiceImages[1, 5]); } } return(null); }
public void CheckFieldLinksForFigure(GameFigure setFigure) //чистка отрисовки на всех клетках и установка конфигурации относительно выбранной фигуры { ClearBoardDrawing(); List <GameFieldPoint> figureAttackPoints; foreach (var item in figures) { figureAttackPoints = item.GetDrawPointsWithoutFigure(setFigure); foreach (var point in figureAttackPoints) { point.attackFigures.Add(item); } item.ClearMove(); } }
public void DrawPointState(GameFigure setFigure) { if (attackFigures.Count == 0 || (attackFigures.Count == 1 && attackFigures[0] == setFigure)) { PointState = PointState.empty; if (GameFieldSettingsPack.DrawEmptyCell) { gameFieldPointArea.positionArea.SetActive(true); } } else { bool protectOnly = true; bool drawKey = true; PointState = PointState.block; foreach (var item in attackFigures) { if (drawKey && item.army != setFigure.army) { PointState = PointState.underAttack; protectOnly = false; if (GameFieldSettingsPack.DrawUnderAttackCell) { gameFieldPointArea.positionArea.SetActive(true); } else if (GameFieldSettingsPack.DrawEmptyCell) { gameFieldPointArea.meshRenderer.material.color = gameFieldPointArea.moveColor; gameFieldPointArea.positionArea.SetActive(true); } drawKey = false; } item.DrawRelations(transform.position); } if (GameFieldSettingsPack.DrawProtectCell && protectOnly) { gameFieldPointArea.positionArea.SetActive(true); } else if (GameFieldSettingsPack.DrawEmptyCell && protectOnly) { gameFieldPointArea.meshRenderer.material.color = gameFieldPointArea.moveColor; gameFieldPointArea.positionArea.SetActive(true); } } }
public bool Nuke(GameFigure target) { var nuke = GetNukeToCast(target); if (nuke != null && _data.MainHero.RangeTo(target) >= nuke.MinDistance && _data.PlayerIsCasting == false && _data.MainHero.RangeTo(target) <= nuke.MaxDistance + 100 && (nuke.NukeType == NukeType.Item ? _data.Inventory.Any(item => item.Value.ItemId == nuke.NukeId) : true) && (nuke.NukeType == NukeType.Skill ? _data.Skills.Any(skill => skill.Value.SkillId == nuke.NukeId) : true)) { int timeout = 0; while (((timeout < 3) || (target.IsDead && _data.SurroundingMonsters.Any(mob => mob.ObjectId == target.ObjectId) && nuke.TargetIsDead)) && EngineRunning) { if (!nuke.TargetIsDead && target.IsDead) { break; } _data.LastUsedNukeId = nuke.NukeId; if (nuke.NukeType == NukeType.Skill) { _actionsController.UseSkill(nuke.NukeId, false, false); } else if (nuke.NukeType == NukeType.Item) { _actionsController.UseItem(_data.Inventory.First(item => item.Value.ItemId == nuke.NukeId).Key, false); } Thread.Sleep(500); timeout++; if (_data.AttackFlag && GetNukeToCast(target) != nuke) { break; } } nuke.LastUsed = Environment.TickCount - 500; return(true); } return(false); }
public void ChekFiguresUnderMyAttack() { List <GameFieldPoint> points = GetPointsUnderAttack(); foreach (var item in points) { if (!item.emptyField) { GameFigure enemy = item.figureOnThisPoint; if (enemy.army != army) { enemy.underAttack = true; } } else if (!item.attackFigures.Contains(this)) { item.attackFigures.Add(this); } } }
public Form1() { InitializeComponent(); this.comboBox1.SelectedIndex = 0; this.comboBox2.SelectedIndex = 0; this.selected = null; this.moved = false; this.timer = new Timer(); timer.Tick += new EventHandler(TimerElapsed); timer.Interval = 1000; this.tableView = new PictureBox[5][]; for (int i = 0; i < 5; i++) { this.tableView[i] = new PictureBox[5]; for (int j = 0; j < 5; j++) { Control c = this.tableLayoutPanel1.GetControlFromPosition(j, i); this.tableView[i][j] = (PictureBox)c; } } }
public override void Parse(L2PlayerData data) { int unitType = reader.ReadInt(); //writeD(_activeChar.isServitor() ? 2 : _activeChar.isPet() ? 1 : 0); int objId = reader.ReadInt(); //writeD(_activeChar.getObjectId()); int buffsCount = reader.ReadInt(); //writeD(_effects.size()); if (data.MainHero.ObjectId != objId && data.AllUnits.All(unita => unita.ObjectId != objId)) { if (unitType == 0) { data.Players.Add(objId, new Player() { ObjectId = objId }); } else { data.Npcs.Add(objId, new Npc() { ObjectId = objId }); } } GameFigure unit = data.MainHero.ObjectId != objId?data.AllUnits.First(fig => fig.ObjectId == objId) : data.MainHero; unit.Buffs.Clear(); for (int i = 0; i < buffsCount; i++) { int Id = reader.ReadInt(); int level = reader.ReadShort(); int time = reader.ReadInt(); Buff buff = new Buff(Id, level, time); unit.Buffs.Add(Id, buff); } }
public void ClearFigureUnderAttackLink() //Убрать метку "Под ударом" { enemyLink.SetActive(false); shields.SetActive(false); currentEnemy = null; }
public override List <GameFieldPoint> GetDrawPointsWithoutFigure(GameFigure setFigure) { return(GetPointsUnderAttack()); }
public abstract List <GameFieldPoint> GetDrawPointsWithoutFigure(GameFigure setFigure); //клетки для трисовки без учёта указанной фигуры
private void PictureBoxClickHandler(int i, int j, object sender, EventArgs e) { try { if (g == null) { throw new GameNotYetStarted(); } if (g.GetPlayer(g.Turn).Type == GamePlayer.PlayerType.Human) { if (g.State == Game.GameState.WaitingForPlayer1ToPlaceFigure1 || g.State == Game.GameState.WaitingForPlayer1ToPlaceFigure2 || g.State == Game.GameState.WaitingForPlayer2ToPlaceFigure1 || g.State == Game.GameState.WaitingForPlayer2ToPlaceFigure2) { if (!g.PlaceFigure(i, j)) { throw new InvalidMove(); } } else if (g.State == Game.GameState.WaitingForPlayer1Move || g.State == Game.GameState.WaitingForPlayer2Move) { if (selected == null) { selected = g.Table.FigureAt(i, j); if (selected != null && !g.GetCurrentPlayer().PlayersFigure(selected)) { selected = null; } } else { if (selected.OnSpot(i, j) && !moved) { selected = null; } else if (!moved) { moved = g.MoveFigure(selected, i, j, false); if (!moved) { throw new InvalidMove(); } } else { if (g.Build(selected, i, j, false)) { moved = false; selected = null; } else { throw new InvalidMove(); } } } } if (g.IsFinished()) { selected = null; moved = false; } RefreshTableView(); timer.Start(); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public PartyHealBuffRule GetRuleForCast(bool inCombat) { if (Math.Abs(Environment.TickCount - _timeStamp) < 50) { return(_latestRule); } _timeStamp = Environment.TickCount; PartyHealBuffRule nuke = null; foreach (var nukeRule in NukesToUse) { if ((nukeRule.NukeType == NukeType.Item ? !_data.Inventory.Any(item => item.Value.ItemId == nukeRule.PartyHealBuffId) : false) || (nukeRule.NukeType == NukeType.Skill ? !_data.Skills.Any(skill => skill.Value.SkillId == nukeRule.PartyHealBuffId) : false)) { continue; } foreach (var partyUnit in nukeRule.PlayersToBuff) { if (partyUnit.Enable) { Player ptMember = _data.PartyMembers.FirstOrDefault( member => member.Name.Equals( partyUnit.Name.Split(new string[] { "'s" }, StringSplitOptions.None)[0])); if (ptMember == null) { continue; } GameFigure target = (partyUnit.Name.Contains("'s") ? (GameFigure)ptMember.PlayerSummons.FirstOrDefault( summ => summ.Name.Trim() .Equals( partyUnit.Name.Split(new string[] { "'s" }, StringSplitOptions.None)[1].Trim(), StringComparison.OrdinalIgnoreCase)) : (GameFigure)ptMember); if (target == null) { continue; } GameFigure condFigure = _data.MainHero; if (_data.SurroundingPlayers.All(player => player.ObjectId != target.ObjectId)) { continue; } if (!nukeRule.Enabled) { continue; } //cond checks if (condFigure != null) { if (nukeRule.HealthPercentOver > 0 && nukeRule.HealthPercentOver > condFigure.HealthPercent) { continue; } if (nukeRule.HealthPercentBelow > 0 && nukeRule.HealthPercentBelow < condFigure.HealthPercent) { continue; } if (nukeRule.ManaPercentOver > 0 && nukeRule.ManaPercentOver > condFigure.ManaPercent) { continue; } if (nukeRule.ManaPercentBelow > 0 && nukeRule.ManaPercentBelow < condFigure.ManaPercent) { continue; } if (condFigure is MainHero && nukeRule.CombatPointsPercentOver > 0 && nukeRule.CombatPointsPercentOver > condFigure.CombatPointsPercent) { continue; } if (condFigure is MainHero && nukeRule.CombatPointsPercentBelow > 0 && nukeRule.CombatPointsPercentBelow < condFigure.CombatPointsPercent) { continue; } } condFigure = target; if (condFigure != null) { if (nukeRule.PartyMemberHealthPercentOver > 0 && nukeRule.PartyMemberHealthPercentOver > condFigure.HealthPercent) { continue; } if (nukeRule.PartyMemberHealthPercentBelow > 0 && nukeRule.PartyMemberHealthPercentBelow < condFigure.HealthPercent) { continue; } if (nukeRule.PartyMemberManaPercentOver > 0 && nukeRule.PartyMemberManaPercentOver > condFigure.ManaPercent) { continue; } if (nukeRule.PartyMemberManaPercentBelow > 0 && nukeRule.PartyMemberManaPercentBelow < condFigure.ManaPercent) { continue; } if (nukeRule.PartyMemberCombatPointsPercentOver > 0 && nukeRule.PartyMemberCombatPointsPercentOver > condFigure.CombatPointsPercent) { continue; } if (nukeRule.PartyMemberCombatPointsPercentBelow > 0 && nukeRule.PartyMemberCombatPointsPercentBelow < condFigure.CombatPointsPercent) { continue; } if (nukeRule.PartyMemberIsDead && !condFigure.IsDead) { continue; } if (!nukeRule.PartyMemberIsDead && condFigure.IsDead) { continue; } } int health = 0, maxHealth = 0, ptMembersAroundCount = 0; if (nukeRule.AveragePartyMemberHealthPercentOver > 0 || nukeRule.AveragePartyMemberHealthPercentBelow > 0) { foreach (var partyMember in _data.PartyMembers) { if (_data.MainHero.RangeTo(partyMember) < 1000) { ptMembersAroundCount++; health += partyMember.Health; maxHealth += partyMember.MaxHealth; } } } double avrgPtHealthPercent = ptMembersAroundCount > 0 ? (health / (double)maxHealth) * 100.0 : 0; if (nukeRule.AveragePartyMemberHealthPercentOver > 0 && avrgPtHealthPercent > 0 && nukeRule.AveragePartyMemberHealthPercentOver > avrgPtHealthPercent) { continue; } if (nukeRule.AveragePartyMemberHealthPercentBelow > 0 && avrgPtHealthPercent > 0 && nukeRule.AveragePartyMemberHealthPercentBelow < avrgPtHealthPercent) { continue; } if (nukeRule.DeadPartyMembersOver > 0 && nukeRule.DeadPartyMembersOver > _data.PartyMembers.Count(member => member.IsDead)) { continue; } if (nukeRule.DeadPartyMembersBelow > 0 && nukeRule.DeadPartyMembersBelow < _data.PartyMembers.Count(member => member.IsDead)) { continue; } if (Math.Abs(Environment.TickCount - nukeRule.LastUsed) < nukeRule.Interval * 1000) { continue; } if (nukeRule.UseIfBuffIsMissing && nukeRule.SelectedBuffsStr.Trim().Length > 0 && nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && target.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { var rule = nukeRule.SelectedBuffsFilter.First( buffRule => buffRule.Enable && target.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase))); var name = rule.Name; if (nukeRule.TimerCheckActivated) { var seconds = target.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.SecondsLeft; if (nukeRule.TimerComparisonTypeEnum == ComparisonType.Less && seconds > nukeRule.TimerSeconds) { continue; } else if (nukeRule.TimerComparisonTypeEnum == ComparisonType.More && seconds < nukeRule.TimerSeconds) { continue; } } if (nukeRule.SkillLevelComparisonActivated) { var level = target.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.Level; if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Less && level > nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.More && level < nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Equal && level != nukeRule.SkillLevelRequired) { continue; } } } if (nukeRule.UseIfBuffIsMissing && nukeRule.SelectedBuffsStr.Trim().Length > 0 && !nukeRule.TimerCheckActivated && !nukeRule.SkillLevelComparisonActivated && nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && target.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { continue; } if (nukeRule.UseIfBuffIsPresent && nukeRule.SelectedBuffsStr.Trim().Length > 0 && nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && target.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { var rule = nukeRule.SelectedBuffsFilter.First( buffRule => buffRule.Enable && target.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase))); var name = rule.Name; if (nukeRule.TimerCheckActivated) { var seconds = target.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.SecondsLeft; if (nukeRule.TimerComparisonTypeEnum == ComparisonType.Less && seconds > nukeRule.TimerSeconds) { continue; } else if (nukeRule.TimerComparisonTypeEnum == ComparisonType.More && seconds < nukeRule.TimerSeconds) { continue; } } if (nukeRule.SkillLevelComparisonActivated) { var level = target.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.Level; if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Less && level > nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.More && level < nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Equal && level != nukeRule.SkillLevelRequired) { continue; } } } if (nukeRule.UseIfBuffIsPresent && nukeRule.SelectedBuffsStr.Trim().Length > 0 && !nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && target.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { continue; } if (nukeRule.NukeType == NukeType.Skill && !_data.Skills[nukeRule.PartyHealBuffId].CanBeUsed()) { continue; } if (!nukeRule.UseInCombat && inCombat) { continue; } if (nukeRule.NukeType == NukeType.Skill && _data.MainHero.Mana < ExportedData.SkillManaConsumption[nukeRule.PartyHealBuffId][ _data.Skills[nukeRule.PartyHealBuffId].SkillLevel] * 0.75) { continue; } if (nukeRule.RequiresTarget) { if (_data.MainHero.RangeTo(target) > nukeRule.MaxDistance) { continue; } } nuke = nukeRule; nuke.ChosenTarget = target; break; } } } _latestRule = nuke; return(nuke); }
public override List <GameFieldPoint> GetDrawPointsWithoutFigure(GameFigure setFigure) { List <GameFieldPoint> pointsForDraw = new List <GameFieldPoint>(); Vector2Int newCell = currentPosition; bool iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //вперёд вправо { newCell += new Vector2Int(1, 1); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //назад вправо { newCell += new Vector2Int(1, -1); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //назад влево { newCell += new Vector2Int(-1, -1); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //вперёд влево { newCell += new Vector2Int(-1, 1); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //вперёд { newCell += new Vector2Int(0, 1); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //назад { newCell += new Vector2Int(0, -1); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //вправо { newCell += new Vector2Int(1, 0); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } newCell = currentPosition; iCanMoveInThisDirection = true; while (iCanMoveInThisDirection) //влево { newCell += new Vector2Int(-1, 0); if (OpportunityToMove(newCell)) { pointsForDraw.Add(gameField[newCell.y, newCell.x]); if (!IsEmptyCell(newCell)) { if (gameField[newCell.y, newCell.x].figureOnThisPoint != setFigure) { iCanMoveInThisDirection = false; } } } else { iCanMoveInThisDirection = false; } } return(pointsForDraw); }
public NukeRule GetNukeToCast(GameFigure target) { //if (Math.Abs(Environment.TickCount - _timeStamp) < 50) //{ // return _latestRule; //} _timeStamp = Environment.TickCount; NukeRule nuke = null; if (target != null) { foreach (var nukeRule in NukesToUse) { if ((nukeRule.NukeType == NukeType.Item ? !_data.Inventory.Any(item => item.Value.ItemId == nukeRule.NukeId) : false) || (nukeRule.NukeType == NukeType.Skill ? !_data.Skills.Any(skill => skill.Value.SkillId == nukeRule.NukeId) : false)) { continue; } GameFigure selfCondFigure = _data.MainHero; if (!nukeRule.Enabled) { continue; } //cond checks if (selfCondFigure != null) { if (nukeRule.HealthPercentOver > 0 && nukeRule.HealthPercentOver > selfCondFigure.HealthPercent) { continue; } if (nukeRule.HealthPercentBelow > 0 && nukeRule.HealthPercentBelow < selfCondFigure.HealthPercent) { continue; } if (nukeRule.ManaPercentOver > 0 && nukeRule.ManaPercentOver > selfCondFigure.ManaPercent) { continue; } if (nukeRule.ManaPercentBelow > 0 && nukeRule.ManaPercentBelow < selfCondFigure.ManaPercent) { continue; } if (selfCondFigure is MainHero && nukeRule.CombatPointsPercentOver > 0 && nukeRule.CombatPointsPercentOver > selfCondFigure.CombatPointsPercent) { continue; } if (selfCondFigure is MainHero && nukeRule.CombatPointsPercentBelow > 0 && nukeRule.CombatPointsPercentBelow < selfCondFigure.CombatPointsPercent) { continue; } } if (target != null && target.Health > 0) { if (nukeRule.TargetHealthPercentOver > 0 && nukeRule.TargetHealthPercentOver > target.HealthPercent) { continue; } if (nukeRule.TargetHealthPercentBelow > 0 && nukeRule.TargetHealthPercentBelow < target.HealthPercent) { continue; } if (nukeRule.TargetManaPercentOver > 0 && nukeRule.TargetManaPercentOver > target.ManaPercent) { continue; } if (nukeRule.TargetManaPercentBelow > 0 && nukeRule.TargetManaPercentBelow < target.ManaPercent) { continue; } } if (nukeRule.TargetIsDead && !target.IsDead) { continue; } if (!nukeRule.TargetIsDead && target.IsDead) { continue; } if (nukeRule.TargetIsSpoiled && (!(target is Npc) || ((Npc)target).IsSweepable == false)) { continue; } if (nukeRule.RepeatUntilSuccess && _data.LandedSkills.ContainsKey(nukeRule.NukeId) && _data.LandedSkills[nukeRule.NukeId] == target.ObjectId) { continue; } if (Math.Abs(Environment.TickCount - nukeRule.LastUsed) < nukeRule.Interval * 1000) { continue; } if (nukeRule.MonsterFilterType == FilterType.Inclusive && nukeRule.MonsterFilterStr.Trim().Length > 0 && !nukeRule.MonsterFilter.Any(mob => mob.Enable && mob.Name.Trim().Equals(ExportedData.NpcIdToName[target.UnitId].Trim(), StringComparison.OrdinalIgnoreCase))) { continue; } if (nukeRule.MonsterFilterType == FilterType.Exclusive && nukeRule.MonsterFilterStr.Trim().Length > 0 && nukeRule.MonsterFilter.Any(mob => mob.Enable && mob.Name.Trim().Equals(ExportedData.NpcIdToName[target.UnitId].Trim(), StringComparison.OrdinalIgnoreCase))) { continue; } if (nukeRule.AoeActivated) { if (nukeRule.AoeMonstersAroundType == TargetType.Self) { int mobsCount = _data.SurroundingMonsters.Count(mob => mob.RangeTo(_data.MainHero) < nukeRule.AoeRange && !mob.IsDead); if (nukeRule.AoeCountComparisonTypeEnum == ComparisonType.Less && mobsCount >= nukeRule.AoeMonsterCount) { continue; } else if (nukeRule.AoeCountComparisonTypeEnum == ComparisonType.More && mobsCount <= nukeRule.AoeMonsterCount) { continue; } } else { int mobsCount = _data.SurroundingMonsters.Count(mob => mob.RangeTo(target) < nukeRule.AoeRange && !mob.IsDead); if (nukeRule.AoeCountComparisonTypeEnum == ComparisonType.Less && mobsCount >= nukeRule.AoeMonsterCount) { continue; } else if (nukeRule.AoeCountComparisonTypeEnum == ComparisonType.More && mobsCount <= nukeRule.AoeMonsterCount) { continue; } } } if (nukeRule.NukeType == NukeType.Skill && !_data.Skills[nukeRule.NukeId].CanBeUsed()) { continue; } if (nukeRule.NukeType == NukeType.Skill && _data.MainHero.Mana < ExportedData.SkillManaConsumption[nukeRule.NukeId][_data.Skills[nukeRule.NukeId].SkillLevel]) { continue; } nuke = nukeRule; break; } } _latestRule = nuke; return(nuke); }
public void SetPointAsWaypointForFigure(GameFigure setFigure) { //figureOnThisPoint = setFigure; OnPositionClick += setFigure.SetTargetPos; pointForMove = true; }
public override void Parse(L2PlayerData data) { GameFigure unit = null; int objId = reader.ReadInt(); if (data.MainHero.ObjectId == objId) { unit = data.MainHero; } else if (data.Players.ContainsKey(objId)) { unit = data.Players[objId]; } else if (data.Npcs.ContainsKey(objId)) { unit = data.Npcs[objId]; } if (unit == null) { return; } int atributeCount = reader.ReadInt(); for (int i = 0; i < atributeCount; i++) { int atriType = reader.ReadInt(); int atriValue = reader.ReadInt(); switch (atriType) { case CUR_HP: unit.Health = atriValue; break; case MAX_HP: unit.MaxHealth = atriValue; break; case CUR_MP: unit.Mana = atriValue; break; case MAX_MP: unit.MaxMana = atriValue; break; case CUR_CP: unit.CombatPoints = atriValue; break; case MAX_CP: unit.MaxCombatPoints = atriValue; break; case LEVEL: unit.Level = atriValue; break; } } }
public GamePeice(GamePoint point, GameSide side = GameSide.Undefined, GameFigure figure = GameFigure.None) { Side = side; Point = point; Figure = figure; }
public override List <GameFieldPoint> GetDrawPointsWithoutFigure(GameFigure setFigure) { return(GetPointsForStepWithOtherFigures()); }
public SelfHealBuffRule GetRuleForCast(bool inCombat) { if (Math.Abs(Environment.TickCount - _timeStamp) < 50) { return(_latestRule); } _timeStamp = Environment.TickCount; SelfHealBuffRule nuke = null; foreach (var nukeRule in NukesToUse) { if ((nukeRule.NukeType == NukeType.Item ? !_data.Inventory.Any(item => item.Value.ItemId == nukeRule.SelfHealBuffId) : false) || (nukeRule.NukeType == NukeType.Skill ? !_data.Skills.Any(skill => skill.Value.SkillId == nukeRule.SelfHealBuffId) : false)) { continue; } GameFigure condFigure = _data.MainHero; if (!nukeRule.Enabled) { continue; } //cond checks if (condFigure != null) { if (nukeRule.HealthPercentOver > 0 && nukeRule.HealthPercentOver > condFigure.HealthPercent) { continue; } if (nukeRule.HealthPercentBelow > 0 && nukeRule.HealthPercentBelow < condFigure.HealthPercent) { continue; } if (nukeRule.ManaPercentOver > 0 && nukeRule.ManaPercentOver > condFigure.ManaPercent) { continue; } if (nukeRule.ManaPercentBelow > 0 && nukeRule.ManaPercentBelow < condFigure.ManaPercent) { continue; } if (condFigure is MainHero && nukeRule.CombatPointsPercentOver > 0 && nukeRule.CombatPointsPercentOver > condFigure.CombatPointsPercent) { continue; } if (condFigure is MainHero && nukeRule.CombatPointsPercentBelow > 0 && nukeRule.CombatPointsPercentBelow < condFigure.CombatPointsPercent) { continue; } } condFigure = _data.MainHero.PlayerSummons.Count > 0 ? _data.MainHero.PlayerSummons.First() : null; if (condFigure != null) { if (nukeRule.PetHealthPercentOver > 0 && nukeRule.PetHealthPercentOver > condFigure.HealthPercent) { continue; } if (nukeRule.PetHealthPercentBelow > 0 && nukeRule.PetHealthPercentBelow < condFigure.HealthPercent) { continue; } if (nukeRule.PetManaPercentOver > 0 && nukeRule.PetManaPercentOver > condFigure.ManaPercent) { continue; } if (nukeRule.PetManaPercentBelow > 0 && nukeRule.PetManaPercentBelow < condFigure.ManaPercent) { continue; } } if (nukeRule.PetSummonCountBelow > 0 && _data.MainHero.PlayerSummons.Count >= nukeRule.PetSummonCountBelow) { continue; } if (Math.Abs(Environment.TickCount - nukeRule.LastUsed) < nukeRule.Interval * 1000) { continue; } if (nukeRule.HasDeathPenalty && _data.MainHero.DeathPenaltyLevel == 0) { continue; } if (nukeRule.UseIfBuffIsMissing && nukeRule.SelectedBuffsStr.Trim().Length > 0 && nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && _data.MainHero.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { var rule = nukeRule.SelectedBuffsFilter.FirstOrDefault( buffRule => buffRule.Enable && _data.MainHero.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase))); if (rule == null) { continue; } var name = rule.Name; if (nukeRule.TimerCheckActivated) { var seconds = _data.MainHero.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.SecondsLeft; if (nukeRule.TimerComparisonTypeEnum == ComparisonType.Less && seconds > nukeRule.TimerSeconds) { continue; } else if (nukeRule.TimerComparisonTypeEnum == ComparisonType.More && seconds < nukeRule.TimerSeconds) { continue; } } if (nukeRule.SkillLevelComparisonActivated) { var level = _data.MainHero.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.Level; if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Less && level > nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.More && level < nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Equal && level != nukeRule.SkillLevelRequired) { continue; } } } if (nukeRule.UseIfBuffIsMissing && nukeRule.SelectedBuffsStr.Trim().Length > 0 && !nukeRule.TimerCheckActivated && !nukeRule.SkillLevelComparisonActivated && nukeRule.SelectedBuffsFilter.Any(buffRule => buffRule.Enable && _data.MainHero.Buffs.Any(buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { continue; } if (nukeRule.UseIfBuffIsPresent && nukeRule.SelectedBuffsStr.Trim().Length > 0 && nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && _data.MainHero.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { var rule = nukeRule.SelectedBuffsFilter.First( buffRule => buffRule.Enable && _data.MainHero.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase))); var name = rule.Name; if (nukeRule.TimerCheckActivated) { var seconds = _data.MainHero.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.SecondsLeft; if (nukeRule.TimerComparisonTypeEnum == ComparisonType.Less && seconds > nukeRule.TimerSeconds) { continue; } else if (nukeRule.TimerComparisonTypeEnum == ComparisonType.More && seconds < nukeRule.TimerSeconds) { continue; } } if (nukeRule.SkillLevelComparisonActivated) { var level = _data.MainHero.Buffs.First( buff => buff.Value.BuffName.Equals(name, StringComparison.OrdinalIgnoreCase)) .Value.Level; if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Less && level > nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.More && level < nukeRule.SkillLevelRequired) { continue; } else if (nukeRule.SkillLevelComparisonTypeEnum == ComparisonType.Equal && level != nukeRule.SkillLevelRequired) { continue; } } } if (nukeRule.UseIfBuffIsPresent && nukeRule.SelectedBuffsStr.Trim().Length > 0 && !nukeRule.SelectedBuffsFilter.Any( buffRule => buffRule.Enable && _data.MainHero.Buffs.Any( buff => buff.Value.BuffName.Equals(buffRule.Name, StringComparison.OrdinalIgnoreCase)))) { continue; } if (nukeRule.NukeType == NukeType.Skill && !_data.Skills[nukeRule.SelfHealBuffId].CanBeUsed()) { continue; } if (!nukeRule.UseInCombat && inCombat) { continue; } if (nukeRule.NukeType == NukeType.Skill && _data.MainHero.Mana < ExportedData.SkillManaConsumption[nukeRule.SelfHealBuffId][_data.Skills[nukeRule.SelfHealBuffId].SkillLevel]) { continue; } nuke = nukeRule; break; } _latestRule = nuke; return(nuke); }
public void SetFigure(GameFigure setFigure) { figureOnThisPoint = setFigure; emptyField = false; }