// Use this for initialization void Start() { GameObject stateObject = GameObject.Find("BalanceState"); BalanceState stateScript = (BalanceState)stateObject.GetComponent(typeof(BalanceState)); speed = 1f; }
public async Task OnGetAsync() { Accounts = await _accountQueries.GetList(); CanDistribute = Accounts.Accounts.Count(x => x.AvailBalance > 0) > 0; BalanceState = await _inventorizationQueries.GetBalanceState(); }
public async Task OnGetAsync(string dateFrom, string dateTo, int pageNumber = 1) { BalanceState = await _inventorizationQueries.GetBalanceState(); if (string.IsNullOrEmpty(dateFrom) || string.IsNullOrEmpty(dateTo)) { Filter = ReportTableFilter.CurrentYear(); } else { Filter = new ReportTableFilter(dateFrom, dateTo); foreach (var error in Filter.Validate()) { ModelState.AddModelError(error.PropertyName, error.Message); } } if (ModelState.IsValid) { Incomes = await LoadIncomesAsync(pageNumber); } else { IsDataValid = false; } }
public async Task <IActionResult> OnPostAsync() { BalanceState = await _inventorizationQueries.GetBalanceState(); return(await AddCategory.ProcessAsync(ModelState, nameof(AddCategory), async() => { await _categoriesCommands.Update(new CategoryModel { Name = AddCategory.Category }); return RedirectToPage("./Categories", new { pageNumber = -1 }); }, async() => { await LoadCategoriesAsync(AddCategory.PageNumber); return Page(); }, async vrList => { if (!AddCategory.Category.IsNullOrEmpty()) { var category = await _categoriesQueries.GetByName(AddCategory.Category); if (category != null) { vrList.Add(new ModelValidationResult(nameof(AddCategory.Category), "Категория товаров с таким именем уже есть")); } } })); }
/// <summary> /// Determines whether the player is balancing on an edge. /// </summary> /// <param name="trA">The result of sensor A.</param> /// <param name="trB">The result of sensor B.</param> private void DetectBalancing(TraceResult trA, TraceResult trB) { if (trA.Hit == trB.Hit) { return; } var flipped = _player.FlipHorizontally; var position = _player.Position; var size = _player.Size; TraceResult tr = trA.Hit ? trA : trB; var reversed = (trA.Hit && flipped) || (trB.Hit && !flipped); double edgeDiff; double objectWidth; if (tr.Entity == null) { var tile = tr.Tile; objectWidth = tile.Definition.Rect.Size.X; edgeDiff = Math.Abs(position.X - (tile.WorldPosition.X + objectWidth / 2.0)); } else { var entity = tr.Entity; objectWidth = entity.Size.X; edgeDiff = Math.Abs(position.X - entity.Position.X); } var tq = new TraceQuery { Line = new Line(position, new Point(position.X, position.Y + (size.Y / 2.0))), CollisionPath = _player.CollisionPath, Ignore = _player, Options = TraceLineOptions.SolidOnly }; var trMiddle = _collisionService.TraceLine(tq); if (!trMiddle.Hit) { if (reversed && (edgeDiff > objectWidth / 2)) { _balanceState = BalanceState.Backward; } else if (edgeDiff > (objectWidth / 2) + 6) { _balanceState = BalanceState.ForwardVeryEdge; } else if (edgeDiff > objectWidth / 2) { _balanceState = BalanceState.Forward; } } }
public async Task OnGetAsync(int pageNumber = 1) { ExpenseFlows = await _expenseFlowQueries.GetList(new PaginationArgs { IncludeDeleted = false, ItemsPerPage = 7, PageNumber = pageNumber }); BalanceState = await _inventorizationQueries.GetBalanceState(); }
public async Task <IActionResult> OnPostRefreshAsync() { BalanceState = await _inventorizationQueries.GetBalanceState(); return(await Filter.ProcessAsync(ModelState, nameof(Filter), async() => { Incomes = await LoadIncomesAsync(); return Page(); }, async() => { IsDataValid = false; return await Task.FromResult(Page()); })); }
BalanceState GetBalanceState(decimal?balance, decimal threshold) { BalanceState state = null; if (balance.HasValue) { if (balance < 0) { state = new BalanceStateNegative(); } else if (balance < threshold) { state = new BalanceStateBelowThreshold(); } else { state = new BalanceStateOK(); } } return(state); }
/// <summary> /// Steps the movement of the parent entity by the controller logic. /// </summary> public override void Move() { if (_controlsEnabled) { _controlState = _inputService.CurrentState; } else { _controlState = ControllerState.None; } // may undo the ground speed, X pos etc. CheckWall(); _balanceState = BalanceState.None; if (_falling) { // falling, so work out air speed and perform basic ground checks CalculateAirSpeed(); CheckForGroundInAir(); if (_groundAngle > 180) { _groundAngle = Utils.Lerp(_groundAngle, 360.0, 150, _varService.DeltaTime); } else { _groundAngle = Utils.Lerp(_groundAngle, 0.0, 150, _varService.DeltaTime); } } if (!_falling) { // horizontal control lock timeout _controlLockTime -= _varService.DeltaTime; if (_controlLockTime < 0.0) { _controlLockTime = 0.0; } // too slow to roll? if (_rolling && Math.Abs(_gsp) < 0.5) { Unroll(); } // not falling, track ground, sort out angles/position etc. if (_movementMode == PlayerMovementMode.Floor) { CheckForGroundFloor(); } else if (_movementMode == PlayerMovementMode.RightWall) { CheckForGroundRight(); } else if (_movementMode == PlayerMovementMode.LeftWall) { CheckForGroundLeft(); } else if (_movementMode == PlayerMovementMode.Ceiling) { CheckForGroundCeiling(); } if (_falling) { // now falling (just lost floor), so work out air speed and perform basic ground checks CalculateAirSpeed(); CheckForGroundInAir(); } else { // calculate speed if (!_rolling) { CalculateGroundSpeedRunning(); } else { CalculateGroundSpeedRolling(); } // translate ground speed to X/Y position offsets CalcXYSpeed(); // if the player is scuttling about on the walls or ceiling, fall if too slow if (_ysp <= 0.0) { if (_movementMode != PlayerMovementMode.Floor) { if (_controlLockTime <= 0.0) { if (Math.Abs(_gsp) < 2.5) { _gsp = 0.0; _controlLockTime = 0.25; Fall(); } } } } } } // check input for jump if (_allowJump) { if ((_controlState & ControllerState.Jump) > ControllerState.None) { // only jump if the player has just pressed it if ((_prevControlState & ControllerState.Jump) == ControllerState.None) { Jump(); } } } // check input for roll if ((_controlState & ControllerState.Down) > ControllerState.None) { Roll(); } if ((_controlState & ControllerState.Up) > ControllerState.None) { Looking_Up(); } // impulse position base.Move(); CheckBraking(); SetMovementMode(); // keep track of previous control state _prevControlState = _controlState; }
// Keeps character locked to ground while in ground state // 3D-Ready: No, but pretty close, actually. public bool GroundSnap() { RaycastHit hit = GetGroundRaycast(); balanceState = BalanceState.None; if (GetIsGrounded(hit)) { transform.eulerAngles = new Vector3( 0, 0, Quaternion.FromToRotation(Vector3.up, hit.normal).eulerAngles.z ); Vector3 newPos = hit.point + (transform.up * 0.5F * sizeScale); newPos.z = position.z; // Comment this for 3D movement position = newPos; groundedDetectorCurrent = hit.transform.GetComponentInChildren <CharacterGroundedDetector>(); return(true); } // Didn't find the ground from the player center? // We might be on a ledge. Better check to the left and right of // the character to be sure. for (int dir = -1; dir <= 1; dir += 2) { RaycastHit hitLedge; Physics.Raycast( position + (dir * transform.right * 0.375F * sizeScale * sizeScale), // origin -transform.up, // direction out hitLedge, 0.8F * sizeScale, // max distance ~solidRaycastMask // layer mask ); if (GetIsGrounded(hitLedge)) { balanceState = dir < 0 ? BalanceState.Left : BalanceState.Right; groundedDetectorCurrent = hitLedge.transform.GetComponentInChildren <CharacterGroundedDetector>(); Vector3 newPos = ( hitLedge.point - (dir * transform.right * 0.375F * sizeScale) + (transform.up * 0.5F * sizeScale) ); newPos.x = position.x; newPos.z = position.z; position = newPos; return(true); } } if (stateCurrent == "rolling") { stateCurrent = "rollingAir"; } else { stateCurrent = "air"; } return(false); }
public async Task OnGetAsync(int pageNumber = 1) { BalanceState = await _inventorizationQueries.GetBalanceState(); await LoadCategoriesAsync(pageNumber); }