Example #1
0
 public bool OnAnimationLastFrame(NcSpriteAnimation spriteCom, int nLoopCount)
 {
     if (this.m_SpriteList.Count > this.m_nCurrentIndex)
     {
         this.m_bEndSprite = true;
         if (this.m_bSequenceMode)
         {
             if (this.m_nCurrentIndex < (this.GetSpriteNodeCount() - 1))
             {
                 if ((!this.m_SpriteList[this.m_nCurrentIndex].m_bLoop ? 1 : 3) == nLoopCount)
                 {
                     this.SetSprite((int)(this.m_nCurrentIndex + 1));
                     return(true);
                 }
             }
             else
             {
                 this.SetSprite(0);
             }
         }
         else
         {
             NcSpriteAnimation animation = this.SetSprite(this.m_SpriteList[this.m_nCurrentIndex].m_nNextSpriteIndex) as NcSpriteAnimation;
             if (animation != null)
             {
                 animation.ResetAnimation();
                 return(true);
             }
         }
     }
     return(false);
 }
    // frame 변경될 때 마다... (frame skip 되기도 함)
    public void OnAnimationChangingFrame(NcSpriteAnimation spriteCom, int nOldIndex, int nNewIndex, int nLoopCount)
    {
//      Debug.Log("OnAnimationChangingFrame() - nOldIndex = " + nOldIndex + ", nNewIndex = " + nNewIndex + ", nLoopCount = " + nLoopCount + ", m_nCurrentIndex = " + m_nCurrentIndex);
        if (m_SpriteList.Count <= m_nCurrentIndex)
        {
            return;
        }

        if (m_SpriteList[m_nCurrentIndex].m_EffectPrefab != null)
        {
            if ((nOldIndex < m_SpriteList[m_nCurrentIndex].m_nEffectFrame || nNewIndex <= nOldIndex) && m_SpriteList[m_nCurrentIndex].m_nEffectFrame <= nNewIndex)
            {
                if (nLoopCount == 0 || m_SpriteList[m_nCurrentIndex].m_bEffectOnlyFirst == false)
                {
                    CreateEffectObject();
                }
            }
        }
        if (m_SpriteList[m_nCurrentIndex].m_AudioClip != null)
        {
            if ((nOldIndex < m_SpriteList[m_nCurrentIndex].m_nSoundFrame || nNewIndex <= nOldIndex) && m_SpriteList[m_nCurrentIndex].m_nSoundFrame <= nNewIndex)
            {
                if (nLoopCount == 0 || m_SpriteList[m_nCurrentIndex].m_bSoundOnlyFirst == false)
                {
                    CreateSoundObject(m_SpriteList[m_nCurrentIndex]);
                }
            }
        }
    }
Example #3
0
    // 마지막 frame시간 지나면..(다음 loop 첫프레임이 되면), ret가 참이면 애니변경됨
    public bool OnAnimationLastFrame(NcSpriteAnimation spriteCom, int nLoopCount)
    {
        m_bEndSprite = true;
//      DestroyEffectObject();

        if (m_bSequenceMode)
        {
            if (m_nCurrentIndex < GetSpriteNodeCount() - 1)
            {
                if ((m_SpriteList[m_nCurrentIndex].m_bLoop ? 3 : 1) == nLoopCount)
                {
                    SetSprite(m_nCurrentIndex + 1);
                    return(true);
                }
            }
            else
            {
                SetSprite(0);
            }
        }
        else
        {
            NcSpriteAnimation ncTarSprite = (NcSpriteAnimation)SetSprite(m_SpriteList[m_nCurrentIndex].m_nNextSpriteIndex);
            if (ncTarSprite != null)
            {
                ncTarSprite.Restart();
                return(true);
            }
        }
        return(false);
    }
 public bool OnAnimationLastFrame(NcSpriteAnimation spriteCom, int nLoopCount)
 {
     if (this.m_SpriteList.get_Count() <= this.m_nCurrentIndex)
     {
         return(false);
     }
     this.m_bEndSprite = true;
     if (this.m_bSequenceMode)
     {
         if (this.m_nCurrentIndex < this.GetSpriteNodeCount() - 1)
         {
             if ((this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_bLoop ? 3 : 1) == nLoopCount)
             {
                 this.SetSprite(this.m_nCurrentIndex + 1);
                 return(true);
             }
         }
         else
         {
             this.SetSprite(0);
         }
     }
     else
     {
         NcSpriteAnimation ncSpriteAnimation = this.SetSprite(this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_nNextSpriteIndex) as NcSpriteAnimation;
         if (ncSpriteAnimation != null)
         {
             ncSpriteAnimation.ResetAnimation();
             return(true);
         }
     }
     return(false);
 }
