示例#1
0
 private void Clear()
 {
     m_Info      = null;
     m_Cam       = null;
     m_Players   = null;
     m_Scaling   = null;
     m_AirConfig = null;
     m_BgDef     = null;
     m_BgCfg     = null;
 }
示例#2
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);
        }
示例#3
0
        private bool LoadFromStr(string str)
        {
            Clear();
            if (string.IsNullOrEmpty(str))
            {
                return(false);
            }
            ConfigReader reader = new ConfigReader();

            reader.LoadString(str);

            // 1
            var section = reader.GetSection("Info");

            if (section != null)
            {
                m_Info = new StageInfo();
                if (!section.GetPropertysValues(m_Info))
                {
                    Clear();
                    return(false);
                }
            }
            else
            {
                Clear();
                return(false);
            }

            // 2
            section = reader.GetSection("Camera");
            if (section == null)
            {
                Clear();
                return(false);
            }
            m_Cam = new StageCamera();
            if (!section.GetPropertysValues(m_Cam))
            {
                Clear();
                return(false);
            }

            // 3
            section = reader.GetSection("PlayerInfo");
            if (section == null)
            {
                Clear();
                return(false);
            }
            m_Players = new StagePlayerInfo();
            if (!section.GetPropertysValues(m_Players))
            {
                Clear();
                return(false);
            }

            // 4
            section = reader.GetSection("Scaling");
            if (section != null)
            {
                m_Scaling = new StageScaling();
                if (!section.GetPropertysValues(m_Scaling))
                {
                    Clear();
                    return(false);
                }
            }
            else
            {
                m_Scaling = new StageScaling();
            }

            // 5
            m_AirConfig = new AirConfig(reader);
            if (!m_AirConfig.IsVaild)
            {
                Clear();
                return(false);
            }

            // 6
            section = reader.GetSection("BGdef");
            if (section == null)
            {
                Clear();
                return(false);
            }
            m_BgDef = new BgDef();
            if (!section.GetPropertysValues(m_BgDef))
            {
                Clear();
                return(false);
            }

            // 7.
            m_BgCfg = new BgConfig();
            if (!m_BgCfg.LoadFromReader(reader))
            {
                Clear();
                return(false);
            }

            return(IsVaild);
        }
示例#4
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);
        }