Example #1
0
        public void Awake()
        {
            Debug.Log("Awake BaseCar");
            _audioService = Core.Instance.GetService <AudioService>();
            Assert.AreNotEqual(null, _audioService);

            //Auto init particles
            #region
            if (transform.Find("NitroParticles"))
            {
                var tempNtiroParticles = transform.Find("NitroParticles").GetComponentsInChildren(typeof(ParticleSystem), true);
                if (tempNtiroParticles.Length > 0)
                {
                    foreach (ParticleSystem tempPart in tempNtiroParticles)
                    {
                        nitroParticles.Add(tempPart);
                    }
                }
            }

            if (transform.Find("SmokeParticles"))
            {
                var tempSmokeParticles = transform.Find("SmokeParticles").GetComponentsInChildren(typeof(ParticleSystem), true);
                if (tempSmokeParticles.Length > 0)
                {
                    foreach (ParticleSystem tempPart in tempSmokeParticles)
                    {
                        smokeParticles.Add(tempPart);
                    }
                }
            }
            #endregion



            //Color Block
            #region
            var colorMeshsTemp = transform.GetComponentsInChildren(typeof(MeshRenderer), true);

            foreach (MeshRenderer colorMesh in colorMeshsTemp)
            {
                if (colorMesh.materials.Length > 1)
                {
                    colorMeshs.Add(colorMesh);
                }
            }


            if (colorMeshs[0].materials[0].name.Replace(" (Instance)", "") == "Car_Cuzov")
            {
                colorMat = new Material(colorMeshs[0].materials[0]);
                mainMat  = new Material(colorMeshs[0].materials[1]);
            }
            else if (colorMeshs[0].materials[1].name.Replace(" (Instance)", "") == "Car_Cuzov")
            {
                colorMat = new Material(colorMeshs[0].materials[1]);
                mainMat  = new Material(colorMeshs[0].materials[0]);
            }
            #endregion


            #region createing cardrop audio emitter

            _audioService.CreateCarDropEmitter();



            #endregion

            #region createing engine audio emitter
            _audioService.CreateCarEngineEmitter(engineEmitterName, engineParam1, engineParam2);
            #endregion

            _uiManager = Core.Instance.GetService <UIManager>();
            Assert.AreNotEqual(null, _uiManager);
            _gameWindow = _uiManager.GetWindow(UIWindowEnum.GAMEWINDOW_ASYNC) as GameWindowAsyncMultiplayer;
            Assert.AreNotEqual(null, _gameWindow);
        }