Esempio n. 1
0
        private bool LoadFromReader(ConfigReader reader)
        {
            if (reader == null)
            {
                return(false);
            }

            // load Begin Action
            for (int i = 0; i < reader.SectionCount; ++i)
            {
                ConfigSection section = reader.GetSections(i);
                if (section == null)
                {
                    continue;
                }
                string tile = section.Tile;
                if (tile.StartsWith(_cBeginAction, StringComparison.CurrentCultureIgnoreCase))
                {
                    string stateStr = tile.Substring(_cBeginAction.Length).Trim();
                    int    state;
                    if (int.TryParse(stateStr, out state) && (state >= 0) /*&& (state < (int)PlayerState.psPlayerStateCount)*/)
                    {
                        PlayerState playerState = (PlayerState)state;
                        BeginAction action      = new BeginAction(/*playerState,*/ section);
                        AddOrSetBeginAction(playerState, action);
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        protected void AddOrSetBeginAction(PlayerState state, BeginAction action)
        {
            if (action == null)
            {
                return;
            }
            int key = (int)state;

            if (mBeginActionMap != null && mBeginActionMap.ContainsKey((int)state))
            {
                mBeginActionMap[key] = action;
            }
            else
            {
                if (mBeginActionMap == null)
                {
                    mBeginActionMap = new Dictionary <int, BeginAction> ();
                }
                mBeginActionMap.Add(key, action);
                if (mBeginActionList == null)
                {
                    mBeginActionList = new List <PlayerState> ();
                }
                mBeginActionList.Add(state);
            }
        }
Esempio n. 3
0
 protected void AddOrSetBeginAction(string state, BeginAction action)
 {
     if (action == null || string.IsNullOrEmpty(state))
     {
         return;
     }
     if (mStrBeginActionMap != null && mStrBeginActionMap.ContainsKey(state))
     {
         mStrBeginActionMap[state] = action;
     }
     else
     {
         if (mStrBeginActionMap == null)
         {
             mStrBeginActionMap = new Dictionary <string, BeginAction> ();
         }
         mStrBeginActionMap.Add(state, action);
         if (mStrBeginActionList == null)
         {
             mStrBeginActionList = new List <string> ();
         }
         mStrBeginActionList.Add(state);
     }
 }
Esempio n. 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);
        }