Esempio n. 1
0
    private void Update()
    {
        if (mActionMutex)
        {
            return;
        }
        if (wandGrab == null)
        {
            mPrimRot = 0.0f;
            return;
        }
        float lRot = wandGrab.transform.eulerAngles.z;

        if (lRot > 350.0f && mPrimRot < 10.0f)
        {
            mPrimRot = 360.0f + mPrimRot;
        }
        if (lRot < 10.0f && mPrimRot > 350.0f)
        {
            mPrimRot = mPrimRot - 360.0f;
        }
        this.UpdateValueObj(lRot - mPrimRot);
        obj.Play();
        mPrimRot = lRot;
    }
Esempio n. 2
0
 public virtual void OnCollisionEnter(Collision col)
 {
     Debug.Log("HitCollision " + col.collider.name);
     if (impact != null && impact.CurrentStatus == FmodEventAudioSource.Status.Stopped)
     {
         impact.Play();
     }
 }
Esempio n. 3
0
 public bool CheckValue()
 {
     if (source != null && source.CurrentStatus == FmodEventAudioSource.Status.Stopped)
     {
         source.Play();
     }
     if (source != null && source.GetParameterValue("param01") == wantedValue)
     {
         if (eventDialog != null)
         {
             if (this.charactere == null)
             {
                 return(true);
             }
             GameManager tmp = this.charactere.GetComponent <GameManager>();
             if (tmp == null)
             {
                 return(true);
             }
             tmp.SetDialog(eventDialog, true);
             eventDialog = null;
         }
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
 public virtual void VRAction()
 {
     Debug.Log("VRAction actived");
     if (source != null && source.CurrentStatus == FmodEventAudioSource.Status.Stopped)
     {
         source.Play();
     }
 }
Esempio n. 5
0
 public void end(bool win = true)
 {
     Debug.Log("End");
     if (win)
     {
         source.Stop();
         source.SetSourceEvent(mEtap6[7]);
         source.Play();
     }
     else
     {
         mEnd = true;
         mObjects[9].activeActionMutex();
         mObjects[10].activeActionMutex();
         source.Stop();
         source.SetSourceEvent(mEtap6[3]);
         source.Play();
     }
     mState = eState._FINISH_;
 }
Esempio n. 6
0
    public override void OnInspectorGUI()
    {
        if (target == null)
        {
            return;
        }
        FmodEventAudioSource source = target as FmodEventAudioSource;
        string typeString;
        List <FmodRuntimeEventParameter> parameters;
        bool shouldRepaint = false;

        source.CheckForOldFormat();
        if (source.getSource() == null)
        {
            parameters       = new List <FmodRuntimeEventParameter>();
            typeString       = "No event is loaded";
            m_show3DSettings = false;
        }
        else
        {
            typeString       = "This is a " + (source.type == FmodEvent.SourceType.SOURCE_2D ? "2D" : "3D") + " event.";
            m_show3DSettings = (source.type == FmodEvent.SourceType.SOURCE_2D ? false : true);
            parameters       = source.getParameters();
            if (m_parameters.Count == 0 && parameters.Count > 0)
            {
                foreach (FmodRuntimeEventParameter p in parameters)
                {
                    m_parameters.Add(new SerializedObject(p));
                }
            }
            if (m_event == null && source.eventClip != null)
            {
                m_event = new SerializedObject(source.eventClip.getSource());
            }
            if (m_event != null)
            {
                m_event.Update();
            }
            if (m_source != null && !(m_source.targetObject is FmodEventAudioSource))
            {
                m_source = null;
            }
            if (m_source == null && source.getSource() != null)
            {
                m_source = new SerializedObject(source);
            }
            m_source.Update();
            foreach (SerializedObject p in m_parameters)
            {
                p.Update();
                ((FmodRuntimeEventParameter)p.targetObject).getUnderlyingValue();
            }
        }

        EditorGUILayout.ObjectField("Source event", source.getSource(), typeof(FmodEvent), false);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel(" ");
        EditorGUILayout.LabelField(typeString, GUI.skin.textField, GUILayout.ExpandWidth(false));
        EditorGUILayout.EndHorizontal();

        if (source.getSource() != null)
        {
            FmodEventAudioSource.Status status = source.CurrentStatus;
            bool paused = source.Paused;

            EditorGUILayout.LabelField("Status", source.getStatus(), GUI.skin.textField);

            GUI.enabled = (Application.isPlaying);
            if (paused)
            {
                if (GUILayout.Button("Unpause"))
                {
                    source.Unpause();
                }
            }
            else
            {
                if (GUILayout.Button("Pause"))
                {
                    source.Pause();
                }
            }
            if (status == FmodEventAudioSource.Status.Stopped)
            {
                if (GUILayout.Button("Play"))
                {
                    source.Play();
                }
            }
            else if (status == FmodEventAudioSource.Status.Playing)
            {
                if (GUILayout.Button("Stop"))
                {
                    source.Stop();
                }
            }
            GUI.enabled = true;
        }

        m_showParams = EditorGUILayout.Foldout(m_showParams, "Parameters");
        if (m_showParams)
        {
            EditorGUI.indentLevel += 2;
            if (m_parameters.Count > 0)
            {
                foreach (SerializedObject o in m_parameters)
                {
                    FmodRuntimeEventParameter p    = o.targetObject as FmodRuntimeEventParameter;
                    SerializedProperty        prop = o.FindProperty("m_value");

                    if (p.getName() == "(distance)" || p.getName() == "(listener angle)" || p.getName() == "(event angle)")
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel(p.getName());
                        EditorGUILayout.HelpBox("Parameters named '" + p.getName() + "' are reserved by FMOD for 3D sounds", MessageType.None);
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.Slider(prop, p.MinRange, p.MaxRange, p.getName());
                    }
                    if (p == null || p.m_parameter == null)
                    {
                        Debug.LogWarning("Error happening in gameObject " + source.gameObject);
                    }
                    shouldRepaint = (shouldRepaint || p.Velocity != 0);
                }
            }
            else
            {
                if (source.eventClip == null)
                {
                    EditorGUILayout.LabelField("Load an event to see its parameters");
                }
                else
                {
                    EditorGUILayout.LabelField("This event has no parameters.");
                }
            }
            EditorGUI.indentLevel -= 2;
        }

        if (m_source != null && source.getSource())
        {
            if (m_source.FindProperty("m_volume") == null)
            {
                Debug.Log("NULL volume !");
            }
            EditorGUILayout.Slider(m_source.FindProperty("m_volume"), 0, 100, "Volume");

            m_show3DSettings = EditorGUILayout.Foldout(m_show3DSettings, "3D Sound Settings");
            if (m_show3DSettings)
            {
                EditorGUI.indentLevel += 2;
                FmodEvent.RolloffType rolloffType  = ((FmodEvent)source.getSource()).Rolloff;
                SerializedProperty    minRangeProp = m_source.FindProperty("m_minRange");
                SerializedProperty    maxRangeProp = m_source.FindProperty("m_maxRange");

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Rolloff");
                EditorGUILayout.LabelField(((FmodEvent)source.getSource()).getRolloffTypeString(), GUI.skin.textField, GUILayout.ExpandWidth(false));
                EditorGUILayout.EndHorizontal();
                if (rolloffType == FmodEvent.RolloffType.CUSTOM)
                {
                    EditorGUILayout.HelpBox("This event has a custom rolloff : the Min Distance parameter is unused and the Max Distance parameter acts as a distance multiplier.", MessageType.Warning);
                }
                EditorGUILayout.PropertyField(minRangeProp, new GUIContent("Min Distance"));
                EditorGUILayout.PropertyField(maxRangeProp, new GUIContent("Max Distance"));
                EditorGUI.indentLevel -= 2;
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Play On Awake");
            source.playOnAwake = EditorGUILayout.Toggle(source.playOnAwake);
            EditorGUILayout.EndHorizontal();

            /*
             * UNDERLYING VALUES
             */
            EditorGUILayout.Separator();
            m_showUnderlyingParameters = EditorGUILayout.Foldout(m_showUnderlyingParameters, "Underlying parameters value");
            if (m_showUnderlyingParameters)
            {
                EditorGUI.indentLevel += 2;
                if (m_parameters.Count > 0)
                {
                    GUI.enabled = false;
                    foreach (SerializedObject o in m_parameters)
                    {
                        FmodRuntimeEventParameter p = o.targetObject as FmodRuntimeEventParameter;

                        SerializedProperty underlyingValueProp = o.FindProperty("m_underlyingValue");
                        EditorGUILayout.Slider(underlyingValueProp, p.MinRange, p.MaxRange, p.getName());
                    }
                    GUI.enabled = true;
                }
                else
                {
                    if (source.eventClip == null)
                    {
                        EditorGUILayout.LabelField("Load an event to see its parameters");
                    }
                    else
                    {
                        EditorGUILayout.LabelField("This event has no parameters.");
                    }
                }

                EditorGUI.indentLevel -= 2;
            }

            /*
             * END UNDERLYING VALUES
             */
            foreach (SerializedObject o in m_parameters)
            {
                if (o.ApplyModifiedProperties())
                {
                    FmodRuntimeEventParameter p = o.targetObject as FmodRuntimeEventParameter;
                    p.UpdateValue();
                }
            }
            if (m_source.ApplyModifiedProperties())
            {
                FmodEvent evt = source.getSource();
                if (evt.getSourceType() == FmodEvent.SourceType.SOURCE_3D)
                {
                    source.setMinRange(source.getMinRange());
                    source.setMaxRange(source.getMaxRange());
                }
                source.SetVolume(source.GetVolume());
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
            if (m_showUnderlyingParameters || shouldRepaint)
            {
                Repaint();
            }
        }
    }