Esempio n. 1
0
        public void Awake()
        {
            m_tank = this.GetParent <Tank>();
            wheels = m_tank.GameObject.FindComponentInChildren <Transform>("wheels");

            tracks = m_tank.GameObject.FindComponentInChildren <Transform>("tracks");

            motorAudioSource = m_tank.GameObject.GetComponent <AudioSource>();

            if (this.motorAudioSource == null)
            {
                motorAudioSource = m_tank.GameObject.AddComponent <AudioSource>();
            }

            motorAudioSource.playOnAwake = false;

            motorAudioSource.spatialBlend = 1;

            motorAudioSource.volume = GameSettingInfo.AudioVolume();

            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"Unit.unity3d");
            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");

            Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"Unit.unity3d");
            motorClip = bundleGameObject.Get <AudioClip>("motor");

            this.motorAudioSource.loop = true;

            this.motorAudioSource.clip = this.motorClip;

            axleInfos = new List <AxleInfo>(2);

            // 前轮
            AxleInfo axleInfo = new AxleInfo();

            axleInfo.leftWheel  = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL1");
            axleInfo.rightWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR1");
            axleInfo.montor     = false;
            axleInfo.steering   = true;
            this.axleInfos.Add(axleInfo);
            axleInfo            = new AxleInfo();
            axleInfo.leftWheel  = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL2");
            axleInfo.rightWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR2");
            axleInfo.montor     = true;
            axleInfo.steering   = false;
            this.axleInfos.Add(axleInfo);
        }
        private void InitPhysical()
        {
            wheels = m_tank.FindComponentInChildren <Transform>("wheels");

            tracks = m_tank.FindComponentInChildren <Transform>("tracks");


            motorAudioSource = m_tank.GetComponent <AudioSource>();
            if (motorAudioSource == null)
            {
                motorAudioSource = m_tank.AddComponent <AudioSource>();
            }


            motorAudioSource.spatialBlend = 1;

            motorAudioSource.volume = GameSettingInfo.AudioVolume();

            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            //Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"Unit.unity3d");
            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit);

            //Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"Unit.unity3d");
            motorClip = bundleGameObject.Get <AudioClip>("motor");

            motorAudioSource.loop = true;

            motorAudioSource.clip = this.motorClip;

            axleInfos = new List <AxleInfo>(2);

            // 前轮 转向轮
            AxleInfo axleInfo = new AxleInfo();

            axleInfo.leftWheel  = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL1");
            axleInfo.rightWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR1");
            axleInfo.montor     = false;
            axleInfo.steering   = true;
            this.axleInfos.Add(axleInfo);
            // 后轮 动力轮
            axleInfo            = new AxleInfo();
            axleInfo.leftWheel  = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL2");
            axleInfo.rightWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR2");
            axleInfo.montor     = true;
            axleInfo.steering   = false;
            this.axleInfos.Add(axleInfo);
        }
        public static GameObject Create(Vector3 pos)
        {
            // 创建爆炸效果

            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            //resourcesComponent.LoadBundle(AssetBundleName.Unit);

            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit);

            //resourcesComponent.UnloadBundle(AssetBundleName.Unit);

            GameObject explosion = bundleGameObject.Get <GameObject>(PrefabName.BulletBoomEffect);

            GameObject explosionGameObject = resourcesComponent.NewObj(PrefabType.BulletBoom, explosion);

            explosionGameObject.SetActive(false);

            explosionGameObject.transform.position = pos;


            // 创建爆炸音效

            AudioClip audio = bundleGameObject.Get <AudioClip>(PrefabName.BulletBoomAudio);

            AudioSource audioSource = explosionGameObject.GetComponent <AudioSource>();

            if (audioSource == null)
            {
                audioSource = explosionGameObject.AddComponent <AudioSource>();
                audioSource.spatialBlend = 1;
                audioSource.loop         = false;
                audioSource.clip         = audio;
                audioSource.playOnAwake  = true;
                audioSource.volume       = GameSettingInfo.AudioVolume();
            }


            explosionGameObject.SetActive(true);



            FairyGUI.Timers.inst.Add(7f, 1, (_) => { resourcesComponent.RecycleObj(PrefabType.BulletBoom, explosionGameObject); });

            return(explosionGameObject);
        }
Esempio n. 4
0
        private void GameSetting()
        {
            this.m_name.visible = GameSettingInfo.NameVisible();

            this.m_uiPanel.ui.GetChild("bloodGroup").visible = GameSettingInfo.HpVisible();
        }