예제 #1
0
        public static void Show(string prefabName, Vector3 position, int dir, float angle)
        {
            RectTransform rectTF = Instantiate(PrefabResources.Get(prefabName)) as RectTransform;

            rectTF.parent = GameMenu.INSTANCE.effectPanelTrans;
            ZombieAttackBlood component    = rectTF.GetComponent <ZombieAttackBlood>();
            float             startScaleX  = component.startScaleX;
            float             startScaleY  = component.startScaleY;
            float             minScaleX    = component.minScaleX;
            float             maxScaleX    = component.maxScaleX;
            float             minScaleY    = component.minScaleY;
            float             maxScaleY    = component.maxScaleY;
            float             scaleMoveMul = component.scaleMoveMul;
            float             x            = Random.Range(minScaleX, maxScaleX);
            float             y            = Random.Range(minScaleY, maxScaleY);

            if (dir > 0)
            {
                angle                  += Random.Range(-5, 5);
                position               += new Vector3((Mathf.Cos(angle) * x) * scaleMoveMul, (Mathf.Sin(angle) * y) * scaleMoveMul, 0f);
                rectTF.localPosition    = position;
                rectTF.localEulerAngles = new Vector3(0f, 0f, angle);
                rectTF.localScale       = new Vector3(startScaleX, startScaleY, 1f);
            }
            else if (dir < 0)
            {
                angle                  += UnityEngine.Random.Range(-5, 5);
                position               += new Vector3((-Mathf.Cos(angle) * x) * scaleMoveMul, (Mathf.Sin(angle) * y) * scaleMoveMul, 0f);
                rectTF.localPosition    = position;
                rectTF.localEulerAngles = new Vector3(0f, 0f, 180f - angle);
                rectTF.localScale       = new Vector3(startScaleX, startScaleY, 1f);
            }
            else
            {
                angle                  += UnityEngine.Random.Range(-5, 5);
                position               += new Vector3((-Mathf.Sin(angle) * y) * scaleMoveMul, (Mathf.Cos(angle) * x) * scaleMoveMul, 0f);
                rectTF.localPosition    = position;
                rectTF.localEulerAngles = new Vector3(0f, 0f, 90f + angle);
                rectTF.localScale       = new Vector3(startScaleX, startScaleY, 1f);
            }
            Image img      = rectTF.GetComponent <Image>();
            Tween imgTween = img.DOFade(1, 0.5f);

            imgTween.SetUpdate(true);
            imgTween.Play();
            Tween rectTFTween = rectTF.DOScale(new Vector3(x, y, 1f), 0.3f);

            rectTFTween.SetUpdate(true);
            rectTFTween.Play();
            rectTF.transform.gameObject.SetActive(true);
        }
예제 #2
0
        public override void ShowAttackBlood(int dir, bool isMirror, float angle)
        {
            if (this.rightHandTrans != null)
            {
                Vector3 position = this.rightHandTrans.position;
                // 物体在摄像机范围内,则x、y的范围为[0, 1]
                Vector3 vector2 = GameCameraController.INSTANCE.sceneCamera.WorldToViewportPoint(position) - new Vector3(0.5f, 0.5f, 0f);

                float   num     = ((float)GameMenu.INSTANCE.GetComponent <CanvasScaler>().referenceResolution.y / ((float)Screen.height));
                float   num2    = Screen.width * num;
                float   num3    = Screen.height * num;
                Vector3 vector3 = new Vector3(num2 * vector2.x, num3 * vector2.y, vector2.z);
                ZombieAttackBlood.Show("Effect/ZombieAttack", vector3, dir, angle);
            }
        }