Example #5
0
    public NcEffectBehaviour SetSprite(int nNodeIndex, bool bRunImmediate)
    {
        if (m_SpriteList == null || nNodeIndex < 0 || m_SpriteList.Count <= nNodeIndex)
        {
            return(null);
        }

        if (bRunImmediate)
        {
            OnChangingSprite(m_nCurrentIndex, nNodeIndex);
        }
        m_nCurrentIndex = nNodeIndex;

        if (m_SpriteType == SPRITE_TYPE.NcSpriteAnimation)
        {
            NcSpriteAnimation spriteCom = GetComponent <NcSpriteAnimation>();
            spriteCom.m_NcSpriteFactory = this;
            spriteCom.m_bBuildSpriteObj = false;
            spriteCom.m_bAutoDestruct   = false;
            spriteCom.m_nStartFrame     = m_SpriteList[nNodeIndex].m_nStartFrame;
            spriteCom.m_nFrameCount     = m_SpriteList[nNodeIndex].m_nFrameCount;
            spriteCom.m_fFps            = m_SpriteList[nNodeIndex].m_fFps;
            spriteCom.m_nTilingX        = m_nTilingX;
            spriteCom.m_nTilingY        = m_nTilingY;
//			spriteCom.m_PlayMode		= NcSpriteAnimation.PLAYMODE.DEFAULT;
            spriteCom.m_bLoop = m_SpriteList[nNodeIndex].m_bLoop;

            if (bRunImmediate)
            {
                spriteCom.Restart();
            }
            return(spriteCom);
        }
        if (m_SpriteType == SPRITE_TYPE.NcSpriteTexture)
        {
            NcSpriteTexture uvCom = GetComponent <NcSpriteTexture>();
            if (uvCom != null)
            {
                uvCom.m_nSpriteFactoryIndex = nNodeIndex;
                UpdateNcSpriteTexture(nNodeIndex, uvCom);
                if (bRunImmediate)
                {
                    UpdateUvScale(nNodeIndex, transform);
                    CreateEffectObject();
                }
            }
            return(uvCom);
        }

        return(null);
    }
Example #6
0
    public NcEffectBehaviour SetSprite(int nNodeIndex, bool bRunImmediate)
    {
        if (m_SpriteList == null || nNodeIndex < 0 || m_SpriteList.Count <= nNodeIndex)
        {
            return(null);
        }

        if (bRunImmediate)
        {
            OnChangingSprite(m_nCurrentIndex, nNodeIndex);
        }
        m_nCurrentIndex = nNodeIndex;

        //      if (m_SpriteType == SPRITE_TYPE.NcSpriteAnimation)
        NcSpriteAnimation spriteCom = GetComponent <NcSpriteAnimation>();

        if (spriteCom != null)
        {
            spriteCom.SetSpriteFactoryIndex(nNodeIndex, false);

            if (bRunImmediate)
            {
                spriteCom.ResetAnimation();
            }
        }

        //      if (m_SpriteType == SPRITE_TYPE.NcSpriteTexture)
        NcSpriteTexture uvCom = GetComponent <NcSpriteTexture>();

        if (uvCom != null)
        {
            uvCom.SetSpriteFactoryIndex(nNodeIndex, -1, false);
            if (bRunImmediate)
            {
                //				UpdateUvScale(nNodeIndex, transform);
                CreateEffectObject();
            }
        }

        if (spriteCom != null)
        {
            return(spriteCom);
        }
        if (spriteCom != null)
        {
            return(uvCom);
        }

        return(null);
    }
Example #7
0
 public void OnAnimationChangingFrame(NcSpriteAnimation spriteCom, int nOldIndex, int nNewIndex, int nLoopCount)
 {
     if (this.m_SpriteList.Count > this.m_nCurrentIndex)
     {
         if (((this.m_SpriteList[this.m_nCurrentIndex].m_EffectPrefab != null) && ((nOldIndex < this.m_SpriteList[this.m_nCurrentIndex].m_nEffectFrame) || (nNewIndex <= nOldIndex))) && ((this.m_SpriteList[this.m_nCurrentIndex].m_nEffectFrame <= nNewIndex) && ((nLoopCount == 0) || !this.m_SpriteList[this.m_nCurrentIndex].m_bEffectOnlyFirst)))
         {
             this.CreateEffectObject();
         }
         if (((this.m_SpriteList[this.m_nCurrentIndex].m_AudioClip != null) && ((nOldIndex < this.m_SpriteList[this.m_nCurrentIndex].m_nSoundFrame) || (nNewIndex <= nOldIndex))) && ((this.m_SpriteList[this.m_nCurrentIndex].m_nSoundFrame <= nNewIndex) && ((nLoopCount == 0) || !this.m_SpriteList[this.m_nCurrentIndex].m_bSoundOnlyFirst)))
         {
             this.CreateSoundObject(this.m_SpriteList[this.m_nCurrentIndex]);
         }
     }
 }
