Example #1
0
    public void init(BodyActionInfo cInfo)
    {
        ActionTypeInfo[] actionTypeList = cInfo.actionTypeList;

        //存储动作名对应的索引
        for (int lNameIndex = 0; lNameIndex < cInfo.animationSettingList.Length; ++lNameIndex)
        {
            AnimationSettingForAction animationSettingInfo = cInfo.animationSettingList[lNameIndex];
            AnimationSettingData animationSettingData = new AnimationSettingData();

            animationSettingData.useFader = animationSettingInfo.useFader;
            animationSettingData.animationIndex = lNameIndex;

            actionNameToAniSetting[animationSettingInfo.name] = animationSettingData;
        }

        //遍历动作类型
        for (int i = 0; i < actionTypeList.Length; ++i)
        {
            ActionTypeInfo actionTypeInfo = actionTypeList[i];
            //actionNameToAniSetting[actionTypeInfo.actionTypeName]=i;

            //遍历一个动作类型中的动作/动画
            List<string> animationNameList = new List<string>(actionTypeInfo.animationActionList.Length);
            foreach (UnityAnimationInfo animationInfo in actionTypeInfo.animationActionList)
            {
                animationNameList.Add(animationInfo.animationName);
                if (cInfo.mixingTransform)
                {
                    myAnimation[animationInfo.animationName].AddMixingTransform(cInfo.mixingTransform);
                    myAnimation[animationInfo.animationName].layer = cInfo.layer;
                }

                //AnimationClip   lAnimationClip = myAnimation[animationInfo.animationName].clip;
                //if (!haveAddedEvent.ContainsKey(lAnimationClip))
                //{
                //    //设置动画事件
                //    if (animationInfo.functionName.Length != 0)
                //    {
                //        AnimationEvent lAnimationEvent = new AnimationEvent();
                //        lAnimationEvent.functionName = "messageRedirectReceiver";
                //        lAnimationEvent.stringParameter = animationInfo.functionName;
                //        lAnimationEvent.time = animationInfo.functionImpTime;
                //        lAnimationClip.AddEvent(lAnimationEvent);
                //        //Debug.Log(animationInfo.animationName+"  "+animationInfo.functionName);
                //    }
                //    haveAddedEvent[lAnimationClip] = true;
                //}
            }
            //将动作/动画表存储在 对应类型名称下
            //nameToActionType[actionTypeInfo.actionTypeName]=animationNameList.ToBuiltin(string);
            nameToActionType[actionTypeInfo.actionTypeName] = animationNameList.ToArray();
        }
        //nowActionType = actionTypeList[0].actionTypeName;
        var lNowAniamtion = nameToActionType[nowActionType][nowActionIndex];
        myAnimation.Play(lNowAniamtion);

        animationState = myAnimation[lNowAniamtion];
    }
        // Initialize (Clean up)
        public bool Initialize(AnimationSettingData SettingData)
        {
            if (m_listAnimatonObject == null)
            {
                m_listAnimatonObject = new List <GameObject>();
                if (m_listAnimatonObject == null)
                {
                    return(false);
                }

                m_listAnimatonObject.Clear();
            }

            m_SettingData.Initialize(SettingData);

            return(ClearAnimation());
        }
        // Initialize
        public bool Initialize(AnimationSettingData settingData)
        {
            if (m_param == null)
            {
                m_param = new float[(int)AnimationSettingDataType.Count];
                if (m_param == null)
                {
                    return(false);
                }
            }
            for (AnimationSettingDataType type = AnimationSettingDataType.LineCount; type < AnimationSettingDataType.Count; type++)
            {
                m_param[(int)type] = settingData.GetParam(type);
            }

            return(true);
        }