Ejemplo n.º 1
0
    void Start()
    {
        objectVision = GetComponent<ObjectVision> ();
        jumpSlerpObject = GetComponent<JumpSlerpObject> ();
        rotateObject = GetComponent<RotateObject> ();

        int startDir = Random.Range (1, 30);

        currentDirection = startDir >= 15 ? JumperDirection.left : JumperDirection.right;
    }
Ejemplo n.º 2
0
    public void Jump()
    {
        if (objectVision == null) {
            objectVision = GetComponent<ObjectVision>();
            if (objectVision == null) {
                Debug.LogError("ObjectVision scritp not assigned");
            }
        }

        if (objectVision.hasBarrier())
            return;
        if (objectVision.isOnEdge())
            return;

        if (GetComponent<Rigidbody>().velocity.magnitude > 0.02f) return;

        float jumpX = 0, jumpZ = 0;

        switch (JumpObject.GetTransformDirection(rotateObject.toRotation)) {
            case Direction.Left: jumpX = -jumpDistanceOnSide; jumpZ = 0;
            break;
            case Direction.Right: jumpX = jumpDistanceOnSide; jumpZ = 0;
            break;
            case Direction.Forward: jumpX = 0; jumpZ = jumpDistanceUp;
            break;
            case Direction.Backward: jumpX = 0; jumpZ = -jumpDistanceDown;
            break;
            default: Debug.Log (Direction.Undefined.ToString() + " is not right direction");
            break;
        }

        GetComponent<Rigidbody>().velocity = new Vector3(jumpX,jumpHeight,jumpZ);
        done = false;

        if (!audioSource.isPlaying) {
            audioSource.pitch = Random.Range(0.6f,1.4f);
            audioSource.Play();
        }

        return;
    }
Ejemplo n.º 3
0
    void Start()
    {
        audioSource = GetComponent<AudioSource> ();

        rotateObject = GetComponent<RotateObject> ();
        if (!rotateObject) {
            Debug.LogError("rotate object not assigned");
        }
        objectVision = null;
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        rigidBody = GetComponent<Rigidbody> ();
        audioSource = GetComponent<AudioSource> ();
        jumpSlerpObject = GetComponent<JumpSlerpObject> ();
        rotateObject = GetComponent<RotateObject> ();
        objectVision = GetComponent<ObjectVision> ();

        jumpSlerpObject.OnJumpSlerpEnded += OnJumpEnded;
        rotateObject.OnRotationEnded += OnRotateEnded;
        rotateObject.OnRotationStarted += OnRotateStarted;

        animator = GetComponent<Animator> ();

        isDead = false;
    }