public override int GetAnimationState()
 {
     if ((enabled && NgObject.IsActive(gameObject)) && (m_nDuplicateCount == 0 || m_nDuplicateCount != 0 && m_nCreateCount < m_nDuplicateCount))
     {
         return(1);
     }
     return(0);
 }
Example #2
0
    bool IsAliveAnimation()
    {
        GameObject rootInstObj = NcEffectBehaviour.GetRootInstanceEffect();

        Transform[] tranComs = rootInstObj.GetComponentsInChildren <Transform>(true);
        foreach (Transform trans in tranComs)
        {
            int  bNcAni    = -1;                                        // -1:None, 0:End, 1:Alive
            int  bParticle = -1;
            bool bRen      = false;

            // Check Animation
            NcEffectBehaviour[] effList = trans.GetComponents <NcEffectBehaviour>();
            foreach (NcEffectBehaviour eff in effList)
            {
                switch (eff.GetAnimationState())
                {
                case 1: bNcAni = 1;    break;

                case 0: bNcAni = 0;    break;
                }
            }

            // Check ParticleSystem
            if (trans.GetComponent <ParticleSystem>() != null)
            {
                bParticle = 0;
                if (NgObject.IsActive(trans.gameObject) && (0 < trans.GetComponent <ParticleSystem>().particleCount))
                {
                    bParticle = 1;
                }
            }

            // Check Renderer
            if (trans.GetComponent <Renderer>() != null)
            {
                if (trans.GetComponent <Renderer>().enabled&& NgObject.IsActive(trans.gameObject))
                {
                    bRen = true;
                }
            }

//              Debug.Log("bNcAni " + bNcAni + ", bParticle " + bParticle + ", bRen " + bRen);
            if (0 < bNcAni)
            {
                return(true);
            }
            if (bParticle == 1)
            {
                return(true);
            }
            if (bRen && (trans.GetComponent <MeshFilter>() != null || trans.GetComponent <TrailRenderer>() != null || trans.GetComponent <LineRenderer>() != null))
            {
                return(true);
            }
        }
        return(false);
    }
Example #3
0
 public static void HideAllChildObject(GameObject parent)
 {
     for (int n = parent.transform.childCount - 1; 0 <= n; n--)
     {
         if (n < parent.transform.childCount)
         {
             NgObject.IsActive(parent.transform.GetChild(n).gameObject);
         }
     }
 }
    // Loop Function --------------------------------------------------------------------
    void Awake()
    {
#if UNITY_EDITOR
        if (IsCreatingEditObject() == true)
        {
            m_bEnabled = false;
        }
        else
#endif
        m_bEnabled = (enabled && NgObject.IsActive(gameObject) && GetComponent <NcDontActive>() == null);
    }
Example #5
0
 public override int GetAnimationState()
 {
     if (enabled == false || NgObject.IsActive(gameObject) == false)
     {
         return(-1);
     }
     if ((0 < m_fDurationTime && (m_fStartTime == 0 || GetEngineTime() - m_fStartTime - m_fDelayTime < m_fDurationTime)))
     {
         return(1);
     }
     return(0);
 }
Example #6
0
    public static void HideAllChildObject(GameObject parent)
    {
        int num = parent.get_transform().get_childCount() - 1;

        while (0 <= num)
        {
            if (num < parent.get_transform().get_childCount())
            {
                NgObject.IsActive(parent.get_transform().GetChild(num).get_gameObject());
            }
            num--;
        }
    }
