Stop() public method

public Stop ( ) : void
return void
Beispiel #1
0
    void Awake()
    {
        var camGO = GameObject.Find("MainCamera");

        if (camGO)
        {
            transform.rotation = camGO.transform.rotation;
        }

        Walker = GetComponent <RoadWalker>();
        sprite = GetComponent <tk2dAnimatedSprite>();

        Walker.RoadToWalk = GameUtils.FindAssociatedLevel(transform).transform.Find("Road").GetComponent <Spline>();

        Walker.Step();
        lastPosition = transform.position;
        Walker.Step();
        UpdateDirection();

        transform.Find("RotatedCollider").gameObject.layer = LayerMask.NameToLayer("Player");

        if (MainGameView.Instance)
        {
            Walker.Stop();
            MainGameView.Instance.m_OnSceneReadyCallback += Walker.Resume;
        }
    }
Beispiel #2
0
    void Start()
    {
        transform.localRotation = Quaternion.identity;

        sprite = GetComponent<tk2dAnimatedSprite>();
        parent = transform.parent.GetComponent<Malisse>();
        Walker = GetComponent<RoadWalker>();

        Walker.RoadToWalk = GameUtils.FindAssociatedLevel(transform).transform.Find("Road").GetComponent<Spline>();

        Walker.Stop();
    }
Beispiel #3
0
    IEnumerator JumpBackAndStartle()
    {
        var lastName = sprite.CurrentClip.name;

        if (lastName == "walk_rs")
        {
            sprite.FlipX();
        }

        Walker.Stop();

        sprite.Play("fall");

        // Scatter farthest one!
        var toScatter = GetComponentsInChildren <Rabbit>().OrderBy(x => x.DistanceToMalisse);

        if (toScatter.Any() && toScatter.Last().DistanceToMalisse > 0)
        {
            toScatter.Last().Scatter();
        }

        foreach (var b in GetComponentsInChildren <Rabbit>().Where(x => !x.Scattering))
        {
            if (b.GetComponent <tk2dAnimatedSprite>().CurrentClip.name.StartsWith("r"))
            {
                b.GetComponent <tk2dAnimatedSprite>().FlipX();
            }
            b.GetComponent <tk2dAnimatedSprite>().Play("fall");
            b.GetComponent <Rabbit>().Stunned = true;
        }

        var heights = GetComponentsInChildren <Rabbit>().Select(_ => Random.Range(50.0f, 150)).ToArray();
        var speeds  = GetComponentsInChildren <Rabbit>().Select(_ => Random.Range(1, 2.0f)).ToArray();

        float t = 0;

        while (t < 1)
        {
            float step = Mathf.Pow(1 - t, 1.25f);
            Walker.DistanceFromStart -= Time.deltaTime * 30.0f * step;

            Walker.HeightOffset = Mathf.Sin(t * Mathf.PI) * 200.0f - 70f;

            int i = 0;
            foreach (var b in GetComponentsInChildren <Rabbit>().Where(x => !x.Scattering))
            {
                b.GetComponent <tk2dAnimatedSprite>().Play("timeout", Random.Range(0, 1.0f));
                b.Walker.HeightOffset = Mathf.Sin(Mathf.Clamp01(t * speeds[i]) * Mathf.PI) * heights[i++] - 5.0f;
            }

            yield return(new WaitForEndOfFrame());

            t += Time.deltaTime;
        }

        sprite.Play("timeout");
        Walker.HeightOffset = -75.0f;

        foreach (var b in GetComponentsInChildren <Rabbit>().Where(x => !x.Scattering))
        {
            b.GetComponent <tk2dAnimatedSprite>().Play("timeout", Random.Range(0, 1.0f));
            b.Walker.HeightOffset = -12.0f;
        }

        AudioManager.Instance.PlaySFX(m_SFXHitFloor);

        yield return(new WaitForSeconds(2.0f));

        if (GetComponentsInChildren <Rabbit>().Length > 0)
        {
            Walker.HeightOffset = 0.0f;
            foreach (var b in GetComponentsInChildren <Rabbit>().Where(x => !x.Scattering))
            {
                b.Walker.HeightOffset             = 0.0f;
                b.GetComponent <Rabbit>().Stunned = false;
            }

            Walker.Resume();
        }
        else
        {
            FlowManager.Instance.TriggerAction("GAME_OVER");
        }
    }
Beispiel #4
0
    void Awake()
    {
        var camGO = GameObject.Find("MainCamera");
        if (camGO)
            transform.rotation = camGO.transform.rotation;

        Walker = GetComponent<RoadWalker>();
        sprite = GetComponent<tk2dAnimatedSprite>();

        Walker.RoadToWalk = GameUtils.FindAssociatedLevel(transform).transform.Find("Road").GetComponent<Spline>();

        Walker.Step();
        lastPosition = transform.position;
        Walker.Step();
        UpdateDirection();

        transform.Find("RotatedCollider").gameObject.layer = LayerMask.NameToLayer("Player");

        if (MainGameView.Instance)
        {
            Walker.Stop();
            MainGameView.Instance.m_OnSceneReadyCallback += Walker.Resume;
        }
    }