public override void ClientGetAimingOrientation( ICharacter character, double angleRad, ViewOrientation lastViewOrientation, out ViewOrientation viewOrientation, out float aimCoef) { viewOrientation = default; aimCoef = 0; }
/// <summary> /// Swaps Duplicate value in current Row/Column with a unsorted unique value /// </summary> /// <param name="duplicate"></param> /// <param name="inputPuzzle"></param> /// <returns></returns> private Sudoku BoxAdjacentCellSwap(Cell duplicate, Sudoku inputPuzzle, ViewOrientation focus) { if (focus == ViewOrientation.ROW) { } else { } return(inputPuzzle); }
private async void Current_SizeChanged(object sender, SizeChangedEventArgs e) { var orientation = e.NewSize.Width > e.NewSize.Height ? ViewOrientation.Landscape : ViewOrientation.Portrait; if (this.currentViewOrientation != orientation) { this.currentViewOrientation = orientation; await this.Navigate(this.ContentDataContext?.GetType(), null, NavigationMode.New, NavigationType.Code); } (this.ContentDataContext as ISizeAware)?.SizeChanged(e.NewSize.Width, e.NewSize.Height); }
public void GetCurrentAnimationSetting( ICharacter character, CharacterMoveModes moveModes, double angle, ViewOrientation lastViewOrientation, out string starterAnimationName, out string currentAnimationName, out DrawMode currentDrawMode, out float aimCoef, out ViewOrientation viewOrientation, out bool isIdle) { this.ClientGetAimingOrientation(character, angle, lastViewOrientation, out viewOrientation, out aimCoef); currentDrawMode = viewOrientation.IsLeft ? DrawMode.Default : DrawMode.FlipHorizontally; isIdle = moveModes == CharacterMoveModes.None; if (isIdle) { starterAnimationName = null; currentAnimationName = "Idle"; return; } if ((moveModes & (CharacterMoveModes.Left | CharacterMoveModes.Right)) != CharacterMoveModes.None) { if (viewOrientation.IsLeft && (moveModes & CharacterMoveModes.Left) != 0 || !viewOrientation.IsLeft && (moveModes & CharacterMoveModes.Right) != 0) { starterAnimationName = "RunSideStart"; currentAnimationName = "RunSide"; } else { starterAnimationName = "RunSideBackwardStart"; currentAnimationName = "RunSideBackward"; } } else { // going up or down var isMoveUp = (moveModes & CharacterMoveModes.Up) != 0; starterAnimationName = isMoveUp ? "RunUpStart" : "RunDownStart"; currentAnimationName = isMoveUp ? "RunUp" : "RunDown"; } }
/// <summary> /// Initializes a new instance of <see cref="NavigationFrame"/> /// </summary> public NavigationFrame() { this.BackStack = new List <PageStackEntry>(); this.ForwardStack = new List <PageStackEntry>(); this.Unloaded += NavigationFrame_Unloaded; Application.Current.Activated += Current_Activated; Application.Current.Deactivated += Current_Deactivated; Application.Current.MainWindow.SizeChanged += Current_SizeChanged; Application.Current.MainWindow.Closed += Current_Closed; this.InputBindings.Add(new KeyBinding(new RelayCommand(async() => await this.GoBack(NavigationType.BackButton)), Key.Back, ModifierKeys.None)); this.currentViewOrientation = MonitorInfo.GetCurrentOrientation(); }
void OnOrientationUpdated (ViewOrientation o) { ColumnHeaderView.IsVisible = (o == ViewOrientation.Portrait); SiloScrollView.Orientation = (o == ViewOrientation.Portrait) ? ScrollOrientation.Vertical : ScrollOrientation.Horizontal; SiloStack.Orientation = (o == ViewOrientation.Portrait) ? StackOrientation.Vertical : StackOrientation.Horizontal; ResourceSidebar.IsVisible = (o == ViewOrientation.Landscape); if (o == ViewOrientation.Portrait) SiloScrollView.SetGridColumn (0, 2); else SiloScrollView.SetGridColumn (1, 1); }
void OnOrientationUpdated(ViewOrientation o) { ColumnHeaderView.IsVisible = (o == ViewOrientation.Portrait); SiloScrollView.Orientation = (o == ViewOrientation.Portrait) ? ScrollOrientation.Vertical : ScrollOrientation.Horizontal; SiloStack.Orientation = (o == ViewOrientation.Portrait) ? StackOrientation.Vertical : StackOrientation.Horizontal; ResourceSidebar.IsVisible = (o == ViewOrientation.Landscape); if (o == ViewOrientation.Portrait) { SiloScrollView.SetGridColumn(0, 2); } else { SiloScrollView.SetGridColumn(1, 1); } }
public override void ClientGetAimingOrientation( ICharacter character, double angleRad, ViewOrientation lastViewOrientation, out ViewOrientation viewOrientation, out float aimCoef) { if (character?.GetPublicState <CharacterMobPublicState>().SelectedItemWeaponProto is ProtoItemMobWeaponNova) { // look down as this Spine2D skeleton don't have Nova attack orientation for back view viewOrientation = lastViewOrientation; viewOrientation.IsUp = false; aimCoef = 0; return; } base.ClientGetAimingOrientation(character, angleRad, lastViewOrientation, out viewOrientation, out aimCoef); }
/// <summary> /// Attempts to switch Cell values if same value has been previously sorted. /// </summary> /// <param name="duplicate"></param> /// <param name="restrictions"></param> /// <param name="focus"></param> private bool TryHotSwitch(Cell duplicate, List <int> restrictions, ViewOrientation focus) { if (focus == ViewOrientation.COLUMN) { int startRow = (duplicate.RowPosition / 3) * 3; for (int rowIndex = duplicate.RowPosition; rowIndex < startRow + 3; rowIndex++) { Cell CandidateCell = Puzzle.Grid[duplicate.ColumnPosition][rowIndex]; if (!restrictions.Contains(CandidateCell.Value) && CandidateCell.isSorted) { int tempVal = CandidateCell.Value; CandidateCell.Value = duplicate.Value; duplicate.Value = tempVal; return(true); } } } else { int startCol = (duplicate.ColumnPosition / 3) * 3; for (int colIndex = duplicate.RowPosition; colIndex < startCol + 3; colIndex++) { Cell CandidateCell = Puzzle.Grid[colIndex][duplicate.RowPosition]; if (!restrictions.Contains(CandidateCell.Value) && CandidateCell.isSorted) { int tempVal = CandidateCell.Value; CandidateCell.Value = duplicate.Value; duplicate.Value = tempVal; return(true); } } } return(false); }
public virtual void ClientGetAimingOrientation( [CanBeNull] ICharacter character, double angleRad, ViewOrientation lastViewOrientation, out ViewOrientation viewOrientation, out float aimCoef) { var angleDeg = angleRad * MathConstants.RadToDeg; viewOrientation = new ViewOrientation( isUp: this.ClientIsOrientedUp(angleDeg), isLeft: ClientCharacterAnimationHelper.IsLeftHalfOfCircle(angleDeg)); if (viewOrientation.IsLeft == lastViewOrientation.IsLeft && viewOrientation.IsUp != lastViewOrientation.IsUp) { // switched up/down if (lastViewOrientation.IsUp) { // COMMENTED OUT - we don't need tolerance for keeping the up orientation //// if view orientation was up, but now down //if (lastViewOrientation.IsLeft) //{ // // if view orientation was up-left, but now down-left // if (angleDeg < 90 + toleranceUpVerticalFlipDeg) // { // // keep up-left orientation // viewOrientation.IsUp = true; // } //} //else // if view orientation was up-right, but now down-right //{ // if (angleDeg > 90 - toleranceUpVerticalFlipDeg) // { // // keep up-right orientation // viewOrientation.IsUp = true; // } //} } else { // if view orientation was down, but now up if (lastViewOrientation.IsLeft) { // if view orientation was down-left, but now up-left if (angleDeg > 180 - this.OrientationThresholdDownToUpFlipDeg) { // keep down-left orientation viewOrientation.IsUp = false; } } else // if view orientation was down-right, but now up-right { if (angleDeg < this.OrientationThresholdDownToUpFlipDeg) { // keep down-right orientation viewOrientation.IsUp = false; } } } } else if (viewOrientation.IsLeft != lastViewOrientation.IsLeft && viewOrientation.IsUp == lastViewOrientation.IsUp) { // switched left/right if (lastViewOrientation.IsUp) { if (lastViewOrientation.IsLeft) { // if view orientation was left-up, but now right-up if (angleDeg > 90 - this.OrientationThresholdUpHorizontalFlipDeg) { // keep up-left orientation viewOrientation.IsLeft = true; } } else { // if view orientation was right-up, but now left-up if (angleDeg < 90 + this.OrientationThresholdUpHorizontalFlipDeg) { // keep up-right orientation viewOrientation.IsLeft = false; } } } else { if (lastViewOrientation.IsLeft) { // if view orientation was left-down, but now right-down if (angleDeg < 270 + this.OrientationThresholdDownHorizontalFlipDeg && angleDeg > 270) { // keep down-left orientation viewOrientation.IsLeft = true; } } else { // if view orientation was right-down, but now left-down if (angleDeg > 270 - this.OrientationThresholdDownHorizontalFlipDeg && angleDeg < 270) { // keep down-right orientation viewOrientation.IsLeft = false; } } } } // let's calculate aim coef var aimAngle = angleDeg; if (viewOrientation.IsUp) { // offset angle aimAngle += 45; // calculated angle between 0 and 270 degrees aimAngle %= 360; // calculate coef (from 0 to 2) aimCoef = (float)(aimAngle / 180); if (viewOrientation.IsLeft) { // if left orientation, aimCoef values will be from 1 to 2 // remap them to values from 1 to 0 respectively aimCoef = 1.5f - aimCoef; } } else // if oriented down { if (aimAngle < 90) { // it means we're in first quarter, extend aimAngle // on 360 degrees to keep coordinates continuum (from 180*3/4 to 180*(2+(1/4))) aimAngle += 360; } // offset angle aimAngle -= 45; // calculated angle between 0 and 270 degrees aimAngle = 360 - aimAngle; // calculate coef (from 0 to 2) aimCoef = (float)(aimAngle / 180); if (viewOrientation.IsLeft) { // if left orientation, aimCoef values will be from 1 to 2 // remap them to values from 1 to 0 respectively aimCoef = 1.5f - aimCoef; } // invert coefficient aimCoef = 1f - aimCoef; } //Api.Logger.WriteDev( // $"AngleDeg: {angleDeg:F2}. Aiming coef: {aimCoef:F2}. Current view data: isUp={viewOrientation.IsUp} isLeft={viewOrientation.IsLeft}"); }
public static void SetOrientation(ViewOrientation o) { viewOrientation = o; }
void OnOrientationEventReceived(ViewOrientation orientation) { Orientation = (orientation == ViewOrientation.Portrait) ? StackOrientation.Horizontal : StackOrientation.Vertical; UpdateOrientation(); }
void OnOrientationEventReceived (ViewOrientation orientation) { Orientation = (orientation == ViewOrientation.Portrait) ? StackOrientation.Horizontal : StackOrientation.Vertical; UpdateOrientation (); }