Example #1
0
    void ChangedState(cGlobalData.StateOfTheWorld State)
    {
        bool Invisibility = (State == InvisibilityState);
        MeshRenderer[] ChildMeshObj = transform.GetComponentsInChildren<MeshRenderer>();
        SkinnedMeshRenderer[] ChildSkinnedMeshObj = transform.GetComponentsInChildren<SkinnedMeshRenderer>();

        foreach (MeshRenderer ChildMesh in ChildMeshObj){
            ChildMesh.renderer.enabled = !Invisibility;
        }

        foreach (SkinnedMeshRenderer ChildMesh in ChildSkinnedMeshObj){
            ChildMesh.renderer.enabled = !Invisibility;
        }

        if(DisebledColliders){
            Collider[] Colliders = transform.GetComponents<Collider>();

            foreach (Collider ThisCollider in Colliders){
                ThisCollider.enabled = !Invisibility;
            }

            Collider[] ChildColliders = transform.GetComponentsInChildren<Collider>();

            foreach (Collider ChildCollider in ChildColliders){
                ChildCollider.enabled = !Invisibility;
            }

            if(ItIsPlatform){
                cPlatformController[] Scripts = transform.GetComponents<cPlatformController>();
                foreach (cPlatformController Script in Scripts){
                    Script.enabled = !Invisibility;
                }
            }
        }

        if(DisebledParticles){
            ParticleSystem[] ChildParticles = transform.GetComponentsInChildren<ParticleSystem>();

            foreach (ParticleSystem ChildParticle in ChildParticles){
                if(Invisibility){
                    ChildParticle.Pause();
                    ChildParticle.Clear();
                }
                else{
                    ChildParticle.Play();
                }

            }
        }
    }
    void ChangedState(cGlobalData.StateOfTheWorld State)
    {
        if(CurrentState == State){
            return;
        }

        CurrentState = State;
        bool NeedOpen = (State == OpenState);

        string AnimationName = "";
        if(NeedOpen){
            AnimationName = "DoorOpen";
        }
        else{
            AnimationName = "DoorClose";
        }

        animation.CrossFade(AnimationName);

        collider.enabled = !NeedOpen;
    }