Example #1
0
    /// <summary>
    /// This method is used to initialize all the objects used in the script.
    /// </summary>
    private void Awake()
    {
        // Get the snow globe object
        m_snowBall = GameObject.Find("SnowGlobe");

        // Get the water container object(water bucket)
        m_waterContainer = GameObject.Find("WaterContainer");

        // Get the water drop collector object.
        m_waterCollector = GameObject.Find("WaterCollector");

        // Get the pipe object
        m_vapourPipe = GameObject.Find("VapourSourceForPipe");

        // Gett the ice material
        m_iceMaterial = (Material)Resources.Load("IceMaterial");

        // Get the heater object - TODO chaging the color of heater
        m_heater = GameObject.Find("Heater");

        if (m_snowBall == null || m_waterContainer == null ||
            m_iceMaterial == null || m_vapourPipe == null ||
            m_waterCollector == null || m_heater == null)
        {
            Debug.LogError("ERROR - Some of the game objects are missing");
            return;
        }

        // Check that water is present inside the bucket
        if(m_waterContainer.transform.Find("ReflectiveWater") == null)
        {
            Debug.LogError("ERROR - No Reflective water found");
            return;
        }

        // check for vapour emitter at the end where water drops are collected
        if(m_vapourPipe.transform.Find("VapourEmitter") == null)
        {
            Debug.LogError("ERROR - No vapour emitter found");
            return;
        }

        // Access the vapour emitter object as it has been checked in the above step
        m_vapourEmitter = m_vapourPipe.transform.Find("VapourEmitter").gameObject;

        // Access the water drop script
        m_waterDropScript = (InstantiateWaterDrop)m_vapourPipe.GetComponent(typeof(InstantiateWaterDrop));

        // Get the reflective water script
        m_refWater = m_waterContainer.transform.Find("ReflectiveWater").gameObject;

        // get the water material. This is used to change water to ice and vice versa
        m_waterMaterial = m_refWater.renderer.material;

        // Check if water script is attached. If found get a pointer to it
        if (m_refWater.GetComponent(typeof(WaterSimple)) != null)
            m_waterScript = (WaterSimple)m_refWater.GetComponent(typeof(WaterSimple));
        else
            Debug.LogError("ERROR - No water script found");

        // Get a pointer to pully movement script
        if (m_waterCollector.GetComponent(typeof(PullyMovement)) != null)
            m_pullyScript = (PullyMovement)m_waterCollector.GetComponent(typeof(PullyMovement));
        else
            Debug.LogError("ERROR - No Pully script found");

        if (m_heater.GetComponent(typeof(ColorControl)) != null)
        {
            m_colorChangeScript = (ColorControl)m_heater.GetComponent(typeof(ColorControl));
            m_colorChangeScript.SetColorParams(ColorControl.PrimaryColor.r, 1.5f, 0.001f, false);
        }
        else
            Debug.LogError("ERROR - No ColorControl script found");
    }
Example #2
0
    private void Awake()
    {
        // Get the water container object(water bucket)
        mWaterContainer = GameObject.Find("WaterContainer");

        // Get the reflective water script
        mRefWater = mWaterContainer.transform.Find("ReflectiveWater").gameObject;

        // get the water material. This is used to change water to ice and vice versa
        mWaterMaterial = mRefWater.renderer.material;

        // Gett the ice material
        mIceMaterial = (Material)Resources.Load("IceMaterial");

        // Get the pipe object
        mVapourPipe = GameObject.Find("VapourSourceForPipe");

        mWaterScript = (WaterSimple)mRefWater.GetComponent(typeof(WaterSimple));

        // Access the vapour emitter object as it has been checked in the above step
        mVapourEmitter = mVapourPipe.transform.Find("VapourEmitter").gameObject;

        // Access the water drop script
        mWaterDropScript = (InstantiateWaterDrop)mVapourPipe.GetComponent(typeof(InstantiateWaterDrop));

        mColorChangeScript = GameObject.Find("Heater").GetComponent<ColorControl>();

        mColorChangeScript.SetColorParams(ColorControl.PrimaryColor.r, 1.5f, 0.001f, false);

        mPullyScript = GameObject.Find("WaterCollector").GetComponent<PullyMovement>();

        particleEmitter = gameObject.transform.parent.gameObject.particleEmitter;
        audio = gameObject.transform.parent.gameObject.audio;
    }