public void LookLeftTest() { LookHelper lookHelper = this.CreateLookHelper(); lookHelper.Look(-1f, 0); Assert.AreEqual( "H" + MessageHelper.IntToMessageValue(this.controlSettings.HorizontalMaximumDegree), lookHelper.HorizontalServoCommand); lookHelper.Look(-0.5f, 0); Assert.AreEqual( "H" + MessageHelper.IntToMessageValue((this.controlSettings.HorizontalMaximumDegree - this.controlSettings.HorizontalMinimumDegree) * 3 / 4), lookHelper.HorizontalServoCommand); }
// Move player and change opacity of layers above. private void MovePlayer() { _rigidBody2D.velocity = new Vector2(_moveX * flSpeed, _moveY * flSpeed); _rotation = LookHelper.SmoothLookAtMouse(transform, 0.05f, Registry.ENTITY_SPRITE_OFFSET); // _head.transform.rotation = _rotation; _tempVector.x = transform.position.x; _tempVector.y = transform.position.y; _tempVector.z = Registry.Instance.CEILING_LAYER_Z; // MakeObstructingObjectsTransparent(); _animator.SetBool("isRunning", _moveX != 0 || _moveY != 0); _animator.SetFloat("speed", Mathf.Abs(Mathf.Max(_moveX, _moveY))); }
private async Task SaveAction() { string validName = await ServiceLocator.ContextService.ConvertToValidFileName(LookName); List <string> nameList = new List <string>(); foreach (var lookItem in _receivedSelectedSprite.Looks) { nameList.Add(lookItem.Name); } LookName = await ServiceLocator.ContextService.FindUniqueName(validName, nameList); var message = new GenericMessage <PortableImage>(Image); Messenger.Default.Send(message, ViewModelMessagingToken.LookImageToSaveListener); ServiceLocator.DispatcherService.RunOnMainThread(() => { ServiceLocator.NavigationService.RemoveBackEntry(); ServiceLocator.NavigationService.NavigateBack(this.GetType()); }); //ServiceLocator.DispatcherService.RunOnMainThread(() => // ServiceLocator.NavigationService.NavigateTo<LookSavingViewModel>()); var newDimention = new ImageDimension { Height = SelectedSize.NewHeight, Width = SelectedSize.NewWidth }; var look = await LookHelper.Save(Image, LookName, newDimention, CurrentProgram.BasePath); ServiceLocator.DispatcherService.RunOnMainThread(() => { _receivedSelectedSprite.Looks.Add(look); //ServiceLocator.NavigationService.RemoveBackEntryForPlatform(NavigationPlatform.WindowsPhone); //ServiceLocator.NavigationService.RemoveBackEntryForPlatform(NavigationPlatform.WindowsPhone); ResetViewModel(); //ServiceLocator.NavigationService.NavigateBack( // new List<NavigationPlatform>{NavigationPlatform.WindowsStore}); }); }
public void CorrectCoordinatesFromCyrcleToSquareAreaTest() { // Джойстик в центре: float x = 0; float y = 0; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.AreEqual(0, x); Assert.AreEqual(0, y); // Джойстик на 0 градусов на 100%: x = 1; y = 0; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.AreEqual(1, x); Assert.AreEqual(0, y); // Джойстик на 90 градусов на 100%: x = 0; y = 1; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.AreEqual(0, x); Assert.AreEqual(1, y); // Джойстик на 45 градусов на 100%: x = (float)Math.Sqrt(2f) / 2f; y = x; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.AreEqual(1, x); Assert.AreEqual(1, y); // Джойстик на 45 градусов на 50%: x = (float)Math.Sqrt(2f) / 2f / 2; y = x; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.Greater(0.000001, Math.Abs(0.5f - x)); Assert.Greater(0.000001, Math.Abs(0.5f - y)); // Джойстик на 30 градусов на 50%: x = (float)Math.Cos(Math.PI / 6) * 0.5f; y = (float)Math.Sin(Math.PI / 6) * 0.5f; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.Greater(0.000001, Math.Abs(0.5f - x)); Assert.Greater(0.000001, Math.Abs((0.5f * (float)Math.Tan(Math.PI / 6)) - y)); // Джойстик на 60 градусов на 50%: x = (float)Math.Cos(Math.PI / 3) * 0.5f; y = (float)Math.Sin(Math.PI / 3) * 0.5f; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.Greater(0.000001, Math.Abs((0.5f * (float)Math.Tan(Math.PI / 6)) - x)); Assert.Greater(0.000001, Math.Abs(0.5f - y)); // Джойстик на 135 градусов на 50%: x = -(float)Math.Sqrt(2f) / 2f / 2; y = Math.Abs(x); LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.Greater(0.000001, Math.Abs(-0.5f - x)); Assert.Greater(0.000001, Math.Abs(0.5f - y)); // Джойстик на 225 градусов на 50%: x = -(float)Math.Sqrt(2f) / 2f / 2; y = x; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.Greater(0.000001, Math.Abs(-0.5f - x)); Assert.Greater(0.000001, Math.Abs(-0.5f - y)); // Джойстик на 315 градусов на 50%: x = (float)Math.Sqrt(2f) / 2f / 2; y = -x; LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y); Assert.Greater(0.000001, Math.Abs(0.5f - x)); Assert.Greater(0.000001, Math.Abs(-0.5f - y)); }
private void Awake() { ignoreState = new IgnoreState(); lookHelper = new LookHelper(); }