Example #1
0
 public void appear()
 {
     mat.color = new Color(1, 1, 1, 1);
     state     = ChispaWorldState.comingOut;
     anim.SetBool("isOut", true);
     transitioning = true;
 }
Example #2
0
    // Update is called once per frame
    new void Update()
    {
        elapsedTime += Time.deltaTime;
        if (elapsedTime > (1.0f / animationSpeed))
        {
            frame = (frame + 1) % images.Length;

            mat.sprite = images [frame];
        }

        if (state != ChispaWorldState.idle)
        {
            timeToEmit += Time.deltaTime;
            if (timeToEmit > (1.0f / dustFrequency))
            {
                timeToEmit = 0.0f;
                float      newAngle  = FloatRandom.floatRandomRange(0, 6.28f);
                GameObject newDustGO = (GameObject)Instantiate(dustPrefab, this.transform.position,
                                                               Quaternion.Euler(0, 0, newAngle));
            }
        }



        if (state == ChispaWorldState.comingOut)
        {
            if (anim.GetCurrentAnimatorStateInfo(0).IsName("ChispaRemainsOut"))
            {
                notifyFinishAction();
                state         = ChispaWorldState.Out;
                transitioning = false;
            }

            /*AnimatorStateInfo inf = anim.GetCurrentAnimatorStateInfo (0);
             * float nt = inf.normalizedTime;
             *
             *
             * if ((anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f)
             *      && !anim.IsInTransition(0)) {
             *
             *      notifyFinishAction();
             *      state = ChispaWorldState.Out;
             * }*/
        }



        if (state == ChispaWorldState.returning)
        {
            if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
            {
                mat.color = new Color(0, 0, 0, 0);
                notifyFinishAction();
                state         = ChispaWorldState.idle;
                transitioning = false;
            }
        }
    }
Example #3
0
    // Use this for initialization
    new void Start()
    {
        frame       = 0;
        timeToEmit  = 0.0f;
        elapsedTime = 0.0f;

        //mat = this.GetComponent<Renderer> ().material;
        mat  = this.GetComponent <SpriteRenderer> ();
        anim = this.GetComponent <Animator> ();

        state     = ChispaWorldState.idle;
        mat.color = new Color(0, 0, 0, 0);

        transitioning = false;
    }
Example #4
0
 public void disappear()
 {
     state = ChispaWorldState.returning;
     anim.SetBool("isOut", false);
     transitioning = true;
 }