Beispiel #1
0
        public UnityCar CreateCar(IGame game, ICar car, Vector3 pos, Vector3 scale)
        {
            GameObject carGo = Instantiate(CarPrefab, pos, Quaternion.identity);

            UnityCar unityCar = carGo.GetComponent <UnityCar>();

            unityCar.transform.localScale = scale;
            unityCar.Init(game, car.GetMoveSpeedProvider(), car.GetRotateSpeedProvider(), car.GetAcceleration(), car.GetSurfaceInfo());

#if UNITY_STANDALONE
            PlayerPCInput input = unityCar.gameObject.AddComponent <PlayerPCInput>();
            input.Init(unityCar, game);
#elif UNITY_ANDROID || UNITY_IOS
            GameObject        inputObj    = Instantiate(PlayerMobileInput);
            PlayerMobileInput mobileInput = inputObj.GetComponent <PlayerMobileInput>();
            mobileInput.Init(unityCar, game);
#endif

            CameraFollow cameraFollow = unityCar.gameObject.AddComponent <CameraFollow>();
            cameraFollow.Init(Camera.main, unityCar.gameObject, car);

            GameObject   hudGo        = Instantiate(HUDPrefab);
            UIController uIController = hudGo.GetComponent <UIController>();
            uIController.Init(car);

            return(unityCar);
        }
 public void Init(UnityCar carObj, IGame game)
 {
     m_CarObj = carObj;
     m_Game   = game;
 }