Пример #1
0
    public static void Door_UpdateAction(InstalledObject _inObj, float _deltaTime)
    {
        //if (Debug.isDebugBuild)
        //    Debug.Log("Door_UpdateAction: " + _inObj.inObjParameters["openness"]);

        if (_inObj.GetParameter("is_opening") >= 1)
        {
            _inObj.ChangeParameter("openness", _deltaTime * 4);
            if (_inObj.GetParameter("openness") >= 1)
            {
                _inObj.SetParameter("is_opening", 0);
            }
        }
        else
        {
            _inObj.ChangeParameter("openness", -_deltaTime * 4);
        }

        _inObj.SetParameter("openness", Mathf.Clamp01(_inObj.GetParameter("openness")));

        if (_inObj.cbOnChanged != null)
        {
            _inObj.cbOnChanged(_inObj);
        }
    }
Пример #2
0
    public static void Door_UpdateAction(InstalledObject installedObject, float deltaTime)
    {
        // If the door isOpening is 'true' open the door a little bit more
        if (installedObject.GetParameter("isOpening") >= 1)
        {
            installedObject.ChangeParameter("OpenValue", (deltaTime * 4));

            // If door is fully opened, close it again (right away)
            if (installedObject.GetParameter("OpenValue") >= 1)
            {
                installedObject.SetParameter("isOpening", 0);
            }
        }
        // Close door again
        else
        {
            installedObject.ChangeParameter("OpenValue", (deltaTime * -4));
        }

        // Clamp value between 0 & 1
        installedObject.SetParameter("OpenValue", Mathf.Clamp01(installedObject.GetParameter("OpenValue")));

        // Call the callback if there is any
        if (installedObject.cb_OnChanged != null)
        {
            installedObject.cb_OnChanged(installedObject);
        }
    }
    public static void Door_UpdateAction(InstalledObject obj, float deltaTime)
    {
        //Debug.Log("Door_UpdateAction");
        if (obj.GetParameter("openingState") >= 1)
        {
            obj.ChangeParameter("openness", deltaTime * 4);
            if (obj.GetParameter("openness") >= 1)
            {
                obj.SetParameter("openingState", 0);
            }
        }
        else
        {
            obj.ChangeParameter("openness", deltaTime * -4);
        }

        obj.SetParameter("openness", Mathf.Clamp01(obj.GetParameter("openness")));

        if (obj.CbOnInstalledObjectChanged != null)
        {
            obj.CbOnInstalledObjectChanged(obj);
        }
    }