Exemple #1
0
 private void ParseSettingsJSON(WebJSON.Settings msg)
 {
     if (msg.ViewCollision.HasValue)
     {
         controller.viewCollision = msg.ViewCollision.Value;
     }
     if (msg.Luminosity.HasValue)
     {
         controller.lightManager.luminosity = msg.Luminosity.Value;
     }
     if (msg.Saturate.HasValue)
     {
         controller.lightManager.saturate = msg.Saturate.Value;
     }
     if (msg.ViewGraphs.HasValue)
     {
         controller.viewGraphs = msg.ViewGraphs.Value;
     }
     if (msg.EnableLighting.HasValue)
     {
         controller.lightManager.enableLighting = msg.EnableLighting.Value;
     }
     if (msg.EnableFog.HasValue)
     {
         controller.lightManager.enableFog = msg.EnableFog.Value;
     }
     if (msg.ViewInvisible.HasValue)
     {
         controller.viewInvisible = msg.ViewInvisible.Value;
     }
     if (msg.DisplayInactive.HasValue)
     {
         controller.sectorManager.displayInactiveSectors = msg.DisplayInactive.Value;
     }
     if (msg.PlayAnimations.HasValue)
     {
         controller.playAnimations = msg.PlayAnimations.Value;
     }
     if (msg.PlayTextureAnimations.HasValue)
     {
         controller.playTextureAnimations = msg.PlayTextureAnimations.Value;
     }
     if (msg.ShowPersos.HasValue)
     {
         controller.showPersos = msg.ShowPersos.Value;
     }
 }
