private void Start() { comboManager = GetComponent <ComboManager>(); trickManager = GetComponent <TrickManager>(); trickManager_Mobile = GetComponent <TrickManager_Mobile>(); animator = GetComponentInChildren <Animator>(); }
void DoBehaviour(RaycastHit hit) { if (!m_leavingGround) { // If the player is facing away from its movement vector, change to switch. Otherwise, they are in the regular stance float fwdVelDot = Vector3.Dot(transform.forward, m_rb.velocity); if (m_switch && fwdVelDot > 0) { m_switch = false; TrickManager.GetInstance().WriteToStanceTextBox("Regular"); } else if (!m_switch && fwdVelDot < 0) { m_switch = true; TrickManager.GetInstance().WriteToStanceTextBox("Switch"); } // Find the vector in front of the player or under the player that best suits m_moveDir = (m_switch) ? -transform.forward : transform.forward; // Find the degree to which the curent terrain and the previous differ Vector3 lastUp = m_currentUp; float transitionAngle = Vector3.Angle(lastUp, hit.normal); // If that angle is too high, stop sticking to the ground and instead, leave the ground. if (transitionAngle >= m_maxAdhesionDelta) { LeaveGround(); } SetGroundedData(hit); } }
public CobraFlip(Plane plane, PlaneMovement planeMovement, TrickManager trickManager) : base(plane, planeMovement, trickManager) { trickScoreMultiplier = 1.5f; finishTimerTime = 4; cooldown = 3f; }
public static TrickManager GetInstance() { if (instance == null) { instance = new TrickManager(); } return(instance); }
/// <summary> /// Update the player's controller /// </summary> public void UpdatePlayer() { SetPlayerUp(); UpdateRotation(); UpdateCamera(); //DebugDropIn(); TrickManager.GetInstance().WriteToSpeedTextBox(m_rb.velocity.magnitude + ""); }
private void Awake() { if (_instance == null) { _instance = this; } else if (_instance != null) { Destroy(this); } }
/// <summary> /// Make the player jump /// </summary> public void Jump() { if (m_touchingGround) { m_rb.velocity += Vector3.up * m_jumpAmount; } m_grinding = false; LeaveGround(); TrickManager.GetInstance().WriteToTrickTextBox("Ollie"); }
public void DeleteSaveData() { if (File.Exists(Application.persistentDataPath + savefile)) { File.Delete(Application.persistentDataPath + savefile); } if (File.Exists(Application.persistentDataPath + "gamemanager_trapeze.save")) { File.Delete(Application.persistentDataPath + "gamemanager_trapeze.save"); } TutorialManager.DeleteSaveData(); TrickManager.DeleteSaveData(); }
protected void DoAtStart() { gm = GameManager_Trapeze.GetInstance(); InitRBs(); if (!facingRight) { facingRight = true; TurnAround(); } AttachTo(attachedTo); lowerLegsRB.AddForce(10 * Vector2.right, ForceMode2D.Impulse); tm = TrickManager.GetInstance(); animator.enabled = false; //TurnAround(); }
private void FixedUpdate() { float rollInput = inputMaster.Player.Roll.ReadValue <float>(); float pitchInput = inputMaster.Player.Pitch.ReadValue <float>(); float yawnInput = inputMaster.Player.Yawn.ReadValue <float>(); PlaneMovement.PitchInput(pitchInput); PlaneMovement.RollInput(rollInput); PlaneMovement.YawnInput(yawnInput); PlaneMovement.ThrustInput(inputMaster.Player.Thrust.ReadValue <float>()); PlaneMovement.Movement(); TrickManager.TickTricks(); PlaneAnimatorFacade.SetPitch(pitchInput); PlaneAnimatorFacade.SetRoll(rollInput); PlaneAnimatorFacade.SetYawn(yawnInput); }
// Start is called before the first frame update void Start() { switch (m_boxType) { case (BoxType.Tricks): TrickManager.GetInstance().SetTrickBox(m_textBox); break; case (BoxType.Stance): TrickManager.GetInstance().SetStanceBox(m_textBox); break; case (BoxType.Speed): TrickManager.GetInstance().SetSpeedBox(m_textBox); break; } }
private void InitComponents() { if (rbd == null) { rbd = GetComponent <Rigidbody>(); } if (animator == null) { animator = GetComponentInChildren <Animator>(); } PlaneMovement = new PlaneMovement(this, rbd, stats, transform); TrickManager = new TrickManager(levelManager, this); PlaneMovement.PostConstruct(); PlaneAnimatorFacade = new PlaneAnimatorFacade(animator); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } //DeleteSaveData(); LoadSaveData(); foreach (Trick t in tricks) { tricktionary.Add(t.code, t); } currentSwipe = new List <SwipeDirection>(); }
/// <summary> /// Drop into a bank or other sufficiently sloped surface /// </summary> public bool DropIn() { if (!m_droppingIn && !m_touchingGround && m_rb.velocity.y > 0.5f) { bool rampFound = false; float spacing = 0.5f; int numOfRaysToCast = 30; // Pick the best direction to look for a slope Vector3 bestVector; float angleDelta = Vector3.Angle(m_currentUp, Vector3.up); if (angleDelta <= 45) { bestVector = m_moveDir; } else { bestVector = -transform.up; } // Make the vector only use X and Z, then normalize bestVector.y = 0; bestVector.Normalize(); // Perform a series of raycasts in front of the player for (int i = 1; i <= numOfRaysToCast; i++) { if (!rampFound) { if (Physics.Raycast(transform.position + (bestVector * spacing * i), Vector3.down, out RaycastHit hit)) { rampFound = TryDropinLocation(hit); if (rampFound) { TrickManager.GetInstance().WriteToTrickTextBox("Transfer"); return(true); } } } } } return(false); }
public void DetectDuoTrick(string number, string trickName, string nextNode, string wrongNode) { if (detecting) { return; } detecting = true; SetTarget("player"); if (targetManager == null) { return; } numDetected = 0; targetNum = int.Parse(number); successNode = nextNode; failNode = wrongNode; targetTrick = trickName; TrickManager.GetInstance().OnDuoTrick += this.InvokeDuoTrickDetected; }
private void DuoTrickDetected() { if (!detecting) { return; } if (targetManager.GetLastTrickPerformed().Equals(targetTrick)) { numDetected++; if (numDetected >= targetNum) { TrickManager.GetInstance().OnDuoTrick -= this.InvokeDuoTrickDetected; string s = successNode; ResetVars(); dialogueRunner.StartDialogue(s); } } else { dialogueRunner.StartDialogue(failNode); } }
public DriftTrick(Plane plane, PlaneMovement planeMovement, TrickManager trickManager) : base(plane, planeMovement, trickManager) { }
protected ATrick(Plane plane, PlaneMovement planeMovement, TrickManager trickManager) { this.plane = plane; this.planeMovement = planeMovement; this.trickManager = trickManager; }
public BarrelRoll(Plane plane, PlaneMovement planeMovement, TrickManager trickManager) : base(plane, planeMovement, trickManager) { trickScoreMultiplier = 3f; }
public void Grind() { float sphereRad = 2f; // Perform a spherecast. If anything the cast touches has a rail, add it to a list of possible rails. Collider[] hitColliders = Physics.OverlapSphere(transform.position, sphereRad); if (hitColliders.Length > 0) { // Look through the list of rails and find the spline that is closest to the player. List <RailData> rails = new List <RailData>(); foreach (var c in hitColliders) { Transform parent = c.transform; while (parent != null) { RailData railData = parent.GetComponent <RailData>(); if (railData) { bool sameRail = false; foreach (var rail in rails) { if (rail == railData) { sameRail = true; break; } } if (!sameRail) { rails.Add(railData); } break; } else { parent = parent.parent; } } } if (rails.Count > 0) { // Default to the first rail BGCcMath closestRail = rails[0].m_railData[0]; float closestDist = Vector3.Distance(transform.position, rails[0].m_railData[0].CalcPositionByClosestPoint(transform.position)); foreach (var rail in rails) { foreach (var r in rail.m_railData) { // Find the coping that is nearest to the player float newClosestDist = Vector3.Distance(transform.position, r.CalcPositionByClosestPoint(transform.position)); if (newClosestDist < closestDist) { closestRail = r; closestDist = newClosestDist; } } } if (closestDist <= sphereRad) { // If the player is facing away from its movement vector, change to switch. Otherwise, they are in the regular stance float fwdVelDot = Vector3.Dot(transform.forward, m_rb.velocity); if (m_switch && fwdVelDot > 0) { m_switch = false; TrickManager.GetInstance().WriteToStanceTextBox("Regular"); } else if (!m_switch && fwdVelDot < 0) { m_switch = true; TrickManager.GetInstance().WriteToStanceTextBox("Switch"); } // Find the vector in front of the player or under the player that best suits m_moveDir = (m_switch) ? -transform.forward : transform.forward; m_currentRail = closestRail; m_grinding = true; } } } }
public void UpdateHighSpeed(bool highSpeed) { TrickManager.SetHighSpeed(highSpeed); }