public PinsConfiguration(Glove selectedGlove)
        {
            InitializeComponent();

            this.selectedGlove = selectedGlove;

            initializeBoards();

            configManager = new ConfigManager();
        }
 public DataReceiver getDataReceiver(Glove selectedGlove)
 {
     foreach (DataReceiver data in DataReceivers)
     {
         if (data.SerialPort.Equals(selectedGlove.Port))
         {
             return(data);
         }
     }
     return(null);
 }
 public void setRawData(Glove selectedGlove, bool value)
 {
     if (value == true)
     {
         this.serviceClient.setRawData(selectedGlove.BluetoothAddress, 1);
     }
     else
     {
         this.serviceClient.setRawData(selectedGlove.BluetoothAddress, 0);
     }
 }
 /// <summary>
 /// Closes a connection with a glove
 /// </summary>
 /// <param name="selectedGlove">A Glove object to be connected</param>
 /// <returns>Result code</returns>
 public int Disconnect(Glove selectedGlove)
 {
     try
     {
         return(this.serviceClient.Disconnect(selectedGlove.BluetoothAddress));
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Beispiel #5
0
    private void RechargeGlove(Glove glove)
    {
        Debug.Log("charge " + glove.name);
        glove.Enable(true);
        float dif = chargeValue - glove.charge.runTimeValue;

        if (dif > 0)
        {
            glove.AddCharge(dif);
        }
    }
Beispiel #6
0
    /// <summary>
    /// Attempts to play positive feedback. Then will always deal damage to this unit.
    /// </summary>
    internal void SuccessfulHit(float hitStrength, Collider collision, Glove glove)
    {
        if (playFeedback)
        {
            GenerateTimingFeedback();
            Global.PlayRandomAudio(properties.goodHitSounds, audioSource);
        }

        glove.GoodPunch();

        unitHealth.DealDamage(1);
    }
Beispiel #7
0
    public void OnTriggerEnter(Collider collider)
    {
        Debug.Log("Blocked " + collider.gameObject.name);
        Glove glove = collider.gameObject.GetComponent <Glove>();

        if (glove != null)
        {
            glove.Enable(false);
            glove.SetCharge(0);
        }
        onGloveBlocked.Invoke();
    }
 /// <summary>
 /// Establishes connection with a glove
 /// </summary>
 /// <param name="selectedGlove">A Glove object to be connected</param>
 /// <returns>Result code</returns>
 public int Connect(Glove selectedGlove)
 {
     startCaptureData(selectedGlove);
     try
     {
         return(this.serviceClient.Connect(selectedGlove.BluetoothAddress));
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Beispiel #9
0
    public void OnTriggerEnter(Collider collider)
    {
        //if (collider.GetComponent<PhotonView>() && collider.GetComponent<PhotonView>().isMine)
        //    return;
        Glove glove = collider.gameObject.GetComponent <Glove>();

        if (glove != null)
        {
            glove.Enable(false);
            glove.SetCharge(0);
            audioSource.PlayOneShot(hit);
        }
    }
        public void OpenProfileConfiguration(string fileName, Glove selectedGlove)
        {
            selectedGlove.GloveConfiguration.GloveProfile = new Glove.Configuration.Profile();
            serviceClient.resetFlexors(selectedGlove.BluetoothAddress);

            Dictionary <String, String> openedConfiguration = new Dictionary <String, String>();

            XDocument xml = XDocument.Load(fileName);

            if (!xml.Root.Attribute("gloveHash").Equals(selectedGlove.GloveConfiguration.GloveHash))
            {
                //avisar
            }
            try
            {
                openedConfiguration = xml.Root.Element("mappings").Elements("mapping")
                                      .ToDictionary(c => (String)c.Element("region"),
                                                    c => (String)c.Element("actuator"));
            }
            catch
            {
                openedConfiguration = new Dictionary <String, String>();
            }

            selectedGlove.GloveConfiguration.GloveProfile.Mappings = openedConfiguration;

            Dictionary <int, int> openedConfiguration2 = new Dictionary <int, int>();

            try
            {
                openedConfiguration2 = xml.Root.Element("FlexorsMappings").Elements("mapping")
                                       .ToDictionary(c => (Int32)c.Element("region"),
                                                     c => (Int32)c.Element("flexor"));
            }
            catch
            {
                openedConfiguration2 = new Dictionary <int, int>();
            }

            selectedGlove.GloveConfiguration.GloveProfile.FlexorsMappings = openedConfiguration2;

            foreach (KeyValuePair <int, int> mapping in selectedGlove.GloveConfiguration.GloveProfile.FlexorsMappings)
            {
                serviceClient.addFlexor(selectedGlove.BluetoothAddress, mapping.Value, mapping.Key);
            }

            //Aqui deberia comprobarse que sean todos valores validos
            selectedGlove.GloveConfiguration.GloveProfile.ProfileName = fileName;
            selectedGlove.GloveConfiguration.GloveProfile.GloveHash   = selectedGlove.GloveConfiguration.GloveHash;
            serviceClient.SaveGlove(selectedGlove);
        }
Beispiel #11
0
    //public Glove left, right;
    //public float minRechargeDistance = 1;

    //public void Update() {
    //    if (Vector3.Distance(transform.position, left.transform.position) < minRechargeDistance)
    //        RechargeGlove(left);
    //    if (Vector3.Distance(transform.position, right.transform.position) < minRechargeDistance)
    //        RechargeGlove(right);
    //}

    public void OnTriggerEnter(Collider other)
    {
        Glove glove = other.GetComponent <Glove>();

        if (glove != null)
        {
            glove.Enable(true);
            float dif = chargeValue - glove.charge.runTimeValue;
            if (dif > 0)
            {
                glove.AddCharge(dif);
            }
        }
    }
 public void startCaptureData(Glove selectedGlove)
 {
     WebSocketClient = new WebSocket("ws://localhost:" + selectedGlove.WebSocketPort + "/" + selectedGlove.Port);
     try
     {
         mytask = Task.Run(() =>
         {
             readData();
         });
     }
     catch
     {
     }
 }
 public void startCaptureData(Glove selectedGlove)
 {
     if (DataReceivers != null)
     {
         foreach (DataReceiver d in DataReceivers)
         {
             if (d.SerialPort == selectedGlove.Port)
             {
                 return; //already exist
             }
         }
         DataReceiver data = new DataReceiver(selectedGlove.WebSocketPort, selectedGlove.Port);
         DataReceivers.Add(data);
     }
 }
 public void stopCaptureData(Glove selectedGlove)
 {
     if (DataReceivers != null)
     {
         foreach (DataReceiver d in DataReceivers)
         {
             if (d.SerialPort == selectedGlove.Port)
             {
                 d.WebSocketActive = false;
                 Thread.Sleep(100);
                 DataReceivers.Remove(d);
                 return;
             }
         }
     }
 }
Beispiel #15
0
        public void saveGloveProfile(string fileName, Glove selectedGlove)
        {
            XElement rootXML = new XElement("hand");

            rootXML.SetAttributeValue("gloveHash", selectedGlove.GloveConfiguration.GloveHash);
            XElement mappings = new XElement("mappings");

            rootXML.Add(mappings);
            foreach (KeyValuePair <string, string> mapping in selectedGlove.GloveConfiguration.GloveProfile.Mappings)
            {
                XElement mappingXML = new XElement("mapping", new XElement("region", mapping.Key), new XElement("actuator", mapping.Value));
                mappings.Add(mappingXML);
            }
            rootXML.Save(fileName);
            selectedGlove.GloveConfiguration.GloveProfile.ProfileName = fileName;
            serviceClient.SaveGlove(selectedGlove);
        }
Beispiel #16
0
        public string exportGlove(Controller controller)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Id;Order;GloveName;Color");
            sb.Append("\n");
            for (int i = 0; i < Form1._Form1.glovesBox.Items.Count; i++)
            {
                Glove temp = controller.leggiGuanto(i);
                sb.Append(temp.getId() + ";");
                sb.Append(temp.getOrder() + ";");
                sb.Append(temp.getName() + ";");
                sb.Append(temp.getColor() + ";");
                sb.Append("\n");
            }
            return(sb.ToString());
        }
Beispiel #17
0
        public void OpenGloveConfiguration(string fileName, Glove selectedGlove)
        {
            selectedGlove.GloveConfiguration = new Glove.Configuration();

            XDocument       xml          = XDocument.Load(fileName);
            List <XElement> Xpins        = xml.Root.Element("boardPins").Elements("positivePin").ToList();
            List <int>      positivePins = new List <int>();

            foreach (XElement xpin in Xpins)
            {
                int pinNumber = Int32.Parse(xpin.Attribute("pin").Value);
                positivePins.Add(pinNumber);
            }

            Xpins = xml.Root.Element("boardPins").Elements("negativePin").ToList();
            List <int> negativePins = new List <int>();

            foreach (XElement xpin in Xpins)
            {
                int pinNumber = Int32.Parse(xpin.Attribute("pin").Value);
                negativePins.Add(pinNumber);
            }

            int baudRate = Int32.Parse(xml.Root.Attribute("baudRate").Value);

            selectedGlove.GloveConfiguration.PositivePins = positivePins.ToArray();
            selectedGlove.GloveConfiguration.NegativePins = negativePins.ToArray();
            selectedGlove.GloveConfiguration.BaudRate     = baudRate;
            selectedGlove.GloveConfiguration.GloveHash    = (string)xml.Root.Attribute("gloveHash");
            selectedGlove.GloveConfiguration.GloveName    = (string)xml.Root.Attribute("gloveName");

            List <string> positiveInit = new List <string>();
            List <string> negativeInit = new List <string>();

            for (int i = 0; i < positivePins.Count; i++)
            {
                positiveInit.Add("HIGH");
                negativeInit.Add("LOW");
            }

            selectedGlove.GloveConfiguration.PositiveInit = positiveInit.ToArray();
            selectedGlove.GloveConfiguration.NegativeInit = negativeInit.ToArray();

            //Tell the service to update the glove configuration
            serviceClient.SaveGlove(selectedGlove);
        }
        public HandConfiguration(Glove selectedGlove)
        {
            InitializeComponent();
            configManager      = new ConfigManager();
            this.selectedGlove = selectedGlove;

            if (this.selectedGlove.GloveConfiguration.GloveProfile == null)
            {
                this.selectedGlove.GloveConfiguration.GloveProfile                 = new Glove.Configuration.Profile();
                this.selectedGlove.GloveConfiguration.GloveProfile.Mappings        = new Dictionary <string, string>();
                this.selectedGlove.GloveConfiguration.GloveProfile.FlexorsMappings = new Dictionary <int, int>();
                if (selectedGlove.Connected == true)
                {
                    gloves.resetFlexors(this.selectedGlove);
                }
            }
        }
 public void restoreConfiguration(Glove glove)
 {
     if (glove.GloveConfiguration != null && glove.GloveConfiguration.GloveProfile != null)
     {
         if (glove.GloveConfiguration.GloveProfile.FlexorsMappings != null && glove.GloveConfiguration.GloveProfile.FlexorsMappings.Count > 0)
         {
             foreach (KeyValuePair <int, int> mapping in glove.GloveConfiguration.GloveProfile.FlexorsMappings)
             {
                 gloves.addFlexor(glove, mapping.Value, mapping.Key);
             }
         }
         if (glove.GloveConfiguration.GloveProfile.imuStatus == true)
         {
             gloves.setIMUStatus(glove, true);
         }
     }
 }
        /// <summary>
        /// Activates a region with certain intensity
        /// </summary>
        /// <param name="selectedGlove"></param>
        /// <param name="region"></param>
        /// <param name="intensity"></param>
        public void Activate(Glove selectedGlove, int region, int intensity)
        {
            int actuator = -1;

            foreach (var item in selectedGlove.GloveConfiguration.GloveProfile.Mappings)
            {
                if (item.Key.Equals(region.ToString()))
                {
                    actuator = Int32.Parse(item.Value);
                    break;
                }
            }
            if (actuator == -1)
            {
                return;
            }
            this.serviceClient.Activate(selectedGlove.BluetoothAddress, actuator, intensity);
        }
Beispiel #21
0
 public void OnMouseDown()
 {
     try
     {
         gloves = api.Devices;
         Debug.Log("dsadas");
         Debug.Log(gloves);
     }
     catch
     {
         Debug.Log("ERROR: El servicio no esta activo");
     }
     guante = gloves[1];
     api.Activate(guante, 1, 255);
     GetComponent <Rigidbody>().useGravity = false;
     this.transform.position = theDest.position;
     this.transform.parent   = GameObject.Find("Destination").transform;
 }
        public VibeBoardsConfiguration(Glove selectedGlove)
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            EndpointAddress  address = new EndpointAddress("http://localhost:8733/Design_Time_Addresses/OpenGloveWCF/OGService/");

            serviceClient = new OGServiceClient(binding, address);

            InitializeComponent();

            configManager = new ConfigManager();

            this.selectedGlove = selectedGlove;

            this.initializeSelectors();
            if (this.selectedGlove.GloveConfiguration.GloveProfile == null)
            {
                this.selectedGlove.GloveConfiguration.GloveProfile          = new Glove.Configuration.Profile();
                this.selectedGlove.GloveConfiguration.GloveProfile.Mappings = new Dictionary <string, string>();
                foreach (ComboBox selector in this.selectors)
                {
                    selector.Items.Add("");

                    foreach (var item in selectedGlove.GloveConfiguration.PositivePins)
                    {
                        selector.Items.Add(item);
                    }
                }
            }
            else
            {
                this.updateView();
                foreach (ComboBox selector in this.selectors)
                {
                    selector.SelectionChanged -= new SelectionChangedEventHandler(selectorsSelectionChanged);
                }
            }

            // Flip controls based on hand side.
            if (this.selectedGlove.Side == Side.Left)
            {
                flipControls();
            }
        }
 public void OnMouseDown()
 {
     try
     {
         gloves = api.Devices;
         Debug.Log("dsadas");
         Debug.Log(gloves);
     }
     catch
     {
         Debug.Log("ERROR: El servicio no esta activo");
     }
     //List<int> regions = new List<int>() { 0, 1, 2, 3, 25, 18 };
     //List<int> intensity = new List<int>() { 255, 255, 255, 255, 255, 255 };
     Debug.Log("ssss");
     guante = gloves[0];
     api.Activate(guante, regions, intensity);
     GetComponent <Rigidbody>().useGravity = false;
     this.transform.position = theDest.position;
     this.transform.parent   = GameObject.Find("Destination").transform;
 }
    public void interact(GameAgent interactor)
    {
        source.PlayOneShot(chestOpeningSFX);
        int    randomItemIndex  = Settings.globalRNG.Next(itemOptions.Length);
        int    randomItemAmount = Settings.globalRNG.Next(1, 5);
        string itemChoice       = itemOptions[randomItemIndex];
        Item   toAdd;

        switch (itemChoice)
        {
        case "health":
            toAdd = new HealthPot(randomItemAmount); break;

        case "mana":
            toAdd = new ManaPot(randomItemAmount); break;

        case "helmet":
            toAdd = new Helmet(); break;

        case "armor":
            toAdd = new Armor(); break;

        case "gloves":
            toAdd = new Glove(); break;

        case "boot":
            toAdd = new Boot(); break;

        default:
            toAdd = null; break;
        }
        if (toAdd == null)
        {
            return;
        }

        interactor.inventory.AddItem(toAdd);
        UI_TextAlert.DisplayText("Received " + toAdd.Amount + " " + toAdd.Name + "(s)!");
        GameManager.kill(this, 0.5f);
    }
Beispiel #25
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            Glove   glove  = other.GetComponent <Glove>();
            Vector3 hitVel = glove.GetControllerVelocity();

            //print(GetHitDirection(hitVel.normalized));

            if (glove.gloveColor != boxColor || hitVel.sqrMagnitude < hitVelSqrThreshold)
            {
                return;
            }

            switch (boxType)
            {
            case BoxType.Normal:
                Hit();
                break;

            case BoxType.Slider:
                Hit(50);
                break;

            case BoxType.Directional:
                //Check whether Direction is Correct
                if (hitDir == GetHitDirection(hitVel.normalized))
                {
                    Hit();                                                                       //Check Directional Input
                }
                break;
            }
        }
        else if (other.tag == "Destroy Zone")
        {
            gm.BreakCombo();
            ForceDespawn();
        }
    }
