void Update() { if (spawnedIn && setCourse && Vector2.Distance(transform.position, destination) < 2) //If shuttle arrived { arrivedAtStation = true; GameManager.Instance.shuttleArrived = true; setCourse = false; mm.SetPosition(destination); mm.StopMovement(); mm.RotateTo(Orientation.Right); //Rotate shuttle correctly so doors are facing correctly mm.ChangeDir(Orientation.Left); //Reverse into station evac doors. StartCoroutine(ReverseIntoStation(mm)); } if (arrivedAtStation && !departed) { waitAtStationTime += Time.deltaTime; if (waitAtStationTime > 60f) { DepartStation(); } } if (departed && !roundEnded) { departingFlightTime += Time.deltaTime; if (departingFlightTime > 60f) { roundEnded = true; GameManager.Instance.RoundEnd(); } } }
void Update() { if (GameManager.Instance.GetRoundTime <= 150f && spawnedIn == false && setCourse == false) // Warp close to station 2.5 mins before round ends { SpawnNearStation(); setCourse = true; } if (spawnedIn && setCourse && Vector2.Distance(transform.position, destination) < 2) //If shuttle arrived { arrivedAtStation = true; GameManager.Instance.shuttleArrived = true; setCourse = false; mm.SetPosition(destination); mm.StopMovement(); mm.RotateTo(Orientation.Right); //Rotate shuttle correctly so doors are facing correctly mm.ChangeDir(Orientation.Left); //Reverse into station evac doors. StartCoroutine(ReverseIntoStation(mm)); } if (GameManager.Instance.GetRoundTime <= 30f && arrivedAtStation == true) // Depart the shuttle { mm.ChangeDir(Orientation.Right); mm.StartMovement(); } }
public void LandShuttleOnGround(Vector3 teleportCoordinate) { matrixMove.IsForceStopped = true; matrixMove.StopMovement(); //Maybe change collision type? //matrixMove.matrixColliderType = matrixMove.SetPosition(teleportCoordinate); }
IEnumerator ProcessSpaceBody(MatrixMove mm) { bool validPos = false; while (!validPos) { Vector3 proposedPosition = RandomPositionInSolarSystem(); bool failedChecks = false; //Make sure it is away from the middle of space matrix if (Vector3.Distance(proposedPosition, MatrixManager.Instance.spaceMatrix.transform.parent.transform.position) < minDistanceBetweenSpaceBodies) { failedChecks = true; } for (int i = 0; i < SpaceBodies.Count; i++) { if (Vector3.Distance(proposedPosition, SpaceBodies[i].transform.position) < minDistanceBetweenSpaceBodies) { failedChecks = true; } } if (!failedChecks) { validPos = true; mm.SetPosition(proposedPosition); SpaceBodies.Add(mm); } yield return(YieldHelper.EndOfFrame); } yield return(YieldHelper.EndOfFrame); isProcessingSpaceBody = false; }
private void Update() { if (!CustomNetworkManager.Instance._isServer) { return; } if (moving && Vector2.Distance(transform.position, destination) < 2) //arrived to dest { moving = false; mm.SetPosition(destination); mm.StopMovement(); mm.SteerTo(Orientation.Up); if (CargoManager.Instance.ShuttleStatus == ShuttleStatus.OnRouteStation) { mm.ChangeFlyingDirection(Orientation.Down); StartCoroutine(ReverseIntoStation()); } } if (CargoManager.Instance.CurrentFlyTime <= 0f && CargoManager.Instance.ShuttleStatus == ShuttleStatus.OnRouteCentcom) { UnloadCargo(); CargoManager.Instance.OnShuttleArrival(); } }
public void SpawnNearStation() { //Makes sure asteroids don't spawn at/inside station Vector2 clampVal = Random.insideUnitCircle * asteroidDistance; if (clampVal.x > 0) { clampVal.x = Mathf.Clamp(clampVal.x, distanceFromStation, asteroidDistance); } else { clampVal.x = Mathf.Clamp(clampVal.x, -distanceFromStation, -asteroidDistance); } mm.SetPosition(clampVal); }
IEnumerator ProcessSpaceBody(MatrixMove mm) { if (SceneManager.GetActiveScene().name == "BoxStationV1") { minDistanceBetweenSpaceBodies = 200f; } //Change this for larger maps to avoid asteroid spawning on station. else { minDistanceBetweenSpaceBodies = 200f; } bool validPos = false; while (!validPos) { Vector3 proposedPosition = RandomPositionInSolarSystem(); bool failedChecks = Vector3.Distance(proposedPosition, MatrixManager.Instance.spaceMatrix.transform.parent.transform.position) < minDistanceBetweenSpaceBodies; //Make sure it is away from the middle of space matrix for (int i = 0; i < SpaceBodies.Count; i++) { if (Vector3.Distance(proposedPosition, SpaceBodies[i].transform.position) < minDistanceBetweenSpaceBodies) { failedChecks = true; } } if (!failedChecks) { validPos = true; mm.SetPosition(proposedPosition); SpaceBodies.Add(mm); } yield return(WaitFor.EndOfFrame); } yield return(WaitFor.EndOfFrame); isProcessingSpaceBody = false; }
IEnumerator ProcessSpaceBody(MatrixMove mm) { if (SceneManager.GetActiveScene().name == "BoxStationV1") { minDistanceBetweenSpaceBodies = 200f; } //Change this for larger maps to avoid asteroid spawning on station. else { minDistanceBetweenSpaceBodies = 200f; } //Fills list of Vectors all along shuttle path var beginning = GameManager.Instance.PrimaryEscapeShuttle.stationTeleportLocation; var target = GameManager.Instance.PrimaryEscapeShuttle.stationDockingLocation; var distance = (int)Vector2.Distance(beginning, target); if (!EscapeShuttlePathGenerated) //Only generated once { EscapeShuttlePath.Add(beginning); //Adds original vector for (int i = 0; i < (distance / 50); i++) { beginning = Vector2.MoveTowards(beginning, target, 50); //Vector 50 distance apart from prev vector EscapeShuttlePath.Add(beginning); } EscapeShuttlePathGenerated = true; } bool validPos = false; while (!validPos) { Vector3 proposedPosition = RandomPositionInSolarSystem(); bool failedChecks = Vector3.Distance(proposedPosition, MatrixManager.Instance.spaceMatrix.transform.parent.transform.position) < minDistanceBetweenSpaceBodies; //Make sure it is away from the middle of space matrix //Checks whether position is near (100 distance) any of the shuttle path vectors foreach (var vectors in EscapeShuttlePath) { if (Vector3.Distance(proposedPosition, vectors) < 100) { failedChecks = true; } } //Checks whether the other spacebodies are near for (int i = 0; i < SpaceBodies.Count; i++) { if (Vector3.Distance(proposedPosition, SpaceBodies[i].transform.position) < minDistanceBetweenSpaceBodies) { failedChecks = true; } } if (!failedChecks) { validPos = true; mm.SetPosition(proposedPosition); SpaceBodies.Add(mm); } yield return(WaitFor.EndOfFrame); } yield return(WaitFor.EndOfFrame); isProcessingSpaceBody = false; }