protected virtual void SetAnimations() { if (Velocity.X > 0) { _animationManager.Play(_animations["WalkRight"]); currentFaceDirection = FaceDirections.Right; } else if (Velocity.X < 0) { _animationManager.Play(_animations["WalkLeft"]); currentFaceDirection = FaceDirections.Left; } else if (Velocity.Y < 0) { _animationManager.Play(_animations["WalkUp"]); currentFaceDirection = FaceDirections.Up; } else if (Velocity.Y > 0) { _animationManager.Play(_animations["WalkDown"]); currentFaceDirection = FaceDirections.Down; } else { _animationManager.Stop(); } }
void GoDownRight() { face_direction = FaceDirections.SD; current_face_direction = face_direction; transform.rotation = DownRight; direction = (Vector3.forward + Vector3.up).normalized; }
void GoDown() { face_direction = FaceDirections.S; current_face_direction = face_direction; transform.rotation = Down; direction = Vector3.up; }
void GoUpLeft() { face_direction = FaceDirections.WA; current_face_direction = face_direction; transform.rotation = UpLeft; direction = (Vector3.forward + Vector3.up).normalized; }
void GoRight() { face_direction = FaceDirections.D; current_face_direction = face_direction; transform.rotation = Right; direction = Vector3.up; }
void GoLeft() { face_direction = FaceDirections.A; current_face_direction = face_direction; transform.rotation = Left; direction = Vector3.up; }
public IReadOnlyCollection <Vector2> GeneratePositoins() { FaceDirections extremeFace = (FaceDirections)UnityEngine.Random.Range(0, 2); Vector2[,] generatedTilePositions = tilePositionGenerator.GenerateTilePositoins(extremeFace, extremeCellPositions); extremeCellPositions = tilePositionGenerator.GenerateExtremeCellPositions(generatedTilePositions); List <Vector2> result = new List <Vector2>(); for (int y = 0; y <= generatedTilePositions.GetUpperBound(1); y++) { for (int x = 0; x <= generatedTilePositions.GetUpperBound(0); x++) { result.Add(generatedTilePositions[x, y]); } } return(result.AsReadOnly()); }
void VehicleInput() { previous_face_direction = current_face_direction; if (input == up_vector) { GoUp(); } else if (input == up_right_vector) { GoUpRight(); } else if (input == right_vector) { GoRight(); } else if (input == down_right_vector) { GoDownRight(); } else if (input == down_vector) { GoDown(); } else if (input == down_left_vector) { GoDownLeft(); } else if (input == left_vector) { GoLeft(); } else if (input == up_left_vector) { GoUpLeft(); } else { face_direction = current_face_direction; } }
/// <summary> /// Creates tile positions. /// </summary> /// <returns>The tile positoins.</returns> public Vector2[,] GenerateTilePositoins(FaceDirections extremeFace, Dictionary <FaceDirections, Vector2[]> extremeCellPositions) { Vector2[,] result = new Vector2[GeneratedAreaSize.x, GeneratedAreaSize.y]; Vector2[] extremeCellPositionItems = extremeCellPositions[extremeFace]; switch (extremeFace) { case FaceDirections.Top: // значит следующие тайлы генерируются сверху for (int y = 0; y < GeneratedAreaSize.y; y++) { var yAxisExtremeCellPositionItems = extremeCellPositionItems[y]; for (int x = 0; x < GeneratedAreaSize.x; x++) { var xAxisExtremeCellPositionItems = extremeCellPositionItems[x]; var tilePosition = new Vector2(xAxisExtremeCellPositionItems.x, yAxisExtremeCellPositionItems.y + tileSize * (y + 1)); result[x, y] = tilePosition; } } break; case FaceDirections.Right: // значит следующие тайлы генерируются с боку for (int y = 0; y < GeneratedAreaSize.y; y++) { var yAxisExtremeCellPositionItems = extremeCellPositionItems[y]; for (int x = 0; x < GeneratedAreaSize.x; x++) { var xAxisExtremeCellPositionItems = extremeCellPositionItems[x]; var tilePosition = new Vector2(xAxisExtremeCellPositionItems.x + tileSize * (x + 1), yAxisExtremeCellPositionItems.y); result[x, y] = tilePosition; } } break; default: throw new Exception($"[SquareTilePositionGenerator.GenerateTilePositoins] unhandled FaceDirections: {extremeFace}"); } return(result); }
public static Vector3[] faceVertices(FaceDirections dir, Vector3 pos) { return(faceVertices((int)dir, pos)); }
public virtual void Move(FaceDirections direction) { this.m_direction = direction; this.m_moving = true; }
void GoUp() { current_face_direction = FaceDirections.W; transform.rotation = Up; direction = Vector3.up; }
void VehicleInput() { previous_face_direction = current_face_direction; if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.D)) { face_direction = FaceDirections.WD; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, -45.0f); direction = (Vector3.forward + Vector3.up).normalized; } else if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.A)) { face_direction = FaceDirections.WA; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, 45.0f); direction = (Vector3.forward + Vector3.up).normalized; } // else if (Input.GetKey(KeyCode.S) && Input.GetKey(KeyCode.A)) { face_direction = FaceDirections.SA; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, 135.0f); direction = (Vector3.forward + Vector3.up).normalized; } else if (Input.GetKey(KeyCode.S) && Input.GetKey(KeyCode.D)) { face_direction = FaceDirections.SD; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, -135.0f); direction = (Vector3.forward + Vector3.up).normalized; } // else if (Input.GetKey(KeyCode.W)) { face_direction = FaceDirections.W; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); direction = Vector3.up; } else if (Input.GetKey(KeyCode.S)) { face_direction = FaceDirections.S; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, 180.0f); direction = Vector3.up; } else if (Input.GetKey(KeyCode.A)) { face_direction = FaceDirections.A; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, 90.0f); direction = Vector3.up; } else if (Input.GetKey(KeyCode.D)) { face_direction = FaceDirections.D; current_face_direction = face_direction; transform.rotation = Quaternion.Euler(0.0f, 0.0f, -90.0f); direction = Vector3.up; } else { face_direction = current_face_direction; direction = Vector3.zero; gear = 1; } }