Beispiel #26
0
        public ConfigurationTool(Glove selectedGlove)
        {
            InitializeComponent();

            configManager = new ConfigManager();

            this.selectedGlove = selectedGlove;

            this.initializeSelectors();
            if (this.selectedGlove.GloveConfiguration.GloveProfile == null)
            {
                this.selectedGlove.GloveConfiguration.GloveProfile          = new Glove.Configuration.Profile();
                this.selectedGlove.GloveConfiguration.GloveProfile.Mappings = new Dictionary <string, string>();
                foreach (ComboBox selector in this.selectors)
                {
                    selector.Items.Add("");

                    foreach (var item in selectedGlove.GloveConfiguration.PositivePins)
                    {
                        selector.Items.Add(item);
                    }
                }
            }
            else
            {
                this.updateView();
                foreach (ComboBox selector in this.selectors)
                {
                    selector.SelectionChanged -= new SelectionChangedEventHandler(selectorsSelectionChanged);
                }
            }

            // Flip controls based on hand side.
            if (this.selectedGlove.Side == Side.Left)
            {
                flipControls();
            }
        }
Beispiel #27
0
    /// <summary>
    /// Constructor which loads the HandModel
    /// </summary>
    void Start()
    {
        // Ensure the library initialized correctly.
        Manus.ManusInit();

        // Initialize the glove and the associated skeletal model.
        glove = new Glove(hand);
        if (hand == GLOVE_HAND.GLOVE_LEFT)
        {
            modelObject   = Resources.Load <GameObject>("Manus_Handv2_Left");
            animationClip = Resources.Load <AnimationClip>("Manus_Handv2_Left");
        }
        else
        {
            modelObject   = Resources.Load <GameObject>("Manus_Handv2_Right");
            animationClip = Resources.Load <AnimationClip>("Manus_Handv2_Right");
        }

        gameRoot  = FindDeepChild(gameObject.transform, "Wrist");
        modelRoot = FindDeepChild(modelObject.transform, "Wrist");

        modelObject.SetActive(true);
    }
