public void Use(List <HexCell> cells) { HexCell cell = cells[0]; if (cell.Type == HexTileType.Wall) { // _moveCells = GetMoveTargets(cell); // Active.Prepare(this, _moveCells); _theWall = cell; Active.Prepare(this, GetMoveTargets(cell)); AnimationPlayer.Add(new MoveTo(ParentCharacter.CharacterObject.transform, cell.transform.position, 0.13f)); } else { // int removeAfterIndex = _moveCells.FindIndex(c => c == cell); // List<HexCell> realMoveCells = _moveCells.GetRange(0, removeAfterIndex); ParentCharacter.MoveTo(cell); List <HexCell> realMoveCells = _theWall.GetLine(_theWall.GetDirection(cell), _theWall.GetDistance(cell)); List <Character> targets = realMoveCells.SelectMany(c => ParentCharacter.DefaultGetBasicAttackCells(c)) .ToList().WhereOnlyEnemiesOf(Owner).GetCharacters().Distinct().ToList(); targets.ForEach(t => ParentCharacter.Attack(this, t, new Damage(ParentCharacter.AttackPoints.Value, DamageType.Physical))); Finish(); } }
public override void Awake() { ParentCharacter.BeforeBasicAttack += (character, damage) => { if (character.ParentCell.Effects.ContainsType(typeof(HexCellEffects.Conflagration))) { damage.Value = (int)(damage.Value * (DamagePercent / 100f)); } }; ParentCharacter.GetBasicAttackCells = () => { var cellRange = ParentCharacter.DefaultGetBasicAttackCells(); IEnumerable <HexCell> cellsWithConflagrationAndEnemyCharacters = HexMapDrawer.Instance.Cells .Where(c => c.Effects.Any(e => e.GetType() == typeof(HexCellEffects.Conflagration))) .Where(c => c.CharacterOnCell != null && c.CharacterOnCell.Owner != ParentCharacter.Owner); cellRange.AddRange(cellsWithConflagrationAndEnemyCharacters); return(cellRange.Distinct().ToList()); }; }
public Conflagration() : base(AbilityType.Normal, "Conflagration", 2) { OnAwake += () => { ParentCharacter.BeforeBasicAttack += (character, damage) => { bool isEnemyOnConflagration = character.ParentCell.Effects.ContainsType(typeof(HexCellEffects.Conflagration)); bool isEnemyInBasicAttackRange = ParentCharacter.DefaultGetBasicAttackCells().GetCharacters().Contains(character); if (!isEnemyInBasicAttackRange && isEnemyOnConflagration) { damage.Value = (int)(damage.Value * (DamagePercent / 100f)); } }; ParentCharacter.GetBasicAttackCells = () => { List <HexCell> cellRange = ParentCharacter.DefaultGetBasicAttackCells(); IEnumerable <HexCell> cellsWithConflagrationAndEnemyCharacters = HexMapDrawer.Instance.Cells .Where(c => c.Effects.Any(e => e.GetType() == typeof(HexCellEffects.Conflagration))) .Where(c => c.CharacterOnCell != null && c.CharacterOnCell.Owner != ParentCharacter.Owner); cellRange.AddRange(cellsWithConflagrationAndEnemyCharacters); return(cellRange.Distinct().ToList()); }; }; }