Exemple #2
0
    private void ParseSettingsJSON(WebJSON.Settings msg)
    {
        if (msg.ShowObjects.HasValue)
        {
            Settings.ShowObjects = msg.ShowObjects.Value;
        }
        if (msg.ShowTiles.HasValue)
        {
            Settings.ShowTiles = msg.ShowTiles.Value;
        }
        if (msg.ShowCollision.HasValue)
        {
            Settings.ShowCollision = msg.ShowCollision.Value;
        }
        if (msg.ShowLinks.HasValue)
        {
            Settings.ShowLinks = msg.ShowLinks.Value;
        }
        if (msg.ShowObjCollision.HasValue)
        {
            Settings.ShowObjCollision = msg.ShowObjCollision.Value;
        }
        if (msg.AnimateSprites.HasValue)
        {
            Settings.AnimateSprites = msg.AnimateSprites.Value;
        }
        if (msg.AnimateTiles.HasValue)
        {
            Settings.AnimateTiles = msg.AnimateTiles.Value;
        }
        if (msg.ShowAlwaysObjects.HasValue)
        {
            Settings.ShowAlwaysObjects = msg.ShowAlwaysObjects.Value;
        }
        if (msg.ShowEditorObjects.HasValue)
        {
            Settings.ShowEditorObjects = msg.ShowEditorObjects.Value;
        }
        if (msg.ShowObjOffsets.HasValue)
        {
            Settings.ShowObjOffsets = msg.ShowObjOffsets.Value;
        }
        if (msg.ShowDefaultObjIcons.HasValue)
        {
            Settings.ShowDefaultObjIcons = msg.ShowDefaultObjIcons.Value;
        }
        if (msg.ShowRayman.HasValue)
        {
            Settings.ShowRayman = msg.ShowRayman.Value;
        }
        if (msg.ShowDebugInfo.HasValue)
        {
            Settings.ShowDebugInfo = msg.ShowDebugInfo.Value;
        }
        if (msg.StateSwitchingMode.HasValue)
        {
            Settings.StateSwitchingMode = msg.StateSwitchingMode.Value;
        }

        if (msg.Layers != null && msg.Layers.Length > 0)
        {
            var lvl = LevelEditorData.Level;
            var tilemapController = Controller.obj?.levelController?.controllerTilemap;
            if (lvl != null && tilemapController != null)
            {
                foreach (var layer in msg.Layers)
                {
                    switch (layer.Index)
                    {
                    case -2:
                        if (lvl.Background != null && tilemapController.background != null)
                        {
                            var bg = tilemapController.background;
                            if (layer.IsVisible.HasValue && layer.IsVisible.Value != bg.gameObject.activeSelf)
                            {
                                bg.gameObject.SetActive(layer.IsVisible.Value);
                            }
                        }
                        break;

                    case -1:
                        if (lvl.ParallaxBackground != null && tilemapController.backgroundParallax != null)
                        {
                            var bg = tilemapController.backgroundParallax;
                            if (layer.IsVisible.HasValue && layer.IsVisible.Value != bg.gameObject.activeSelf)
                            {
                                bg.gameObject.SetActive(layer.IsVisible.Value);
                            }
                        }
                        break;

                    default:
                        if (layer.Index < lvl.Maps.Length && tilemapController.GraphicsTilemaps != null)
                        {
                            var tilemap = tilemapController.GraphicsTilemaps[layer.Index];
                            if (layer.IsVisible.HasValue && layer.IsVisible.Value != tilemap.gameObject.activeSelf)
                            {
                                tilemap.gameObject.SetActive(layer.IsVisible.Value);
                            }
                        }
                        break;
                    }
                }
            }
        }
        if (msg.Palette.HasValue)
        {
            if (Controller.obj?.levelController?.controllerTilemap != null)
            {
                if (Controller.obj.levelController.controllerTilemap.HasAutoPaletteOption)
                {
                    Controller.obj.levelController.controllerTilemap.currentPalette = msg.Palette.Value;
                }
                else
                {
                    Controller.obj.levelController.controllerTilemap.currentPalette = msg.Palette.Value + 1;
                }
            }
        }

        if (msg.BackgroundTint.HasValue)
        {
            var bgTint = Controller.obj?.levelController?.controllerTilemap?.backgroundTint;
            if (bgTint != null)
            {
                bgTint.color = msg.BackgroundTint.Value;
            }
        }
        if (msg.BackgroundTintDark.HasValue)
        {
            Camera.main.backgroundColor = msg.BackgroundTintDark.Value;
            if (Controller.obj?.levelController?.renderCamera != null)
            {
                Controller.obj.levelController.renderCamera.backgroundColor = msg.BackgroundTintDark.Value;
            }
        }
    }
    private void ParseSettingsJSON(WebJSON.Settings msg)
    {
        if (msg.ShowObjects.HasValue)
        {
            Settings.ShowObjects = msg.ShowObjects.Value;
        }
        if (msg.ShowTiles.HasValue)
        {
            Settings.ShowTiles = msg.ShowTiles.Value;
        }
        if (msg.ShowCollision.HasValue)
        {
            Settings.ShowCollision = msg.ShowCollision.Value;
        }
        if (msg.ShowLinks.HasValue)
        {
            Settings.ShowLinks = msg.ShowLinks.Value;
        }
        if (msg.ShowObjCollision.HasValue)
        {
            Settings.ShowObjCollision = msg.ShowObjCollision.Value;
        }
        if (msg.AnimateSprites.HasValue)
        {
            Settings.AnimateSprites = msg.AnimateSprites.Value;
        }
        if (msg.AnimateTiles.HasValue)
        {
            Settings.AnimateTiles = msg.AnimateTiles.Value;
        }
        if (msg.ShowAlwaysObjects.HasValue)
        {
            Settings.ShowAlwaysObjects = msg.ShowAlwaysObjects.Value;
        }
        if (msg.ShowEditorObjects.HasValue)
        {
            Settings.ShowEditorObjects = msg.ShowEditorObjects.Value;
        }
        if (msg.ShowObjOffsets.HasValue)
        {
            Settings.ShowObjOffsets = msg.ShowObjOffsets.Value;
        }
        if (msg.ShowGizmos.HasValue)
        {
            Settings.ShowDefaultObjIcons = msg.ShowGizmos.Value;
        }
        if (msg.ShowRayman.HasValue)
        {
            Settings.ShowRayman = msg.ShowRayman.Value;
        }
        if (msg.ShowDebugInfo.HasValue)
        {
            Settings.ShowDebugInfo = msg.ShowDebugInfo.Value;
        }
        if (msg.StateSwitchingMode.HasValue)
        {
            Settings.StateSwitchingMode = msg.StateSwitchingMode.Value;
        }
        if (msg.ShowGridMap.HasValue)
        {
            Settings.ShowGridMap = msg.ShowGridMap.Value;
        }
        if (msg.CrashTimeTrialMode.HasValue)
        {
            Settings.GBAVV_Crash_TimeTrialMode = msg.CrashTimeTrialMode.Value;
        }

        if (msg.Layers != null && msg.Layers.Length > 0)
        {
            var lvl = LevelEditorData.Level;
            var tilemapController = Controller.obj?.levelController?.controllerTilemap;
            if (lvl != null && tilemapController != null)
            {
                foreach (var layer in msg.Layers)
                {
                    switch (layer.Index)
                    {
                    case LevelTilemapController.Index_Background:
                        if (lvl.Background != null && tilemapController.background != null)
                        {
                            var bg = tilemapController.background;
                            if (layer.IsVisible.HasValue && layer.IsVisible.Value != bg.gameObject.activeSelf)
                            {
                                bg.gameObject.SetActive(layer.IsVisible.Value);
                            }
                        }
                        break;

                    case LevelTilemapController.Index_ParallaxBackground:
                        if (lvl.ParallaxBackground != null && tilemapController.backgroundParallax != null)
                        {
                            var bg = tilemapController.backgroundParallax;
                            if (layer.IsVisible.HasValue && layer.IsVisible.Value != bg.gameObject.activeSelf)
                            {
                                bg.gameObject.SetActive(layer.IsVisible.Value);
                            }
                        }
                        break;

                    default:
                        if (layer.Index < lvl.Maps.Length && tilemapController.IsLayerVisible != null)
                        {
                            tilemapController.IsLayerVisible[layer.Index] = layer.IsVisible.Value;
                        }
                        break;
                    }
                }
            }
        }
        if (msg.ObjectLayers != null && msg.ObjectLayers.Length > 0 && LevelEditorData.ShowEventsForMaps != null)
        {
            foreach (var layer in msg.ObjectLayers)
            {
                if (layer.IsVisible.HasValue)
                {
                    if (LevelEditorData.ShowEventsForMaps.Length > layer.Index)
                    {
                        LevelEditorData.ShowEventsForMaps[layer.Index] = layer.IsVisible.Value;
                    }
                }
            }
        }
        bool updatedShowCollision = false;

        if (msg.FreeCameraMode.HasValue)
        {
            if (LevelEditorData.Level?.IsometricData != null)
            {
                var cam = Controller.obj?.levelController?.editor?.cam;
                if (cam != null)
                {
                    if (cam.ToggleFreeCameraMode(msg.FreeCameraMode.Value))
                    {
                        updatedShowCollision = true;
                    }
                }
            }
        }
        if (msg.Palette.HasValue)
        {
            if (Controller.obj?.levelController?.controllerTilemap != null)
            {
                if (Controller.obj.levelController.controllerTilemap.HasAutoPaletteOption)
                {
                    Controller.obj.levelController.controllerTilemap.currentPalette = msg.Palette.Value;
                }
                else
                {
                    Controller.obj.levelController.controllerTilemap.currentPalette = msg.Palette.Value + 1;
                }
            }
        }

        if (msg.BackgroundTint.HasValue)
        {
            var bgTint = Controller.obj?.levelController?.controllerTilemap?.backgroundTint;
            if (bgTint != null)
            {
                bgTint.color = msg.BackgroundTint.Value;
            }
        }
        if (msg.BackgroundTintDark.HasValue)
        {
            Camera.main.backgroundColor = msg.BackgroundTintDark.Value;
        }
        if (updatedShowCollision)
        {
            SendSettings();
        }
    }
