private IEnumerator TutorialStartOverTime(GameObject display) { // Start a 'fake' game so all the other components think we're playing gameInProgress = true; currentSession = new GameplaySession(Time.time, Settings.FuelOnStartup); // Turn off the lander physics so we don't fly about LanderPhysics.Instance.UseGravity = false; LanderPhysics.Instance.ApplyPhysics = false; LanderProximity.Instance.DetectObstacles = false; LanderEffects.Instance.EmitTrail = false; LanderEffects.Instance.ShowGyro = false; LanderEffects.Instance.ShowLander(); LanderInput.Instance.ThrottleVisibility = LanderInput.ThrottleVisibilityEnum.Hidden; // Let everyone know gameplay has started OnGameplayStarted(); // Wait for the tutorial to finish while (display.gameObject.activeSelf) { yield return(null); } // End fake gameplay gameInProgress = false; LanderInput.Instance.ThrottleVisibility = LanderInput.ThrottleVisibilityEnum.Hidden; // Hide lander LanderEffects.Instance.HideLander(); yield break; }
// Background coroutine which sets up a session public IEnumerator SetSession_coroutine() { WWWForm form = new WWWForm(); form.AddField("gameID", this.gameID); WWW www = new WWW(SetSessionIDURL, form); yield return(www); Session = new GameplaySession(int.Parse(www.text), this.gameID); SessionSet = true; //Flags that session is now running int condition; /* * Randomly allocate participants a condition */ if (NumberOfConditions > 0) { condition = UnityEngine.Random.Range(0, NumberOfConditions); } else { condition = 0; } // Records the condition that the participant is in Analytics.LogWithTimestamp("Condition", "" + condition); }
/* * This code is relevant if you are logging local data */ public void SetLocalSession() { /* * Define and record session parameters for logging to local logs */ string localSessionLocation = "Logs/LastSession.txt"; int sessionID = 0; if (File.Exists(localSessionLocation)) { string s = File.ReadAllText(localSessionLocation); File.Delete(localSessionLocation); sessionID = int.Parse(s); sessionID += 1; } File.WriteAllText(localSessionLocation, sessionID + ""); Session = new GameplaySession(sessionID, 0); SessionSet = true; //Flags that session is now running int condition; if (NumberOfConditions > 0) { condition = UnityEngine.Random.Range(0, NumberOfConditions); } else { condition = 0; } Analytics.Get().Session.AddInfo("Condition", "" + condition); }
private IEnumerator GameStartOverTime() { currentSession = new GameplaySession(Time.time, Settings.FuelOnStartup); // Set up our lander for entry LanderEffects.Instance.ShowGyro = false; LanderEffects.Instance.EmitTrail = false; // Move the lander into position above the landing pad Vector3 landingPadPosition = LandingPadManager.Instance.LandingPad.transform.position; Vector3 landerStartPosition = LandingPadManager.Instance.LanderStartupPosition; // Get a random position around the room that doesn't collide with the walls /*bool foundRandomPosition = false; * Vector3 landerStartPosition = Vector3.zero; * while (!foundRandomPosition) { * Vector3 randomPosition = (UnityEngine.Random.onUnitSphere * Settings.StartDistanceFromPad); * randomPosition.y = Mathf.Abs(randomPosition.y) + Settings.MinStartAltitude; * landerStartPosition = landingPadPosition + randomPosition; * * // If the position is too close to player, skip this position * if (Vector3.Distance(landerStartPosition, Veil.Instance.HeadTransform.position) < Settings.MinDistanceFromPlayer) { * yield return null; * continue; * } * * // If the position is behind the player, skip this position * Vector3 dir = landerStartPosition - Veil.Instance.HeadTransform.position; * dir.y = 0f; * Vector3 forward = Veil.Instance.HeadTransform.forward; * forward.y = 0f; * * dir.Normalize(); * forward.Normalize(); * * // If the position is behind the player, continue * if (Vector3.Dot(dir, forward) < 0.5) { * yield return null; * continue; * } * * // Make sure the lander doesn't intersect with any room stuff * Collider[] colliders = Physics.OverlapSphere(landerStartPosition, Settings.PlacementCheckRadius, 1 << EnvironmentManager.RoomSurfaceLayer, QueryTriggerInteraction.Ignore); * if (colliders.Length == 0) { * foundRandomPosition = true; * } * yield return null; * }*/ // Turn on our effects for entry LanderEffects.Instance.ForceThrust = true; LanderEffects.Instance.ShowLander(); LanderAudio.Instance.ForceThrustVolume = 1f; LanderInput.Instance.SetForward(Vector3.forward); LanderInput.Instance.ResetInput(); GameplayMessage.Instance.DisplayMessage("Module Incoming..."); // Get the lander into position with the opening animation LanderOpening.Instance.DoLanderOpening(landerStartPosition); while (!LanderOpening.Instance.InPosition) { yield return(null); } yield return(new WaitForSeconds(0.25f)); // Set everything up for user-controlled motion LanderEffects.Instance.ShowGyro = true; LanderEffects.Instance.ForceThrust = false; LanderEffects.Instance.EmitTrail = true; LanderPhysics.Instance.LanderPosition = landerStartPosition; LanderPhysics.Instance.UseGravity = true; LanderPhysics.Instance.ApplyPhysics = true; LanderProximity.Instance.DetectObstacles = true; LanderInput.Instance.ApplyInput = true; LanderAudio.Instance.ForceThrustVolume = 0f; LanderInput.Instance.ThrottleVisibility = LanderInput.ThrottleVisibilityEnum.Normal; positionLastFrame = landerStartPosition; GameplayMessage.Instance.DisplayMessage("Begin!"); // Start the game gameInProgress = true; // Let everyone know gameplay has started OnGameplayStarted(); yield break; }
public void Reset() { currentSession = new GameplaySession(Time.time, 1); }