コード例 #1
0
    public GameObject PlayAniSoundAndEff(Transform parentTf, eAnimName anim, float particleSize, bool is2D = false)
    {
        if (UnitAnim == null)
        {
            return(null);
        }

        UnitAnim.PlayAnimationSound(anim);
        UnitAnim.PlayAnimationVoice(anim);

        string effName = UnitAnim.GetAnimationEffect(anim);

        if (string.IsNullOrEmpty(effName))
        {
            return(null);
        }

        string path = null;

        if (gameObject.name.Contains("par"))
        {
            if (gameObject.name.Contains("makgyeran"))
            {
                path = "_PARTNER/mak_gyeran";
            }
            else
            {
                string[] split = effName.Split('_');
                int      length = 0, arr = 0;
                for (int i = 0; i < split.Length; i++)
                {
                    if (length < split[i].Length)//제일 긴 것이 이름일 것이다.
                    {
                        length = split[i].Length;
                        arr    = i;
                    }
                }

                path = string.Format("_PARTNER/{0}", split[arr]);
            }

            if (gameObject.name.Contains("jopunghwa"))
            {
                SetWeaponEffectActive(false);
            }
        }
        else if (gameObject.name.Contains("pc"))
        {
            if (gameObject.name.Contains("pc_f"))
            {
                path = string.Format("_PC/fighter");
            }
            else if (gameObject.name.Contains("pc_p"))
            {
                path = string.Format("_PC/pojol");
            }
            else if (gameObject.name.Contains("pc_d"))
            {
                path = string.Format("_PC/doctor");
            }
        }

        Object     obj   = Resources.Load(string.Format("Effect/{0}/{1}", path, effName));
        GameObject effGo = null;

        if (obj != null)
        {
            effGo = Instantiate(obj) as GameObject;
            CheckRenderQ(RenderQ, effGo.transform);

            List <ParticleSystem> list = UIHelper.FindComponents <ParticleSystem>(effGo.transform);
            ResettingParticle(null, list, particleSize);
        }

        if (effGo == null)
        {
            return(null);
        }

        NGUITools.SetChildLayer(effGo.transform, LayerMask.NameToLayer("UI"));
        effGo.SetActive(true);

        effGo.transform.parent           = parentTf;
        effGo.transform.localPosition    = Vector3.zero;
        effGo.transform.localScale       = Vector3.one;
        effGo.transform.localEulerAngles = is2D ? new Vector3(10, 0, 0) : Vector3.zero;//Quaternion.Euler(Vector3.zero);

        return(effGo);
    }