Example #8
0
 public void OnAnimationChangingFrame(NcSpriteAnimation spriteCom, int nOldIndex, int nNewIndex, int nLoopCount)
 {
     if (this.m_SpriteList.get_Count() <= this.m_nCurrentIndex)
     {
         return;
     }
     if (this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_EffectPrefab != null && (nOldIndex < this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_nEffectFrame || nNewIndex <= nOldIndex) && this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_nEffectFrame <= nNewIndex && (nLoopCount == 0 || !this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_bEffectOnlyFirst))
     {
         this.CreateEffectObject();
     }
     if (this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_AudioClip != null && (nOldIndex < this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_nSoundFrame || nNewIndex <= nOldIndex) && this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_nSoundFrame <= nNewIndex && (nLoopCount == 0 || !this.m_SpriteList.get_Item(this.m_nCurrentIndex).m_bSoundOnlyFirst))
     {
         this.CreateSoundObject(this.m_SpriteList.get_Item(this.m_nCurrentIndex));
     }
 }
Example #9
0
    public NcEffectBehaviour SetSprite(int nNodeIndex, bool bRunImmediate)
    {
        if (this.m_SpriteList == null || nNodeIndex < 0 || this.m_SpriteList.Count <= nNodeIndex)
        {
            return(null);
        }
        if (bRunImmediate)
        {
            this.OnChangingSprite(this.m_nCurrentIndex, nNodeIndex);
        }
        this.m_nCurrentIndex = nNodeIndex;
        NcSpriteAnimation component = base.GetComponent <NcSpriteAnimation>();

        if (component != null)
        {
            component.SetSpriteFactoryIndex(nNodeIndex, false);
            if (bRunImmediate)
            {
                component.ResetAnimation();
            }
        }
        NcSpriteTexture component2 = base.GetComponent <NcSpriteTexture>();

        if (component2 != null)
        {
            component2.SetSpriteFactoryIndex(nNodeIndex, -1, false);
            if (bRunImmediate)
            {
                this.CreateEffectObject();
            }
        }
        if (component != null)
        {
            return(component);
        }
        if (component != null)
        {
            return(component2);
        }
        return(null);
    }
Example #10
0
 // 첫 frame 시작할때...
 public void OnAnimationStartFrame(NcSpriteAnimation spriteCom)
 {
 }
