Exemplo n.º 1
0
        // Set the static arcadeConfiguration property and update the properties that can be changed in the editor.
        public void SetArcadeConfiguration(ArcadeConfiguration arcadeConfiguration)
        {
            descriptiveName = arcadeConfiguration.descriptiveName;
            id = arcadeConfiguration.id;
            System.Enum.TryParse(arcadeConfiguration.arcadeType, true, out arcadeType);
            System.Enum.TryParse(arcadeConfiguration.gameLauncherMethod, true, out gameLauncherMethod);
            externalModels = arcadeConfiguration.externalModels;
            showFPS        = arcadeConfiguration.showFPS;

            // TODO: Transforms setup not here
            arcadeControl.transform.position      = arcadeConfiguration.camera.position;
            arcadeControl.transform.rotation      = Quaternion.identity;
            arcadeControl.transform.localRotation = Quaternion.identity;
            arcadeControl.transform.GetChild(0).transform.rotation      = Quaternion.identity;
            arcadeControl.transform.GetChild(0).transform.localRotation = arcadeConfiguration.camera.rotation;
            arcadeControl.transform.GetChild(0).transform.position      = Vector3.zero;
            arcadeControl.transform.GetChild(0).transform.localPosition = new Vector3(0, arcadeConfiguration.camera.height, 0);
            RigidbodyFirstPersonController rigidbodyFirstPersonController = arcadeControl.GetComponent <RigidbodyFirstPersonController>();

            if (rigidbodyFirstPersonController != null)
            {
                rigidbodyFirstPersonController.Setup();
            }
            fpsArcadeProperties   = arcadeConfiguration.fpsArcadeProperties;
            cylArcadeProperties   = arcadeConfiguration.cylArcadeProperties;
            modelSharedProperties = arcadeConfiguration.modelSharedProperties;
            zones = arcadeConfiguration.zones;
            UnityEngine.RenderSettings.ambientIntensity = modelSharedProperties.renderSettings.ambientIntensity; // TODO: not here

            ArcadeManager.arcadeConfiguration = arcadeConfiguration;
        }
Exemplo n.º 2
0
        private void ActionGetArtworkFromSelectedModel(GameObject targetObjectParent)
        {
            if (ArcadeStateManager.selectedModelSetup == null || !(Application.isPlaying) || !(targetObjectParent.activeSelf))
            {
                return;
            }
            ModelProperties       modelProperties       = ArcadeStateManager.selectedModelSetup.GetModelProperties();
            ModelSharedProperties modelSharedProperties = ArcadeStateManager.selectedModelSetup.modelSharedProperties;
            ModelSetup            objModelSetup         = targetObjectParent.GetComponent <ModelSetup>();

            if (objModelSetup != null)
            {
                targetObjectParent.tag = "gamemodel";
                objModelSetup.Setup(modelProperties, modelSharedProperties);
            }
        }
Exemplo n.º 3
0
        private void SetupVideo(GameObject child, List <Texture2D> textureList, string url, ModelComponentType modelComponentType, ModelSharedProperties modelSharedProperties)
        {
            var modelVideoSetup = child.GetComponent <ModelVideoSetup>();

            if (modelVideoSetup == null)
            {
                modelVideoSetup = child.AddComponent <ModelVideoSetup>();
            }
            var video  = child.GetComponent <UnityEngine.Video.VideoPlayer>();
            var taudio = child.GetComponent <UnityEngine.AudioSource>();

            if (taudio == null && modelSharedProperties.spatialSound == true)
            {
                if (url != null)
                {
                    taudio              = child.AddComponent <UnityEngine.AudioSource>();
                    taudio.playOnAwake  = false;
                    taudio.spatialBlend = 1;
                    taudio.spatialize   = true;
                    taudio.minDistance  = 1;
                    taudio.maxDistance  = 20;
                    taudio.enabled      = false;
                }
            }
            if (video == null)
            {
                if (url != null)
                {
                    video = child.AddComponent <UnityEngine.Video.VideoPlayer>();
                }
            }
            else
            {
                if (url == null)
                {
                    if (Application.isPlaying)
                    {
                        Destroy(video);
                    }
                    else
                    {
                        DestroyImmediate(video);
                    }
                }
            }
            if (video != null)
            {
                video.Pause();
                if (modelSharedProperties.spatialSound)
                {
                    video.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource;
                    video.SetTargetAudioSource(0, taudio);
                }
                video.enabled = false;
            }
            if (modelVideoSetup != null)
            {
                modelVideoSetup.Setup(textureList, url, animatedTextureSpeed, modelComponentType, GetModelProperties(), modelSharedProperties);
            }
        }
