Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     _sprite         = GetComponent <SpriteRenderer>();
     animator        = GetComponent <Animator>();
     initialPosition = transform.position;
     direction       = MOVING_STATE.LEFT;
     //maxDist += transform.position.x;
     //minDist -= transform.position.x;
     movingSpeed = 0.3f;
     timeCount   = 0;
     EnemyState  = InitState;
     isGrounded  = false;
 }
Ejemplo n.º 2
0
        void MoveBackward()
        {
            if (movementLimiter.position.x >= movingRangeMin)
            {
                movingState = MOVING_STATE.Backward;

                moveDirection = backward * moveSpeed * Time.deltaTime;


                rotateGear.Rotate(Vector3.forward, rotateSpeed * Time.deltaTime);

                if (rotateGear2)
                {
                    rotateGear2.Rotate(Vector3.forward, rotateSpeed * Time.deltaTime);
                }
            }
            else
            {
                MoveIdle();
            }
        }
Ejemplo n.º 3
0
    private void Moving()
    {
        switch (direction)
        {
        case MOVING_STATE.LEFT:
            if (transform.position.x >= minDist)
            {
                transform.position += Vector3.right * -movingSpeed * Time.deltaTime;
                _sprite.flipX       = false;
                animator.SetBool("isMoving", true);
            }
            else
            {
                direction  = MOVING_STATE.RIGHT;
                EnemyState = ENEMY_STATE.IDLE;
                animator.SetBool("isMoving", false);
            }
            break;

        case MOVING_STATE.RIGHT:
            if (transform.position.x <= maxDist)
            {
                transform.position += Vector3.right * movingSpeed * Time.deltaTime;
                _sprite.flipX       = true;
                animator.SetBool("isMoving", true);
            }
            else
            {
                direction  = MOVING_STATE.LEFT;
                EnemyState = ENEMY_STATE.IDLE;
                animator.SetBool("isMoving", false);
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 4
0
        void MoveIdle()
        {
            movingState = MOVING_STATE.Idle;

            moveDirection = Vector3.zero;
        }