Example #7
0
    public static void HideAllChildObject(GameObject parent)
    {
        int num = parent.transform.childCount - 1;

        while (0 <= num)
        {
            if (num < parent.transform.childCount)
            {
                NgObject.IsActive(parent.transform.GetChild(num).gameObject);
            }
            num--;
        }
    }
    // Create ---------------------------------------------------------------------------
    public static NcAutoDestruct CreateAutoDestruct(GameObject baseGameObject, float fLifeTime, float fDestroyTime, bool bSmoothHide)
    {
        NcAutoDestruct ncAutoDestruct = baseGameObject.AddComponent <NcAutoDestruct>();

        ncAutoDestruct.m_fLifeTime          = fLifeTime;
        ncAutoDestruct.m_fSmoothDestroyTime = fDestroyTime;
        ncAutoDestruct.m_bSmoothHide        = bSmoothHide;
        if (NgObject.IsActive(baseGameObject))
        {
            ncAutoDestruct.Start();
            ncAutoDestruct.Update();
        }
        return(ncAutoDestruct);
    }
Example #9
0
    public override int GetAnimationState()
    {
        if ((enabled && NgObject.IsActive(gameObject)) || (m_AudioSource != null && m_AudioSource.isPlaying))
        {
            return(1);
        }
//      if ((enabled && NgObject.IsActive(gameObject)) && m_AudioClip != null &&
//          ((m_fRepeatTime == 0 && m_nCreateCount < 1) ||
//           (m_fRepeatTime != 0 && m_nRepeatCount == 0) ||
//           (m_fRepeatTime != 0 && m_nRepeatCount != 0 && m_nCreateCount < m_nRepeatCount) ||
//           m_bLoop ||
//           (m_AudioSource != null && m_AudioSource.isPlaying)))
//          return 1;
        return(0);
    }
    public override int GetAnimationState()
    {
        int re;

        if (m_bRepeat == false)
        {
            if (enabled && NgObject.IsActive(gameObject))
            {
                re = 1;
            }
            re = 0;
        }
        re = -1;
//      Debug.Log("bNcAni " + re);
        return(re);
    }
 public override int GetAnimationState()
 {
     if ((enabled && NgObject.IsActive(gameObject)) && m_AttachPrefab != null)
     {
         if (m_AttachType == AttachType.Active &&
             ((m_nRepeatCount == 0 && m_nCreateCount < 1) ||
              (0 < m_fRepeatTime && m_nRepeatCount == 0) ||
              (0 < m_nRepeatCount && m_nCreateCount < m_nRepeatCount)))
         {
             return(1);
         }
         if (m_AttachType == AttachType.Destroy)
         {
             return(1);
         }
     }
     return(0);
 }