Exemplo n.º 4
0
        public void Setup(ModelProperties modelProperties, ModelSharedProperties modelSharedProperties)
        {
            this.modelSharedProperties = modelSharedProperties;
            SetModelProperties(modelProperties);

            List <GameObject> thisChildren = new List <GameObject>();

            if (!Application.isPlaying)
            {
                foreach (Transform child in transform)
                {
                    if (child.gameObject != null)
                    {
                        thisChildren.Add(child.gameObject);
                    }
                }
            }
            else
            {
                thisChildren = new List <GameObject>();
                transform.GetChild(0).transform.tag = transform.tag;
                foreach (Transform child in transform.GetChild(0).transform)
                {
                    if (child.gameObject != null)
                    {
                        thisChildren.Add(child.gameObject);
                    }
                }
            }

            List <EmulatorConfiguration> emulatorList = new List <EmulatorConfiguration>();

            emulatorList = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.id == emulator).ToList();
            if (emulatorList.Count < 1)
            {
                return;
            }

            EmulatorProperties emulatorSelected = emulatorList[0].emulator;

            if (emulatorSelected == null)
            {
                return;
            }

            // TODO: setup some default paths for marquees, screenshots and generics.

            // Marquee setup
            if (thisChildren.Count > 0)
            {
                Texture2D        tex         = null;
                List <Texture2D> textureList = new List <Texture2D>();
                string           url         = null;
                // image and image cylcing (cycling with id_*.ext)
                textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), id);
                if (textureList.Count < 1)
                {
                    textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), idParent);
                }
                // video
                url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), id);
                if (url == null)
                {
                    url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), idParent);
                }
                // if we only have one or zero images we dont have to setup videoplayer/image cycling
                if (url == null && textureList.Count <= 1)
                {
                    var marquee = thisChildren[0].GetComponent <ModelImageSetup>();
                    if (marquee == null)
                    {
                        marquee = thisChildren[0].AddComponent <ModelImageSetup>();
                    }
                    if (textureList.Count > 0)
                    {
                        tex = textureList[0];
                    }
                    marquee.Setup(tex, modelSharedProperties.renderSettings, modelProperties, (gameObject.CompareTag("gamemodel") || gameObject.CompareTag("propmodel") ? ModelComponentType.Marquee : ModelComponentType.Generic));
                }
                else
                {
                    SetupVideo(thisChildren[0], textureList, url, (gameObject.CompareTag("gamemodel") || gameObject.CompareTag("propmodel") ? ModelComponentType.Marquee : ModelComponentType.Generic), modelSharedProperties);
                }
            }

            // Screen setup
            if (thisChildren.Count > 1)
            {
                List <Texture2D> textureList = new List <Texture2D>();
                string           url         = null;
                // image and image cycling (cycling with id_*.ext)
                textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), id);
                if (textureList.Count < 1)
                {
                    textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), idParent);
                }
                if (textureList.Count <= 1)
                {
                    var tList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.titlePath), id);
                    if (tList.Count < 1)
                    {
                        tList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.titlePath), idParent);
                    }
                    if (tList.Count > 0)
                    {
                        textureList.AddRange(tList);
                    }
                }
                // video
                url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), id);
                if (url == null)
                {
                    url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), idParent);
                }
                if (url == null)
                {
                    url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenVideoPath), id);
                }
                if (url == null)
                {
                    url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenVideoPath), idParent);
                }
                SetupVideo(thisChildren[1], textureList, url, ModelComponentType.Screen, modelSharedProperties);
            }

            // Generic Texture setup
            if (thisChildren.Count > 2)
            {
                List <Texture2D> textureList = new List <Texture2D>();
                string           url         = null;
                // image and image cycling (cycling with id_*.ext)
                textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), id);
                if (textureList.Count < 1)
                {
                    textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), idParent);
                }
                // video
                url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), id);
                if (url == null)
                {
                    url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), idParent);
                }
                // if we only have one or zero images we dont have to setup videoplayer/image cycling
                if (url == null && textureList.Count == 1)
                {
                    var generic = thisChildren[2].GetComponent <ModelImageSetup>();
                    if (generic == null)
                    {
                        generic = thisChildren[2].AddComponent <ModelImageSetup>();
                    }
                    var tex = textureList[0];
                    generic.Setup(tex, modelSharedProperties.renderSettings, modelProperties, ModelComponentType.Generic);
                }
                else if (url != null || textureList.Count > 1)
                {
                    SetupVideo(thisChildren[2], textureList, url, ModelComponentType.Generic, modelSharedProperties);
                }
            }
        }
