public IEnumerator MoveUnitInDirection(Direction direction) { movingDirection = direction; Tile target = occupiedTile.directionMap[direction]; if (target != null) { // Going to another tile if (!target.HasUnit()) { AudioManager.instance.PlaySFX("Move"); yield return(MoveAnimation(target.transform.position)); target.PlaceUnit(this); InfoHolder.ResetUnit(); } else { Debug.Log("encountered enemy"); if (playertype != target.Unit.playertype) { Unit targetUnit = target.Unit; CheckAbilityCond(Ability.ActivationType.ATTACK); yield return(AttackAnimation(targetUnit)); yield return(targetUnit.TakeDamage(attack, this)); yield return(TakeDamage(targetUnit.attack, targetUnit)); } } } else { if (playertype == PlayerType.DOG && direction == Direction.RIGHT) { // Dog attacks Nexus yield return(TussleManager.instance.AttackNexus(this, PlayerType.CAT)); } else if (playertype == PlayerType.CAT && direction == Direction.LEFT) { yield return(TussleManager.instance.AttackNexus(this, PlayerType.DOG)); } } movementLeft--; // StartBounceAnimation(); yield return(new WaitForSeconds(stepDuration)); }
private void OnMouseExit() { InfoHolder.ResetUnit(); }