Exemple #1
0
 private TransType GetTransType(ActionDrawMode drawMode)
 {
     if (drawMode == ActionDrawMode.adNone)
     {
         return(m_TransType);
     }
     return((TransType)drawMode);
 }
Exemple #2
0
    public ImageFrame GetCurImageFrame(out ActionFlip flip, out ActionDrawMode drawMode)
    {
        flip     = ActionFlip.afNone;
        drawMode = ActionDrawMode.adNone;
        var aniNode = CurAniNode;

        if (aniNode.frameGroup < 0 || aniNode.frameIndex < 0)
        {
            return(null);
        }

        var frame = GetImageFrame(aniNode.frameGroup, aniNode.frameIndex);

        if (frame != null)
        {
            flip     = aniNode.flipTag;
            drawMode = aniNode.drawMode;
        }
        return(frame);
    }
Exemple #3
0
        public BeginAction(/*PlayerState state, */ ConfigSection section)
        {
            //this.State = state;
            if (section != null)
            {
                int    aniStartIdx     = 0;
                Rect[] clsn2DefaultArr = null;

                ReadClsn(out clsn2DefaultArr, section, ref aniStartIdx, _cClsn2Default, _cClsn2DKeyName);


                string str        = section.GetContent(aniStartIdx);
                Rect[] frameClsn2 = null;
                Rect[] frameClsn1 = null;
                if (!string.IsNullOrEmpty(str))
                {
                    List <string> arr         = new List <string>();
                    bool          isLoopStart = false;
                    int           i           = aniStartIdx;
                    while (i < section.ContentListCount)
                    {
                        arr.Clear();

                        string line = section.GetContent(i);
                        if (string.IsNullOrEmpty(line))
                        {
                            ++i;
                            continue;
                        }

                        if (line.StartsWith("Loopstart", StringComparison.CurrentCultureIgnoreCase))
                        {
                            isLoopStart = true;
                            ++i;
                            continue;
                        }

                        // 说明需要设置默认clsDefault
                        if (line.StartsWith(_cClsn2Default))
                        {
                            aniStartIdx = i;
                            if (ReadClsn(out clsn2DefaultArr, section, ref aniStartIdx, _cClsn2Default, _cClsn2DKeyName))
                            {
                                i = aniStartIdx;
                            }
                            else
                            {
                                ++i;
                            }
                            continue;
                        }

                        if (line.StartsWith(_cClsn2))
                        {
                            aniStartIdx = i;
                            if (ReadClsn(out frameClsn2, section, ref aniStartIdx, _cClsn2, _cClsn2DKeyName))
                            {
                                i = aniStartIdx;
                            }
                            else
                            {
                                ++i;
                            }
                            continue;
                        }

                        if (line.StartsWith(_cClsn1))
                        {
                            aniStartIdx = i;
                            if (ReadClsn(out frameClsn1, section, ref aniStartIdx, _cClsn1, _cClsn1DKeyName))
                            {
                                i = aniStartIdx;
                            }
                            else
                            {
                                ++i;
                            }
                            continue;
                        }

                        if (section.GetArray(i, arr))
                        {
                            if (arr.Count >= 5)
                            {
                                int        ImageGroup = GetIntFromStr(arr[0], -1);
                                int        ImageIndex = GetIntFromStr(arr[1], -1);
                                int        Tick       = int.Parse(arr[4].Trim());
                                bool       hasFlip    = arr.Count >= 6;
                                ActionFlip flipMode   = ActionFlip.afNone;
                                if (hasFlip)
                                {
                                    string flipStr = arr[5].Trim();
                                    if (string.Compare(flipStr, "H", true) == 0)
                                    {
                                        flipMode = ActionFlip.afH;
                                    }
                                    else if (string.Compare(flipStr, "V", true) == 0)
                                    {
                                        flipMode = ActionFlip.afV;
                                    }
                                    else if (string.Compare(flipStr, "HV", true) == 0 ||
                                             string.Compare(flipStr, "VH", true) == 0)
                                    {
                                        flipMode = ActionFlip.afHV;
                                    }
                                }
                                bool           hasDrawMode = arr.Count >= 7;
                                ActionDrawMode drawMode    = ActionDrawMode.adNone;
                                if (hasDrawMode)
                                {
                                    string drawStr = arr [6].Trim();
                                    if (string.Compare(drawStr, "A", true) == 0)
                                    {
                                        drawMode = ActionDrawMode.ad_A;
                                    }
                                    else if (string.Compare(drawStr, "S", true) == 0)
                                    {
                                        drawMode = ActionDrawMode.ad_S;
                                    }
                                    else if (string.Compare(drawStr, "A1", true) == 0)
                                    {
                                        drawMode = ActionDrawMode.ad_A1;
                                    }
                                }

                                ActionFrame frame = new ActionFrame();
                                frame.Group    = ImageGroup;
                                frame.Index    = ImageIndex;
                                frame.Tick     = Tick;
                                frame.Flip     = flipMode;
                                frame.DrawMode = drawMode;
                                if (aniStartIdx > 0 && clsn2DefaultArr != null)
                                {
                                    frame.defaultClsn2Arr = clsn2DefaultArr;
                                    clsn2DefaultArr       = null;
                                }
                                if (frameClsn2 != null)
                                {
                                    frame.localClsn2Arr = frameClsn2;
                                    frameClsn2          = null;
                                }
                                if (frameClsn1 != null)
                                {
                                    frame.localCls1Arr = frameClsn1;
                                    frameClsn1         = null;
                                }
                                if (isLoopStart)
                                {
                                    frame.IsLoopStart = isLoopStart;
                                    isLoopStart       = false;
                                }
                                ActionFrameList.Add(frame);
                            }
                        }
                        ++i;
                    }
                }
            }
        }
