public override IPromise <bool> MoveTo(IntVector2 direction) { GameManager.instance.BeforeHeroMove(); var cell = Position; var next = cell; for (int i = 0; i < 100; i++) { next = cell.ToDirection(direction); if (next != null && !next.Figures.Any(IsTarget)) { cell = next; } } return(Promise.Do(() => { if (next == null) { return Promise.Resolved(); } var target = next.figures[0]; if (target == null || !target.gameObject.activeSelf) { return Promise.Resolved(); } var onHit = target.GetComponentInChildren <OnShotgunHit>(); if (onHit == null) { return Promise.Resolved(); } shotgunSound.Play(); return PlayBulletFlyAnimation(Position, next).Then(() => { onHit.Run(); }); }).Then(() => { cell = Position.ToDirection(direction); if (cell != null) { if (cell.figures.FirstOrDefault() is Crate) { Position.MoveHere(cell.figures.First()); } var oldPosition = Position; cell.MoveHere(this); moveSound.Play(); GameManager.instance.HeroMoved(this, oldPosition, Position, direction); } }).Return(true)); }