//------------------------------------------------------ // Boost() // Boost function // // var // float fTimer = timesincelevelload //------------------------------------------------------ public void Boost(float v) { float m_fTimer = Time.fixedTime + m_fCooldown; var m_PlayerVelocity = Vector3.Dot(m_PlayerRB.transform.forward, Vector3.Normalize(m_PlayerRB.velocity)); // if button clicked and cooldown, add boost for duration if (Input.GetAxis("Fire2") > 0 && m_fTimer >= fCooldown) { m_PlayerRB.AddForce(m_PlayerRB.transform.forward * boostSpeed, ForceMode.Impulse); m_PlayerRB.mass = m_PlayerRB.mass * BoostMultiply; m_PlayerRB.drag = m_PlayerRB.drag * BoostMultiply; m_PlayerRB.angularDrag = m_PlayerRB.angularDrag * BoostMultiply; fCooldown = m_fTimer + m_fCooldown; m_fDuration = m_fTimer + m_fDurationDefault; m_bBoosting = true; // Boost Effect PlayerBoost.Play(); if (m_PlayerParticles != null) { m_PlayerParticles.Play(m_PlayerParticles.m_Boost); } } // if boosting = true and timer is higher then duration, then return mass drag and angular drag to default values if (m_fTimer > m_fDuration && m_bBoosting == true) { m_PlayerRB.mass = DefaultMass; m_PlayerRB.drag = DefaultDrag; m_PlayerRB.angularDrag = DefaultAngularDrag; m_bBoosting = false; } }
public void OrderSuccess(Order order) { m_PlayerParticles.Play(m_PlayerParticles.m_GainMoney); // Specific Success Stuff int nScore = int.Parse(score.text); float fQuart = m_fOrderExpiryTime / 4; float fRemaining = (Time.time - order.m_fStartTime); if (fRemaining < fQuart) { nScore += m_nReward_75; } else if (fRemaining < fQuart * 2) { nScore += m_nReward_50; } else if (fRemaining < fQuart * 3) { nScore += m_nReward_25; } else { nScore += m_nReward_00; } score.text = nScore.ToString(); if (TicketComplete) { TicketComplete.Play(); } else { Debug.LogWarning("Connect TicketComplete you knob"); } // Run Order Complete OrderComplete(order); }
// TODO: Troubleshoot Death Animation! protected override void OnTakeDamage() { if (!invulnerable && currentHealth > 0) { Debug.Log("Player has taken damage!"); currentHealth--; UpdateHealth(); if (currentHealth != 0) { PlayerParticles.Play(); StartCoroutine(RunInvincibilityFrames()); } else { Died(); } } }
// Update is called once per frame void FixedUpdate() { var pos = transform.position; pos.y = 0; transform.position = pos; if (Vector3.Distance(m_aPrevPos[0], transform.position) > 10f) { m_aPrevPos[1] = m_aPrevPos[0]; m_aPrevPos[0] = transform.position; m_aPrevPos[0].y = 0; } float fCurrentTime = Time.fixedTime; float fDeltaTime = Time.fixedDeltaTime; float fVer = Input.GetAxis("Vertical"); float fHor = Input.GetAxis("Horizontal"); // Fast Accel Vector3 v3Impulse = transform.forward * m_fAccel * fDeltaTime * fVer; Vector3 v3NewVelocity = m_PlayerRB.velocity += v3Impulse; float fMaxSpeed = m_fMaxSpeed; // Dash // IF Can dash if (fCurrentTime > m_fBoostEndTime + m_fBoostCooldown) { if (!m_bDashStarted) { if (Input.GetButton("Fire2")) { m_PlayerParticles.Play(m_PlayerParticles.m_Boost); m_bDashStarted = true; m_fBoostEndTime = fCurrentTime + m_fBoostDuration; v3NewVelocity += transform.forward * m_fBoostAccel * fDeltaTime * 60; PlayerBoost.Play(); m_DashUI.StartCharge(m_fBoostCooldown + m_fBoostDuration); } } } // IF Dashing if (m_bDashStarted) { fMaxSpeed = m_fBoostMaxSpeed; v3NewVelocity += transform.forward * m_fBoostAccel * fDeltaTime * 60; if (fCurrentTime > m_fBoostEndTime) { m_bDashStarted = false; //m_DashUI.StartCharge(m_fBoostCooldown); } } // IF Turning if (Mathf.Abs(fHor) > 0.1f) { // Quick Turn float fDot = Vector3.Dot(transform.forward, v3NewVelocity.normalized); float fMag = v3NewVelocity.magnitude; float fTurnRate = 0.0f; if (fMag < m_fMaxTurnSpeed) { fTurnRate = m_fMaxTurnRate; } else if (fMag > m_fMinTurnSpeed) { fTurnRate = m_fMinTurnRate; } else { float fLerp = (fMag - m_fMaxTurnSpeed) / (m_fMinTurnSpeed - m_fMaxTurnSpeed); fTurnRate = Mathf.Lerp(m_fMaxTurnRate, m_fMinTurnRate, fLerp); } float fSign = fDot / Mathf.Abs(fDot); float fRot = fTurnRate * fDeltaTime * fHor * fSign; if (!float.IsNaN(fRot)) { Vector3 v3Angular = m_PlayerRB.angularVelocity; v3Angular.y += fRot; m_PlayerRB.angularVelocity = v3Angular; } // Stop Turn if (fVer >= 0) { if (fMag < m_fMaxSpeed * 0.2f) { float fStopRot = 0.0f; // Turn On Spot if (m_eRotType == RotType.OnSpot) { fStopRot = m_fStopRot * fDeltaTime * fHor; } // Small fwd movement if (m_eRotType == RotType.SmallFwd) { fStopRot = m_fStopRot * fDeltaTime * fHor; v3NewVelocity += transform.forward * m_fAccel * fDeltaTime; } if (!float.IsNaN(fStopRot)) { transform.Rotate(transform.up, fStopRot); //transform.RotateAround(m_CenOfMass.position, transform.up, fStopRot); Vector3 v3Angular = m_PlayerRB.angularVelocity; v3Angular.y += fStopRot; m_PlayerRB.angularVelocity = v3Angular; } } } } float fNewDot = Vector3.Dot(transform.forward, v3NewVelocity.normalized); float fNewMag = v3NewVelocity.magnitude; Vector3 v3Fwd = transform.forward * fNewMag * fNewDot; Vector3 v3Side = v3NewVelocity - v3Fwd; v3NewVelocity = v3Fwd + (v3Side * (1 - 2 * fDeltaTime)); // Apply Movement if (v3NewVelocity.magnitude > fMaxSpeed) { v3NewVelocity = v3NewVelocity.normalized * m_fMaxSpeed; } m_PlayerRB.velocity = v3NewVelocity; // RESET if (Input.GetButtonDown("ResetPlayer")) { if (Vector3.Distance(m_aPrevPos[0], transform.position) > 5f) { transform.position = m_aPrevPos[1]; } else { transform.position = m_aPrevPos[0]; } m_PlayerRB.rotation = Quaternion.identity; } }
public bool AddFood(Food food) { var particle = m_PlayerParticles.m_PickUpBurger; switch (food.m_sFoodName) { case "Burger": particle = m_PlayerParticles.m_PickUpBurger; break; case "Chinese": particle = m_PlayerParticles.m_PickUpChinese; break; case "Sushi": particle = m_PlayerParticles.m_PickUpSushi; break; case "Doughnuts": particle = m_PlayerParticles.m_PickUpDoughnuts; break; default: Debug.LogError("Wrong particle name, " + name); break; } // IF Left food slot has default if (m_LeftFood == m_DefaultFood) { // Play Particles m_PlayerParticles.Play(particle); // Set held food to new food and return true m_LeftFood = food; m_LeftImage.texture = food.m_FoodTexture; var colorFood = m_LeftImage.color; colorFood.a = 255; m_LeftImage.color = colorFood; if (m_LeftBackImage) { var color = food.m_TicketColor; color.a = m_DefaultBackColour.a; m_LeftBackImage.color = color; } m_CollectOrder.Play(); return(true); } // IF Right food slot has default if (m_RightFood == m_DefaultFood) { // Play Particles m_PlayerParticles.Play(particle); // Set held food to new food and return true m_RightFood = food; m_RightImage.texture = food.m_FoodTexture; var colorFood = m_RightImage.color; colorFood.a = 255; m_RightImage.color = colorFood; if (m_RightBackImage) { var color = food.m_TicketColor; color.a = m_DefaultBackColour.a; m_RightBackImage.color = color; } m_CollectOrder.Play(); return(true); } // Failed to add food return false return(false); }