Beispiel #1
0
    private int GetEffectIndexByHeroStar(XEffectConfigObject effectConfig)
    {
        if (effectConfig.isDecideByStar && effectConfig.isDecideByStar == effectConfig.isDecideByEquipStar)
        {
            return(_effectResIndex);
        }

        int index = _effectResIndex;

        if (effectConfig.isDecideByStar)
        {
            index = _heroStarsIndex;
        }
        else if (effectConfig.isDecideByEquipStar)
        {
            index = _heroEquipStarsIndex;
        }

        if (effectConfig.effectFiles.Length <= index)
        {
            index = effectConfig.effectFiles.Length - 1;
        }

        return(index >= 0 ? index : 0);
    }
Beispiel #2
0
    protected void AddFrameEffect(int status, XEffectConfigObject config, XEffectComponent xeffect)
    {
        xeffect.interruptType        = config.interrupt;
        xeffect.freezeByAnimation    = config.freezeByAnimation;
        xeffect.activedAnimatorState = status;

        List <XEffectComponent> list = null;

        _animatorFrameEffects.TryGetValue(status, out list);
        if (list == null)
        {
            list = new List <XEffectComponent>();
            _animatorFrameEffects.Add(status, list);
        }

        list.Add(xeffect);
    }
Beispiel #3
0
    protected void generateEffectConfig()
    {
        string prefabPath = AssetDatabase.GetAssetPath(gameObject).ToLower();
        string assetPath  = prefabPath.Replace("/effect/", "/data/effect/");

        assetPath = assetPath.Replace(".prefab", ".asset");
        XEffectConfigObject config = ScriptableObject.CreateInstance <XEffectConfigObject>();

        config.effectFiles[0] = prefabPath.Replace("assets/resources/", "").Replace(".prefab", "");

        string directory = Path.GetDirectoryName(Path.Combine(Path.Combine(Application.dataPath, "resources/data/"),
                                                              prefabPath.Replace("assets/resources/", "")));

        if (!Directory.Exists(directory))
        {
            Directory.CreateDirectory(directory);
        }

        AssetDatabase.CreateAsset(config, assetPath);

        Debug.Log(string.Format("<color=yellow>Create XEffect Config ==>  {0}</color>", assetPath));
    }
Beispiel #4
0
    protected void HandleAnimationEffect(AnimationEvent e)
    {
        XEffectConfigObject config = e.objectReferenceParameter as XEffectConfigObject;

        if (config == null)
        {
            return;
        }

        float  time = e.floatParameter;
        string res  = config.getRes(GetEffectIndexByHeroStar(config));

        if (!string.IsNullOrEmpty(res))
        {
            int animatorState = e.animatorStateInfo.fullPathHash;
            if (config.follow == XEffectComponent.EffectFollowType.Both)
            {
                XEffectManager.GenerateAsync(GetBoneNogPoint(config.linkBone).gameObject, res, time,
                                             delegate(XEffectComponent xeffect)
                {
                    if (xeffect != null)
                    {
                        if (IsPvp() == false)
                        {
                            MakeOffsetScale(xeffect, e);
                        }

                        if (gameObject != null)
                        {
                            AddFrameEffect(animatorState, config, xeffect);
                        }
                        else
                        {
                            xeffect.Stop();
                        }
                    }
                });
            }
            else
            {
                Transform  bone = GetBoneNogPoint(config.linkBone);
                Quaternion rot  = _nogPoint.center.rotation;
                if (bone.transform.lossyScale.x < 0 && config.isIgnoreMorror)
                {
                    rot.eulerAngles += new Vector3(0f, -180f, 0f);
                }

                XEffectManager.GenerateAsync(bone.gameObject, bone.position, rot, res, time,
                                             delegate(XEffectComponent xeffect)
                {
                    if (xeffect == null)
                    {
                        return;
                    }
                    if (gameObject != null)
                    {
                        if (!IsPvp())
                        {
                            MakeOffsetScale(xeffect, e);
                        }

                        if (config.follow == XEffectComponent.EffectFollowType.Position || config.follow == XEffectComponent.EffectFollowType.PositionButY)
                        {
                            xeffect.onlyFollowPosition = true;
                            if (config.follow == XEffectComponent.EffectFollowType.PositionButY)
                            {
                                xeffect.ignoreFollowHeight = true;
                                xeffect.followStayHeight   = bone.position.y;
                            }
                            AddFrameEffect(animatorState, config, xeffect);
                            xeffect.Mirror(bone.transform.lossyScale.x < 0);
                        }
                        else
                        {
                            xeffect.onlyFollowPosition = false;
                        }
                    }
                    else
                    {
                        xeffect.Stop();
                    }
                });
            }
        }
    }