protected override void OnRecoverFinished() { IntVector2 direction = directions[index]; Action action = hitDigOrMove.GetAction(direction); if (action.GetType() == typeof(ActionTryMove) && !hitDigOrMove.WillBump(direction)) { index = (index + 1) % directions.Count; } DoAction(action, direction); }
protected override void OnRecoverFinished() { int randIndex = Random.Range(0, randomDirections.Length); for (int i = 0; i < randomDirections.Length; i++) { IntVector2 direction = randomDirections[(randIndex + i) % randomDirections.Length]; if (!hitDigOrMove.WillBump(direction) || i == randomDirections.Length - 1) { DoAction(hitDigOrMove.GetAction(direction), direction); return; } } }
protected override void OnReadyForNextAction(GameObject target) { CheckAndUpdateIfInLineWithPlayer(target); IntVector2 currentPos = intTransform.GetPos(); IntVector2 targetPos = target.GetComponent <IntTransform>().GetPos(); IntVector2 direction = GetDirection(currentPos, targetPos); // If we don't have a shovel, this shouldn't be able to dig, instead change direction if (hitDigOrMove.WillBump(direction)) { headingHorizontal = !headingHorizontal; direction = GetDirection(currentPos, targetPos); } DoAction(hitDigOrMove.GetAction(direction), direction); if (target) { CheckAndUpdateIfInLineWithPlayer(target); } }