public bool GetAxisAsButtonUp(GamepadAxis axis, int playerNumber, PositiveNegativeAxis whichDirection) { var mapping = this.AxisToButtonStates.Where(state => state.BelongingMapping == this.PlayerMappings[playerNumber] && state.Axis == axis && state.DoesAxisMatter == whichDirection).ToList(); if (mapping.Count != 0) { return(!mapping[0].PressedInCurrentFrame && mapping[0].PressedLastFrame); } else { //Add to list (Basically "subscribe" to it var newAxisState = new AxisState() { BelongingMapping = this.PlayerMappings[playerNumber], Axis = axis, DoesAxisMatter = whichDirection }; if (this.PlayerMappings[playerNumber].OverridesAxisReading) { float value = this.PlayerMappings[playerNumber].OverrideAxisReading(axis); newAxisState.PressedInCurrentFrame = value != 0; } else { GamepadAxisInfo info = this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis]; float value = Input.GetAxisRaw(info.AxisName); int multiplier = whichDirection == PositiveNegativeAxis.Negative ? -1 : 1; if (multiplier < 0) { newAxisState.PressedInCurrentFrame = value < info.UnpressedValue + (multiplier * info.DeadZoneOffset); } else { newAxisState.PressedInCurrentFrame = value > info.UnpressedValue + (multiplier * info.DeadZoneOffset); } } //newAxisState.PressedInCurrentFrame = value > info.UnpressedValue + (multiplier * info.DeadZoneOffset); this.AxisToButtonStates.Add(newAxisState); return(!newAxisState.PressedInCurrentFrame && newAxisState.PressedLastFrame); } }
internal LClass(Tile startSide, Tile upStart, Tile downStart) { Side = new Compass(startSide); Up = new PositiveNegativeAxis(upStart); Down = new PositiveNegativeAxis(downStart); }