public void TearDown() { this.mockDataValidator = null; this.mockDataManager = null; this.mockRotator = null; this.mockMoveProcessors = null; }
/// <summary> Поворот группы фигур </summary> /// <param name="rotatorArg"> Класс отвечающий за поворот объектов </param> /// <param name="isByClockArg"> true - по часовой стрелке поворот </param> /// <returns> true, если поворот успешно удался </returns> public bool Rotate(IRotator rotatorArg, bool isByClockArg) { Vector3Int centerRotate = rotatorArg.CalculateCenter(InnerPositions.ToArray(), isByClockArg); IFigure figureRotate = _figures.Where(figure => figure.Position.x == centerRotate.x && figure.Position.y == centerRotate.y && figure.Position.z == centerRotate.z).First(); if (figureRotate == null) { return(false); } foreach (var figure in _figures) { if (figure != figureRotate) { if (!rotatorArg.IsCanRotate(figure.Position, centerRotate, isByClockArg)) { return(false); } } } foreach (var figure in _figures) { if (figure != figureRotate) { figure.Rotate(rotatorArg, centerRotate, isByClockArg); } } return(true); }
public GameManager(IGameDataManager dataManager, IRotator rotator, IGameDataValidator dataValidator, IMoveProcessor[] moveProcessors) { this.dataManager = dataManager; this.rotator = rotator; this.dataValidator = dataValidator; this.processors = moveProcessors.ToDictionary(p => p.MoveDirection, p => p); }
public Figure(IDrawer drawer, IScaler scaler, IUpdater updater, IMover mover, IRotator rotator) { Updater = updater; Scaler = scaler; Drawer = drawer; Mover = mover; Rotator = rotator; }
public void StartRotating(IRotator rotator) { if (rotator != null) { RotationOperator = rotator; rotator.RotateInFixedUpdate(this); } }
public FrontWheelRotationConstraint(RotationDiff parent, IRotator handle, IRotator rear, IRotator destination, bool offHandleConstraint = false) { this.parent = parent; this.handle = new RotationDiff(handle); this.rear = new RotationDiff(rear); this.destination = destination; this.offHandleConstraint = offHandleConstraint; defaultRotation = destination.Rotation; }
/// <summary> /// Вращение объекта /// </summary> /// <param name="rotatorArg"> Объект используемый для вращения </param> /// <param name="isByClockArg"> true - по часовой стрелке </param> /// <returns> true - если вращение удалось </returns> public bool Rotate(IRotator rotatorArg, bool isByClockArg) { if (isByClockArg) { _model.transform.Rotate(0, 0, 90); } else { _model.transform.Rotate(0, 0, -90); } return(true); }
public async Task Disconnect() { if (RotatorInfo.Connected) { if (updateTimer != null) { await updateTimer.Stop(); } rotator?.Disconnect(); rotator = null; RotatorInfo = DeviceInfo.CreateDefaultInstance <RotatorInfo>(); BroadcastRotatorInfo(); Logger.Info("Disconnected Rotator"); } }
public ConfigurationMode1(string nameArg, Camera cameraArg, GameObject modelCubeArg) { _name = nameArg; _map = new MapGame(new Vector3Int(10, 20, 1)); _modelCube = modelCubeArg; _obstructions = new Obstructions(); _cmdObstructionIsExists = new CommandObstructionIsExists(_obstructions); _cmdObstructionAdd = new CommandObstructionAdd(_obstructions); _cmdObstructionReplace = new CommandObstructionReplace(_obstructions); _cmdObstructionDelete = new CommandObstructionDelete(_obstructions); _mover = new Mover(_map.Size, _cmdObstructionIsExists, _cmdObstructionReplace); _rotator = new Rotator(_mover, _map.Size); }
public bool Rotate(IRotator rotatorArg, Vector3Int centerArg, bool isByClockArg) { Vector3Int oldPosition = Position; Vector3Int newPosition; newPosition = rotatorArg.Rotate(Position, centerArg, isByClockArg); if (oldPosition.x != newPosition.x || oldPosition.y != newPosition.y || oldPosition.z != newPosition.z) { _model.transform.position = newPosition; return(true); } return(false); }
public void Setup() { this.mockDataManager = MockRepository.GenerateMock <IGameDataManager>(); this.mockDataValidator = MockRepository.GenerateMock <IGameDataValidator>(); this.mockRotator = MockRepository.GenerateMock <IRotator>(); this.mockMoveProcessors = new IMoveProcessor[4]; this.mockMoveProcessors[0] = MockRepository.GenerateMock <IMoveProcessor>(); this.mockMoveProcessors[1] = MockRepository.GenerateMock <IMoveProcessor>(); this.mockMoveProcessors[2] = MockRepository.GenerateMock <IMoveProcessor>(); this.mockMoveProcessors[3] = MockRepository.GenerateMock <IMoveProcessor>(); this.mockMoveProcessors[0].Stub(mp => mp.MoveDirection).Return(Direction.North); this.mockMoveProcessors[1].Stub(mp => mp.MoveDirection).Return(Direction.East); this.mockMoveProcessors[2].Stub(mp => mp.MoveDirection).Return(Direction.South); this.mockMoveProcessors[3].Stub(mp => mp.MoveDirection).Return(Direction.West); }
public bool Rotate(IRotator rotatorArg, Vector3Int centerArg, bool isByClockArg) { Vector3Int centerInt = centerArg; foreach (var figure in _figures) { if (!rotatorArg.IsCanRotate(figure.Position, centerInt, isByClockArg)) { return(false); } } foreach (var figure in _figures) { figure.Rotate(rotatorArg, centerArg, isByClockArg); } return(true); }
// Use this for initialization void Start () { if (root == null) { root = transform; } director = gameObject.GetComponentInChildren<IDirection>(); if (director == null) { Debug.LogError ("Cannot find IDirection"); } mover = gameObject.GetComponentInChildren<IMover>(); if (mover == null) { Debug.LogError ("Cannot find IMover"); } rotator = gameObject.GetComponentInChildren<IRotator>(); if (rotator == null) { Debug.LogError ("Cannot find IRotator"); } }
void Awake() { bicycleRotator = new TransformRotator(transform); bicycle = new RotationDiff(bicycleRotator); handleRotator = new TransformRotator(handle); frontWheelRotator = new TransformRotator(frontWheel); rearWheelRotator = new TransformRotator(rearWheel); rightPedalCrankArmJointRotator = new TransformRotator(rightPedalCrankArmJoint); leftPedalCrankArmJointRotator = new TransformRotator(leftPedalCrankArmJoint); rightPedalJointRotator = new TransformRotator(rightPedalJoint); leftPedalJointRotator = new TransformRotator(leftPedalJoint); pedalJointConstraint = new PedalJointRotationConstraint(rightPedalCrankArmJointRotator, leftPedalCrankArmJointRotator); rearWheelConstraint = new RearWheelRotationConstraint(rightPedalCrankArmJointRotator, rearWheelRotator); frontWheelConstraint = new FrontWheelRotationConstraint(bicycle, handleRotator, rearWheelRotator, frontWheelRotator, offHandleConstraint); pedalHorizontalConstraint = new PedalHorizontalConstraint(bicycleRotator, leftPedalJointRotator, rightPedalJointRotator); }
/// <summary> Класс описывает логику игры на SceneGame (Компонент Model). </summary> /// <see> Для получения информации по сущностям перейдите в Scripts/Global/GameConfigurators/AbstractConfigurator.cs </see> public TetrisGame() { AbstractConfigurator configurator = DataConfigs.LoadConfigurator(); if (configurator == null) { throw new TetrisException("Не выбран режим игры!"); } _map = configurator.CreateMap(); _generator = configurator.CreateGenerator(); _factory = configurator.CreateFactoryFigure(); _mover = configurator.CreateMover(); _rotator = configurator.CreateRotator(); _vectorDrop = configurator.CreateVectorDropInt(); _delayDrop = configurator.DelayFrameDrop(); _obstructions = configurator.CreateObstructions(); _stackFigures = configurator.CreateStackFigures(); _figure = _generator.NewFigure(_factory); }
public RemindersController(IRotator rotator) { _rotator = rotator ?? throw new ArgumentNullException(nameof(rotator)); }
public PedalJointRotationConstraint(IRotator pedal, IRotator destination) { this.pedal = new RotationDiff(pedal); this.destination = destination; defaultRotation = destination.Rotation; }
public RotationDiff(IRotator rotator) { this.rotator = rotator; Default = rotator.Rotation; DefaultInv = Quaternion.Inverse(Default); }
public RotatorSelectedItems(IRotator rotator) { this.Rotator = rotator; }
private void Start() { _translator = GetComponent <ITranslator>(); _rotator = GetComponent <IRotator>(); }
public RotatorTests() { _rowExtractorMock.Setup(x => x.Extract(_matrix, 1, 0)).Returns(_rows); _rowExtractorMock.Setup(x => x.ToMatrix(_rows, 1, 0)).Returns(_rotationResult); _rotator = new Rotator(_rowExtractorMock.Object, _elementShifterMock.Object); }
public RearWheelRotationConstraint(IRotator pedalJoint, IRotator destination) { this.pedalJoint = new RotationDiff(pedalJoint); this.destination = destination; defaultRotation = destination.Rotation; }
public async Task <bool> Connect() { await ss.WaitAsync(); try { await Disconnect(); if (updateTimer != null) { await updateTimer.Stop(); } if (RotatorChooserVM.SelectedDevice.Id == "No_Device") { profileService.ActiveProfile.RotatorSettings.Id = RotatorChooserVM.SelectedDevice.Id; return(false); } applicationStatusMediator.StatusUpdate( new ApplicationStatus() { Source = Title, Status = Locale.Loc.Instance["LblConnecting"] } ); var rotator = (IRotator)RotatorChooserVM.SelectedDevice; _connectRotatorCts?.Dispose(); _connectRotatorCts = new CancellationTokenSource(); if (rotator != null) { try { var connected = await rotator?.Connect(_connectRotatorCts.Token); _connectRotatorCts.Token.ThrowIfCancellationRequested(); if (connected) { this.rotator = rotator; if (this.rotator.CanReverse) { this.rotator.Reverse = profileService.ActiveProfile.RotatorSettings.Reverse; } RotatorInfo = new RotatorInfo { Connected = true, IsMoving = rotator.IsMoving, Name = rotator.Name, Description = rotator.Description, Position = rotator.Position, StepSize = rotator.StepSize, DriverInfo = rotator.DriverInfo, DriverVersion = rotator.DriverVersion, CanReverse = rotator.CanReverse, Reverse = rotator.Reverse }; Notification.ShowSuccess(Locale.Loc.Instance["LblRotatorConnected"]); updateTimer.Interval = profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval; updateTimer.Start(); TargetPosition = rotator.Position; profileService.ActiveProfile.RotatorSettings.Id = rotator.Id; profileService.ActiveProfile.RotatorSettings.Reverse = this.rotator.Reverse; Logger.Info($"Successfully connected Rotator. Id: {rotator.Id} Name: {rotator.Name} Driver Version: {rotator.DriverVersion}"); return(true); } else { RotatorInfo.Connected = false; this.rotator = null; return(false); } } catch (OperationCanceledException) { if (RotatorInfo.Connected) { await Disconnect(); } return(false); } } else { return(false); } } finally { ss.Release(); applicationStatusMediator.StatusUpdate( new ApplicationStatus() { Source = Title, Status = string.Empty } ); } }
public CalendarController(IRotator rotator) { _rotator = rotator ?? throw new ArgumentNullException(nameof(rotator)); }
public PedalHorizontalConstraint(IRotator body, IRotator leftPedal, IRotator rightPedal) { this.body = body; this.leftPedal = leftPedal; this.rightPedal = rightPedal; }
/// <summary> /// Awake. /// </summary> private void Awake() { Mover = new Mover(this, _moverType); Rotator = new Rotator(this, _rotatorType); }