示例#1
0
        private IEnumerator ShoutCoroutine(float radius)
        {
            float shoutTimer = 0.0f;

            GameObject currentShout = Instantiate(shoutMarkerPrefab) as GameObject;
            Shout      tempShout    = new Shout(currentShout, radius);

            listShoutMarkers.Add(tempShout);
            currentShout.SetActive(false);

            currentShout.transform.localScale = Vector3.one;
            Vector3 shoutPosition = transform.position;

            shoutPosition.y = currentShout.transform.position.y;
            currentShout.transform.position = shoutPosition;
            currentShout.SetActive(true);

            if (playsound)
            {
                SoundController.instance.PlayClip("shoutClip");
                playsound = false;
            }
            float          startingTime = Time.time;
            SpriteRenderer objectSprite = currentShout.GetComponent <SpriteRenderer>();
            Color          col          = new Color(1, 1, 1, 1);


            while (shoutTimer <= 1)
            {
                shoutTimer  = (Time.time - startingTime) * 1;
                shoutTimer /= 0.6f * (Time.time - startingTime + 0.5f);
                col.a       = 1.5f - shoutTimer;
                currentShout.transform.localScale = Vector3.one * shoutTimer * radius * 2;
                GameController.instance.PlayerShouted(currentShout.transform);
                yield return(null);

                objectSprite.color = col;
            }
            GameController.instance.PlayerShouted(currentShout.transform);
            listShoutMarkers.Remove(tempShout);
            Destroy(currentShout);
        }
        private IEnumerator ShoutCoroutine(float radius)
        {
            float shoutTimer = 0.0f;

            GameObject currentShout = Instantiate(shoutMarkerPrefab) as GameObject;
            Shout tempShout = new Shout(currentShout, radius);
            listShoutMarkers.Add(tempShout);
            currentShout.SetActive(false);

            currentShout.transform.localScale = Vector3.one;
            Vector3 shoutPosition = transform.position;
            shoutPosition.y = currentShout.transform.position.y;
            currentShout.transform.position = shoutPosition;
            currentShout.SetActive(true);

            if(playsound)
            {
                SoundController.instance.PlayClip("shoutClip");
                playsound = false;
            }
            float startingTime = Time.time;
            SpriteRenderer objectSprite = currentShout.GetComponent<SpriteRenderer>();
            Color col = new Color(1,1,1,1);

            while(shoutTimer <= 1)
            {
                shoutTimer = (Time.time - startingTime) * 1  ;
                shoutTimer /= 0.6f * (Time.time - startingTime + 0.5f);
                col.a = 1.5f - shoutTimer;
                currentShout.transform.localScale = Vector3.one * shoutTimer * radius * 2;
                GameController.instance.PlayerShouted(currentShout.transform);
                yield return null;
                objectSprite.color = col;
            }
            GameController.instance.PlayerShouted(currentShout.transform);
            listShoutMarkers.Remove(tempShout);
            Destroy(currentShout);
        }