Esempio n. 1
0
        /// <summary>
        /// 加載圖片
        /// </summary>
        /// <param name="sf">sff文件舉兵</param>
        /// <param name="group">讀取的動畫Group組</param>
        /// <param name="charName">名稱</param>
        /// <param name="startLoadImage">動畫開始的位置</param>
        /// <param name="isAniLoad">是否是自動連續加載</param>
        /// <param name="useSaveGroup">是否使用saveGroup參數</param>
        /// <param name="saveGroup">保存到MAP的Group的KEY</param>
        private void LoadCharState(SffFile sf, PlayerState group, string charName, int startLoadImage = 0)
        {
            // if (group == PlayerState.psPlayerStateCount)
            //    return;

            int g = (int)group;

            if (HasLoadImageFrame(g, startLoadImage))
            {
                return;
            }

            SFFSUBHEADER h;

            if (!sf.GetSubHeader(g, startLoadImage, out h))
            {
                return;
            }

            if (g != h.GroubNumber || startLoadImage != h.ImageNumber)
            {
                KeyValuePair <int, int> key   = new KeyValuePair <int, int>(g, startLoadImage);
                KeyValuePair <int, int> value = new KeyValuePair <int, int>(h.GroubNumber, h.ImageNumber);
                mGroupImageLinkMap[key] = value;
            }

            if (this.HasLoadImageFrame(h.GroubNumber, h.ImageNumber))
            {
                return;
            }

            KeyValuePair <PCXHEADER, PCXDATA> d;

            if (!sf.GetPcxData((uint)h.GroubNumber, (uint)h.ImageNumber, out d))
            {
                return;
            }
            float offX = ((float)(d.Key.x + h.x)) / d.Key.widht;//+ 1.0f;
            float offY = -((float)(d.Key.y + h.y)) / d.Key.height + 1.0f;

            Texture2D tex = sf.GetIndexTexture((uint)h.GroubNumber, (uint)h.ImageNumber);

            if (tex != null)
            {
                KeyValuePair <short, short> palletLink;
                if (d.Value.IsVaildPalletLink)
                {
                    palletLink = d.Value.palletLink;
                }
                else
                {
                    palletLink = new KeyValuePair <short, short>(-1, -1);
                }
                ImageFrame frame = new ImageFrame(this, h.ImageNumber, tex, offX, offY, charName,
                                                  palletLink, d.Value.GetPalletTexture(mIs32BitPallet));

                AddImageFrame((PlayerState)h.GroubNumber, frame);
            }
        }
Esempio n. 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);
        }
Esempio n. 3
0
        private void GeneratorTempDataToTexture()
        {
            if (m_TempData == null || AppConfig.IsAppQuit)
            {
                return;
            }
            if (mLocalPalletTex == null)
            {
                mLocalPalletTex = SffFile.GeneratorPalletTexture(m_TempData.pallet, mParentLib.Is32BitPallet);
            }

            if (m_Sprite == null || m_Sprite.texture == null)
            {
                Texture2D tex = SffFile.GetIndexTexture(m_TempData.width, m_TempData.height, m_TempData.data);
                SetTexture2D(tex, m_TempData.offX, m_TempData.offY, m_TempData.name);
            }

            m_TempData = null;
        }
Esempio n. 4
0
        private bool AddPalletTexture(string palletName, string fileName, bool is32Bit)
        {
            if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(palletName))
            {
                return(false);
            }
            if (mPalletMap.ContainsKey(palletName))
            {
                return(true);
            }
            byte[]    source = AppConfig.GetInstance().Loader.LoadBytes(fileName);
            Texture2D tex    = SffFile.GeneratorActTexture(source, is32Bit);

            if (tex == null)
            {
                return(false);
            }
            mPalletMap.Add(palletName, tex);
            return(true);
        }