Example #12
0
    public override int GetAnimationState()
    {
        if (enabled == false || NgObject.IsActive(gameObject) == false)
        {
            return(-1);
        }

        if (m_bBurst)
        {
            if (0 < m_nBurstRepeatCount)
            {
                if (m_nCreateCount < m_nBurstRepeatCount)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            return(1);
        }
        else
        {
            if (0 < m_fStartDelayTime)
            {
                return(1);
            }
            if (0 < m_fEmitTime && m_fSleepTime <= 0)
            {
                if (m_nCreateCount < 1)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }
        return(-1);             // loop
    }
    // Loop Function --------------------------------------------------------------------
    void Awake()
    {
        m_nCreateCount = 0;
        m_fStartTime   = -m_fDuplicateTime;
        m_ClonObject   = null;
        m_bInvoke      = false;

        if (enabled == false)
        {
            return;
        }

//      Debug.Log("Duration.Awake");
#if UNITY_EDITOR
        if (IsCreatingEditObject() == false)
#endif
        if (transform.parent != null && (enabled && NgObject.IsActive(gameObject) && GetComponent <NcDontActive>() == null))
        {
            InitCloneObject();
        }
    }
Example #14
0
    private bool IsAliveAnimation()
    {
        GameObject rootInstanceEffect = NcEffectBehaviour.GetRootInstanceEffect();

        Transform[] componentsInChildren = rootInstanceEffect.GetComponentsInChildren <Transform>(true);
        Transform[] array = componentsInChildren;
        for (int i = 0; i < array.Length; i++)
        {
            Transform           transform  = array[i];
            int                 num        = -1;
            int                 num2       = -1;
            bool                flag       = false;
            NcEffectBehaviour[] components = transform.GetComponents <NcEffectBehaviour>();
            NcEffectBehaviour[] array2     = components;
            for (int j = 0; j < array2.Length; j++)
            {
                NcEffectBehaviour ncEffectBehaviour = array2[j];
                int animationState = ncEffectBehaviour.GetAnimationState();
                if (animationState != 0)
                {
                    if (animationState == 1)
                    {
                        num = 1;
                    }
                }
                else
                {
                    num = 0;
                }
            }
            if (transform.particleSystem != null)
            {
                num2 = 0;
                if (NgObject.IsActive(transform.gameObject) && ((transform.particleSystem.enableEmission && transform.particleSystem.IsAlive()) || 0 < transform.particleSystem.particleCount))
                {
                    num2 = 1;
                }
            }
            if (num2 < 1 && transform.particleEmitter != null)
            {
                num2 = 0;
                if (NgObject.IsActive(transform.gameObject) && (transform.particleEmitter.emit || 0 < transform.particleEmitter.particleCount))
                {
                    num2 = 1;
                }
            }
            if (transform.renderer != null && transform.renderer.enabled && NgObject.IsActive(transform.gameObject))
            {
                flag = true;
            }
            if (0 < num)
            {
                return(true);
            }
            if (num2 == 1)
            {
                return(true);
            }
            if (flag && (transform.GetComponent <MeshFilter>() != null || transform.GetComponent <TrailRenderer>() != null || transform.GetComponent <LineRenderer>() != null))
            {
                return(true);
            }
        }
        return(false);
    }
    // Loop Function --------------------------------------------------------------------
    void Update()
    {
        if (m_bStartDetach == false)
        {
            m_bStartDetach = true;

            if (transform.parent != null)
            {
                m_ParentGameObject = transform.parent.gameObject;
                NcDetachObject.Create(m_ParentGameObject, transform.gameObject);
            }

            // Detach Parent
            GameObject parentObj = GetRootInstanceEffect();

            if (m_bFollowParentTransform)
            {
                m_OriginalPos.SetLocalTransform(transform);
                ChangeParent(parentObj.transform, transform, false, null);
                m_OriginalPos.CopyToLocalTransform(transform);
            }
            else
            {
                ChangeParent(parentObj.transform, transform, false, null);
            }

            if (m_bParentHideToStartDestroy == false)
            {
                StartDestroy();
            }
        }

        // Live time
        if (0 < m_fStartDestroyTime)
        {
            if (0 < m_fSmoothDestroyTime)
            {
                if (m_bSmoothHide)
                {
                    float fRate = 1 - ((GetEngineTime() - m_fStartDestroyTime) / m_fSmoothDestroyTime);
                    if (fRate < 0)
                    {
                        fRate = 0;
                    }

                    // Recursively
                    Renderer[] rens = transform.GetComponentsInChildren <Renderer>(true);
                    for (int n = 0; n < rens.Length; n++)
                    {
                        Renderer ren     = rens[n];
                        string   colName = GetMaterialColorName(ren.material);

                        if (colName != null)
                        {
                            Color col = ren.material.GetColor(colName);
                            col.a = Mathf.Min(fRate, col.a);
                            ren.material.SetColor(colName, col);
                        }
                    }
                }
                if (m_fStartDestroyTime + m_fSmoothDestroyTime < GetEngineTime())
                {
                    Object.Destroy(gameObject);
                }
            }
        }
        else
        {
            if (m_bParentHideToStartDestroy)
            {
                if (m_ParentGameObject == null || NgObject.IsActive(m_ParentGameObject) == false)
                {
                    StartDestroy();
                }
            }
        }

        // follow parent transform
        if (m_bFollowParentTransform && m_ParentGameObject != null && m_ParentGameObject.transform != null)
        {
            NcTransformTool tmp = new NcTransformTool();
            tmp.SetTransform(m_OriginalPos);
            tmp.AddTransform(m_ParentGameObject.transform);
            tmp.CopyToLocalTransform(transform);
        }
    }