Example #11
0
    // ==========================================================================================================
    void winEffectList(int id)
    {
        if (GetGroupIndex() < 0)
        {
            return;
        }

        Rect effectRect = FXMakerLayout.GetEffectListRect();

        // window desc -----------------------------------------------------------
        FXMakerTooltip.WindowDescription(effectRect, FXMakerLayout.WINDOWID.EFFECT_LIST, null);

        // mini ----------------------------------------------------------------
        m_bMinimize = GUI.Toggle(new Rect(3, 1, FXMakerLayout.m_fMinimizeClickWidth, FXMakerLayout.m_fMinimizeClickHeight), m_bMinimize, "Mini");
        GUI.changed = false;
        if (FXMakerLayout.m_bMinimizeAll || m_bMinimize)
        {
            RenameCurrentPrefab(m_EditingName);
            FXMakerMain.inst.SaveTooltip();
            return;
        }

        // 扁瓷 滚瓢 -----------------------------------------------------------
        Rect rect1Row = new Rect(FXMakerLayout.m_rectInnerMargin.x, 20, effectRect.width - FXMakerLayout.m_rectInnerMargin.x * 2, 25);
        Rect rect2Row = new Rect(FXMakerLayout.m_rectInnerMargin.x, 50, effectRect.width - FXMakerLayout.m_rectInnerMargin.x * 2, 20);
        Rect rect3Row = new Rect(FXMakerLayout.m_rectInnerMargin.x, 75, effectRect.width - FXMakerLayout.m_rectInnerMargin.x * 2, 12);

        // Add button
        if (m_nEffectCount < FXMakerLayout.m_nMaxPrefabListCount)
        {
            if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect1Row, 5, 0, 1), FXMakerTooltip.GetHcToolEffect("New"), IsReadOnlyFolder() == 0))
            {
                RenameCurrentPrefab(m_EditingName);
                ShowNewMenu();
                return;
            }
        }

        if (m_nEffectCount <= 0)
        {
            // right button
            if (Input.GetMouseButtonUp(1))
            {
                ShowRightMenu(-1, false);
            }
            return;
        }

        // Selected state
        bool bEnable = (FXMakerMain.inst.IsCurrentEffectObject() && IsReadOnlyFolder() == 0);

        // Delete button
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect1Row, 5, 1, 1), FXMakerTooltip.GetHcToolEffect("Del"), bEnable))
        {
            RenameCurrentPrefab(m_EditingName);
            m_bProcessDelete = true;
        }

        if (m_bProcessDelete)
        {
            m_bProcessDelete = FxmPopupManager.inst.ShowModalOkCancelMessage("'" + m_EffectContents[m_nEffectIndex].text + "'\n" + FXMakerTooltip.GetHsToolMessage("DIALOG_DELETEPREFAB", ""));
            if (m_bProcessDelete == false)
            {
                if (FxmPopupManager.inst.GetModalMessageValue() == FXMakerLayout.MODALRETURN_TYPE.MODALRETURN_OK)
                {
                    NcSpriteAnimation spriteCom = FXMakerMain.inst.GetOriginalEffectPrefab().GetComponent <NcSpriteAnimation>();
                    if (spriteCom != null && spriteCom.m_bBuildSpriteObj && spriteCom.GetComponent <Renderer>().sharedMaterial != null)
                    {
                        m_bProcessDelSprite = true;
                    }
                    else
                    {
                        GameObject deletePrefab = FXMakerMain.inst.ClearCurrentEffectObject(m_CurrentEffectRoot, true);
                        FXMakerAsset.DeleteEffectPrefab(deletePrefab);
                        SelectToolbar(m_nProjectIndex, GetGroupIndex(), m_nEffectIndex);
                        return;
                    }
                }
            }
        }

        if (m_bProcessDelSprite)
        {
            m_bProcessDelSprite = FxmPopupManager.inst.ShowModalOkCancelMessage("'" + m_EffectContents[m_nEffectIndex].text + "'\n" + FXMakerTooltip.GetHsToolMessage("DIALOG_DELETESPRITE", ""));
            if (m_bProcessDelSprite == false)
            {
                if (FxmPopupManager.inst.GetModalMessageValue() == FXMakerLayout.MODALRETURN_TYPE.MODALRETURN_OK)
                {
                    // delete material, texture
                    NcSpriteAnimation spriteCom = FXMakerMain.inst.GetOriginalEffectPrefab().GetComponent <NcSpriteAnimation>();
                    if (spriteCom.GetComponent <Renderer>().sharedMaterial.mainTexture != null)
                    {
                        string path = AssetDatabase.GetAssetPath(spriteCom.GetComponent <Renderer>().sharedMaterial.mainTexture);
                        AssetDatabase.MoveAssetToTrash(path);
//						AssetDatabase.DeleteAsset(path);
                    }
                    string matpath = AssetDatabase.GetAssetPath(spriteCom.GetComponent <Renderer>().sharedMaterial);
                    AssetDatabase.MoveAssetToTrash(matpath);
//					AssetDatabase.DeleteAsset(matpath);
                }
                // delete prefab
                GameObject deletePrefab = FXMakerMain.inst.ClearCurrentEffectObject(m_CurrentEffectRoot, true);
                FXMakerAsset.DeleteEffectPrefab(deletePrefab);
                SelectToolbar(m_nProjectIndex, GetGroupIndex(), m_nEffectIndex);
                return;
            }
        }

        // Clone button
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect1Row, 5, 2, 1), FXMakerTooltip.GetHcToolEffect("Clone"), bEnable))
        {
            RenameCurrentPrefab(m_EditingName);
            ClonePrefab();
            return;
        }

        // Capture Thumb button
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect1Row, 5, 3, 1), FXMakerTooltip.GetHcToolEffect("Thumb"), bEnable))
        {
            RenameCurrentPrefab(m_EditingName);
            ThumbPrefab();
            return;
        }

//      // History button
//      if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect1Row, 5, 4, 1), FXMakertip.GetHcToolEffect("History"), bEnable))
//      {
//          SetActiveEffect(m_nEffectIndex);
//          return;
//      }

        // Sprite button
        if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect1Row, 5, 4, 1), FXMakerTooltip.GetHcToolEffect("Sprite"), bEnable))
        {
            RenameCurrentPrefab(m_EditingName);
            SpritePrefab();
            return;
        }

        // Selected state
        if (FXMakerMain.inst.IsCurrentEffectObject())
        {
            // ChangeName
            if (FXMakerMain.inst.IsCurrentEffectObject() && 0 <= m_nEffectIndex && m_nEffectIndex < m_nEffectCount)
            {
                GUI.SetNextControlName("TextField");
                FXMakerLayout.GUIEnableBackup(IsReadOnlyFolder() == 0);
//              FXMakerMain.inst.ToggleGlobalLangSkin(true);
                m_EditingName = GUI.TextField(FXMakerLayout.GetInnerHorizontalRect(rect2Row, 4, 0, 4), m_EditingName, 50);
//              FXMakerMain.inst.ToggleGlobalLangSkin(false);
                FXMakerLayout.GUIEnableRestore();

                bool bEnterKey = (Event.current.isKey && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter));
                if (bEnterKey || (FXMakerMain.GetPrevWindowFocus() == (int)FXMakerLayout.WINDOWID.EFFECT_LIST && FXMakerMain.GetWindowFocus() != (int)FXMakerLayout.WINDOWID.EFFECT_LIST))
                {
                    RenameCurrentPrefab(m_EditingName);
                }
            }
        }

        // Resize --------------------------------------------------------------
        bool bChangeScrollColumn = false;

        m_nScrollColumn = (int)GUI.HorizontalScrollbar(rect3Row, m_nScrollColumn, 1, 1, m_nMaxObjectColumn + 1);
        if (GUI.changed)
        {
            UnityEditor.EditorPrefs.SetInt("FXMakerEffect.Effect_nScrollColumn", m_nScrollColumn);
            bChangeScrollColumn = true;

            Rect rect = FXMakerLayout.GetAspectScrollViewRect((int)rect3Row.width, FXMakerLayout.m_fScrollButtonAspect, m_nEffectCount, m_nScrollColumn, false);
            m_EffectListScrollPos.y = rect.height * (m_nEffectIndex - m_nScrollColumn) / (float)m_nEffectCount;
        }
        // Draw line
        Rect lineRect = rect3Row;

        lineRect.y      = rect3Row.yMax + 5;
        lineRect.height = 3;
        NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y), (int)lineRect.width, new Color(0.1f, 0.1f, 0.1f, 0.7f), 2, false);

        // Effect List ------------------------------------------------------
        Rect listRect   = FXMakerLayout.GetChildVerticalRect(effectRect, m_nGuiTopHeight, 1, 0, 1);
        Rect scrollRect = FXMakerLayout.GetAspectScrollViewRect((int)listRect.width, FXMakerLayout.m_fScrollButtonAspect, m_nEffectCount, m_nScrollColumn, false);
        Rect gridRect   = FXMakerLayout.GetAspectScrollGridRect((int)listRect.width, FXMakerLayout.m_fScrollButtonAspect, m_nEffectCount, m_nScrollColumn, false);

        m_EffectListScrollPos = GUI.BeginScrollView(listRect, m_EffectListScrollPos, scrollRect);
//      FXMakerMain.inst.ToggleGlobalLangSkin(true);
//		int		nEffectIndex	= GUI.SelectionGrid(listRect, m_nEffectIndex, m_EffectNameStrings, m_nScrollColumn);
//		int		nEffectIndex	= GUI.SelectionGrid(gridRect, m_nEffectIndex, m_EffectContents, m_nScrollColumn);
        int nEffectIndex = FXMakerLayout.TooltipSelectionGrid(FXMakerLayout.GetOffsetRect(effectRect, 0, -m_EffectListScrollPos.y), listRect, gridRect, m_nEffectIndex, m_EffectContents, m_nScrollColumn);

//      FXMakerMain.inst.ToggleGlobalLangSkin(false);

        // move key
        if (FXMakerMain.inst.GetFocusInputKey(FXMakerLayout.GetWindowId(FXMakerLayout.WINDOWID.EFFECT_LIST)) != 0)
        {
            switch (FXMakerMain.inst.GetFocusInputKey(FXMakerLayout.GetWindowId(FXMakerLayout.WINDOWID.EFFECT_LIST)))
            {
            case KeyCode.LeftArrow: nEffectIndex--;                                       FXMakerMain.inst.SetFocusInputKey(0);   break;

            case KeyCode.RightArrow: nEffectIndex++;                                       FXMakerMain.inst.SetFocusInputKey(0);   break;

            case KeyCode.UpArrow: nEffectIndex -= m_nScrollColumn;        FXMakerMain.inst.SetFocusInputKey(0);   break;

            case KeyCode.DownArrow: nEffectIndex += m_nScrollColumn;        FXMakerMain.inst.SetFocusInputKey(0);   break;
            }
            if (nEffectIndex < 0)
            {
                nEffectIndex = 0;
            }
            if (m_nEffectCount <= nEffectIndex)
            {
                nEffectIndex = m_nEffectCount - 1;
            }
        }

        // select
        if ((bChangeScrollColumn == false && GUI.changed) || m_nEffectIndex != nEffectIndex)
        {
            RenameCurrentPrefab(m_EditingName);

            // right button
            if (Input.GetMouseButtonUp(1))
            {
                ShowRightMenu(nEffectIndex, true);
            }

            // active
            NgUtil.LogDevelop("changed m_nEffectIndex - id = " + id + ", value = " + m_EffectContents[nEffectIndex].text);
            if (nEffectIndex == m_nEffectIndex && FXMakerMain.inst.IsCurrentEffectObject())
            {
                FXMakerMain.inst.CreateCurrentInstanceEffect(true);
            }
            else
            {
                SetActiveEffect(nEffectIndex);
            }
        }
        else
        {
            // right button
            if (Input.GetMouseButtonUp(1))
            {
                RenameCurrentPrefab(m_EditingName);
                ShowRightMenu(-1, false);
            }
        }
        GUI.EndScrollView();
        FXMakerMain.inst.SaveTooltip();
    }
 // Property -------------------------------------------------------------------------
 // Event Function -------------------------------------------------------------------
 void OnEnable()
 {
     m_Sel = target as NcSpriteAnimation;
      		m_UndoManager	= new FXMakerUndoManager(m_Sel, "NcSpriteAnimation");
 }