Esempio n. 5
0
        /*
         *      public static PlayerState SceneGroupToSaveGroup(PlayerState group)
         *      {
         *              return SceneGroupToSaveGroup ((int)group);
         *      }
         *
         *
         * public static PlayerState SceneGroupToSaveGroup(int group)
         * {
         *  return (PlayerState)(-(group + 1));
         * }
         */

        public bool LoadScene(string fileName, BgConfig config)
        {
            if (string.IsNullOrEmpty(fileName) || config == null)
            {
                return(false);
            }
            SffFile sf = new SffFile();

            if (!sf.LoadFromFileName(fileName))
            {
                return(false);
            }
            /* 处理场景 */

            for (int i = 0; i < config.BgCount; ++i)
            {
                var bg = config.GetBg(i);
                if (bg != null)
                {
                    if (bg.bgType == BgType.normal)
                    {
                        var staticBg = bg as BgStaticInfo;
                        // PlayerState saveGroup = SceneGroupToSaveGroup(staticBg.srpiteno_Group);
                        PlayerState group = (PlayerState)(staticBg.srpiteno_Group);
                        //   if (!HasLoadImageFrame(saveGroup, staticBg.srpiteno_Group, staticBg.spriteno_Image))
                        //       LoadCharState(sf, group, bg.name, staticBg.spriteno_Image, false, true, saveGroup);
                        if (!HasLoadImageFrame(staticBg.srpiteno_Group, staticBg.spriteno_Image))
                        {
                            LoadCharState(sf, group, bg.name, staticBg.spriteno_Image);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 6
0
		public Texture2D GetPalletTexture(bool is32Bit)
		{
			return SffFile.GeneratorPalletTexture(pallet, is32Bit);
		}
Esempio n. 7
0
        /*
         *      public static PlayerState SceneGroupToSaveGroup(PlayerState group)
         *      {
         *              return SceneGroupToSaveGroup ((int)group);
         *      }
         *
         *
         * public static PlayerState SceneGroupToSaveGroup(int group)
         * {
         *  return (PlayerState)(-(group + 1));
         * }
         */

        public bool LoadScene(string fileName, SceneConfig config)
        {
            if (string.IsNullOrEmpty(fileName) || config == null || config.BgCfg == null)
            {
                return(false);
            }
            SffFile sf = new SffFile();

            if (!sf.LoadFromFileName(fileName))
            {
                return(false);
            }
            /* 处理场景 */

            var cfg = config.BgCfg;

            for (int i = 0; i < cfg.BgCount; ++i)
            {
                var bg = cfg.GetBg(i);
                if (bg != null)
                {
                    if (bg.bgType == BgType.normal)
                    {
                        var staticBg = bg as BgStaticInfo;
                        // PlayerState saveGroup = SceneGroupToSaveGroup(staticBg.srpiteno_Group);
                        PlayerState group = (PlayerState)(staticBg.srpiteno_Group);
                        //   if (!HasLoadImageFrame(saveGroup, staticBg.srpiteno_Group, staticBg.spriteno_Image))
                        //       LoadCharState(sf, group, bg.name, staticBg.spriteno_Image, false, true, saveGroup);
                        if (!HasLoadImageFrame(staticBg.srpiteno_Group, staticBg.spriteno_Image))
                        {
                            LoadCharState(sf, group, bg.name, staticBg.spriteno_Image);
                        }
                    }
                }
            }

            if (config.AirCfg != null)
            {
                if (!LoadAir("Scene", config.AirCfg))
                {
                    ClearAll();
                    return(false);
                }

                for (int i = 0; i < config.AirCfg.GetStateCount(); ++i)
                {
                    var key   = config.AirCfg.GetStateByIndex(i);
                    var value = config.AirCfg.GetBeginAction(key);
                    if (value != null)
                    {
                        for (int j = 0; j < value.ActionFrameListCount; ++j)
                        {
                            ActionFrame frame;
                            if (value.GetFrame(j, out frame))
                            {
                                if (!HasLoadImageFrame(frame.Group, frame.Index))
                                {
                                    string name = string.Format("Scene_{0:D}_{1:D}", frame.Group, frame.Index);
                                    LoadCharState(sf, (PlayerState)frame.Group, name, frame.Index);
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }