Exemplo n.º 1
0
    // Update is called once per frame
    void EnableTerraformation(bool state)
    {
        if (state)
        {
            m_icoPlanet = m_dropzone.catchedObject.GetComponent <IcoPlanet>();

            if (m_icoPlanet)
            {
                AkSoundEngine.PostEvent("Play_Anim_Extrud", gameObject);
                m_icoPlanet.Animate();

                Invoke("EnableButton", 2);

                m_icoPlanet.GetComponent <Collider>().enabled = false;

                MTK_Interactable interactable = m_icoPlanet.GetComponent <MTK_Interactable>();
                interactable.isDistanceGrabbable = false;
                interactable.isGrabbable         = false;

                foreach (IcoSegment segment in m_icoPlanet.Segments)
                {
                    segment.GetComponent <MTK_Interactable>().isGrabbable = true;
                    segment.GetComponent <Collider>().enabled             = true;
                }

                AkSoundEngine.PostEvent("Soundseed_Play", gameObject);
                AkSoundEngine.PostEvent("Mute_Planet", gameObject);
            }
            else
            {
                m_dropzone.Release();
            }
        }
        else if (m_icoPlanet)
        {
            MTK_Interactable interactable = m_icoPlanet.GetComponent <MTK_Interactable>();
            interactable.isDistanceGrabbable = true;
            interactable.isGrabbable         = true;

            m_icoPlanet.GetComponent <Collider>().enabled = true;
            foreach (IcoSegment segment in m_icoPlanet.Segments)
            {
                segment.GetComponent <MTK_Interactable>().isGrabbable = false;
                segment.GetComponent <Collider>().enabled             = false;
            }
            m_icoPlanet.GenerateMeshCollider();

            m_icoPlanet = null;

            AkSoundEngine.PostEvent("Soundseed_Stop", gameObject);
            AkSoundEngine.PostEvent("UnMute_Planet", gameObject);
        }
    }
Exemplo n.º 2
0
    protected override void OnWorkshopUpdateState(bool state, MTK_Interactable current)
    {
        IcoPlanet ico = m_dropzone.catchedObject.GetComponent <IcoPlanet>();

        if (state)
        {
            if (ico)
            {
                ico.GetComponent <MeshCollider>().enabled = false;

                foreach (IcoSegment segment in ico.Segments)
                {
                    segment.GetComponent <MeshCollider>().enabled = true;
                    if (segment.GetComponent <IcoSegment>())
                    {
                        foreach (Transform decoration in segment.transform)
                        {
                            decoration.GetComponent <MTK_Interactable>().isGrabbable = true;
                        }
                    }
                }
            }
            else
            {
                m_dropzone.Release();
            }
        }
        else
        {
            m_placingEnabled = false;

            if (ico)
            {
                ico.GetComponent <MeshCollider>().enabled = true;
                foreach (Transform segment in m_dropzone.catchedObject.transform)
                {
                    if (segment.GetComponent <IcoSegment>())
                    {
                        segment.GetComponent <MeshCollider>().enabled = false;
                        foreach (Transform decoration in segment)
                        {
                            decoration.GetComponent <MTK_Interactable>().isGrabbable = false;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
    void CleanupPlanet(IcoPlanet planet)
    {
        foreach (Transform child in planet.transform)
        {
            if (!child.GetComponent <IcoSegment>())
            {
                Destroy(child.gameObject);
            }
        }

        // Set transforms
        planet.GetComponent <Rigidbody>().isKinematic = true;

        planet.transform.parent   = transform;
        planet.transform.rotation = Quaternion.identity;
        planet.transform.position = Vector3.zero;

        foreach (IcoSegment segment in planet.Segments)
        {
            segment.transform.localScale = Vector3.one;
        }
        planet.transform.localScale = Vector3.one;


        // Destroy useless components
        Destroy(planet.GetComponent <MTK_Interactable>());
        Destroy(planet.GetComponent <MeshCollider>());
        Destroy(planet.GetComponent <Outline>());
        foreach (MTK_JointType joint in planet.GetComponents <MTK_JointType>())
        {
            Destroy(joint);
        }

        foreach (IcoSegment segment in planet.Segments)
        {
            segment.GetComponent <MeshCollider>().enabled = true;
            Destroy(segment.GetComponent <Outline>());
            Destroy(segment.GetComponent <MTK_Interactable>());
            foreach (MTK_JointType joint in segment.GetComponents <MTK_JointType>())
            {
                Destroy(joint);
            }
        }
    }