// Coroutine destruction / activation
    IEnumerator  DestroyChipFunction()
    {
        matching = true;
        AudioAssistant.Shot("ChipCrush");

        yield return(new WaitForSeconds(0.1f));

        matching = false;

        chip.ParentRemove();


        float   velocity = 0;
        Vector3 impuls   = new Vector3(Random.Range(-3f, 3f), Random.Range(1f, 5f), 0);

//		if (chip.impulse != Vector3.zero)
        impuls      += chip.impulse;
        chip.impulse = Vector3.zero;
        SpriteRenderer sprite = GetComponent <SpriteRenderer>();

        sprite.sortingLayerName = "Foreground";

        SetSortingLayer sLayer = GetComponentInChildren <SetSortingLayer> ();

        sLayer.sortingLayerName = "Foreground";
        sLayer.Refresh();

        float rotationSpeed = Random.Range(-720f, 720f);
        float growSpeed     = Random.Range(0.2f, 0.8f);

//		animation.Play("Minimizing");
//		animation ["Minimizing"].speed *= animation ["Minimizing"].length / t;
        while (transform.position.y > -10)
        {
            velocity           += Time.deltaTime * 20;
            velocity            = Mathf.Min(velocity, 40);
            transform.position += impuls * Time.deltaTime * transform.localScale.x;
            transform.position -= Vector3.up * Time.deltaTime * velocity * transform.localScale.x;
            transform.Rotate(0, 0, rotationSpeed * Time.deltaTime);
            transform.localScale += Vector3.one * growSpeed * Time.deltaTime;
            yield return(0);
        }

        Destroy(gameObject);
    }
Example #2
0
        // Update is called once per frame
        void Update()
        {
            switch (gameState)
            {
            case GAME_STATE.PLAY:
                countdown -= Time.deltaTime;
                if (countdown < 0)
                {
                    //addCurrency(UnityEngine.Random.Range(-1f, 4f));
                    countdown = 2;
                }

                for (int i = 0; i < timers.Count; i += 1)
                {
                    timers[i].Update(Time.deltaTime);
                }


                for (int i = tempText.Count - 1; i >= 0; i -= 1)
                {
                    GameObject      go  = tempText[i];
                    SetSortingLayer ssl = go.GetComponentInChildren <SetSortingLayer>();
                    float           a   = Mathf.Sin(ssl.lifeTime);
                    go.transform.Translate(0, 0.1f * a, 0);
                    ssl.lifeTime -= Time.deltaTime;

                    if (ssl.lifeTime <= 0)
                    {
                        SimplePool.Despawn(go);
                        tempText.RemoveAt(i);
                    }
                }


                //add pause and speed controls
                world.Update(Time.deltaTime);


                //foreach (Character chr in world.characters) {
                //  if (!Characters_ScrollItem_Map.ContainsKey(chr)) {
                //    GameObject g = Instantiate(debugCharItemPrefab, Vector2.zero, Quaternion.identity);
                //    g.transform.SetParent(debugCharContent.transform);
                //    Characters_ScrollItem_Map[chr] = g;

                //  }

                //  GameObject go = Characters_ScrollItem_Map[chr];
                //  go.GetComponent<scrollItemDebugCharacters>().Set(chr);


                //}

                break;

            case GAME_STATE.PAUSE:
                break;

            default:
                break;
            }
        }