Esempio n. 1
0
 //--Internal
 private void setSimulationFromLogic_internal(ISimulatableLogic inLogicToSetFrom)
 {
     //if (!isSimulation()) {
     //    throw new Exception("Try to setup object as simulation");
     //}
     implementation_setSimulationFromLogic(inLogicToSetFrom);
 }
Esempio n. 2
0
    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;
    }
Esempio n. 3
0
 protected abstract void implementation_setSimulationFromLogic(ISimulatableLogic inLogicToSetFrom);
Esempio n. 4
0
 public void setSimulationFrom(ISimulatableLogic inLogicToSetFrom)
 {
     setSimulationFromLogic_internal(inLogicToSetFrom);
 }
Esempio n. 5
0
 void Start()
 {
     _simulatableLogic = gameObject.GetComponent <ISimulatableLogic>();
     _simulatableLogic.initialize();
 }