public bool CanMove(CharacterBase gameObjectBehavior) { if (Input.GetKey(KeyCode.Space) && gameObjectBehavior.GetBombs() > 0) { return(false); } direction = PhysicsHelper.GetDirectionByKeyboard(); return(direction != Vector3.zero); }
private IEnumerator MakeMove(MonoBehaviour gameObjectBehavior, Vector3 start, Vector3 finish, float duration) { float elapsedTime = 0; float ratio = 0; while (ratio < duration) { elapsedTime += Time.deltaTime; ratio = elapsedTime / duration; if (!PhysicsHelper.CharacterSphereCast(gameObjectBehavior)) { gameObjectBehavior.transform.position = Vector3.Lerp(start, finish, ratio); } yield return(new WaitForEndOfFrame()); } }
public void Move(CharacterBase gameObjectBehavior) { //Helper.Rotate(gameObjectBehavior, direction); if (CanMove(gameObjectBehavior)) { Vector3 currentPosition = gameObjectBehavior.transform.position; Vector3 nextPosition = gameObjectBehavior.transform.position + direction; PhysicsHelper.Rotate(gameObjectBehavior, nextPosition, Enums.TypeOfVector3.NextPosition); if (!PhysicsHelper.CharacterSphereCast(gameObjectBehavior)) { gameObjectBehavior.StartCoroutine(MakeMove(gameObjectBehavior, currentPosition, nextPosition, duration)); } } }
private void RotateAndMove(CharacterBase gameObjectBehavior) { wallPass = gameObjectBehavior.CanWallPass(); PhysicsHelper.Rotate(gameObjectBehavior, direction, Enums.TypeOfVector3.Direction); if (!IsBorder(gameObjectBehavior.transform.position, direction)) { if (wallPass) { //gameObjectBehavior.transform.Translate(direction * Time.deltaTime * speed, Space.World); gameObjectBehavior.transform.position += direction * Time.deltaTime * speed; } else if (!PhysicsHelper.CharacterSphereCast(gameObjectBehavior)) { //gameObjectBehavior.transform.Translate(direction * Time.deltaTime * speed, Space.World); gameObjectBehavior.transform.position += direction * Time.deltaTime * speed; } } }
public bool CanMove(CharacterBase gameObjectBehavior) { direction = PhysicsHelper.GetDirectionByKeyboard(); return(direction != Vector3.zero); }