/// <summary> /// Enables the powerup /// </summary> protected override void EnablePowerUpEffect() { _xMassSpeed = Random.value / 100f; _yMassSpeed = Random.value / 100f; _zMassSpeed = Random.value / 100f; _backupColor = AttachedPlayer.GetComponent <Renderer>().material.color; }
/// <summary> /// Updates the powerup /// </summary> protected override void UpdatePowerUpEffect() { Vector3 centerOfMass = AttachedPlayer.GetComponent <Rigidbody>().centerOfMass; centerOfMass += new Vector3(_xMassSpeed, _yMassSpeed, _zMassSpeed); // Limits x component of center of mass and invert x component moovement if (centerOfMass.x > 0.5f) { centerOfMass = new Vector3(0.5f, centerOfMass.y, centerOfMass.z); _xMassSpeed *= -1; } else if (centerOfMass.z < -0.5f) { centerOfMass = new Vector3(-0.5f, centerOfMass.y, centerOfMass.z); _xMassSpeed *= -1; } // Limits y component of center of mass if (centerOfMass.y > 0.5f) { centerOfMass = new Vector3(centerOfMass.x, 0.5f, centerOfMass.z); _yMassSpeed *= -1; } else if (centerOfMass.y < -0.5f) { centerOfMass = new Vector3(centerOfMass.x, -0.5f, centerOfMass.z); _yMassSpeed *= -1; } // Limits z component of center of mass if (centerOfMass.z > 0.5f) { centerOfMass = new Vector3(centerOfMass.x, centerOfMass.y, 0.5f); _zMassSpeed *= -1; } else if (centerOfMass.z < -0.5f) { centerOfMass = new Vector3(centerOfMass.x, centerOfMass.y, -0.5f); _zMassSpeed *= -1; } AttachedPlayer.GetComponent <Rigidbody>().centerOfMass = centerOfMass; Vector3 color = centerOfMass + new Vector3(0.5f, 0.5f, 0.5f); AttachedPlayer.GetComponent <Renderer>().material.color = new Color(color.x, color.y, color.z); }
/// <summary> /// /// </summary> protected override void UpdatePowerUpEffect() { AttachedPlayer.GetComponent <Renderer>().material.color = new Color(Random.value, Random.value, Random.value); }
/// <summary> /// Disables the powerup /// </summary> protected override void DisablePowerUpEffect() { AttachedPlayer.GetComponent <Renderer>().material.color = backupColor; }
/// <summary> /// Disables the powerup /// </summary> protected override void DisablePowerUpEffect() { AttachedPlayer.GetComponent <Rigidbody>().centerOfMass = Vector3.zero; AttachedPlayer.GetComponent <Renderer>().material.color = _backupColor; }
/// <summary> /// Disables the power up effect /// </summary> protected override void DisablePowerUpEffect() { AttachedPlayer.GetComponent <Rigidbody>().mass -= 1; }