Exemplo n.º 1
0
        public Controls(TextAsset controlSettings)
        {
            var reader = new StringReader(controlSettings.text);

            for (;;)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                string[] words    = line.Split(',');
                string   name     = words[0].Trim();
                string[] controls = words[1].Split('+');

                var controlAssignment = new ControlAssignment()
                {
                    Name = name
                };
                foreach (string control in controls)
                {
                    string word = control.ToLower().Trim();
                    switch (word)
                    {
                    case "ctrl":
                    case "control":
                        controlAssignment.WantsControlPressed = true;
                        break;

                    case "shft":
                    case "shift":
                        controlAssignment.WantsShiftPressed = true;
                        break;

                    case "alt":
                        controlAssignment.WantsAltPressed = true;
                        break;

                    default:
                        try
                        {
                            controlAssignment.KeyCode = (KeyCode)Enum.Parse(typeof(KeyCode), word.ToUpper());
                        }
                        catch
                        {
                            Debug.LogWarning("Unknown control '" + word + "' ignored");
                        }
                        break;
                    }
                }
                m_controlAssignments.Add(controlAssignment);
            }
        }
Exemplo n.º 2
0
 public void AddRule(string lhs, ControlAssignment rhs)
 {
     this.AddRule(lhs, new ControlAssignment[] { rhs });
 }