protected override void implementation_setSimulationFromLogic( ISimulatableLogic inLogicToSetFrom) { CarPhysicsLogic theLogicToSetFrom = inLogicToSetFrom as CarPhysicsLogic; if (!theLogicToSetFrom) { //TODO: Make universal though for incorrect type casts throw new Exception("Simulation object has no compitable simulatable logic"); } GameObject theGameObjectToSetFrom = theLogicToSetFrom.gameObject; //Set rigid body var theRigidBodyToSetFrom = theGameObjectToSetFrom.GetComponent <Rigidbody2D>(); _rigidBody.angularVelocity = theRigidBodyToSetFrom.angularVelocity; _rigidBody.velocity = theRigidBodyToSetFrom.velocity; //Set logic state _gasValue = theLogicToSetFrom._gasValue; _isGasWasChangedOnUpdate = theLogicToSetFrom._isGasWasChangedOnUpdate; _steeringWheelValue = theLogicToSetFrom._steeringWheelValue; _isSteeringWheelWasRotatedOnUpdate = theLogicToSetFrom._isSteeringWheelWasRotatedOnUpdate; }
void Start() { _simulationManager = Object.FindObjectOfType <SimulationManager>(); _carPhysics = gameObject.GetComponent <CarPhysicsLogic>(); }
//Methods //-Implementation private void Start() { _carPhysics = gameObject.GetComponentInChildren <CarPhysicsLogic>(); _weaponsLogic = gameObject.GetComponentsInChildren <WeaponLogic>(); }