public void SaveAdjustPrefs(AdjustValue valueName, float value) { if (valueName == AdjustValue.BothDamp) { PlayerPrefs.SetFloat(AdjustValue.FrontDamp.ToString(), value); PlayerPrefs.SetFloat(AdjustValue.BackDamp.ToString(), value); return; } if (valueName == AdjustValue.BothFreq) { PlayerPrefs.SetFloat(AdjustValue.FrontFreq.ToString(), value); PlayerPrefs.SetFloat(AdjustValue.BackFreq.ToString(), value); return; } PlayerPrefs.SetFloat(valueName.ToString(), value); }
public float getAdjustValue(AdjustValue valueName) { return(adjustManager.getAdjustValue(valueName)); }
public void setAdjustValue(AdjustValue valueName, float value) { adjustManager.setAdjustValue(valueName, value); }
public float getAdjustValue(AdjustValue valueName) { if (valueName == AdjustValue.Gravity) { return(Physics2D.gravity.y); } else if (valueName == AdjustValue.TireFriction) { return(GameObject.FindGameObjectWithTag("FrontTire").GetComponent <CircleCollider2D>().sharedMaterial.friction); } else if (valueName == AdjustValue.GroundFriction) { return(GameObject.FindGameObjectWithTag("GroundEditable").GetComponent <EdgeCollider2D>().sharedMaterial.friction); } else if (valueName == AdjustValue.SpeedForward) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().speedForward); } else if (valueName == AdjustValue.TorqueForward) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().torqueForward); } else if (valueName == AdjustValue.SpeedBackward) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().speedBackward); } else if (valueName == AdjustValue.TorqueBackward) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().torqueBackward); } else if (valueName == AdjustValue.SpeedFree) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().speedFree); } else if (valueName == AdjustValue.TorqueFree) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().torqueFree); } else if (valueName == AdjustValue.TyreMass) { return(GameObject.FindGameObjectWithTag("FrontTire").GetComponent <Rigidbody2D>().mass); } else if (valueName == AdjustValue.BothDamp) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <WheelJoint2D>().suspension.dampingRatio); } else if (valueName == AdjustValue.BothFreq) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <WheelJoint2D>().suspension.frequency); } else if (valueName == AdjustValue.FrontDamp) { return(GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>()[0].suspension.dampingRatio); } else if (valueName == AdjustValue.FrontFreq) { return(GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>()[0].suspension.frequency); } else if (valueName == AdjustValue.BackDamp) { return(GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>()[1].suspension.dampingRatio); } else if (valueName == AdjustValue.BackFreq) { return(GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>()[1].suspension.frequency); } else if (valueName == AdjustValue.CarBodyMass) { return(GameObject.FindGameObjectWithTag("CarController").GetComponent <Rigidbody2D>().mass); } return(0.0f); }
public void setAdjustValue(AdjustValue valueName, float value) { SaveAdjustPrefs(valueName, value); if (valueName == AdjustValue.Gravity) { Physics2D.gravity = new Vector2(0, value); } else if (valueName == AdjustValue.TireFriction) { GameObject.FindGameObjectWithTag("FrontTire").GetComponent <CircleCollider2D>().sharedMaterial.friction = value; GameObject.FindGameObjectWithTag("BackTire").GetComponent <CircleCollider2D>().sharedMaterial.friction = value; GameObject.FindGameObjectWithTag("FrontTire").GetComponent <CircleCollider2D>().sharedMaterial = GameObject.FindGameObjectWithTag("FrontTire").GetComponent <CircleCollider2D>().sharedMaterial; GameObject.FindGameObjectWithTag("BackTire").GetComponent <CircleCollider2D>().sharedMaterial = GameObject.FindGameObjectWithTag("BackTire").GetComponent <CircleCollider2D>().sharedMaterial; } else if (valueName == AdjustValue.GroundFriction) { GameObject.FindGameObjectWithTag("GroundEditable").GetComponent <EdgeCollider2D>().sharedMaterial.friction = value; GameObject.FindGameObjectWithTag("GroundEditable").GetComponent <EdgeCollider2D>().sharedMaterial = GameObject.FindGameObjectWithTag("GroundEditable").GetComponent <EdgeCollider2D>().sharedMaterial; } else if (valueName == AdjustValue.SpeedForward) { GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().speedForward = value; } else if (valueName == AdjustValue.TorqueForward) { GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().torqueForward = value; } else if (valueName == AdjustValue.SpeedBackward) { GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().speedBackward = value; } else if (valueName == AdjustValue.TorqueBackward) { GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().torqueBackward = value; } else if (valueName == AdjustValue.SpeedFree) { GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().speedFree = value; } else if (valueName == AdjustValue.TorqueFree) { GameObject.FindGameObjectWithTag("CarController").GetComponent <CarController>().torqueFree = value; } else if (valueName == AdjustValue.TyreMass) { GameObject.FindGameObjectWithTag("FrontTire").GetComponent <Rigidbody2D>().mass = value; GameObject.FindGameObjectWithTag("BackTire").GetComponent <Rigidbody2D>().mass = value; } else if (valueName == AdjustValue.BothDamp) { WheelJoint2D[] joints; JointSuspension2D suspension; joints = GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>(); foreach (WheelJoint2D joint in joints) { suspension = joint.suspension; suspension.dampingRatio = value; joint.suspension = suspension; } } else if (valueName == AdjustValue.BothFreq) { WheelJoint2D[] joints; JointSuspension2D suspension; joints = GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>(); foreach (WheelJoint2D joint in joints) { suspension = joint.suspension; suspension.frequency = value; joint.suspension = suspension; } } else if (valueName == AdjustValue.FrontDamp) { WheelJoint2D[] joints; JointSuspension2D suspension; joints = GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>(); suspension = joints[0].suspension; suspension.dampingRatio = value; joints[0].suspension = suspension; } else if (valueName == AdjustValue.FrontFreq) { WheelJoint2D[] joints; JointSuspension2D suspension; joints = GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>(); suspension = joints[0].suspension; suspension.frequency = value; joints[0].suspension = suspension; } else if (valueName == AdjustValue.BackDamp) { WheelJoint2D[] joints; JointSuspension2D suspension; joints = GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>(); suspension = joints[1].suspension; suspension.dampingRatio = value; joints[1].suspension = suspension; } else if (valueName == AdjustValue.BackFreq) { WheelJoint2D[] joints; JointSuspension2D suspension; joints = GameObject.FindGameObjectWithTag("CarController").GetComponents <WheelJoint2D>(); suspension = joints[1].suspension; suspension.frequency = value; joints[1].suspension = suspension; } else if (valueName == AdjustValue.CarBodyMass) { GameObject.FindGameObjectWithTag("CarController").GetComponent <Rigidbody2D>().mass = value; } }