コード例 #1
0
ファイル: ArcadeManager.cs プロジェクト: 3DArcade/3DArcade
        // 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;
        }
コード例 #2
0
        public void SaveArcadeConfiguration(ArcadeConfiguration arcadeConfiguration)
        {
            string filePath = ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath;
            var    fileName = arcadeConfiguration.id + ".json";

            FileManager.SaveJSONData(arcadeConfiguration, filePath, fileName);
        }
コード例 #3
0
ファイル: ArcadeManager.cs プロジェクト: 3DArcade/3DArcade
        private void Start()
        {
#if UNITY_EDITOR
            // When we return from play mode Start() is called again, we use that to reset and load our arcade configuration. We need to do this because we loose our script references when we exit play mode. That will cause lots of havoc, if you then try to save an arcadeconfiguration.
            if (!Application.isPlaying)
            {
                loadSaveArcadeConfiguration.ResetArcade();
                ArcadeManager.loadSaveArcadeConfiguration.LoadArcadesConfigurationList();
                List <ArcadeConfiguration> arcadeConfigurations = arcadesConfigurationList.Where(x => x.id == id).ToList();
                if (arcadeConfigurations.Count > 0)
                {
                    arcadeConfiguration = arcadeConfigurations[0];
                    bool success = loadSaveArcadeConfiguration.LoadArcade(arcadeConfiguration);
                    print("Loaded arcade configuration " + arcadeConfiguration.descriptiveName + " successfully is " + success);
                }
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
                return;
            }

            // Show the main menu
            if (EditorModeShowMainMenuOnPlay)
            {
                loadSaveArcadeConfiguration.ResetArcade();
                if (!ShowMainMenu())
                {
                    Debug.Log("Main Menu could not be loaded");
                    // TODO: Show an error dialog
                }
            }
            else
            {
                arcadeConfiguration = GetArcadeConfiguration();
                loadSaveArcadeConfiguration.ResetArcade();
                loadSaveArcadeConfiguration.StartArcade(arcadeConfiguration, null);
            }
#else
            // Show the main menu
            loadSaveArcadeConfiguration.ResetArcade();
            if (!ShowMainMenu())
            {
                Debug.Log("Main Menu could not be loaded");
                // TODO: Show an error dialog
            }
#endif
            bool ShowMainMenu()
            {
                if (StartArcadeWith(generalConfiguration.mainMenuArcadeConfiguration, null))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #4
0
ファイル: ArcadeManager.cs プロジェクト: 3DArcade/3DArcade
        //void OnDestroy()
        //{
        //}

        // Load arcadeconfigurations from file and then show them in the main menu.

        public static bool StartArcadeWith(string arcadeConfigurationID, GameObject selectedArcadeModel)
        {
            ArcadeConfiguration arcadeConfiguration = loadSaveArcadeConfiguration.GetArcadeConfigurationByID(arcadeConfigurationID);

            if (arcadeConfiguration != null)
            {
                loadSaveArcadeConfiguration.StartArcade(arcadeConfiguration, selectedArcadeModel);
                return(true);
            }
            return(false);
        }
コード例 #5
0
        // This saves an ArcadeConfiguration from the loaded gameobjects, not from ArcadeManager's static arcadeConfiguration. Only useful if we support making changes in the editor!
        public void SaveArcade()
        {
            if (arcadeManager == null)
            {
                Debug.Log("No Arcade node found");
                return;
            }
            ArcadeConfiguration arcadeConfiguration = arcadeManager.GetArcadeConfiguration();

            SaveArcadeConfiguration(arcadeConfiguration);
        }
コード例 #6
0
        public void DeleteArcadeConfiguration(ArcadeConfiguration arcadeConfiguration)
        {
            string filePath = ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath;
            var    fileName = arcadeConfiguration.id + ".json";

            FileManager.DeleteFile(filePath, fileName);
            fileName = arcadeConfiguration.id + ".json.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = arcadeConfiguration.id + ".jpg";
            FileManager.DeleteFile(filePath, fileName);
            fileName = arcadeConfiguration.id + ".jpg.meta";
            FileManager.DeleteFile(filePath, fileName);
        }
コード例 #7
0
        public bool LoadArcadesConfigurationList()
        {
            var files = FileManager.FilesFromDirectory(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, "*.json", SearchOption.AllDirectories);

            if (files != null)
            {
                ArcadeManager.arcadesConfigurationList.Clear();
                foreach (FileInfo file in files)
                {
                    ArcadeConfiguration cfg = FileManager.LoadJSONData <ArcadeConfiguration>(file.FullName);
                    ArcadeManager.arcadesConfigurationList.Add(cfg);
                }
                return(true);
            }
            return(false);
        }
コード例 #8
0
ファイル: CylController.cs プロジェクト: 3DArcade/3DArcade
        public bool SetupCylArcade(ArcadeConfiguration arcadeConfiguration)
        {
            if (arcadeConfiguration.cylArcadeProperties.Count < 1)
            {
                return(false);
            }
            games               = arcadeConfiguration.gameModelList;
            objects             = new List <GameObject>();
            cylArcadeProperties = arcadeConfiguration.cylArcadeProperties[0];

            if (games.Count < cylArcadeProperties.sprockets)
            {
                if (cylArcadeProperties.selectedSprocket == 0)
                {
                }
                else if (cylArcadeProperties.selectedSprocket == cylArcadeProperties.sprockets - 1)
                {
                    cylArcadeProperties.selectedSprocket = games.Count - 1;
                }
                else
                {
                    cylArcadeProperties.selectedSprocket = (((games.Count % 2 == 0) ? games.Count : (games.Count - 1)) / 2) - 1;
                }
                cylArcadeProperties.sprockets = games.Count - 1;
            }

            thisCamera.ResetAspect();
            if (arcadeType == ArcadeType.CylMenu && cylArcadeProperties.cameraAspectRatio != 0)
            {
                //print("aspect " + cylArcadeProperties.cameraAspectRatio);
                thisCamera.aspect = cylArcadeProperties.cameraAspectRatio;
            }

            //print("gamesc " + games.Count + " sp " + cylArcadeProperties.sprockets + " ssp " + cylArcadeProperties.selectedSprocket + " gp " + cylArcadeProperties.gamePosition);

            // Dummy transform to smoothly interpolate our camera towards.
            Transform t = transform.Find("dummyCameraTransform");

            if (t == null)
            {
                dummyCameraTransform                  = new GameObject();
                dummyCameraTransform.name             = "dummyCameraTransform";
                dummyCameraTransform.transform.parent = gameObject.transform;
            }
            else
            {
                dummyCameraTransform = t.gameObject;
            }

            cameraRotationDeltaDamping = cylArcadeProperties.cameraRotationdamping; // Reset damping

            tempTargetModelGamePosition       = cylArcadeProperties.gamePosition;
            cylArcadeProperties.gamePosition -= cylArcadeProperties.sprockets;
            if (cylArcadeProperties.gamePosition < 0)
            {
                cylArcadeProperties.gamePosition += games.Count;
            }
            // Setup first model
            GameObject model = AddModel(cylArcadeProperties.gamePosition);

            objects.Add(model);
            model.transform.position = new Vector3(0, 0, 0);
            model.transform.rotation = Quaternion.identity;
            model.transform.Translate(new Vector3(0, 0, cylArcadeProperties.radius), Space.World);
            // Local rotation of the sprocket
            model.transform.Rotate(cylArcadeProperties.sprocketLocalEularAngleX, cylArcadeProperties.sprocketLocalEularAngleY, cylArcadeProperties.sprocketLocalEularAngleZ);
            for (int i = 0; i < cylArcadeProperties.sprockets; i++)
            {
                cylArcadeProperties.gamePosition += 1;
                if (cylArcadeProperties.gamePosition > games.Count - 1)
                {
                    cylArcadeProperties.gamePosition = 0;
                }
                Forwards(cylArcadeProperties.gamePosition);
            }
            cylArcadeProperties.gamePosition = tempTargetModelGamePosition;
            // Don't animate the camera, so set timer to 1;
            timer         = 1;
            setupFinished = true;
            UpdateCamera();
            return(true);
        }
コード例 #9
0
        public void Set(bool updateArcadesConfigurationList = true)
        {
            if (updateArcadesConfigurationList)
            {
                ArcadeManager.arcadesConfigurationList.Clear();
                if (ArcadeManager.arcadesConfigurationList.Count < 1)
                {
                    if (!(ArcadeManager.loadSaveArcadeConfiguration.LoadArcadesConfigurationList()))
                    {
                        print("Warning no arcade configuration list found when setting up ArcadesConfigurationModelProperties");
                        return;
                    }
                }
            }

            // Arcade configurations
            if (ArcadeManager.arcadesConfigurationList.Count > 0)
            {
                arcades.options.Clear();
                foreach (ArcadeConfiguration item in ArcadeManager.arcadesConfigurationList)
                {
                    arcades.options.Add(new Dropdown.OptionData(item.descriptiveName));
                }

                arcades.value = arcades.options.FindIndex(option => option.text == ArcadeManager.arcadeConfiguration.descriptiveName);
                arcadesIndex  = arcades.value;
                //print("arcades" + arcades.value);
                if (arcades.value < ArcadeManager.arcadesConfigurationList.Count)
                {
                    arcadeConfiguration   = ArcadeManager.arcadesConfigurationList[arcades.value];
                    selectedModelList     = ArcadeManager.arcadesConfigurationList[arcades.value].gameModelList;
                    selectedModelListType = ModelType.Game;
                }
                else
                {
                    arcades.value         = 0;
                    arcadesIndex          = 0;
                    arcadeConfiguration   = ArcadeManager.arcadesConfigurationList[arcades.value];
                    selectedModelList     = ArcadeManager.arcadesConfigurationList[arcades.value].gameModelList;
                    selectedModelListType = ModelType.Game;
                }
                arcades.onValueChanged.AddListener(delegate { DropdownValueChangedHandler(arcades); });
                if (arcadeConfiguration != null)
                {
                    //print("cfg is " + arcadeConfiguration.id);
                    descriptiveName.text = arcadeConfiguration.descriptiveName;
                    id.text = arcadeConfiguration.id;
                    //print("arcade1 " + arcadeConfiguration.gameModelList);
                    SetupDropDownList(gameLauncherMethod, Enum.GetNames(typeof(GameLauncherMethod)).ToList());
                    gameLauncherMethod.value = gameLauncherMethod.options.FindIndex(option => option.text == arcadeConfiguration.gameLauncherMethod);
                    gameLauncherMethod.RefreshShownValue();
                    SetupDropDownList(videoOnModelEnabled, Enum.GetNames(typeof(ModelVideoEnabled)).ToList());
                    videoOnModelEnabled.value = videoOnModelEnabled.options.FindIndex(option => option.text == arcadeConfiguration.modelSharedProperties.videoOnModelEnabled);
                    videoOnModelEnabled.RefreshShownValue();
                    SetupDropDownList(externalModels, new List <string> {
                        "False", "True"
                    });
                    externalModels.value = arcadeConfiguration.externalModels ? 1 : 0;
                    externalModels.RefreshShownValue();
                    SetupDropDownList(showFPS, new List <string> {
                        "False", "True"
                    });
                    showFPS.value = arcadeConfiguration.showFPS ? 1 : 0;
                    showFPS.RefreshShownValue();
                    SetupDropDownList(modelLists, new List <string>(new string[] { "Game Models", "Arcade Models", "Prop Models" }));
                    modelLists.onValueChanged.AddListener(delegate { DropdownValueChangedHandler(modelLists); });
                    arcades.RefreshShownValue();
                    modelLists.RefreshShownValue();
                    var filePath = FileManager.FileExists(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, arcadeConfiguration.id + ".jpg");
                    if (filePath != null)
                    {
                        var fileName = FileManager.getFilePart(FileManager.FilePart.Name_Extension, null, null, filePath);
                        if (fileName != null)
                        {
                            previewImage.text = fileName;
                        }
                    }
                    filePath = FileManager.FileExists(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, arcadeConfiguration.id + ".png");
                    if (filePath != null)
                    {
                        var fileName = FileManager.getFilePart(FileManager.FilePart.Name_Extension, null, null, filePath);
                        if (fileName != null)
                        {
                            previewImage.text = fileName;
                        }
                    }
                    UpdateModelList();
                    //print("arcade2 " + arcadeConfiguration.gameModelList);
                    ArcadeManager.arcadeConfiguration = arcadeConfiguration;
                }
            }
        }
コード例 #10
0
        private void DropdownValueChangedHandler(Dropdown target)
        {
            Debug.Log("selected: " + target.name + " " + target.value);
            print("cfg " + arcadeConfiguration == null);
            UpdateArcadeConfiguration();
            if (target == modelLists)
            {
                string list = target.options[target.value].text;
                if (target.value == 0)
                {
                    selectedModelList     = arcadeConfiguration.gameModelList;
                    selectedModelListType = ModelType.Game;
                    UpdateModelList();
                }
                if (target.value == 1)
                {
                    selectedModelList     = arcadeConfiguration.arcadeModelList;
                    selectedModelListType = ModelType.Arcade;
                    UpdateModelList();
                }
                if (target.value == 2)
                {
                    selectedModelList     = arcadeConfiguration.propModelList;
                    selectedModelListType = ModelType.Prop;
                    UpdateModelList();
                }
            }
            if (target == arcades)
            {
                arcadesIndex        = arcades.value;
                arcadeConfiguration = ArcadeManager.arcadesConfigurationList[arcades.value];
                ArcadeManager.arcadeConfiguration = arcadeConfiguration;
                selectedModelList     = ArcadeManager.arcadesConfigurationList[arcades.value].gameModelList;
                selectedModelListType = ModelType.Game;
                descriptiveName.text  = arcadeConfiguration.descriptiveName;
                id.text = arcadeConfiguration.id;
                SetupDropDownList(gameLauncherMethod, Enum.GetNames(typeof(GameLauncherMethod)).ToList());
                gameLauncherMethod.value = gameLauncherMethod.options.FindIndex(option => option.text == arcadeConfiguration.gameLauncherMethod);
                SetupDropDownList(videoOnModelEnabled, Enum.GetNames(typeof(ModelVideoEnabled)).ToList());
                videoOnModelEnabled.value = videoOnModelEnabled.options.FindIndex(option => option.text == arcadeConfiguration.modelSharedProperties.videoOnModelEnabled);
                SetupDropDownList(externalModels, new List <string> {
                    "False", "True"
                });
                externalModels.value = arcadeConfiguration.externalModels ? 1 : 0;
                SetupDropDownList(showFPS, new List <string> {
                    "False", "True"
                });
                showFPS.value = arcadeConfiguration.showFPS ? 1 : 0;
                SetupDropDownList(modelLists, new List <string>(new string[] { "Game Models", "Arcade Models", "Prop Models" }));
                modelLists.value = 0;
                // TODO: get file preview image
                var filePath = FileManager.FileExists(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, arcadeConfiguration.id + ".jpg");
                if (filePath != null)
                {
                    var fileName = FileManager.getFilePart(FileManager.FilePart.Name_Extension, null, null, filePath);
                    if (fileName != null)
                    {
                        previewImage.text = fileName;
                    }
                }
                filePath = FileManager.FileExists(ArcadeManager.applicationPath + ArcadeManager.arcadesConfigurationPath, arcadeConfiguration.id + ".png");
                if (filePath != null)
                {
                    var fileName = FileManager.getFilePart(FileManager.FilePart.Name_Extension, null, null, filePath);
                    if (fileName != null)
                    {
                        previewImage.text = fileName;
                    }
                }

                // modelLists.onValueChanged.AddListener(delegate { DropdownValueChangedHandler(modelLists); });
                UpdateModelList();
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        public void StartArcade(ArcadeConfiguration arcadeConfiguration, GameObject selectedArcadeModel)
        {
            Debug.Log("Loading Arcade Configuration " + arcadeConfiguration.id + " in ArcadeType " + arcadeConfiguration.arcadeType);
            if (arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || arcadeConfiguration.arcadeType == ArcadeType.CylArcade.ToString())
            {
                ArcadeManager.arcadeState = ArcadeStates.LoadingArcade;
            }

            // We are loading stuff...dont do these
            RigidbodyFirstPersonController arcadeRigidbodyFirstPersonController = ArcadeManager.arcadeControls[ArcadeType.FpsArcade].GetComponent <RigidbodyFirstPersonController>();

            if (arcadeRigidbodyFirstPersonController != null)
            {
                arcadeRigidbodyFirstPersonController.pause = true;
            }
            RigidbodyFirstPersonController menuRigidbodyFirstPersonController = ArcadeManager.arcadeControls[ArcadeType.FpsMenu].GetComponent <RigidbodyFirstPersonController>();

            if (menuRigidbodyFirstPersonController != null)
            {
                menuRigidbodyFirstPersonController.pause = true;
            }
            Rigidbody arcadeCameraRigidBody = ArcadeManager.arcadeControls[ArcadeType.FpsArcade].GetComponent <Rigidbody>();

            if (arcadeCameraRigidBody != null)
            {
                arcadeCameraRigidBody.isKinematic = true;
            }
            Rigidbody menuCameraRigidBody = ArcadeManager.arcadeControls[ArcadeType.FpsMenu].GetComponent <Rigidbody>();

            if (menuCameraRigidBody != null)
            {
                menuCameraRigidBody.isKinematic = true;
            }
            CapsuleCollider arcadeCapsuleCollider = ArcadeManager.arcadeControls[ArcadeType.FpsArcade].GetComponent <CapsuleCollider>();

            if (arcadeCapsuleCollider != null)
            {
                arcadeCapsuleCollider.enabled = false;
            }
            CapsuleCollider menuCapsuleCollider = ArcadeManager.arcadeControls[ArcadeType.FpsMenu].GetComponent <CapsuleCollider>();

            if (menuCapsuleCollider != null)
            {
                menuCapsuleCollider.enabled = false;
            }

            // Arcade
            if (arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || arcadeConfiguration.arcadeType == ArcadeType.CylArcade.ToString())
            {
                ArcadeManager.activeArcadeType = ArcadeType.None;
                ResetArcade(); // Reset current state to zero

                if (LoadArcade(arcadeConfiguration))
                {
                    UpdateController(ArcadeManager.activeArcadeType);
                    TriggerManager.SendEvent(Event.ArcadeStarted);
                    if (ArcadeManager.arcadeHistory.Count == 1)
                    {
                        TriggerManager.SendEvent(Event.MainMenuStarted);
                    }
                    if (ArcadeManager.activeArcadeType == ArcadeType.FpsArcade)
                    {
                        arcadeCameraRigidBody.isKinematic          = false;
                        arcadeCapsuleCollider.enabled              = true;
                        arcadeRigidbodyFirstPersonController.pause = false;
                    }
                    ArcadeManager.arcadeState = ArcadeStates.Running;
                    Cursor.lockState          = CursorLockMode.Locked;
                    Cursor.visible            = false;
                }
                else
                {
                    Debug.Log("Loading the Arcade Configuration of type " + arcadeConfiguration.arcadeType + " Failed!");
                    // TODO: Show an error dialog!
                }
            }
            // Menu
            if (arcadeConfiguration.arcadeType == ArcadeType.CylMenu.ToString() || arcadeConfiguration.arcadeType == ArcadeType.FpsMenu.ToString())
            {
                ArcadeManager.activeMenuType = ArcadeType.None;
                ResetMenu();

                if (LoadArcade(arcadeConfiguration))
                {
                    UpdateController(Application.isPlaying ? ArcadeManager.activeMenuType : ArcadeManager.activeArcadeType);
                    GameObject obj = ArcadeStateManager.selectedModel;
                    if (obj != null && obj.transform.childCount > 1)
                    {
                        ModelVideoSetup modelVideoSetup = obj.transform.GetChild(1).GetComponent <ModelVideoSetup>();
                        if (modelVideoSetup != null)
                        {
                            modelVideoSetup.ReleasePlayer();
                        }
                        ModelImageSetup modelImageSetup = obj.transform.GetChild(1).GetComponent <ModelImageSetup>();
                        if (modelImageSetup != null)
                        {
                            if (arcadeConfiguration.cylArcadeProperties.Count > 0)
                            {
                                if (arcadeConfiguration.cylArcadeProperties[0].cylArcadeOnScreenSelectedModel)
                                {
                                    modelImageSetup.SetMenuTexture();
                                }
                            }
                        }
                        ArcadeStateManager.savedArcadeModel      = ArcadeStateManager.selectedModel;
                        ArcadeStateManager.savedArcadeModelSetup = ArcadeStateManager.selectedModelSetup;
                    }
                    if (ArcadeManager.activeArcadeType == ArcadeType.FpsMenu)
                    {
                        arcadeCameraRigidBody.isKinematic          = false;
                        arcadeCapsuleCollider.enabled              = true;
                        arcadeRigidbodyFirstPersonController.pause = false;
                    }
                    ArcadeManager.activeMenuType = ArcadeType.CylMenu;
                    ArcadeManager.arcadeState    = ArcadeStates.ArcadeMenu;
                    TriggerManager.SendEvent(Event.MenuStarted);
                    Cursor.lockState = CursorLockMode.Locked;
                    Cursor.visible   = false;
                    return;
                }
                else
                {
                    Debug.Log("Loading the Arcade Configuration of type " + arcadeConfiguration.arcadeType + " Failed!");
                    // TODO: Show an error dialog!
                    ArcadeManager.activeMenuType = ArcadeType.None;
                }
                // If the menu setup fails go back to the regular arcade.
                ArcadeManager.arcadeState = ArcadeStates.Running;
                return;
            }

            void UpdateController(ArcadeType arcadeType)
            {
                ArcadeManager.arcadeControls[arcadeType].transform.position      = arcadeConfiguration.camera.position;
                ArcadeManager.arcadeControls[arcadeType].transform.rotation      = Quaternion.identity;
                ArcadeManager.arcadeControls[arcadeType].transform.localRotation = Quaternion.identity;
                ArcadeManager.arcadeControls[arcadeType].transform.GetChild(0).transform.rotation      = Quaternion.identity;
                ArcadeManager.arcadeControls[arcadeType].transform.GetChild(0).transform.localRotation = arcadeConfiguration.camera.rotation;
                ArcadeManager.arcadeControls[arcadeType].transform.GetChild(0).transform.position      = Vector3.zero;
                ArcadeManager.arcadeControls[arcadeType].transform.GetChild(0).transform.localPosition = new Vector3(0, arcadeConfiguration.camera.height, 0);
                RigidbodyFirstPersonController rigidbodyFirstPersonController = ArcadeManager.arcadeControls[arcadeType].GetComponent <RigidbodyFirstPersonController>();

                if (rigidbodyFirstPersonController != null)
                {
                    rigidbodyFirstPersonController.Setup();
                }
                ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].orthographic           = arcadeConfiguration.camera.orthographic;
                ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].fieldOfView            = arcadeConfiguration.camera.fieldOfView;
                ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].nearClipPlane          = arcadeConfiguration.camera.nearClipPlane;
                ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].farClipPlane           = arcadeConfiguration.camera.farClipPlane;
                ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].rect                   = arcadeConfiguration.camera.viewportRect;
                ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].allowDynamicResolution = arcadeConfiguration.camera.allowDynamicResolution;
                if (arcadeConfiguration.camera.aspectRatio != 0)
                {
                    ArcadeManager.arcadeCameras[ArcadeType.FpsArcade].aspect = arcadeConfiguration.camera.aspectRatio;
                }
            }
        }
コード例 #13
0
        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);
                }
            }
        }