コード例 #1
0
    // Control Function -----------------------------------------------------------------
    void CreateAttachPrefab(Vector3 position, float size)
    {
        if (m_AttachPrefab == null)
        {
            return;
        }
        GameObject createGameObject = (GameObject)CreateGameObject(m_AttachPrefab, m_AttachPrefab.transform.position + position, m_AttachPrefab.transform.rotation);

        if (createGameObject == null)
        {
            return;
        }
        // Change Parent
        ChangeParent(GetRootInstanceEffect().transform, createGameObject.transform, false, null);
        NcTransformTool_B.CopyLossyToLocalScale(createGameObject.transform.lossyScale * size, createGameObject.transform);

        // PrefabAdjustSpeed
        AdjustSpeedRuntime(createGameObject, m_fPrefabSpeed);

        // m_fPrefabLifeTime
        if (0 < m_fPrefabLifeTime)
        {
            NcAutoDestruct_B ncAd = createGameObject.GetComponent <NcAutoDestruct_B>();
            if (ncAd == null)
            {
                ncAd = createGameObject.AddComponent <NcAutoDestruct_B>();
            }
            ncAd.m_fLifeTime = m_fPrefabLifeTime;
        }
    }
コード例 #2
0
    protected void ChangeParent(Transform newParent, Transform child, bool bKeepingLocalTransform, Transform addTransform)
    {
        // Keeping transform
        NcTransformTool_B trans = null;

        if (bKeepingLocalTransform)
        {
            trans = new NcTransformTool_B(child.transform);
            if (addTransform != null)
            {
                trans.AddTransform(addTransform);
            }
        }
        child.parent = newParent;
        if (bKeepingLocalTransform)
        {
            trans.CopyToLocalTransform(child.transform);
        }

        // Update component
        if (bKeepingLocalTransform)
        {
//          NcEffectBehaviour[]	coms = gameObject.GetComponentsInChildren<NcEffectBehaviour>();
//          foreach (NcEffectBehaviour com in coms)
//              com.SendMessage("Update", SendMessageOptions.DontRequireReceiver);
            NcBillboard_B[] ncBills = gameObject.GetComponentsInChildren <NcBillboard_B>();
            foreach (NcBillboard_B ncb in ncBills)
            {
                ncb.UpdateBillboard();
            }
        }
    }
コード例 #3
0
    public Particle[] LegacyScaleParticle(Particle[] parts, bool bScale, bool bPosUpdate)
    {
        float fScale;

        if (bScale)
        {
            fScale = NcTransformTool_B.GetTransformScaleMeanValue(transform);
        }
        else
        {
            fScale = 1 / NcTransformTool_B.GetTransformScaleMeanValue(transform);
        }

        for (int n = 0; n < parts.Length; n++)
        {
            if (IsMeshParticleEmitter() == false)
            {
                if (m_bWorldSpace)
                {
                    if (bPosUpdate)
                    {
                        Vector3 move = (m_OldPos - transform.position);
                        if (bScale)
                        {
                            parts[n].position -= move * (1 - 1 / fScale);
                        }
                    }
                    parts[n].position -= transform.position;
                    parts[n].position *= fScale;
                    parts[n].position += transform.position;
                }
                else
                {
                    parts[n].position *= fScale;
                }
            }
            parts[n].angularVelocity *= fScale;
            parts[n].velocity        *= fScale;
            parts[n].size            *= fScale;
        }
        return(parts);
    }
コード例 #4
0
    public ParticleSystem.Particle[] ShurikenScaleParticle(ParticleSystem.Particle[] parts, int nCount, bool bScale, bool bPosUpdate)
    {
        float fScale;

        if (bScale)
        {
            fScale = NcTransformTool_B.GetTransformScaleMeanValue(transform);
        }
        else
        {
            fScale = 1 / NcTransformTool_B.GetTransformScaleMeanValue(transform);
        }

        for (int n = 0; n < nCount; n++)
        {
            if (m_bWorldSpace)
            {
                if (bPosUpdate)
                {
                    Vector3 move = (m_OldPos - transform.position);
                    if (bScale)
                    {
                        parts[n].position -= move * (1 - 1 / fScale);
                    }
                }
                parts[n].position -= transform.position;
                parts[n].position *= fScale;
                parts[n].position += transform.position;
            }
            else
            {
                parts[n].position *= fScale;
            }
            //          parts[n].angularVelocity *= fScale;
#pragma warning disable CS0618 // Type or member is obsolete
            parts[n].size *= fScale;
#pragma warning restore CS0618 // Type or member is obsolete
                               //           parts[n].velocity *= fScale;
        }
        return(parts);
    }
