Пример #1
0
        public bool CanMove(CharacterBase gameObjectBehavior)
        {
            if (Input.GetKey(KeyCode.Space) && gameObjectBehavior.GetBombs() > 0)
            {
                return(false);
            }

            direction = PhysicsHelper.GetDirectionByKeyboard();

            return(direction != Vector3.zero);
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        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));
                }
            }
        }
Пример #4
0
        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;
                }
            }
        }
Пример #5
0
 public bool CanMove(CharacterBase gameObjectBehavior)
 {
     direction = PhysicsHelper.GetDirectionByKeyboard();
     return(direction != Vector3.zero);
 }