void punchEnemies(Stack <GameObject> enemyStack) { if (enemyStack.Count == 0) { return; } var enemy = enemyStack.Pop(); // var enemyCollider = enemy.GetComponent<Collider2D>(); var enemyController = enemy.GetComponent <AIController>(); var playerController = character.GetComponent <CollisionController>(); //set collision between character and enemy manually playerController.OnCollisionEnter2DManual(enemy); enemyController.OnCollisionEnter2DManual(character); Vector2 target = enemy.transform.position; Vector2 vecBetween = target - (Vector2)character.transform.position; movmentLogic.RotateToDash(vecBetween); animationLogic.OnMoveSetDirection(new moveAnimationModel { direction = vecBetween.normalized }); LeanTween.move(character, (Vector2)target, superHitTime).setIgnoreTimeScale(true).setEase(LeanTweenType.easeInOutElastic).setOnComplete(() => { punchRecursionLogic(enemyStack); }); }
public void MoveCharacter(MoveCharacterModel model) { //player out of dashes if (playerStatsLogic.dashNum <= 0) { return; } playerStatsLogic.dashNum--; soundLogic.playJumpSound(); ResetRotation(); animationLogic.SetDashing(); Vector2 target = new Vector2(model.touchPoint.x, model.touchPoint.y); Vector2 vecBetween = target - model.player.position; var distToGo = vecBetween.magnitude; if (distToGo > dashDist) { distToGo = dashDist; target = model.player.position + model.Direction * distToGo; } RotateToDash(vecBetween); animationLogic.OnMoveSetDirection(new moveAnimationModel { direction = vecBetween.normalized }); LeanTween.cancel(character.gameObject, true); LeanTween.move(model.player.gameObject, (Vector2)target, CalculateTimeForDistance(distToGo)).setEase(LeanTweenType.easeInOutQuad).setOnComplete( () => { FinishedMoving(playerStatsLogic.combo); }); }