Beispiel #28
0
        public void OpenProfileConfiguration(string fileName, Glove selectedGlove)
        {
            selectedGlove.GloveConfiguration.GloveProfile = new Glove.Configuration.Profile();

            Dictionary <String, String> openedConfiguration = new Dictionary <string, string>();

            XDocument xml = XDocument.Load(fileName);

            if (!xml.Root.Attribute("gloveHash").Equals(selectedGlove.GloveConfiguration.GloveHash))
            {
                //avisar
            }

            openedConfiguration = xml.Root.Element("mappings").Elements("mapping")
                                  .ToDictionary(c => (string)c.Element("region"),
                                                c => (string)c.Element("actuator"));
            selectedGlove.GloveConfiguration.GloveProfile.Mappings = openedConfiguration;

            //Aqui deberia comprobarse que sean todos valores validos
            selectedGlove.GloveConfiguration.GloveProfile.ProfileName = fileName;
            selectedGlove.GloveConfiguration.GloveProfile.GloveHash   = selectedGlove.GloveConfiguration.GloveHash;
            serviceClient.SaveGlove(selectedGlove);
        }
        public void saveGloveConfiguration(string fileName, Glove selectedGlove)
        {
            XElement rootXML   = new XElement("hand");
            XElement boardPins = new XElement("boardPins");

            rootXML.Add(boardPins);
            foreach (int pin in selectedGlove.GloveConfiguration.PositivePins)
            {
                XElement positivePinXML = new XElement("positivePin");
                positivePinXML.SetAttributeValue("pin", pin);
                boardPins.Add(positivePinXML);
            }

            foreach (int pin in selectedGlove.GloveConfiguration.NegativePins)
            {
                XElement negativePinXML = new XElement("negativePin");
                negativePinXML.SetAttributeValue("pin", pin);
                boardPins.Add(negativePinXML);
            }

            foreach (int pin in selectedGlove.GloveConfiguration.FlexPins)
            {
                XElement flexPinXML = new XElement("flexPin");
                flexPinXML.SetAttributeValue("pin", pin);
                boardPins.Add(flexPinXML);
            }

            selectedGlove.GloveConfiguration.GloveHash = selectedGlove.GloveConfiguration.PositivePins.GetHashCode().ToString();
            rootXML.SetAttributeValue("baudRate", selectedGlove.GloveConfiguration.BaudRate);
            rootXML.SetAttributeValue("gloveHash", selectedGlove.GloveConfiguration.GloveHash);
            rootXML.SetAttributeValue("gloveName", fileName);
            selectedGlove.GloveConfiguration.GloveName = fileName;

            rootXML.Save(fileName);

            serviceClient.SaveGlove(selectedGlove);
        }
Beispiel #30
0
        public Glove loadGlove(int index, BinaryReader reader)
        {
            Glove guanto = null;

            UInt16 gloveId;
            byte   order;
            string gloveName;
            string color;

            try
            {
                reader.BaseStream.Position = index * block + 104;
                gloveName = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(98)).TrimEnd('\0');

                reader.BaseStream.Position = index * block;
                gloveId = reader.ReadUInt16();

                reader.BaseStream.Position = index * block + 2;
                order = reader.ReadByte();

                reader.BaseStream.Position = index * block + 4;
                color = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(98)).TrimEnd('\0');

                guanto = new Glove(gloveId);
                guanto.setName(gloveName);
                guanto.setOrder(order);
                guanto.setColor(color);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                SplashScreen._SplashScreen.Close();
            }

            return(guanto);
        }