Exemple #4
0
    private WebJSON.Settings GetSettingsJSON()
    {
        WebJSON.Settings s = new WebJSON.Settings()
        {
            ShowObjects         = Settings.ShowObjects,
            ShowTiles           = Settings.ShowTiles,
            ShowCollision       = Settings.ShowCollision,
            ShowLinks           = Settings.ShowLinks,
            ShowObjCollision    = Settings.ShowObjCollision,
            AnimateSprites      = Settings.AnimateSprites,
            AnimateTiles        = Settings.AnimateTiles,
            ShowAlwaysObjects   = Settings.ShowAlwaysObjects,
            ShowEditorObjects   = Settings.ShowEditorObjects,
            ShowDebugInfo       = Settings.ShowDebugInfo,
            ShowDefaultObjIcons = Settings.ShowDefaultObjIcons,
            ShowObjOffsets      = Settings.ShowObjOffsets,
            ShowRayman          = Settings.ShowRayman,
            StateSwitchingMode  = Settings.StateSwitchingMode
        };

        // Add layers
        var lvl = LevelEditorData.Level;

        if (lvl != null)
        {
            List <WebJSON.Layer> layers = new List <WebJSON.Layer>();
            if (lvl.Background != null && Controller.obj?.levelController?.controllerTilemap?.background != null)
            {
                layers.Add(new WebJSON.Layer()
                {
                    Index     = -2,
                    IsVisible = Controller.obj.levelController.controllerTilemap.background.gameObject.activeSelf
                });
            }

            if (lvl.ParallaxBackground != null && Controller.obj?.levelController?.controllerTilemap?.backgroundParallax != null)
            {
                layers.Add(new WebJSON.Layer()
                {
                    Index     = -1,
                    IsVisible = Controller.obj.levelController.controllerTilemap.backgroundParallax.gameObject.activeSelf
                });
            }

            if (Controller.obj?.levelController?.controllerTilemap?.GraphicsTilemaps != null)
            {
                for (int i = 0; i < lvl.Maps.Length; i++)
                {
                    var tilemaps = Controller.obj.levelController.controllerTilemap.GraphicsTilemaps;
                    layers.Add(new WebJSON.Layer()
                    {
                        Index     = i,
                        IsVisible = tilemaps[i].gameObject.activeSelf
                    });
                }
            }
            if (layers.Count > 0)
            {
                s.Layers = layers.ToArray();
            }

            if (Controller.obj.levelController.controllerTilemap.HasAutoPaletteOption)
            {
                s.Palettes = new string[] { "Auto" }
                .Concat(Enumerable.Range(0, lvl.Maps.Max(x => x.TileSet.Length)).Select(x => x.ToString())).ToArray();

                if (Controller.obj?.levelController?.controllerTilemap != null)
                {
                    s.Palette = Controller.obj.levelController.controllerTilemap.currentPalette;
                }
            }
            else
            {
                s.Palettes = Enumerable.Range(0, lvl.Maps.Max(x => x.TileSet.Length)).Select(x => x.ToString()).ToArray();

                if (Controller.obj?.levelController?.controllerTilemap != null)
                {
                    s.Palette = Controller.obj.levelController.controllerTilemap.currentPalette - 1;
                }
            }
        }

        return(s);
    }
    private WebJSON.Settings GetSettingsJSON()
    {
        WebJSON.Settings s = new WebJSON.Settings()
        {
            ShowObjects        = Settings.ShowObjects,
            ShowTiles          = Settings.ShowTiles,
            ShowCollision      = Settings.ShowCollision,
            ShowLinks          = Settings.ShowLinks,
            ShowObjCollision   = Settings.ShowObjCollision,
            AnimateSprites     = Settings.AnimateSprites,
            AnimateTiles       = Settings.AnimateTiles,
            ShowAlwaysObjects  = Settings.ShowAlwaysObjects,
            ShowEditorObjects  = Settings.ShowEditorObjects,
            ShowDebugInfo      = Settings.ShowDebugInfo,
            ShowGizmos         = Settings.ShowDefaultObjIcons,
            ShowObjOffsets     = Settings.ShowObjOffsets,
            ShowRayman         = Settings.ShowRayman,
            StateSwitchingMode = Settings.StateSwitchingMode,
            ShowGridMap        = Settings.ShowGridMap,
            CrashTimeTrialMode = Settings.GBAVV_Crash_TimeTrialMode
        };

        // Add layers
        var c = LevelEditorData.MainContext;

        s.CanUseStateSwitchingMode = (c?.Settings?.MajorEngineVersion == MajorEngineVersion.Rayman1) == true;
        s.CanUseCrashTimeTrialMode = (c?.Settings?.EngineVersion == EngineVersion.GBAVV_Crash1 || c?.Settings?.EngineVersion == EngineVersion.GBAVV_Crash2) == true;
        var lvl = LevelEditorData.Level;

        if (Controller.obj?.levelController?.controllerTilemap != null)
        {
            var tc = Controller.obj?.levelController?.controllerTilemap;
            s.HasAnimatedTiles = tc.HasAnimatedTiles;
        }
        if (lvl != null)
        {
            s.CanUseFreeCameraMode = lvl.IsometricData != null;
            List <WebJSON.Layer> layers = new List <WebJSON.Layer>();
            if (lvl.Background != null && Controller.obj?.levelController?.controllerTilemap?.background != null)
            {
                layers.Add(new WebJSON.Layer()
                {
                    Index     = LevelTilemapController.Index_Background,
                    IsVisible = Controller.obj.levelController.controllerTilemap.background.gameObject.activeSelf
                });
            }

            if (lvl.ParallaxBackground != null && Controller.obj?.levelController?.controllerTilemap?.backgroundParallax != null)
            {
                layers.Add(new WebJSON.Layer()
                {
                    Index     = LevelTilemapController.Index_ParallaxBackground,
                    IsVisible = Controller.obj.levelController.controllerTilemap.backgroundParallax.gameObject.activeSelf
                });
            }

            var visibility = Controller.obj?.levelController?.controllerTilemap?.IsLayerVisible;
            if (visibility != null)
            {
                for (int i = 0; i < visibility.Length; i++)
                {
                    /*if (!LevelEditorData.Level.Maps[i].Type.HasFlag(Unity_Map.MapType.Graphics))
                     *  continue;*/
                    layers.Add(new WebJSON.Layer()
                    {
                        Index     = i,
                        IsVisible = visibility[i]
                    });
                }
            }
            if (layers.Count > 0)
            {
                s.Layers = layers.ToArray();
            }
            if (c?.Settings.EngineVersion == EngineVersion.R2_PS1)
            {
                var objLayers = Controller.obj.levelController.Objects
                                .Select(o => o.ObjData.MapLayer).Distinct()
                                .Where(l => l.HasValue && (LevelEditorData.ShowEventsForMaps?.Length ?? 0) > l.Value);
                s.ObjectLayers = objLayers.Select(l => new WebJSON.Layer()
                {
                    Index     = l.Value,
                    IsVisible = LevelEditorData.ShowEventsForMaps[l.Value]
                }).OrderBy(ol => ol.Index).ToArray();
            }

            if (Controller.obj.levelController.controllerTilemap.HasAutoPaletteOption)
            {
                s.Palettes = new string[] { "Auto" }
                .Concat(Enumerable.Range(0, lvl.Maps.Max(x => x.TileSet.Length)).Select(x => x.ToString())).ToArray();

                if (Controller.obj?.levelController?.controllerTilemap != null)
                {
                    s.Palette = Controller.obj.levelController.controllerTilemap.currentPalette;
                }
            }
            else
            {
                s.Palettes = Enumerable.Range(0, lvl.Maps.Max(x => x.TileSet.Length)).Select(x => x.ToString()).ToArray();

                if (Controller.obj?.levelController?.controllerTilemap != null)
                {
                    s.Palette = Controller.obj.levelController.controllerTilemap.currentPalette - 1;
                }
            }
        }

        // Add free camera mode
        if (LevelEditorData.Level?.IsometricData != null)
        {
            var cam = Controller.obj?.levelController?.editor?.cam;
            if (cam != null)
            {
                s.FreeCameraMode = cam.FreeCameraMode;
            }
        }

        return(s);
    }