コード例 #5
0
 // --------------------------------------------------------------------------
 public void SetTransform(NcTransformTool_B val)
 {
     m_vecPos   = val.m_vecPos;
     m_vecRot   = val.m_vecRot;
     m_vecScale = val.m_vecScale;
 }
コード例 #6
0
    void LegacySetParticle()
    {
        ParticleEmitter  pe = m_pe;
        ParticleAnimator pa = m_pa;
        ParticleRenderer pr = m_pr;

        if (pe == null || pr == null)
        {
            return;
        }

        if (m_bLegacyRuntimeScale)
        {
            Vector3 vecVelScale = Vector3.one * m_fStartSpeedRate;
            float   fVelScale   = m_fStartSpeedRate;

            pe.minSize     *= m_fStartSizeRate;
            pe.maxSize     *= m_fStartSizeRate;
            pe.minEnergy   *= m_fStartLifeTimeRate;
            pe.maxEnergy   *= m_fStartLifeTimeRate;
            pe.minEmission *= m_fStartEmissionRate;
            pe.maxEmission *= m_fStartEmissionRate;

            pe.worldVelocity         = Vector3.Scale(pe.worldVelocity, vecVelScale);
            pe.localVelocity         = Vector3.Scale(pe.localVelocity, vecVelScale);
            pe.rndVelocity           = Vector3.Scale(pe.rndVelocity, vecVelScale);
            pe.angularVelocity      *= fVelScale;
            pe.rndAngularVelocity   *= fVelScale;
            pe.emitterVelocityScale *= fVelScale;

//          NgAssembly.LogFieldsPropertis(pe);

            if (pa != null)
            {
                pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale);
                pa.force    = Vector3.Scale(pa.force, vecVelScale);
//				pa.damping					*= fScale;
            }

//          pr.velocityScale			*= fVelScale;
            pr.lengthScale *= m_fRenderLengthRate;
        }
        else
        {
            Vector3 vecVelScale = (m_bScaleWithTransform ? pe.transform.lossyScale : Vector3.one) * m_fStartSpeedRate;
            float   fVelScale   = (m_bScaleWithTransform ? NcTransformTool_B.GetTransformScaleMeanValue(pe.transform) : 1) * m_fStartSpeedRate;
            float   fScale      = (m_bScaleWithTransform ? NcTransformTool_B.GetTransformScaleMeanValue(pe.transform) : 1) * m_fStartSizeRate;

            pe.minSize     *= fScale;
            pe.maxSize     *= fScale;
            pe.minEnergy   *= m_fStartLifeTimeRate;
            pe.maxEnergy   *= m_fStartLifeTimeRate;
            pe.minEmission *= m_fStartEmissionRate;
            pe.maxEmission *= m_fStartEmissionRate;

            pe.worldVelocity         = Vector3.Scale(pe.worldVelocity, vecVelScale);
            pe.localVelocity         = Vector3.Scale(pe.localVelocity, vecVelScale);
            pe.rndVelocity           = Vector3.Scale(pe.rndVelocity, vecVelScale);
            pe.angularVelocity      *= fVelScale;
            pe.rndAngularVelocity   *= fVelScale;
            pe.emitterVelocityScale *= fVelScale;

//          NgAssembly.LogFieldsPropertis(pe);

            if (pa != null)
            {
                pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale);
                pa.force    = Vector3.Scale(pa.force, vecVelScale);
//				pa.damping					*= fScale;
            }

//          pr.velocityScale			*= fVelScale;
            pr.lengthScale *= m_fRenderLengthRate;
        }
    }
コード例 #7
0
 public float GetScaleMaxMeshNormalVelocity()
 {
     return(m_fLegacyMaxMeshNormalVelocity * (m_bScaleWithTransform ? NcTransformTool_B.GetTransformScaleMeanValue(transform) : 1));
 }
コード例 #8
0
    // Loop Function --------------------------------------------------------------------
    void Update()
    {
        if (m_bStartDetach == false)
        {
            m_bStartDetach = true;

            if (transform.parent != null)
            {
                m_ParentGameObject = transform.parent.gameObject;
                NcDetachObject_B.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 || IsActive(m_ParentGameObject) == false)
                {
                    StartDestroy();
                }
            }
        }

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