Exemple #4
0
    private void UpdateImageFrame(ImageFrame frame, ActionFlip flip, ActionDrawMode drawMode, bool isNoMask)
    {
        InitFrameInfo(frame);
        SpriteRenderer r = this.SpriteRender;

        if (r == null)
        {
            return;
        }

        if (frame == null)
        {
            r.sprite = null;
            var m1 = r.sharedMaterial;
            if (m1 != null)
            {
                m1.SetTexture("_PalletTex", null);
                m1.SetTexture("_MainTex", null);
                m_IsPalletNull = true;
            }
            return;
        }

        InitSpriteRender(GetTransType(drawMode));
        r.sprite = frame.Data;
        if (r.sprite != null)
        {
            Transform  trans = r.transform;
            Quaternion quat  = trans.localRotation;
            switch (flip)
            {
            case ActionFlip.afH:
                quat.eulerAngles += new Vector3(0, 180, 0);
                break;

            case ActionFlip.afV:
                quat.eulerAngles += new Vector3(180, 0, 0);
                break;

            case ActionFlip.afHV:
                quat.eulerAngles += new Vector3(180, 180, 0);
                break;

            default:
                quat.eulerAngles = Vector3.zero;
                break;
            }

            trans.localRotation = quat;
        }

        Material mat = r.sharedMaterial;

        if (mat != null)
        {
            var palletTex = frame.LocalPalletTex;
            if (palletTex == null)
            {
                string sceneFileName = StageMgr.GetInstance().LoadedSceneFileName;
                // 再尝试额外加载一个文件
                if (frame.LoadSceneExtLocalPalletTex(sceneFileName, m_Group))
                {
                    palletTex = frame.LocalPalletTex;
                    // int saveGroup = (int)ImageLibrary.SceneGroupToSaveGroup(group);
                    //  StageMgr.GetInstance().SetLastPalletLink(saveGroup, frame.Image);
                    StageMgr.GetInstance().SetLastPalletLink(m_Group, frame.Image);
                }
                else
                {
                    StageMgr.GetInstance().LinkImageFramePalletLastLink(frame);
                    palletTex = frame.LocalPalletTex;
                }
            }
            mat.SetTexture("_PalletTex", palletTex);
            mat.SetTexture("_MainTex", frame.Data.texture);
            m_IsPalletNull = palletTex == null;
            CheckMaskKey(isNoMask);
        }
    }