Ejemplo n.º 1
0
        public static void RemoveListener(IStatusListener listenerToRemove)
        {
            if (sm_Listeners == null)
            {
                return;
            }

            ListenerNode nodeToRemove = new ListenerNode()
            {
                listener = null, wantsTrace = false
            };

            foreach (var lNode in sm_Listeners)
            {
                if (lNode.listener == listenerToRemove)
                {
                    nodeToRemove = lNode;
                    break;
                }
            }

            if (nodeToRemove.listener != null)
            {
                sm_Listeners.Remove(nodeToRemove);
            }
        }
Ejemplo n.º 2
0
    public static void loadSpeakerPositions()
    {
        Debug.Log("Loading speakers!");
        string xmlPath = EditorUtility.OpenFilePanel("Listener Positions", "", "xml");

        if (xmlPath.Length != 0)
        {
            ListenerNode[] listenerNodes = FindObjectsOfType(typeof(ListenerNode)) as ListenerNode[];

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(xmlPath);

            XmlNode docRoot = xmlDoc.DocumentElement;

            XmlNodeList nodeList = docRoot.SelectNodes("/speakers/speaker");
            for (int i = 0; i < nodeList.Count; i++)
            {
                XmlNode node = nodeList.Item(i);

                int channel = int.Parse(node.Attributes.GetNamedItem("channel").FirstChild.Value);

                Debug.Log(node.SelectSingleNode("position"));

                float x = float.Parse(node.SelectSingleNode("./position").Attributes.GetNamedItem("x").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
                float y = float.Parse(node.SelectSingleNode("./position").Attributes.GetNamedItem("y").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
                float z = float.Parse(node.SelectSingleNode("./position").Attributes.GetNamedItem("z").FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                ListenerNode foundNode = null;

                foreach (ListenerNode listenerNode in listenerNodes)
                {
                    if (listenerNode.channel == channel)
                    {
                        //Found listener
                        foundNode = listenerNode;
                        break;
                    }
                }

                if (foundNode == null)
                {
                    foundNode         = createNewListenerNode();
                    foundNode.channel = channel;
                    foundNode.name    = "ListenerNode " + channel;
                }

                foundNode.transform.position = new Vector3(x, y, z);
            }
        }
    }
Ejemplo n.º 3
0
        public static void AddListener(IStatusListener listener, bool wantsTrace)
        {
            if (sm_Listeners == null)
            {
                sm_Listeners = new List <ListenerNode>();
            }

            var node = new ListenerNode()
            {
                listener   = listener,
                wantsTrace = wantsTrace
            };

            sm_Listeners.Add(node);
        }
Ejemplo n.º 4
0
    // Target target = target! - hidden field

    public override void OnInspectorGUI()
    {
        ListenerNode ourTarget = (ListenerNode)target;

        DrawDefaultInspector();

        // Layers
        SoundOMaticClient hyperNode = (SoundOMaticClient)SoundOMaticClient.findCloseComponent <SoundOMaticClient>(ourTarget.gameObject);
        int mask = 0;

        foreach (int layer in ourTarget.getLayers())
        {
            mask |= 1 << layer;
        }
        mask = EditorGUILayout.MaskField("Layers", mask, hyperNode.layers);
        ArrayList foundLayers = new ArrayList();

        for (int layer = 0; layer < hyperNode.layers.Length; layer++)
        {
            if ((mask & 1 << layer) == (1 << layer))
            {
                foundLayers.Add(layer);
            }
        }
        ourTarget.setLayers((int[])foundLayers.ToArray(typeof(int)));
        if (ourTarget.getLayers().Length > 1)
        {
            string msg   = "Choosen layers: ";
            bool   first = true;
            foreach (int layer in ourTarget.getLayers())
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    msg += ", ";
                }
                msg += hyperNode.layers[layer];
            }
            EditorGUILayout.HelpBox(msg, MessageType.Info);
        }
        else if (ourTarget.getLayers().Length == 0)
        {
            EditorGUILayout.HelpBox("This ListenerNode does not have any active layers!", MessageType.Warning);
        }
    }
Ejemplo n.º 5
0
    void traverseAudioTree(GameObject topObject)
    {
        // Remotely sync this level
        if (topObject.transform.childCount > 1)
        {
            sendPacket("sync");
        }

        foreach (Transform child in topObject.transform)          // Get immediate children
        {
            GameObject childObject = child.gameObject;
            if (childObject.activeSelf)
            {
                AudioNode    audioNode    = (AudioNode)childObject.GetComponent("AudioNode");
                ListenerNode listenerNode = (ListenerNode)childObject.GetComponent("ListenerNode");
                if (audioNode != null)
                {
                    // Add to this level's command queue
                    audioNode.sendUpdate(this);
                }
                else if (listenerNode != null)
                {
                    listenerNode.sendUpdate(this);
                }
                else
                {
                    // Not an AudioNode, nothing to do
                }
            }
        }
        // No remote sync is needed from here on
        if (topObject.transform.childCount > 1)
        {
            sendPacket("unsync");
        }

        // Traverse sub-trees
        foreach (Transform child in topObject.transform)
        {
            GameObject childObject = child.gameObject;
            if (childObject.activeSelf)
            {
                traverseAudioTree(childObject);
            }
        }
        flush();
    }
Ejemplo n.º 6
0
        public static void RemoveListener(IStatusListener listenerToRemove)
        {
            if (sm_Listeners == null) return;

            ListenerNode nodeToRemove = new ListenerNode() { listener = null, wantsTrace = false };

            foreach (var lNode in sm_Listeners)
            {
                if (lNode.listener == listenerToRemove)
                {
                    nodeToRemove = lNode;
                    break;
                }
            }

            if (nodeToRemove.listener != null)
            {
                sm_Listeners.Remove(nodeToRemove);
            }
        }
Ejemplo n.º 7
0
        public static void AddListener(IStatusListener listener, bool wantsTrace)
        {
            if (sm_Listeners == null)
            {
                sm_Listeners = new List<ListenerNode>();
            }

            var node = new ListenerNode()
            {
                listener = listener,
                wantsTrace = wantsTrace
            };

            sm_Listeners.Add(node);
        }