private void AssignButtonToAction(int ButtonID, ControllerButtonType ButtonType, int ControllerInputBindingsNameX, int ControllerID)
 {
     ControllerInputBindings[ControllerInputBindingsNameX].ButtonID        = ButtonID;
     ControllerInputBindings[ControllerInputBindingsNameX].ButtonType      = (int)ButtonType;
     ControllerInputBindings[ControllerInputBindingsNameX].ActionToPerform = (ControllerInputBindingsName)ControllerInputBindingsNameX;
     ControllerInputBindings[ControllerInputBindingsNameX].ControllerID    = ControllerID;
 }
        // UIのPresentetor層からコールされるモデルのロジック
        public void SetCurrentAdjuster(ControllerButtonType type)
        {
            switch (type)
            {
            case ControllerButtonType.Move:
                CurrentAdjuster = _positionAdjuster;
                break;

            case ControllerButtonType.Rotate:
                CurrentAdjuster = _rotateAdjuster;
                break;

            case ControllerButtonType.Scale:
                CurrentAdjuster = _scaleAdjuster;
                break;

            case ControllerButtonType.Done:
                CurrentAdjuster = null;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            _currentState.Value = type;
        }
Exemple #3
0
        public async Task <ControllerAction> AddOrUpdateControllerActionAsync(
            ControllerEvent controllerEvent,
            string deviceId,
            int channel,
            bool isInvert,
            ControllerButtonType buttonType,
            ControllerAxisType axisType,
            ControllerAxisCharacteristic axisCharacteristic,
            int maxOutputPercent,
            int axisDeadZonePercent,
            ChannelOutputType channelOutputType,
            int maxServoAngle,
            int servoBaseAngle,
            int stepperAngle,
            string sequenceName)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerAction = controllerEvent.ControllerActions.FirstOrDefault(ca => ca.DeviceId == deviceId && ca.Channel == channel);
                if (controllerAction != null)
                {
                    controllerAction.IsInvert            = isInvert;
                    controllerAction.ButtonType          = buttonType;
                    controllerAction.AxisType            = axisType;
                    controllerAction.AxisCharacteristic  = axisCharacteristic;
                    controllerAction.MaxOutputPercent    = maxOutputPercent;
                    controllerAction.AxisDeadZonePercent = axisDeadZonePercent;
                    controllerAction.ChannelOutputType   = channelOutputType;
                    controllerAction.MaxServoAngle       = maxServoAngle;
                    controllerAction.ServoBaseAngle      = servoBaseAngle;
                    controllerAction.StepperAngle        = stepperAngle;
                    controllerAction.SequenceName        = sequenceName;
                    await _creationRepository.UpdateControllerActionAsync(controllerAction);
                }
                else
                {
                    controllerAction = new ControllerAction
                    {
                        DeviceId            = deviceId,
                        Channel             = channel,
                        IsInvert            = isInvert,
                        ButtonType          = buttonType,
                        AxisType            = axisType,
                        AxisCharacteristic  = axisCharacteristic,
                        MaxOutputPercent    = maxOutputPercent,
                        AxisDeadZonePercent = axisDeadZonePercent,
                        ChannelOutputType   = channelOutputType,
                        MaxServoAngle       = maxServoAngle,
                        ServoBaseAngle      = servoBaseAngle,
                        StepperAngle        = stepperAngle,
                        SequenceName        = sequenceName
                    };
                    await _creationRepository.InsertControllerActionAsync(controllerEvent, controllerAction);
                }

                return(controllerAction);
            }
        }
        public async Task UpdateControllerActionAsync(
            ControllerAction controllerAction,
            string deviceId,
            int channel,
            bool isInvert,
            ControllerButtonType buttonType,
            ControllerAxisType axisType,
            ControllerAxisCharacteristic axisCharacteristic,
            int maxOutputPercent,
            int axisActiveZonePercent,
            int axisDeadZonePercent,
            ChannelOutputType channelOutputType,
            int maxServoAngle,
            int servoBaseAngle,
            int stepperAngle,
            string sequenceName)
        {
            using (await _asyncLock.LockAsync())
            {
                var otherControllerAction = controllerAction.ControllerEvent.ControllerActions.FirstOrDefault(ca => ca.Id != controllerAction.Id && ca.DeviceId == deviceId && ca.Channel == channel);
                if (otherControllerAction != null)
                {
                    var parent = otherControllerAction.ControllerEvent;
                    await _creationRepository.DeleteControllerActionAsync(otherControllerAction);

                    parent.ControllerActions.Remove(otherControllerAction);
                }

                controllerAction.DeviceId              = deviceId;
                controllerAction.Channel               = channel;
                controllerAction.IsInvert              = isInvert;
                controllerAction.ButtonType            = buttonType;
                controllerAction.AxisType              = axisType;
                controllerAction.AxisCharacteristic    = axisCharacteristic;
                controllerAction.MaxOutputPercent      = maxOutputPercent;
                controllerAction.AxisActiveZonePercent = axisActiveZonePercent;
                controllerAction.AxisDeadZonePercent   = axisDeadZonePercent;
                controllerAction.ChannelOutputType     = channelOutputType;
                controllerAction.MaxServoAngle         = maxServoAngle;
                controllerAction.ServoBaseAngle        = servoBaseAngle;
                controllerAction.StepperAngle          = stepperAngle;
                controllerAction.SequenceName          = sequenceName;
                await _creationRepository.UpdateControllerActionAsync(controllerAction);
            }
        }
        private void AssignButtonToAction(int ButtonID, ControllerButtonType ButtonType, int Action)
        {
            switch (Action)
            {
            case (int)ButtonActionAssignmentName.SelectPreviousTeleport:     // Forward Teleport List
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectPreviousTeleport].ButtonID        = ButtonID;
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectPreviousTeleport].ButtonType      = (int)ButtonType;
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectPreviousTeleport].ActionToPerform = ButtonActionAssignmentName.SelectPreviousTeleport;
                break;

            case (int)ButtonActionAssignmentName.TeleportToDestination:     // Forward Teleport List
                ControllerInputBindings[(int)ControllerInputBindingsName.TeleportToDestination].ButtonID        = ButtonID;
                ControllerInputBindings[(int)ControllerInputBindingsName.TeleportToDestination].ButtonType      = (int)ButtonType;
                ControllerInputBindings[(int)ControllerInputBindingsName.TeleportToDestination].ActionToPerform = ButtonActionAssignmentName.TeleportToDestination;
                break;

            case (int)ButtonActionAssignmentName.SelectNextTeleport:     // Forward Teleport List
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectNextTeleport].ButtonID        = ButtonID;
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectNextTeleport].ButtonType      = (int)ButtonType;
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectNextTeleport].ActionToPerform = ButtonActionAssignmentName.SelectNextTeleport;
                break;

            case (int)ButtonActionAssignmentName.SaveGameStatus:     // Forward Teleport List
                ControllerInputBindings[(int)ControllerInputBindingsName.SaveGameStatus].ButtonID        = ButtonID;
                ControllerInputBindings[(int)ControllerInputBindingsName.SaveGameStatus].ButtonType      = (int)ButtonType;
                ControllerInputBindings[(int)ControllerInputBindingsName.SaveGameStatus].ActionToPerform = ButtonActionAssignmentName.SaveGameStatus;
                break;

            case (int)ButtonActionAssignmentName.LockYPosition:     // Lock Character in Height
                ControllerInputBindings[(int)ControllerInputBindingsName.LockYPosition].ButtonID        = ButtonID;
                ControllerInputBindings[(int)ControllerInputBindingsName.LockYPosition].ButtonType      = (int)ButtonType;
                ControllerInputBindings[(int)ControllerInputBindingsName.LockYPosition].ActionToPerform = ButtonActionAssignmentName.LockYPosition;
                break;

            case (int)ButtonActionAssignmentName.ToggleMode:     // Lock Character in Height
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectNextTeleport].ButtonID        = ButtonID;
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectNextTeleport].ButtonType      = (int)ButtonType;
                ControllerInputBindings[(int)ControllerInputBindingsName.SelectNextTeleport].ActionToPerform = ButtonActionAssignmentName.ToggleMode;
                break;
            }
        }
 // UIロジック
 // ステートに応じてボタンの色を変更する
 public void SetButtonColor(ControllerButtonType currentButton)
 {
     GetComponent <Renderer>().material.color =
         _buttonType == currentButton ? Color.green : Color.gray;
 }