/// <inheritdoc/> public ControllerElement this[ControllerElement virtualElement] { get { string optionKey = (from option in this._Options where option.Value.TargetElement == virtualElement select option.Key).FirstOrDefault(); if (optionKey == null) { throw new KeyNotFoundException( "This template does not support the target element or element type."); } return(this.inputTemplateInterceptor.InputValues[optionKey]); } set { string optionKey = (from option in this._Options where option.Value.TargetElement == virtualElement where option.Value.InputOptionType.HasFlag(InputOptionType.Keyboard) == value.IsKeyboardKey() where option.Value.InputOptionType.HasFlag(InputOptionType.ControllerAxes) == value.IsAxis() select option.Key).FirstOrDefault(); if (optionKey == null) { throw new KeyNotFoundException( "This template does not support the target element or element type."); } this.inputTemplateInterceptor.InputValues[optionKey] = value; } }
private void RenderController(ControllerElement controller) { this.output.WriteLine(string.Format("angular.module('webApp').factory('{0}Stub',", controller.Name.Camelize())); this.output.PushIndent(Tab); this.output.WriteLine("function($http, $q, fifthweekConstants, utilities) {"); this.output.PushIndent(Tab); this.output.WriteLine("'use strict';"); this.output.WriteLine(string.Empty); this.output.WriteLine("var apiBaseUri = fifthweekConstants.apiBaseUri;"); this.output.WriteLine("var service = {};"); this.output.WriteLine(string.Empty); foreach (var method in controller.Methods) { this.RenderMethod(method); } this.output.WriteLine("return service;"); this.output.PopIndent(); this.output.WriteLine("});"); this.output.PopIndent(); this.output.WriteLine(string.Empty); }
public override void SerializerNodeValue(ControllerElement controllerElementValue, string value, string key, IConfigurationSerializationContext <string> context, int index) { if (index != 0) { context.Append(","); } context.Append($@"""{key}"":""{value}"""); }
/// <inheritdoc/> public virtual string SerializeInput(string key, ControllerElement element, IInputMapping inputMapping) { return (element == ControllerElement.NoElement ? this.ConfigurationSerializer.SerializeLine(key, this.ConfigurationSerializer.TypeMapper.ConvertValue((object?)null)) : this.ConfigurationSerializer.SerializeLine(key, inputMapping[element])); }
internal DeviceCapabilityElementConfigurationNode(string key, ControllerElement element, DeviceCapability value, string mappedValue, DeviceCapabilityClass type) : base(key, value) { this.DeviceType = type; this.Value = mappedValue; this.VirtualElement = element; }
public DeviceCapability this[ControllerElement layoutElement] { get { this.controllerElements.TryGetValue(layoutElement, out ControllerElementMapping map); return(map.DeviceCapability); } set { this.controllerElements[layoutElement] = new ControllerElementMapping(layoutElement, value); } }
/// <inheritdoc/> public IControllerElementInfo?this[ControllerElement element] { get { if (this.controllerElements.ContainsKey(element) || element == ControllerElement.NoElement) { return(this.controllerElements[element]); } return(null); } }
public override bool Equals(System.Object other) { if (other.GetType() != this.GetType()) { return(false); } ControllerElement cur = (ControllerElement)other; GameHandler.log("Other: " + cur.Typ + " " + cur.Pos + " " + cur.ID); GameHandler.log("This: " + Typ + " " + Pos + " " + ID); return(Typ.Equals(cur.Typ) && Pos == cur.Pos && ID == cur.ID); }
public void SetValues(Vector3 position, Vector3 forward, Quaternion rotation, ControllerElement element) { if (element == ControllerElement.Grip) { gripPosition = position; gripForward = forward; gripRotation = rotation; } else { pointerPosition = position; pointerForward = forward; pointerRotation = rotation; } }
public ControllerElement this[ControllerElement layoutElement] { get { return(this.controllerElements.FirstOrDefault(l => l.LayoutElement == layoutElement)? .DeviceElement ?? ControllerElement.NoElement); } set { var mappedElement = this.controllerElements.FirstOrDefault(l => l.LayoutElement == layoutElement); if (mappedElement != null) { mappedElement.DeviceElement = value; } } }
private void RenderController(ControllerElement controller) { this.output.WriteLine(string.Format("describe('{0} stub', function() {{", controller.Name.Humanize(LetterCasing.LowerCase))); this.output.PushIndent(Tab); this.output.WriteLine("'use strict';"); this.output.WriteLine(string.Empty); this.output.WriteLine("var fifthweekConstants;"); this.output.WriteLine("var $httpBackend;"); this.output.WriteLine("var $rootScope;"); this.output.WriteLine("var target;"); this.output.WriteLine("var utilities;"); this.output.WriteLine(string.Empty); this.output.WriteLine("beforeEach(module('webApp', 'stateMock'));"); this.output.WriteLine(string.Empty); this.output.WriteLine("beforeEach(inject(function($injector) {"); this.output.PushIndent(Tab); this.output.WriteLine("fifthweekConstants = $injector.get('fifthweekConstants');"); this.output.WriteLine("$httpBackend = $injector.get('$httpBackend');"); this.output.WriteLine("$rootScope = $injector.get('$rootScope');"); this.output.WriteLine("utilities = $injector.get('utilities');"); this.output.WriteLine(string.Format("target = $injector.get('{0}Stub');", controller.Name.Camelize())); this.output.PopIndent(); this.output.WriteLine("}));"); this.output.WriteLine(string.Empty); this.output.WriteLine("afterEach(function() {"); this.output.PushIndent(Tab); this.output.WriteLine("$httpBackend.verifyNoOutstandingExpectation();"); this.output.WriteLine("$httpBackend.verifyNoOutstandingRequest();"); this.output.PopIndent(); this.output.WriteLine("});"); foreach (var method in controller.Methods) { this.RenderMethod(method); } this.output.PopIndent(); this.output.WriteLine("});"); this.output.WriteLine(string.Empty); }
/// <inheritdoc/> public DeviceCapability this[ControllerElement virtualElement] { set { IEnumerable <string> optionKeys = from option in this._Options where option.Value.TargetElement == virtualElement where FlagEnums.HasAnyFlags(option.Value.OptionType, value.GetClass()) select option.Key; if (!optionKeys.Any()) { throw new KeyNotFoundException( "This template does not support the target element or element type."); } foreach (string optionKey in optionKeys) { this.inputTemplateInterceptor.InputValues[optionKey] = value; } } }
void IInputReader.Poll(int controllerIndex, IInputDevice device) { Controller controller = this.inputConfig.Controllers .FirstOrDefault(c => c.Index == controllerIndex && c.Connected && String.Equals(c.Type, device.Name, StringComparison.Ordinal)); if (controller != null) { foreach (IInputElement deviceElement in device.InputElements) { ControllerElement configElement = controller.Elements.FirstOrDefault(e => String.Equals(e.Id, deviceElement.Id, StringComparison.Ordinal)); if (configElement != null) { if (deviceElement is IButtonInputElement) { this.UpdateButtonState((IButtonInputElement)deviceElement, configElement.Mappings); } } } } }
// Normal Game Mode private IEnumerator Game() { Mid = true; AnzeigeMid = "Begin"; bool correct = true; SequenzCounter = 0; //Debug.Log("Sequenz Check..."); // Sequenz wiederholen while (correct && SequenzCounter < Sequenz.Count) { yield return(new WaitUntil(() => ActionDone || Hate <= 0 || TimeCurrent > TimeToBeat)); Mid = false; //Debug.Log("Action has been done!"); if (Mode == Modes.HateFest) { Hating = true; } if (Mode == Modes.TimeTrial || Mode == Modes.TotalDestruction) { measureTime = true; } ActionDone = false; ControllerElement Last = new ControllerElement(LastAction, LastPos, LastID); if (Hate <= 0) { Last = new ControllerElement("HATEFEST"); } if (TimeCurrent > TimeToBeat) /* Debug.Log("OVERTIME");*/ Last {
/// <inheritdoc/> public string this[ControllerElement element] { get { if (this.elementMappings.TryGetValue(element, out string mappedValue)) { return(mappedValue); } if (element.IsKeyboardKey() && this.elementMappings.TryGetValue(ControllerElement.KeyNone, out string keyNone)) { return(keyNone); } if (this.elementMappings.TryGetValue(ControllerElement.NoElement, out string noElement)) { return(noElement); } return(string.Empty); } }
/// <summary> /// Serializes the value of a <see cref="EnumConfigurationNode"/>. Override this when implementing a serializer. /// </summary> /// <param name="controllerElementValue">The value of the node</param> /// <param name="value"> /// The raw value of the node as the string representation of the element consistent with the /// <see cref="IDeviceInputMapping"/> the syntax tree was originally serialized with.</param> /// <param name="key">The key of the node.</param> /// <param name="context">The serialization context.</param> /// <param name="index">The position or index of the given node within the current block in the context.</param> public abstract void SerializerNodeValue(ControllerElement controllerElementValue, string value, string key, IConfigurationSerializationContext <T> context, int index);
public void SetWorldValues(Vector3 position, Vector3 forward, Quaternion rotation, ControllerElement element) { if (element == ControllerElement.Grip) { gripPosition = position; gripForward = forward * AxisLengthScaleFactor; gripRotation = rotation; } else { pointerPosition = position; pointerForward = forward * AxisLengthScaleFactor; pointerRotation = rotation; } }
/// <summary> /// Checks if the element is an axis element /// </summary> /// <param name="element">The controller element to check.</param> /// <returns>Whether the element is a keyboard key element</returns> public static bool IsAxis(this ControllerElement element) { return(element.GetMember().Name.Contains("Axis")); }
/// <summary> /// Checks if the element is a keyboard key element. /// </summary> /// <param name="element">The controller element to check.</param> /// <returns>Whether the element is a keyboard key element</returns> public static bool IsKeyboardKey(this ControllerElement element) { return(element >= ControllerElement.KeyNone); }
/// <inheritdoc/> public string this[ControllerElement element] => this.elementMappings.ContainsKey(element) ? this.elementMappings[element] : this.nullMapping;
public DeviceCapability this[ControllerElement e] => this.Mapping.TryGetValue(e, out DeviceCapability d) ? d : DeviceCapability.None;
/// <summary> /// Initializes a new instance of the <see cref="InputOptionAttribute"/> class. /// Marks an attribute as an input option /// </summary> public InputOptionAttribute(string optionName, InputOptionDeviceType inputOptionType, ControllerElement targetElement) { this.OptionName = optionName; this.InputOptionType = inputOptionType; this.TargetElement = targetElement; }
/// <summary> /// Initializes a new instance of the <see cref="InputOptionAttribute"/> class. /// Marks an attribute as an input option /// </summary> public InputOptionAttribute(string optionName, DeviceCapabilityClass inputOptionType, ControllerElement targetElement) { this.OptionName = optionName; this.InputOptionType = inputOptionType; this.TargetElement = targetElement; }
/// <summary> /// Gets the string representation of the <see cref="ControllerElement"/>. /// </summary> /// <param name="this">The <see cref="ControllerElement"/> to parse.</param> /// <returns>The string representation of the <see cref="ControllerElement"/>.</returns> public static string ToString(this ControllerElement @this) { return(Enums.AsString(@this)); }
internal void Add(ControllerElement elementKey, IControllerElementInfo info) { this.controllerElements[elementKey] = info; }
/// <summary> /// Create a new mapping between a virtual controller element and device capability /// </summary> /// <param name="virtualElement">The virtual controller element to map to.</param> /// <param name="deviceElement">The real device capability.</param> public ControllerElementMapping(ControllerElement virtualElement, DeviceCapability deviceElement) { this.LayoutElement = virtualElement; this.DeviceCapability = deviceElement; }
public MappedControllerElement(ControllerElement virtualElement, ControllerElement deviceElement) { this.LayoutElement = virtualElement; this.DeviceElement = deviceElement; }
public override void SerializerNodeValue(ControllerElement controllerElementValue, string value, string key, IConfigurationSerializationContext <string> context, int index) { context.AppendLine($"<{key}>{value}</{key}>"); }