Exemplo 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);
            }
        }
Exemplo n.º 2
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;
        }