public void StartMove() { MoveState = MoveState.Started; OnMoveStarted?.Invoke(this); if (Sleeping) { OnMoveSelected?.Invoke(this, null); } else { SelectMove(); } }
private void Update() { // This is required due to how nav mesh paths are calculated if (updatePosition && !agent.pathPending) { updatePosition = false; var networkLag = (PhotonNetwork.ServerTimestamp - currentMotion.StartTimeStamp) / 1000f; var navAnim = GetComponentInChildren <NavAgentAnimation>(); if (SeatManager.allSeatPositions.Contains(currentMotion.Destination)) { navAnim.TargetState = NavAgentAnimation.State.Sitting; foreach (var seat in SeatManager.allSeats) { if (seat.navigationPoint.position == currentMotion.Destination) { navAnim.nextSeat = seat; } } if (!SeatManager.OccupySeat(navAnim.nextSeat, ownerView.ViewID)) { navAnim.TargetState = NavAgentAnimation.State.Moving; } } else { navAnim.TargetState = NavAgentAnimation.State.Moving; } // Lerps position based on network lag using jumpTimeIgnore if (networkLag > jumpTimeIgnore) { var totalTripTime = PathLength(agent.path.corners) / agent.speed; var step = networkLag / totalTripTime; var syncedPosition = ArrayLerp(agent.path.corners, step); this.agent.Warp(syncedPosition); this.agent.SetDestination(currentMotion.Destination); } OnMoveStarted?.Invoke(); } }
protected bool MoveDown() { bool didMove = false; bool didCombineAny = false; for (int x = 0; x < GridSize.x; x++) { for (int y = GridSize.y - 1; y > 0; y--) { for (int j = y - 1; j >= 0; j--) { if (Grid[x, j] == 0) { continue; } if (Grid[x, y] != 0) { int index = (y * GridSize.x) + x; if (CanCombine(Grid[x, y], Grid[x, j]) && !_CombinedList.Contains(index)) { _CombinedList.Add(index); Combine(x, y, x, j); Grid[x, j] = 0; didCombineAny = true; } else { break; } } else { OnMoveStarted?.Invoke(x, y, x, j); Grid[x, y] = Grid[x, j]; Grid[x, j] = 0; didMove = true; } } } } return(didMove || didCombineAny); }
protected bool MoveRight() { bool didMove = false; bool didCombineAny = false; for (int y = 0; y < GridSize.y; y++) { for (int x = GridSize.x - 1; x > 0; x--) { for (int j = x - 1; j >= 0; j--) { if (Grid[j, y] == 0) { continue; } if (Grid[x, y] != 0) { int index = (y * GridSize.x) + x; if (CanCombine(Grid[x, y], Grid[j, y]) && !_CombinedList.Contains(index)) { _CombinedList.Add(index); Combine(x, y, j, y); Grid[j, y] = 0; didCombineAny = true; } else { break; } } else { OnMoveStarted?.Invoke(x, y, j, y); Grid[x, y] = Grid[j, y]; Grid[j, y] = 0; didMove = true; } } } } return(didMove || didCombineAny); }
private void OnMovePerformed(InputAction.CallbackContext context) { OnMoveStarted?.Invoke(context.ReadValue <float>()); }