private void RiseOutAngleCoast(Vector3Int trackPoint, char waterFlag) { MovementDirection[] movementDirections = XonixUtils.GetXYDirections(); for (int i = 0; i < movementDirections.Length; i++) { var fDirection = movementDirections[i]; var fPosition = XonixUtils.GetNextPosition(trackPoint, fDirection); var sDirection = movementDirections[(i == movementDirections.Length - 1 ? 0 : i + 1)]; var sPosition = XonixUtils.GetNextPosition(trackPoint, sDirection); var mDirection = XonixUtils.GetDiagonalDirectionOfXY(fDirection, sDirection); var mPosition = XonixUtils.GetNextPosition(trackPoint, mDirection); if (HasWaterTile(fPosition, waterFlag) && HasWaterTile(sPosition, waterFlag) && HasWaterTile(mPosition, waterFlag)) { waterTilemap.SetTile(fPosition, GetCoastTileByDirection(fDirection)); waterTilemap.SetTile(mPosition, GetCoastTileByDirection(mDirection, true)); waterTilemap.SetTile(sPosition, GetCoastTileByDirection(sDirection)); break; } } }
private bool RiseAngleCoast(Vector3Int point, char waterFlag) { MovementDirection[] movementDirections = XonixUtils.GetXYDirections(); for (int i = 0; i < movementDirections.Length; i++) { var fDirection = movementDirections[i]; var fPosition = XonixUtils.GetNextPosition(point, fDirection); var sDirection = movementDirections[(i == movementDirections.Length - 1 ? 0 : i + 1)]; var sPosition = XonixUtils.GetNextPosition(point, sDirection); var mDirection = XonixUtils.GetDiagonalDirectionOfXY(fDirection, sDirection); var mPosition = XonixUtils.GetNextPosition(point, mDirection); if (!HasWaterTile(fPosition, waterFlag) && !HasWaterTile(sPosition, waterFlag) && !HasWaterTile(mPosition, waterFlag)) { waterTilemap.SetTile(point, GetCoastTileByDirection(mDirection)); return(true); } } return(false); }
private Vector3 GetNextMovement(MovementDirection di) { foreach (var diagonalD in XonixUtils.GetDiagonalDirections(di)) { if (tilemapUtil.CanMove(NextDiagonalMovement(diagonalD, transform.position), characterType)) { diagonalDirection = diagonalD; return(NextDiagonalMovement(diagonalD, new Vector3())); } } return(new Vector3()); }
public void RespawnPlayer() { playerDead = 0.3f; movement.x = 0; movement.y = 0; direction = SwipeDirection.None; transform.position = new Vector3(0, -11, 0); XonixUtils.UpdateAnimator(animator, direction); }
private void FixedUpdate() { if (CanMove()) { transform.position = (transform.position + movement * moveSpeed * Time.fixedDeltaTime); } else { UpdateMovement(); XonixUtils.UpdateAnimator(animator, direction); } if (!TryAtackPlayer()) { TryAtackPlayerTrack(); } }
private void RiseCoast(Vector3Int trackPoint, char waterFlag) { MovementDirection[] directionsXY = XonixUtils.GetXYDirections(); foreach (var xyDirection in directionsXY) { var nextPos = XonixUtils.GetNextPosition(trackPoint, xyDirection); if (HasWaterTile(nextPos, waterFlag)) { if (!RiseAngleCoast(nextPos, waterFlag)) { waterTilemap.SetTile(nextPos, GetCoastTileByDirection(xyDirection)); } } } }
private void UpdateDirection(SwipeDirection swipeDirection) { if (GameController.isPause) { return; } if (IsDirectionConflict(swipeDirection)) { movement.x = 0; movement.y = 0; direction = SwipeDirection.None; // Decrement player health OnPlayerDamaged(); } else { movement.x = 0; movement.y = 0; direction = swipeDirection; switch (direction) { case SwipeDirection.Up: movement.y = 1; break; case SwipeDirection.Down: movement.y = -1; break; case SwipeDirection.Left: movement.x = -1; break; case SwipeDirection.Right: movement.x = 1; break; } } XonixUtils.UpdateAnimator(animator, direction); }