Exemplo n.º 5
0
        public void Setup(List <Texture2D> textureList, string videoURL, float?animatedTextureSpeed, ModelComponentType modelComponentType, ModelProperties modelProperties, ModelSharedProperties modelSharedProperties)
        {
            //Debug.Log("videosetup " + gameObject.transform.parent.name + " imagecount " + textureList.Count + " " + videoURL + " " + (videoPlayer == null));

            this.modelProperties       = modelProperties;
            this.modelComponentType    = modelComponentType;
            this.imageList             = null;
            this.modelSharedProperties = modelSharedProperties;
            this.dummyNode             = gameObject.transform.parent.transform.parent.gameObject;

            string layer = LayerMask.LayerToName(gameObject.layer);

            if (layer.StartsWith("Arcade"))
            {
                layerMask   = LayerMask.GetMask("Arcade/ArcadeModels", "Arcade/GameModels", "Arcade/PropModels");
                thisCamera  = ArcadeManager.arcadeCameras[ArcadeType.FpsArcade];
                arcadeLayer = true;
            }
            else
            {
                layerMask   = LayerMask.GetMask("Menu/ArcadeModels", "Menu/GameModels", "Menu/PropModels");
                thisCamera  = ArcadeManager.arcadeCameras[ArcadeType.CylMenu];
                arcadeLayer = false;
            }

            if (ArcadeManager.arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || ArcadeManager.arcadeConfiguration.arcadeType == ArcadeType.FpsMenu.ToString())
            {
                isCylArcade = false;
                maxDistance = 5f;
            }
            else
            {
                isCylArcade = true;
                maxDistance = 10000f;
            }

            // Setup image, nescessary for magic pixels and to get an unique material instance.
            Texture2D tex = null;

            if (textureList.Count > 0)
            {
                tex = textureList[0];
            }
            ModelImageSetup modelImageSetup = GetComponent <ModelImageSetup>();

            if (modelImageSetup == null)
            {
                modelImageSetup = gameObject.AddComponent <ModelImageSetup>();
            }
            modelImageSetup.Setup(tex, modelSharedProperties.renderSettings, modelProperties, modelComponentType);

            if (videoURL != null && videoPlayer == null)
            {
                videoPlayer = gameObject.GetComponent <UnityEngine.Video.VideoPlayer>();
            }
            if (animatedTextureSpeed != null)
            {
                waitTime = animatedTextureSpeed.Value;
            }
            videoEnabled = (ModelVideoEnabled)System.Enum.Parse(typeof(ModelVideoEnabled), modelSharedProperties.videoOnModelEnabled);
            if (videoURL == null)
            {
                videoEnabled = ModelVideoEnabled.Never;
            }
            else
            {
                if (videoPlayer != null && videoEnabled != ModelVideoEnabled.Never)
                {
                    videoPlayer.SetDirectAudioMute(0, true);
                    videoPlayer.enabled = true;
                    videoPlayer.url     = videoURL;
                }
            }
            if (textureList.Count > 0)
            {
                imageList = textureList;
                if (renderer != null)
                {
                    renderer.material.mainTexture = textureList[0];
                }
            }
            else
            {
                if (renderer != null && transform.parent.CompareTag("gamemodel") && modelComponentType == ModelComponentType.Screen)
                {
                    renderer.material.mainTexture = Texture2D.blackTexture;
                }
            }
            if (renderer != null && (textureList.Count > 0 || videoEnabled != ModelVideoEnabled.Never))
            {
                SetupVideoPlayer();
            }
        }