Example #13
0
    public void compareLife()
    {
        float life = 0;

        for (int i = 0; i < eod.particleSystemList.Count; i++)
        {
            ParticleSystem ps      = eod.particleSystemList[i];
            float          maxTime = ps.duration + ps.startLifetime;
            life = ps.startDelay + maxTime;
            if (life > lifeTime)
            {
                lifeTime            = life;
                _checkPlayTimeIndex = i;
                checkType           = 1;
                //Log.info(ps.name+" startDelay:" + ps.startDelay + " startLifetime:" + ps.startLifetime);
            }
            //                 ParticleSystemRenderer psr = ps.renderer as ParticleSystemRenderer;
            //                 if (psr.renderMode == ParticleSystemRenderMode.Mesh)
            //                 {
            //                 }
        }

        for (int k = 0; k < eod.ncCurveAnimationList.Count; k++)
        {
            NcCurveAnimation ncca = eod.ncCurveAnimationList[k];
            life  = ncca.m_fDelayTime + ncca.m_fDurationTime;
            life *= _speed;
            if (life > lifeTime)
            {
                lifeTime            = life;
                _checkPlayTimeIndex = k;
                checkType           = 2;
            }
        }
        for (int k = 0; k < eod.ncSpriteAnimationList.Count; k++)
        {
            NcSpriteAnimation nc = eod.ncSpriteAnimationList[k];
            life  = nc.m_fDelayTime + nc.GetDurationTime();
            life *= _speed;
            if (life > lifeTime)
            {
                lifeTime            = life;
                _checkPlayTimeIndex = k;
                checkType           = 3;
            }
        }
        for (int k = 0; k < eod.animationList.Count; k++)
        {
            Animation ani = eod.animationList[k];
            foreach (AnimationState aniS in ani)
            {
                life                     = aniS.length;
                _animationState          = aniS;
                _animationState.wrapMode = WrapMode.ClampForever;
                break;
            }

            if (life > lifeTime)
            {
                lifeTime            = life;
                _checkPlayTimeIndex = k;
                checkType           = 4;
            }
        }
        //Log.info("lifeTime:" + _controller.lifeTime);
    }
 // 첫 frame 시작할때...
 public void OnAnimationStartFrame(NcSpriteAnimation spriteCom)
 {
 }
Example #15
0
    public void play()
    {
        for (int i = 0; i < eod.particleSystemList.Count; i++)
        {
            ParticleSystem ps = eod.particleSystemList[i];
            if (ps != null)
            {
                ps.Play(true);
            }
        }
        //foreach (SpriteAnimation sa in spriteAnimationList)
        //{
        //    sa.delayIng = true;
        //    sa.loop = false;
        //    sa.enabled = true;
        //    sa.isPaused = false;
        //}
        float time = 5000f - (Time.time - oldTime);

        for (int i = 0; i < eod.ncCurveAnimationList.Count; i++)
        {
            NcCurveAnimation nc = eod.ncCurveAnimationList[i];
            if (nc.isDelay())
            {
                nc.m_fDelayTime -= time;
            }
            else
            {
                nc.ResumeAnimation();
            }
        }
        for (int i = 0; i < eod.ncSpriteAnimationList.Count; i++)
        {
            NcSpriteAnimation nc = eod.ncSpriteAnimationList[i];
            if (nc.isDelay())
            {
                nc.m_fDelayTime -= time;
            }
            else
            {
                nc.ResumeAnimation();
            }
        }
        for (int i = 0; i < eod.ncUvAnimationList.Count; i++)
        {
            NcUvAnimation nc = eod.ncUvAnimationList[i];
            nc.ResumeAnimation();
        }
        for (int i = 0; i < eod.ncRotationList.Count; i++)
        {
            NcRotation nc = eod.ncRotationList[i];
            nc.ResumeAnimation();
        }
        for (int i = 0; i < eod.animatorList.Count; i++)
        {
            Animator animator = eod.animatorList[i];
            animator.speed = 1;
        }
        for (int i = 0; i < eod.animationList.Count; i++)
        {
            Animation animation = eod.animationList[i];
            animation.Play();
        }
    }
    // frame 변경될 때 마다... (frame skip 되기도 함)
    public void OnAnimationChangingFrame(NcSpriteAnimation spriteCom, int nOldIndex, int nNewIndex, int nLoopCount)
    {
        // 		Debug.Log("OnAnimationChangingFrame() - nOldIndex = " + nOldIndex + ", nNewIndex = " + nNewIndex + ", nLoopCount = " + nLoopCount + ", m_nCurrentIndex = " + m_nCurrentIndex);
        if (m_SpriteList.Count <= m_nCurrentIndex)
            return;

        if (m_SpriteList[m_nCurrentIndex].m_EffectPrefab != null)
        {
            if ((nOldIndex < m_SpriteList[m_nCurrentIndex].m_nEffectFrame || nNewIndex <= nOldIndex) && m_SpriteList[m_nCurrentIndex].m_nEffectFrame <= nNewIndex)
                if (nLoopCount == 0 || m_SpriteList[m_nCurrentIndex].m_bEffectOnlyFirst == false)
                    CreateEffectObject();
        }
        if (m_SpriteList[m_nCurrentIndex].m_AudioClip != null)
        {
            if ((nOldIndex < m_SpriteList[m_nCurrentIndex].m_nSoundFrame || nNewIndex <= nOldIndex)  && m_SpriteList[m_nCurrentIndex].m_nSoundFrame <= nNewIndex)
                if (nLoopCount == 0 || m_SpriteList[m_nCurrentIndex].m_bSoundOnlyFirst == false)
                    CreateSoundObject(m_SpriteList[m_nCurrentIndex]);
        }
    }
    // 마지막 frame시간 지나면..(다음 loop 첫프레임이 되면), ret가 참이면 애니변경됨
    public bool OnAnimationLastFrame(NcSpriteAnimation spriteCom, int nLoopCount)
    {
        if (m_SpriteList.Count <= m_nCurrentIndex)
            return false;

        m_bEndSprite = true;
        // 		DestroyEffectObject();

        if (m_bSequenceMode)
        {
            if (m_nCurrentIndex < GetSpriteNodeCount() - 1)
            {
                if ((m_SpriteList[m_nCurrentIndex].m_bLoop ? 3 : 1) == nLoopCount)
                {
                    SetSprite(m_nCurrentIndex+1);
                    return true;
                }
            } else SetSprite(0);
        } else {
            NcSpriteAnimation ncTarSprite = SetSprite(m_SpriteList[m_nCurrentIndex].m_nNextSpriteIndex) as NcSpriteAnimation;
            if (ncTarSprite != null)
            {
                ncTarSprite.ResetAnimation();
                return true;
            }
        }
        return false;
    }
 // Property -------------------------------------------------------------------------
 // Event Function -------------------------------------------------------------------
 void OnEnable()
 {
     m_Sel         = target as NcSpriteAnimation;
     m_UndoManager = new FXMakerUndoManager(m_Sel, "NcSpriteAnimation");
 }
