private static List<ModelProperties> GetGamelistFromGamePath(string filePath, EmulatorProperties emulatorProperties, UnityEngine.UI.Slider slider = null) { string emulatorExtension = emulatorProperties.extension; string emulatorID = emulatorProperties.id; if (!emulatorExtension.Contains(".") && emulatorExtension != "") { emulatorExtension = "." + emulatorExtension; } if (emulatorExtension == "") { emulatorExtension = "*.*"; } var files = FileManager.FilesFromDirectory(filePath, emulatorExtension); if (files != null) { List<ModelProperties> gamelist = new List<ModelProperties>(); foreach (FileInfo file in files) { string fileName = Path.GetFileNameWithoutExtension(file.FullName); ModelProperties model = new ModelProperties(); model.descriptiveName = fileName; model.id = fileName; model.idParent = ""; model.emulator = emulatorID.Replace(" ", String.Empty).ToLower(); //model.animationType = "Never"; model.animatedTextureSpeed = 2.0f; gamelist.Add(model); } if (gamelist.Count > 0) { return gamelist; } } return null; }
public void SetModelProperties(ModelProperties modelProperties) { descriptiveName.text = modelProperties.descriptiveName; id.text = modelProperties.id; idParent.text = modelProperties.idParent; SetupDropDownList(gameLauncherMethod, Enum.GetNames(typeof(GameLauncherMethod)).ToList()); gameLauncherMethod.value = gameLauncherMethod.options.FindIndex(option => option.text == modelProperties.gameLauncherMethod); gameLauncherMethod.RefreshShownValue(); var availableModels = ArcadeManager.availableModels.game; if (availableModels.Count > 0 && availableModels[0] != "none") { availableModels.Insert(0, "none"); } SetupDropDownList(model, availableModels); //print("id " + id.text + " parent " + idParent.text); var index = 0; if (modelProperties.model != "" && modelProperties.model != "none") { index = availableModels.FindIndex(x => x == modelProperties.model); if (index == -1) { index = 0; } } model.value = index; model.RefreshShownValue(); currentModel = modelProperties; currentModel.model = model.options[model.value].text; //print("currentset " + currentModel.emulator); }
public ModelProperties GetModelProperties() { var modelProperties = new ModelProperties(); modelProperties.descriptiveName = descriptiveName; modelProperties.id = id; modelProperties.idParent = idParent; modelProperties.emulator = emulator; modelProperties.model = model; //modelProperties.animationType = animationType.ToString(); modelProperties.grabbable = grabbable; //modelProperties.lightmap = lightmap; //modelProperties.animatedTextureSequence = animatedTextureSequence; modelProperties.animatedTextureSpeed = animatedTextureSpeed; //modelProperties.attachToCamera = attachToCamera; // TODO: Move to TriggerEvent System? setParent to, set Transform //modelProperties.hideWhenArcadeIsActive = hideWhenArcadeIsActive; //modelProperties.receiveSelectedModelArtWork = receiveSelectedModelArtWork; // TODO: Move to TriggerEvent System? //modelProperties.receiveActiveMenuRenderTexture = receiveActiveMenuRenderTexture; // TODO: Move to TriggerEvent System? modelProperties.screen = screen; modelProperties.manufacturer = manufacturer; modelProperties.year = year; modelProperties.genre = genre; modelProperties.mature = mature; modelProperties.available = available; modelProperties.runnable = runnable; modelProperties.gameLauncherMethod = gameLauncherMethod.ToString(); modelProperties.playCount = playCount; //modelProperties.audioProperties = audioProperties; modelProperties.zone = zone; modelProperties.triggers = triggers; modelProperties.triggerIDs = triggerIDs; return(modelProperties); }
private static List<ModelProperties> GetGamelistFromHyperspinXML(string filePath, string fileName, EmulatorProperties emulatorProperties, UnityEngine.UI.Slider slider = null) { string emulatorExtension = emulatorProperties.extension; string emulatorID = emulatorProperties.id; string emulatorGamePath = ArcadeManager.applicationPath + emulatorProperties.gamePath; var gamesCollection = HyperspinXML.Menu.Load(Path.Combine(filePath, fileName)); //Debug.Log("invaders is " + gamesCollection.Game.Where(x => x.Name.ToLower() == "invaders").ToList<HyperspinXML.Game>()[0].Genre); List<ModelProperties> gamelist = new List<ModelProperties>(); foreach (HyperspinXML.Game game in gamesCollection.Game) { ModelProperties model = new ModelProperties(); model.descriptiveName = game.Description; model.id = game.Name; model.idParent = game.Cloneof; model.emulator = emulatorID.Replace(" ", String.Empty).ToLower(); //model.animationType = "Never"; model.animatedTextureSpeed = 2.0f; model.manufacturer = game.Manufacturer; model.year = game.Year; model.genre = game.Genre; model.available = IsGameAvailable(emulatorGamePath, model.id, emulatorExtension); // model.mature = game.Rating; gamelist.Add(model); } if (gamelist.Count > 0) { return gamelist; } return null; }
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); } }
private static List<ModelProperties> GetGamelistFromMameXML(string filePath, string fileName, EmulatorProperties emulatorProperties, UnityEngine.UI.Slider slider = null) { if (filePath == null) { filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/mame/"; } if (fileName == null) { fileName = "mame.xml"; } string emulatorExtension = emulatorProperties.extension; string emulatorID = emulatorProperties.id; string emulatorGamePath = ArcadeManager.applicationPath + emulatorProperties.gamePath; var gamesCollection = Mame2003XML.Mame.Load(Path.Combine(filePath, fileName)); INIFile ini = new INIFile(Path.Combine(ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/mame/", emulatorID + ".ini")); //Debug.Log("mame " + gamesCollection.Game.Count); // Debug.Log("invaders is " + gamesCollection.Game.Where(x => x.Name.ToLower() == "invaders").ToList<mame2003XML.Game>()[0].Genre); List<ModelProperties> gamelist = new List<ModelProperties>(); foreach (Mame2003XML.Game game in gamesCollection.Game) { ModelProperties model = new ModelProperties(); model.descriptiveName = game.Description; model.id = game.Name; model.idParent = game.Cloneof; model.emulator = emulatorID.Replace(" ", String.Empty).ToLower(); //model.animationType = "Never"; model.animatedTextureSpeed = 2.0f; model.screen = (game.Video != null ? game.Video.Screen + " " : "") + (game.Video != null ? game.Video.Orientation : ""); model.manufacturer = game.Manufacturer; model.year = game.Year; model.genre = ini.GetValue("Category", model.id, "").Replace("* Mature *", ""); model.mature = ini.GetValue("Category", model.id, "").Contains("Mature") ? true : false; model.runnable = game.Driver != null ? game.Driver.Status == "good" : false; model.available = IsGameAvailable(emulatorGamePath, model.id, emulatorExtension); gamelist.Add(model); } if (gamelist.Count > 0) { return gamelist; } return null; }
private static List<ModelProperties> GetGamelistFrom3DArcadeATF(string filePath, string fileName, EmulatorProperties emulatorProperties, UnityEngine.UI.Slider slider = null) { string emulatorExtension = emulatorProperties.extension; string emulatorID = emulatorProperties.id; string emulatorGamePath = ArcadeManager.applicationPath + emulatorProperties.gamePath; var text = FileManager.LoadTextFromFile(filePath, fileName); if (text == null) { return null; } var lines = text.Split(Environment.NewLine.ToCharArray()); // | Description | Name | Year | Manufacturer | Clone | Romof | Category | VersionAdded | Available | Emulator | Type | Model | Favorites | Video | Orientation | Resolution | Aspect | Frequency | Depth | Stereo | Controltype | Buttons | Players | Coins | Driver | DriverStatus | SoundStatus | ColorStatus | HtmlLinks | TimesPlayed | DurationPlayed | Rating ||||| List<ModelProperties> gamelist = new List<ModelProperties>(); foreach (string line in lines) { var items = line.Split("|".ToCharArray()); if (items.Count() < 35) { continue; } ModelProperties model = new ModelProperties(); model.descriptiveName = items[1]; model.id = items[2]; model.idParent = items[5] != "none" && items[5] != "" ? items[5] : ""; model.emulator = emulatorID.Replace(" ", String.Empty).ToLower(); model.model = items[12] != "none" && items[12] != "" ? items[12] : ""; //model.animationType = "Never"; model.animatedTextureSpeed = 2.0f; model.screen = (items[14] != "none" && items[14] != "" ? items[14] + " " : "") + items[15] != "none" && items[15] != "" ? items[15] : ""; model.manufacturer = items[4] != "none" && items[4] != "" ? items[4] : ""; model.year = items[3] != "none" && items[3] != "" ? items[3] : ""; model.genre = items[7] != "none" && items[7] != "" ? items[7].Replace("*Mature*", "") : ""; model.available = items[9].ToLower() != "no" ? true : false; int number; model.playCount = int.TryParse(items[30], out number) ? number : 0; model.mature = items[7].ToLower().Contains("mature") ? true : false; model.available = IsGameAvailable(emulatorGamePath, model.id, emulatorExtension); gamelist.Add(model); } if (gamelist.Count > 0) { return gamelist; } return null; }
public void SetModelProperties(ModelProperties modelProperties) { descriptiveName = modelProperties.descriptiveName; id = modelProperties.id; idParent = modelProperties.idParent; emulator = modelProperties.emulator; model = modelProperties.model; //System.Enum.TryParse(modelProperties.animationType, true, out animationType); grabbable = modelProperties.grabbable; //lightmap = modelProperties.lightmap; //animatedTextureSequence = modelProperties.animatedTextureSequence; animatedTextureSpeed = modelProperties.animatedTextureSpeed; //attachToCamera = modelProperties.attachToCamera; // TODO: Move to TriggerEvent System? setParent to, set Transform //hideWhenArcadeIsActive = modelProperties.hideWhenArcadeIsActive; //receiveSelectedModelArtWork = modelProperties.receiveSelectedModelArtWork; // TODO: Move to TriggerEvent System? //receiveActiveMenuRenderTexture = modelProperties.receiveActiveMenuRenderTexture; // TODO: Move to TriggerEvent System? screen = modelProperties.screen; manufacturer = modelProperties.manufacturer; year = modelProperties.year; genre = modelProperties.genre; mature = modelProperties.mature; available = modelProperties.available; runnable = modelProperties.runnable; System.Enum.TryParse(modelProperties.gameLauncherMethod, true, out gameLauncherMethod); playCount = modelProperties.playCount; //audioProperties = modelProperties.audioProperties; zone = modelProperties.zone; triggers = modelProperties.triggers; //print("trigger " + triggers.Count); //if (triggers.Count > 0) //{ // print("animation " + triggers[0].animationProperties.name); //} triggerIDs = modelProperties.triggerIDs; }
public bool LoadArcade(ArcadeConfiguration arcadeConfiguration) { if (arcadeManager == null) { Debug.Log("No ArcadeManager reference found, create one..."); return(false); } if (arcadeConfiguration == null) { return(false); } if (arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || arcadeConfiguration.arcadeType == ArcadeType.CylArcade.ToString() || !Application.isPlaying) { arcadeManager.SetArcadeConfiguration(arcadeConfiguration); } else { ArcadeManager.menuConfiguration = arcadeConfiguration; } System.Enum.TryParse(arcadeConfiguration.arcadeType, true, out ArcadeType arcadeType); if (arcadeType == ArcadeType.FpsArcade || arcadeType == ArcadeType.FpsMenu) { ArcadeManager.allZones[arcadeType] = new Dictionary <int, List <int> >(); ArcadeManager.visibleZones[arcadeType] = new Dictionary <int, List <GameObject> >(); foreach (Zone zone in arcadeConfiguration.zones) { ArcadeManager.allZones[arcadeType][zone.zone] = zone.visibleZones; } } SetListOfModelProperties(ModelType.Arcade, arcadeConfiguration.arcadeModelList, "Arcades"); if (arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || !Application.isPlaying) { SetListOfModelProperties(ModelType.Game, arcadeConfiguration.gameModelList, "Games"); } SetListOfModelProperties(ModelType.Prop, arcadeConfiguration.propModelList, "Props"); if (!Application.isPlaying) { return(true); } // TODO: Why true? if (arcadeConfiguration.arcadeType == ArcadeType.CylArcade.ToString()) { ArcadeManager.activeArcadeType = ArcadeType.CylArcade; ArcadeManager.arcadeHistory.Add(arcadeConfiguration.id); CylController cylController = ArcadeManager.arcadeControls[ArcadeType.CylArcade].GetComponentInChildren <CylController>(); cylController.SetupCylArcade(arcadeConfiguration); } if (arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString()) { ArcadeManager.activeArcadeType = ArcadeType.FpsArcade; ArcadeManager.arcadeHistory.Add(arcadeConfiguration.id); } if (arcadeConfiguration.arcadeType == ArcadeType.CylMenu.ToString()) { ArcadeManager.activeMenuType = ArcadeType.CylMenu; CylController cylController = ArcadeManager.arcadeControls[ArcadeType.CylMenu].GetComponentInChildren <CylController>(); cylController.SetupCylArcade(arcadeConfiguration); } if (arcadeConfiguration.arcadeType == ArcadeType.FpsMenu.ToString()) { ArcadeManager.activeMenuType = ArcadeType.FpsMenu; } TriggerManager.Setup(arcadeType); return(true); void SetListOfModelProperties(ModelType modelType, List <ModelProperties> list, string resourceFolder) { ArcadeType tempArcadeType = !Application.isPlaying ? ArcadeType.None : arcadeType; int count = list.Count; for (int i = 0; i < count; i++) { ModelProperties modelProperties = list[i]; AddModelToArcade(modelType, modelProperties, tempArcadeType, false); } } }
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); } } }
public GameObject AddModelToArcade(ModelType modelType, ModelProperties modelProperties, ArcadeType arcadeType, bool addTrigger) { AssetBundle tAsset; GameObject tObj; tAsset = GetExternalModel(modelProperties.model); if (tAsset != null) { return(addExternalModel(tAsset)); } tObj = GetInternalModel(modelProperties.model); if (tObj != null) { return(AddInternalModel(tObj)); } tAsset = GetExternalModel(modelProperties.id); if (tAsset != null) { return(addExternalModel(tAsset)); } tObj = GetInternalModel(modelProperties.id); if (tObj != null) { return(AddInternalModel(tObj)); } tAsset = GetExternalModel(modelProperties.idParent); if (tAsset != null) { return(addExternalModel(tAsset)); } tObj = GetInternalModel(modelProperties.idParent); if (tObj != null) { return(AddInternalModel(tObj)); } // Now check for defaultmodels // First defaultmodel filters in the emulator List <EmulatorConfiguration> emulatorConfiguration = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.id == modelProperties.emulator).ToList(); if (emulatorConfiguration.Count > 1) { List <DefaultModelFilter> defaultModelFilters = emulatorConfiguration[0].emulator.defaultModelFilters; foreach (DefaultModelFilter defaultModel in defaultModelFilters) { bool success = true; foreach (ModelFilter filter in defaultModel.modelFilters) { success &= FilterModel(filter, modelProperties); } if (success) { tAsset = GetExternalModel(defaultModel.model); if (tAsset != null) { return(addExternalModel(tAsset)); } tObj = GetInternalModel(defaultModel.model); if (tObj != null) { return(AddInternalModel(tObj)); } } } } // Generic defaultmodel filters if (arcadeManager.generalConfiguration != null) { List <DefaultModelFilter> defaultModelFilters = arcadeManager.generalConfiguration.defaultModelFilters; foreach (DefaultModelFilter defaultModel in defaultModelFilters) { bool success = true; foreach (ModelFilter filter in defaultModel.modelFilters) { success &= FilterModel(filter, modelProperties); } if (success) { tAsset = GetExternalModel(defaultModel.model); if (tAsset != null) { return(addExternalModel(tAsset)); } tObj = GetInternalModel(defaultModel.model); if (tObj != null) { return(AddInternalModel(tObj)); } } } } // defaultmodel string[] defaultModels = { "default70hor", "default70vert", "default80hor", "default80vert", "default90hor", "default90vert" }; System.Random rnd = new System.Random(); tObj = GetInternalModel(defaultModels[rnd.Next(defaultModels.Length)]); if (tObj != null) { return(AddInternalModel(tObj)); } return(null); AssetBundle GetExternalModel(string modelName) { List <AssetBundle> prefab = ArcadeManager.modelAssets.Where(x => x.name == modelName).ToList(); if (prefab.Count < 1) { var file = FileManager.FileExists(ArcadeManager.applicationPath + "/3darcade~/Configuration/Assets/" + ArcadeManager.currentOS.ToString() + "/" + modelType.ToString() + "s/", modelName + ".unity3d"); if (file != null) { var asset = AssetBundle.LoadFromFile(file); if (asset != null && asset.name != null && asset.name != "") { ArcadeManager.modelAssets.Add(asset); prefab.Add(asset); return(asset); } } } return(prefab.Count == 1 ? prefab[0] : null); } GameObject addExternalModel(AssetBundle asset) { GameObject me = asset.LoadAsset(asset.name) as GameObject; GameObject child = UnityEngine.Object.Instantiate(me); return(AddModel(child, modelProperties)); } GameObject GetInternalModel(string modelName) { GameObject obj = (UnityEngine.GameObject)Resources.Load(modelType.ToString() + "s/" + modelName, typeof(GameObject)); // TODO: NBNB remove this hack to be able to use gamelist models as prop models if (obj == null) { obj = (UnityEngine.GameObject)Resources.Load(ModelType.Game.ToString() + "s/" + modelName, typeof(GameObject)); } return(obj == null ? null : obj); } GameObject AddInternalModel(GameObject obj) { GameObject child = UnityEngine.Object.Instantiate(obj); return(AddModel(child, modelProperties)); } GameObject AddModel(GameObject obj, ModelProperties model) { GameObject dummyNode; if (Application.isPlaying) { dummyNode = new GameObject("dummy"); obj.transform.SetParent(dummyNode.transform); } else { dummyNode = obj; } var modelSetup = dummyNode.GetComponent <ModelSetup>(); if (modelSetup == null) { dummyNode.AddComponent <ModelSetup>(); modelSetup = dummyNode.GetComponent <ModelSetup>(); } //Rigidbody rigidbody = obj.GetComponent<Rigidbody>(); //if (rigidbody != null) //{ // rigidbody.isKinematic = true; //} dummyNode.transform.position = model.position; // model is redundant you aleady have access to modelProperties dummyNode.transform.rotation = model.rotation; dummyNode.transform.localScale = model.scale; if (modelType == ModelType.Arcade) { dummyNode.tag = "arcademodel"; } if (modelType == ModelType.Game) { dummyNode.tag = "gamemodel"; } if (modelType == ModelType.Prop) { dummyNode.tag = "propmodel"; } bool isArcadeLayer = arcadeType == ArcadeType.FpsArcade || arcadeType == ArcadeType.CylArcade || arcadeType == ArcadeType.None ? true : false; string layer = (isArcadeLayer ? "Arcade/" : "Menu/") + modelType.ToString() + "Models"; dummyNode.layer = LayerMask.NameToLayer(layer); dummyNode.RunOnChildrenRecursive(tChild => tChild.layer = LayerMask.NameToLayer(layer)); GameObject node = null; if (isArcadeLayer) { node = GameObject.Find("Arcade/" + modelType.ToString() + "Models"); } else { node = GameObject.Find("Menu/" + modelType.ToString() + "Models"); } if (node != null) { dummyNode.transform.SetParent(node.transform); } else { Debug.Log("Error: Could not find the models parent node..."); } // Zoning if (arcadeType == ArcadeType.FpsArcade || arcadeType == ArcadeType.FpsMenu) { if (!ArcadeManager.visibleZones[arcadeType].ContainsKey(modelProperties.zone)) { ArcadeManager.visibleZones[arcadeType][modelProperties.zone] = new List <GameObject>(); } if (modelProperties.zone != 0) { ArcadeManager.visibleZones[arcadeType][modelProperties.zone].Add(dummyNode); } else { if (Physics.Raycast(dummyNode.transform.position, -dummyNode.transform.up, out RaycastHit vision, 100.0f)) { GameObject objectHit = vision.transform.gameObject; if (objectHit != null) { ModelSetup hitModelSetup = objectHit.transform.parent.gameObject.GetComponent <ModelSetup>(); if (hitModelSetup != null) { //Debug.Log("zonemodel " + modelSetup.descriptiveName); ArcadeManager.visibleZones[arcadeType][hitModelSetup.zone].Add(dummyNode); } } } } } ArcadeConfiguration arcadeConfiguration = isArcadeLayer ? ArcadeManager.arcadeConfiguration : ArcadeManager.menuConfiguration; modelSetup.Setup(model, arcadeConfiguration.modelSharedProperties); if (addTrigger && modelSetup.triggers.Count > 0 && Application.isPlaying) { TriggerManager.Add(modelSetup, arcadeType); } return(dummyNode); } }
public ModelProperties getSelectedGame() { ModelProperties modelProperties = new ModelProperties(); return(null); }
public void Setup(Texture2D tex, RenderSettings renderSettings, ModelProperties modelProperties, ModelComponentType modelComponentType) { if (!Application.isPlaying) { return; } Renderer thisRenderer = GetComponent <Renderer>(); if (thisRenderer == null || modelProperties == null) { return; } // Generate a Marquee texture when there is none available. if (tex == null && transform.parent.CompareTag("gamemodel") && (modelComponentType == ModelComponentType.Marquee)) { GameObject obj = GameObject.Find("RenderCanvasToTexture"); if (obj != null) { RenderCanvasToTexture renderCanvasToTexture = obj.GetComponent <RenderCanvasToTexture>(); if (renderCanvasToTexture != null) { tex = renderCanvasToTexture.RenderToTexture((thisRenderer.bounds.size.y / thisRenderer.bounds.size.x), modelProperties); } } } // Create a new material from the currentr material, so we have an unique one. var tempMaterial = new Material(thisRenderer.sharedMaterial); var shaderName = tempMaterial.shader.name; var newShader = Shader.Find(shaderName); // TODO: This fixes black textures when some prefabs are loaded from an assetbundle, still nescessary? if (newShader != null) { tempMaterial.shader = newShader; } else { Debug.LogWarning("unable to refresh shader: " + shaderName + " in material " + tempMaterial.name); } tempMaterial.mainTexture = tex != null ? tex : thisRenderer.material.mainTexture; // Also put it on the emissive map. if (modelComponentType == ModelComponentType.Marquee) { Texture myTexture = tempMaterial.GetTexture("_MainTex"); tempMaterial.SetTexture("_EmissionMap", myTexture); tempMaterial.color = Color.black; tempMaterial.SetColor("_EmissionColor", Color.white); tempMaterial.SetVector("_EmissionColor", Color.white * renderSettings.marqueeIntensity); tempMaterial.EnableKeyword("_EMISSION"); tempMaterial.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive; } // Put the new texture on all the model components that use this material, for magic pixels! if (tex != null && modelComponentType != ModelComponentType.Screen) { var r = transform.parent.GetComponentsInChildren(typeof(Renderer)); foreach (Renderer i in r) { if (thisRenderer.sharedMaterial.mainTexture == null || i.sharedMaterial.mainTexture == null) { continue; } int id1 = thisRenderer.sharedMaterial.mainTexture.GetInstanceID(); int id2 = i.sharedMaterial.mainTexture.GetInstanceID(); if (id1 == id2) { if (i.transform.gameObject.name != transform.gameObject.name) { var tempMaterial2 = new Material(i.material); bool isEmissive = i.material.IsKeywordEnabled("_Emission"); i.material = tempMaterial2; i.material.mainTexture = tempMaterial.mainTexture; if (isEmissive) { Texture myTexture = tempMaterial.GetTexture("_MainTex"); i.material.SetTexture("_EmissionMap", myTexture); } } } } } thisRenderer.material = tempMaterial; savedMaterial = tempMaterial; }
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(); } }
public bool FilterModel(ModelFilter modelFilter, ModelProperties modelProperties) { //Debug.Log(modelProperties.genre + " - " + modelFilter.modelProperty + " - " + modelFilter.modelPropertyValue); ModelFilterOperator modelFilterOperator; System.Enum.TryParse(modelFilter.modelFilterOperator, true, out modelFilterOperator); string value = modelProperties.GetType().GetField(modelFilter.modelProperty).GetValue(modelProperties).ToString(); float first; float second; switch (modelFilterOperator) { case ModelFilterOperator.Contains: if (value != "" && value.ToLower().Contains(modelFilter.modelPropertyValue.ToLower())) { return(true); } return(false); case ModelFilterOperator.NotContains: if (value != "" && !value.ToLower().Contains(modelFilter.modelPropertyValue.ToLower())) { return(true); } return(false); case ModelFilterOperator.Equals: if (value != "" && value.ToLower() == modelFilter.modelPropertyValue.ToLower()) { return(true); } return(false); case ModelFilterOperator.NotEquals: if (value != "" && !(value.ToLower() == modelFilter.modelPropertyValue.ToLower())) { return(true); } return(false); case ModelFilterOperator.Starts: if (value != "" && value.ToLower().StartsWith(modelFilter.modelPropertyValue.ToLower(), System.StringComparison.Ordinal)) { return(true); } return(false); case ModelFilterOperator.NotStarts: if (value != "" && !value.ToLower().StartsWith(modelFilter.modelPropertyValue.ToLower(), System.StringComparison.Ordinal)) { return(true); } return(false); case ModelFilterOperator.Smaller: if (float.TryParse(value, out first) && float.TryParse(modelFilter.modelPropertyValue, out second)) { if (first < second) { return(true); } } return(false); case ModelFilterOperator.Larger: if (float.TryParse(value, out first) && float.TryParse(modelFilter.modelPropertyValue, out second)) { if (first > second) { return(true); } } return(false); default: return(false); } }
// Take a "screenshot" of a camera's Render Texture. public Texture2D RenderToTexture(float aspectRatio, ModelProperties modelProperties) { var defaultMarqueeImages = new Sprite[] { defaultMarqueeImage_1, defaultMarqueeImage_2, defaultMarqueeImage_3, defaultMarqueeImage_4, defaultMarqueeImage_5, defaultMarqueeImage_6, defaultMarqueeImage_7, defaultMarqueeImage_8 }; System.Random rnd = new System.Random(); var defaultMarqueeTextColors = new Color[] { Color.green, Color.yellow, Color.white, Color.magenta, Color.blue, Color.cyan }; // The Render Texture in RenderTexture.active is the one that will be read by ReadPixels. var currentRT = RenderTexture.active; RenderTexture.active = renderCanvasCamera.targetTexture; if (aspectRatio > 0.6) { aspectRatio = 0.6f; } if (aspectRatio < 0.2) { aspectRatio = 0.2f; } if (ArcadeManager.currentOS == OS.MacOS) { renderCanvasCamera.aspect = 1 / aspectRatio; } else { renderCanvasCamera.rect = new Rect(0, 0, 1, aspectRatio); // windows? test } var descriptiveName = modelProperties.descriptiveName; int index = descriptiveName.IndexOf("(", StringComparison.Ordinal); if (index > 0) { descriptiveName = descriptiveName.Substring(0, index); } defaultMarqueeText.text = descriptiveName; defaultMarqueeText.outlineColor = new Color32((byte)rnd.Next(), (byte)rnd.Next(), (byte)rnd.Next(), (byte)(rnd.Next(100) + 155)); defaultMarqueeText.overrideColorTags = true; defaultMarqueeText.faceColor = defaultMarqueeTextColors[rnd.Next(defaultMarqueeTextColors.Length)]; defaultMarqueeText.ForceMeshUpdate(); if (defaultMarqueeImage != null) { defaultMarqueeImage.sprite = defaultMarqueeImages[rnd.Next(defaultMarqueeImages.Length)]; } // Render the camera's view. renderCanvasCamera.gameObject.SetActive(true); renderCanvasCamera.Render(); int height = (int)(renderCanvasCamera.targetTexture.height * aspectRatio); Texture2D image = new Texture2D(renderCanvasCamera.targetTexture.width, height); if (ArcadeManager.currentOS == OS.MacOS) { image = new Texture2D(renderCanvasCamera.targetTexture.width, 512); image.ReadPixels(new Rect(0, 0, renderCanvasCamera.targetTexture.width, 512), 0, 0); } else { image.ReadPixels(new Rect(0, renderCanvasCamera.targetTexture.height - height, renderCanvasCamera.targetTexture.width, height), 0, 0); } image.Apply(); renderCanvasCamera.gameObject.SetActive(false); // Replace the original active Render Texture. RenderTexture.active = currentRT; return(image); }
//[MenuItem("CONTEXT/ArcadeManager/Set Main Menu Preview Image")] //private static void GetArcadePreviewImage(MenuCommand menuCommand) //{ // var image = Arcade.FileManager.DialogGetFilePart(null, ArcadeManager.applicationPath, FileManager.FilePart.Path_Name_Extension, "jpg,png"); // if (image != null) // { // if (ArcadeManager.arcadeState == ArcadeStates.ArcadesConfigurationMenu || Application.isEditor) // { // string destinationFolder = ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath; // string destinationFilename = ArcadeManager.arcadeConfiguration.id + FileManager.getFilePart(FileManager.FilePart.Extension, null, null, image); // FileManager.DeleteFile(destinationFolder, ArcadeManager.arcadeConfiguration.id + ".jpg"); // FileManager.DeleteFile(destinationFolder, ArcadeManager.arcadeConfiguration.id + ".png"); // FileManager.CopyFile(image, destinationFolder, destinationFilename); // } // } //} #endif // NB Only use this and the next function to get and set the current arcadeconfiguration. // Update the static arcadeConfiguration property with the properties that can be changed in the editor and then return it. public ArcadeConfiguration GetArcadeConfiguration() { arcadeConfiguration.descriptiveName = descriptiveName; arcadeConfiguration.id = id; arcadeConfiguration.arcadeType = arcadeType.ToString(); arcadeConfiguration.gameLauncherMethod = gameLauncherMethod.ToString(); arcadeConfiguration.externalModels = externalModels; arcadeConfiguration.showFPS = showFPS; arcadeConfiguration.modelSharedProperties = modelSharedProperties; arcadeConfiguration.camera = new CameraProperties(); arcadeConfiguration.camera.position = arcadeControl.transform.position; arcadeConfiguration.camera.rotation = arcadeControl.transform.GetChild(0).transform.rotation; arcadeConfiguration.camera.height = arcadeControl.transform.GetChild(0).transform.localPosition.y; arcadeConfiguration.fpsArcadeProperties = fpsArcadeProperties; arcadeConfiguration.cylArcadeProperties = cylArcadeProperties; arcadeConfiguration.zones = zones; // Add arcadeconfigurations arcade, game and prop lists when nescessary if (arcadeType == ArcadeType.FpsArcade || !Application.isPlaying) { List <ModelProperties> gameModelList = GetListOfModelProperties(ModelType.Game); arcadeConfiguration.gameModelList = gameModelList; } if (ArcadeManager.arcadeState != ArcadeStates.MoveCabs) { List <ModelProperties> arcadeModelList = GetListOfModelProperties(ModelType.Arcade); arcadeConfiguration.arcadeModelList = arcadeModelList; List <ModelProperties> propModelList = GetListOfModelProperties(ModelType.Prop); arcadeConfiguration.propModelList = propModelList; } return(arcadeConfiguration); List <ModelProperties> GetListOfModelProperties(ModelType modelType) { GameObject obj = transform.Find(modelType.ToString() + "Models").gameObject; List <ModelProperties> list = new List <ModelProperties>(); if (obj == null) { Debug.Log("no items found"); return(null); } int count = obj.transform.childCount; for (int i = 0; i < count; i++) { ModelProperties modelProperties = new ModelProperties(); GameObject child; ModelSetup gameModelSetup; if (!Application.isPlaying) { child = obj.transform.GetChild(i).gameObject; gameModelSetup = child.GetComponent <ModelSetup>(); } else { child = obj.transform.GetChild(i).gameObject.transform.GetChild(0).gameObject; gameModelSetup = obj.transform.GetChild(i).gameObject.GetComponent <ModelSetup>(); } // TODO: Null check should not be needed! if (gameModelSetup == null) { continue; } modelProperties = gameModelSetup.GetModelProperties(); modelProperties.position = child.transform.position; modelProperties.rotation = child.transform.rotation; modelProperties.scale = child.transform.lossyScale; list.Add(modelProperties); } return(list); } }