Beispiel #1
0
    private void WalkToTarget(Vector3 target)
    {
        Vector3 levelTarget = new Vector3(target.x, transform.position.y, target.z);
        float   duration    = Vector3.Distance(levelTarget, transform.position) / m_walkSpeed;

        // Flip sprite to face direction
        if (levelTarget.x > transform.position.x)
        {
            transform.localScale = new Vector3(-originalScale.x, originalScale.y, originalScale.z);
        }
        else
        {
            transform.localScale = new Vector3(originalScale.x, originalScale.y, originalScale.z);
        }

        // Animate
        if (!m_audioSource.isPlaying)
        {
            m_audioSource.Play();
        }
        m_walkCycle.StartCycle();
        iTween.MoveTo(gameObject,
                      iTween.Hash("x", levelTarget.x, "y", levelTarget.y, "z", levelTarget.z, "time", duration, "oncomplete", "OnFinish", "easetype", iTween.EaseType.linear));

        // Instantiate walk circle
        Vector3 walkCircleTarget = new Vector3(levelTarget.x, 0.05f, levelTarget.z);

        GameObject.Instantiate(m_walkCirclePrefab, walkCircleTarget, Quaternion.identity);

        // Move camera
        m_cameraFollow.OnWalk(walkCircleTarget);
    }
Beispiel #2
0
    public void ChangeCycleTarget(AnimationCycle target)
    {
        if (target == m_walkCycle)
        {
            return;
        }

        bool wasPlaying = m_walkCycle.m_isPlaying;

        m_walkCycle.StopCycle();

        m_walkCycle = target;
        if (wasPlaying)
        {
            m_walkCycle.StartCycle();
        }
    }