Example #19
0
    // ---------------------------------------------------------------------
    public string EndCapture(Texture2D[] SpriteTextures)
    {
#if UNITY_WEBPLAYER
        Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker.");
        Debug.Break();
        return(null);
#else
        int       nTexSize      = m_nResultTextureSize;
        int       nCapSize      = m_nResultCaptureSize;
        int       nMaxCount     = (nTexSize / nCapSize) * (nTexSize / nCapSize);
        int       nTexHeight    = (m_nSaveFrameCount <= nMaxCount / 2 ? nTexSize / 2 : nTexSize);
        Texture2D spriteTexture = new Texture2D(nTexSize, nTexHeight, TextureFormat.ARGB32, false);
        int       nSaveCount    = 0;

        for (int x = 0; x < spriteTexture.width; x++)
        {
            for (int y = 0; y < spriteTexture.height; y++)
            {
                spriteTexture.SetPixel(x, y, Color.black);
            }
        }

        for (int n = m_nSkipFrameCount; n < m_nTotalFrameCount; n++, nSaveCount++)
        {
            Color[] srcColors = SpriteTextures[n].GetPixels(0);

            if (m_ShaderType == SHADER_TYPE.ALPHA_BLENDED || m_ShaderType == SHADER_TYPE.ALPHA_BLENDED_MOBILE)
            {
                srcColors = NgAtlas.ConvertAlphaTexture(srcColors, true, FXMakerOption.inst.m_AlphaWeightCurve, 1, 1, 1);
            }
            spriteTexture.SetPixels(((nSaveCount) % (nTexSize / nCapSize)) * nCapSize, nTexHeight - (((nSaveCount) / (nTexSize / nCapSize) + 1) * nCapSize), nCapSize, nCapSize, srcColors);
            Object.DestroyImmediate(SpriteTextures[n]);
        }

        byte[] bytes = spriteTexture.EncodeToPNG();
        string texBasePath;
        if (FXMakerLayout.m_bDevelopState)
        {
            texBasePath = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.SPRITE_TOOL);
        }
        else
        {
            texBasePath = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.SPRITE_USER);
        }
        string pathTexture = NgTexture.UniqueTexturePath(texBasePath, m_SelectedPrefabName);

        // save texture
        File.WriteAllBytes(pathTexture, bytes);
        AssetDatabase.Refresh();
        NgTexture.ReimportTexture(pathTexture, m_bGUITexture, m_wrapMode, m_filterMode, m_anisoLevel, m_nSpriteTextureSizes[(int)m_fSpriteTextureIndex], m_SpriteTextureFormat[(int)m_fSpriteTextureFormatIdx]);
        Object.DestroyImmediate(spriteTexture);

        // Create Prefab
        if (m_bCreatePrefab)
        {
            string     pathMaterial = CreateMaterial(pathTexture);
            Material   newMat       = (Material)AssetDatabase.LoadAssetAtPath(pathMaterial, typeof(Material));
            GameObject newPrefab    = (GameObject)Instantiate(FXMakerMain.inst.m_FXMakerSpritePrefab);

            newPrefab.transform.rotation = Quaternion.identity;
            newPrefab.GetComponent <Renderer>().material = newMat;
            NcSpriteAnimation spriteCom = newPrefab.GetComponent <NcSpriteAnimation>();
            spriteCom.m_bBuildSpriteObj = true;
            spriteCom.m_nFrameCount     = m_nSaveFrameCount;
            spriteCom.m_fFps            = m_nResultFps;
            spriteCom.m_nTilingX        = m_nResultTextureSize / m_nResultCaptureSize;
            spriteCom.m_nTilingY        = (m_nSaveFrameCount <= spriteCom.m_nTilingX * spriteCom.m_nTilingX / 2 ? spriteCom.m_nTilingX / 2 : spriteCom.m_nTilingX);
            spriteCom.m_PlayMode        = m_PlayMode;
            spriteCom.m_bLoop           = m_bLoop;
            spriteCom.m_nLoopStartFrame = 0;
            spriteCom.m_nLoopFrameCount = spriteCom.m_nFrameCount;
            spriteCom.m_nLoopingCount   = 0;

            spriteCom.m_bAutoDestruct = !m_bLoop;

            NcCurveAnimation curveCom = newPrefab.GetComponent <NcCurveAnimation>();
            if (curveCom.GetCurveInfoCount() != 3)
            {
                Debug.LogError("FXMakerMain.inst.m_FxmSpritePrefab : curveCom Count Error!!!");
            }

            curveCom.GetCurveInfo(0).m_bEnabled = false;                        // both
            curveCom.GetCurveInfo(1).m_bEnabled = false;                        // fadein
            curveCom.GetCurveInfo(2).m_bEnabled = false;                        // fadeout
            curveCom.m_bAutoDestruct            = false;
            curveCom.m_fDurationTime            = spriteCom.GetDurationTime();

            if (m_bFadeIn && m_bFadeOut)
            {
                curveCom.GetCurveInfo(0).m_bEnabled = true;
            }
            else
            {
                if (m_bFadeIn)
                {
                    curveCom.GetCurveInfo(1).m_bEnabled = true;
                }
                if (m_bFadeOut)
                {
                    curveCom.GetCurveInfo(2).m_bEnabled = true;
                }
            }

            string     basePath     = AssetDatabase.GetAssetPath(FXMakerMain.inst.GetOriginalEffectPrefab());
            string     prefabPath   = UniquePrefabPath(NgFile.TrimFilenameExt(basePath));
            GameObject createPrefab = PrefabUtility.CreatePrefab(prefabPath, newPrefab);
            Destroy(newPrefab);

            // Create Thumb
            CreateSpriteThumb(createPrefab, pathTexture);

            AssetDatabase.SaveAssets();

            return(prefabPath);
        }
        else
        {
            return(pathTexture);
        }
