public override bool AddDockableAttachment(BaseAttachment attach)
    {
        if (base.AddDockableAttachment(attach))
        {
            //attach.rigidbody.velocity = Vector3.zero;
            attach.rigidbody.isKinematic = true;

            InstrumentAttachment instrument = attach as InstrumentAttachment;
            attach.SetToolmodeResponse(new BaseTool.ToolMode[] {
                BaseTool.ToolMode.PRIMARY,
                BaseTool.ToolMode.GRABBING
            });
            instrument.EnableControls();
            instrument.SetCloneable(false);

            GameObject volumetric = UIFactory.CreateVolumetricCylinder();
            volumetric.transform.position = new Vector3(attach.transform.position.x, m_volumetricYOffset, attach.transform.position.z);
            volumetric.transform.parent   = transform;

            iTween.ColorTo(volumetric, iTween.Hash("color", new Color(1.0f, 1.0f, 1.0f, 0.2f), "time", 0.8f));
            m_volumetrics[instrument] = volumetric;

            PlaceObjects();
            //iTween.MoveTo(attach.gameObject, iTween.Hash("position", transform.localPosition, "uselocal", true ));
            return(true);
        }
        return(false);
    }
Exemplo n.º 2
0
        /*
         * Main instrument prefab
         * Grabbable instrument with clips and parameter buttons/sliders
         */
        public static InstrumentAttachment CreateInstrument(BaseInstrument instrument)
        {
            //Create an instrument prefab
            GameObject instrumentGame = Instantiate(Instance.instrumentPrefab) as GameObject;

            instrumentGame.name = instrument.Name;

            //Create instrument attachment
            InstrumentAttachment attach = instrumentGame.AddComponent <InstrumentAttachment>();                 //Instrument attachment needs to be manually added

            //Init instrumentRef and GUI controls
            attach.Init(instrument);
            attach.InitInstrumentControls();

            //Set listener prefixes
            instrumentGame.renderer.materials[1].SetColor("_Color", instrument.color);

            return(attach);
        }
Exemplo n.º 3
0
        public static BaseAttachment CreateGhostDragger(BaseAttachment attach)
        {
            BaseAttachment ghostAttach = null;

            if (attach.GetType() == typeof(SliderAttachment))
            {
                SliderAttachment slider = attach as SliderAttachment;
                ghostAttach = UIFactory.CreateSlider(slider.musicRef, UIFrame.AnchorLocation.BOTTOM_LEFT);
            }
            else if (attach.GetType() == typeof(ClipButtonAttachment))
            {
                ClipButtonAttachment clipButton = attach as ClipButtonAttachment;
                ghostAttach = UIFactory.CreateClipButton(clipButton.musicRef, UIFrame.AnchorLocation.BOTTOM_LEFT);
            }
            else if (attach.GetType() == typeof(ClipCubeAttachment))
            {
                ClipCubeAttachment cubeButton = attach as ClipCubeAttachment;
                ghostAttach = UIFactory.CreateClipCube(cubeButton.musicRef);
            }
            else if (attach.GetType() == typeof(InstrumentAttachment))
            {
                InstrumentAttachment instrument = attach as InstrumentAttachment;
                ghostAttach = UIFactory.CreateInstrument(instrument.musicRef);
            }
            else if (attach.GetType() == typeof(RBFTrainingSpawnerAttachment))
            {
                ghostAttach = UIFactory.CreateRBFSphereTraining();
            }

            ghostAttach.transform.parent     = attach.transform;
            ghostAttach.transform.position   = attach.transform.position;
            ghostAttach.transform.localScale = attach.transform.localScale;
            ghostAttach.transform.parent     = null;
            ghostAttach.SetTransient(true);
            ghostAttach.SetCloneable(false);

            return(ghostAttach);
        }
Exemplo n.º 4
0
    /*
     * Creates instruments from xml lists
     */
    private void CreateInstrumentFromXmlList(XmlNodeList xmlList)
    {
        foreach (XmlNode track in xmlList)
        {
            //Get track definition
            Color color      = Utils.intToColor(int.Parse(track.Attributes["color"].Value));
            int   trackIndex = -1;
            bool  isReturn   = false;

            if (track.Attributes["index"] != null)
            {
                trackIndex = int.Parse(track.Attributes["index"].Value);
                isReturn   = false;
            }
            else if (track.Attributes["returnTrackIndex"] != null)
            {
                trackIndex = int.Parse(track.Attributes["returnTrackIndex"].Value);
                isReturn   = true;
            }
            else
            {
                continue;
            }

            bool isMidi = false;
            bool armed  = false;

            if (!isReturn)
            {
                isMidi = bool.Parse(track.Attributes["midi"].Value);
                armed  = bool.Parse(track.Attributes["armed"].Value);
            }

            BaseInstrument instrumentDef = new BaseInstrument(m_client, m_source, track.Attributes["name"].Value, color, armed, trackIndex, isMidi);

            //Get devices present in track
            XmlNodeList deviceList = track.SelectNodes("device");             //device array
            foreach (XmlNode device in deviceList)
            {
                if ((String)device.Attributes["name"].Value != "Looper" &&
                    (String)device.Attributes["name"].Value != "Scale")
                {
                    //Get params in device
                    XmlNodeList paramList   = device.SelectNodes("parameter");                   //parameter array
                    int         deviceIndex = int.Parse(device.Attributes["index"].Value);

                    foreach (XmlNode parameter in paramList)
                    {
                        string name = parameter.Attributes["name"].Value as String;
                        name = name.Replace("/", "-");
                        name = name.Replace(" ", "_");
                        string deviceName = device.Attributes["name"].Value as String;
                        deviceName = deviceName.Replace("/", "-");
                        deviceName = deviceName.Replace(" ", "_");
                        int parameterIndex = int.Parse(parameter.Attributes["index"].Value);

                        float min = Convert.ToSingle(parameter.Attributes["min"].Value);
                        float max = Convert.ToSingle(parameter.Attributes["max"].Value);
                        instrumentDef.AddParam(name, "float", min, max, deviceName, deviceIndex, parameterIndex);
                    }
                }
            }

            //Get clips in track
            XmlNodeList clipList = track.SelectNodes("clip");
            foreach (XmlNode clip in clipList)
            {
                string name    = clip.Attributes["name"].Value as String;
                int    index   = int.Parse(clip.Attributes["index"].Value);
                bool   looping = Convert.ToBoolean(clip.Attributes["looping"].Value);
                instrumentDef.AddClip(name, looping, index);
            }

            //Get sends in track
            XmlNodeList sendsList = track.SelectNodes("sends");
            foreach (XmlNode send in sendsList)
            {
                string name = send.Attributes["name"].Value as String;
                name = name.Replace("/", "-");
                name = name.Replace(" ", "_");
                name = "Send-" + name;
                float min = Convert.ToSingle(send.Attributes["min"].Value);
                float max = Convert.ToSingle(send.Attributes["max"].Value);
                instrumentDef.AddParam(name, "float", min, max);
            }

            InstrumentController.Instance.AddInstrument(instrumentDef);
            InstrumentAttachment instrument = UIFactory.CreateInstrument(instrumentDef);

            instrument.DockInto(m_instrumentHolder);
        }
        //m_instrumentHolder.HideControls();
    }