示例#1
0
        public bool LoadChar(string charName, AirConfig airCfg = null, string customSpriteName = "")
        {
            ClearAll();
            if (string.IsNullOrEmpty(charName))
            {
                return(false);
            }

            SffFile sf = new SffFile();

            if (!sf.LoadChar(charName, customSpriteName, false))
            {
                ClearAll();
                return(false);
            }

            if (airCfg == null)
            {
                foreach (PlayerState group in PlayerStateEnumValues.GetValues())
                {
                    LoadCharState(sf, group, charName);
                }
            }
            else
            {
                for (int i = 0; i < airCfg.GetStateCount(); ++i)
                {
                    var key   = airCfg.GetStateByIndex(i);
                    var value = airCfg.GetBeginAction(key);
                    if (value != null)
                    {
                        for (int j = 0; j < value.ActionFrameListCount; ++j)
                        {
                            ActionFrame frame;
                            if (value.GetFrame(j, out frame))
                            {
                                LoadCharState(sf, (PlayerState)frame.Group, charName, frame.Index);
                            }
                        }
                    }
                }
            }

            if (airCfg != null && !LoadAir(charName, airCfg))
            {
                ClearAll();
                return(false);
            }

            return(true);
        }
示例#2
0
        private bool LoadAir(string charName, AirConfig airCfg)
        {
            mStateAniMap.Clear();
            if (string.IsNullOrEmpty(charName) || airCfg == null || !airCfg.IsVaild)
            {
                return(false);
            }
            for (int i = 0; i < airCfg.GetStateCount(); ++i)
            {
                int state = (int)airCfg.GetStateByIndex(i);
                if (state == (int)PlayerState.psNone)
                {
                    continue;
                }
                PlayerState action      = (PlayerState)state;
                BeginAction beginAction = airCfg.GetBeginAction(action);
                if (beginAction == null || beginAction.ActionFrameListCount <= 0)
                {
#if DEBUG
                    Debug.LogErrorFormat("beginAction :{0:D} Failed~!", state);
#endif
                    continue;
                }

                /*
                 * List<ImageFrame> frameList = this.GetImageFrameList(action);
                 * if (frameList == null || frameList.Count <= 0)
                 *  continue;
                 */

                List <ImageAnimateNode> aniNodeList;
                if (!mStateAniMap.TryGetValue((int)action, out aniNodeList))
                {
                    aniNodeList = new List <ImageAnimateNode>();
                    mStateAniMap.Add((int)action, aniNodeList);
                }

                ActionFlip lastFlip = ActionFlip.afNone;
                for (int frame = 0; frame < beginAction.ActionFrameListCount; ++frame)
                {
                    ActionFrame actFrame;
                    if (beginAction.GetFrame(frame, out actFrame))
                    {
                        if (actFrame.Index >= 0)
                        {
                            int frameIndex           = actFrame.Index;
                            ImageAnimateNode aniNode = new ImageAnimateNode();
                            aniNode.AniTick  = actFrame.Tick;
                            aniNode.flipTag  = actFrame.Flip;
                            aniNode.drawMode = actFrame.DrawMode;
                            //aniNode.flipTag = lastFlip;
                            lastFlip                = actFrame.Flip;
                            aniNode.frameIndex      = frameIndex;
                            aniNode.frameGroup      = actFrame.Group;
                            aniNode.Group           = action;
                            aniNode.isLoopStart     = actFrame.IsLoopStart;
                            aniNode.defaultClsn2Arr = actFrame.defaultClsn2Arr;
                            aniNode.localCls1Arr    = actFrame.localCls1Arr;
                            aniNode.localClsn2Arr   = actFrame.localClsn2Arr;
                            aniNodeList.Add(aniNode);
                        }
                    }
                }
            }

            return(true);
        }