#endif
    }
Example #20
0
 public void stop()
 {
     for (int i = 0; i < eod.particleSystemList.Count; i++)
     {
         ParticleSystem ps = eod.particleSystemList[i];
         if (ps != null)
         {
             ps.Pause(true);
         }
     }
     //foreach (SpriteAnimation sa in eod.spriteAnimationList)
     //{
     //    sa.delayIng = true;
     //    sa.loop = false;
     //    sa.enabled = true;
     //    sa.isPaused = true;
     //}
     oldTime = Time.time;
     for (int i = 0; i < eod.ncCurveAnimationList.Count; i++)
     {
         NcCurveAnimation nc = eod.ncCurveAnimationList[i];
         if (nc.isDelay())
         {
             nc.m_fDelayTime += 5000f;
         }
         else
         {
             nc.PauseAnimation();
         }
     }
     for (int i = 0; i < eod.ncSpriteAnimationList.Count; i++)
     {
         NcSpriteAnimation nc = eod.ncSpriteAnimationList[i];
         if (nc.isDelay())
         {
             nc.m_fDelayTime += 5000f;
         }
         else
         {
             nc.PauseAnimation();
         }
     }
     for (int i = 0; i < eod.ncUvAnimationList.Count; i++)
     {
         NcUvAnimation nc = eod.ncUvAnimationList[i];
         nc.PauseAnimation();
     }
     for (int i = 0; i < eod.ncRotationList.Count; i++)
     {
         NcRotation nc = eod.ncRotationList[i];
         nc.PauseAnimation();
     }
     for (int i = 0; i < eod.animatorList.Count; i++)
     {
         Animator animator = eod.animatorList[i];
         animator.speed = 0;
     }
     for (int i = 0; i < eod.animationList.Count; i++)
     {
         Animation animation = eod.animationList[i];
         animation.Stop();
     }
 }