Example #1
0
 public void UpdateObjectList()
 {
     foreach (var objectModel in ObjectManager.instance.objectModels)
     {
         _dropDownWithSearth.options.Add(LevelDataManager.PropertyNameToString(objectModel.Value.objectTag));
     }
 }
    void Start()
    {
        stateInformation = new StateInformation();
        interfaceManager = InterfaceManager.GetInstance();
        prefabsManager   = PrefabsManager.GetInstance();
        levelController  = LevelController.instance;
        levelDataManager = LevelDataManager.GetInstance();

        startupModule           = (IStartupModule)StartupModule.GetInstance();
        objectDeletionModule    = (IObjectDeletionModule)ObjectDeletionModule.GetInstance();
        objectPlacementModule   = (IObjectPlacementModule)ObjectPlacementModule.GetInstance();
        objectEditingModule     = (IObjectEditingModule)ObjectEditingModule.GetInstance();
        objectInformationModule = (IObjectInformationModule)ObjectInformationModule.GetInstance();


        GameObject leftMouseButtonObject = Instantiate(mouseButtonPrefab, transform);

        leftMouseButton = leftMouseButtonObject.GetComponent <MouseButton>();
        GameObject rightMouseButtonObject = Instantiate(mouseButtonPrefab, transform);

        rightMouseButton = rightMouseButtonObject.GetComponent <MouseButton>();

        leftMouseButton.Setup(0, mouseButtonLeftPressedTime);
        rightMouseButton.Setup(1, cameraDragTime);

        prefabsManager.AddPrefabs();
        interfaceManager.SetupUI(prefabsManager.GetPrefabTable());

        InitializeLevel(initialLevelWidth, initialLevelHeight);
        SetupLevel();
    }
Example #3
0
 public GameData(LevelDataManager lm, PauseMenuManager pm) {
     //level
     levelIndexes = lm.GetLevelsIndexes();
     levelCleared = lm.GetLevelsCleared();
     levelHumanDeaths = lm.GetLevelsHumanDeaths();
     levelDogDeaths = lm.GetLevelsDogDeaths();
     levelClearTimes = lm.GetLevelsClearTimes();
     //audio
     audioMutes = pm.AudioMute;
     audioVolumes = pm.Volumes;
     //quality
     qualityIndex = pm.qualityIndex;
     qualityResolutionIndex = pm.resolutionIndex;
     qualityIsFullscreen = pm.isFullscreen;
     qualityShowFPS = pm.isShowFPS;
     qualityAntiAliasingIndex = pm.antiAliasingIndex;
     qualityVSyncIndex = pm.vSyncIndex;
     //gameplay
     gameplayShowInteractIndicator = pm.showInteractIndicator;
     gameplayShowHintIndicator = pm.showHintIndicator;
     gameplayShowDogVision = pm.showDogVision;
     //controls
     controlsInputPaths = pm.controlsPaths;
     controlsInputID = pm.controlsID;
     gameplaylanguageIndex = pm.languageIndex;
 }
Example #4
0
        void SetNormalImage()
        {
            string    smoothTexResource = LevelDataManager.SmoothImageResource(storyMessages[frameId].pictureId);
            Texture2D smoothTex         = Resources.Load <Texture2D>(smoothTexResource);

            normalStoryImage.image.texture = smoothTex;
            SetImageSize(normalStoryImage);
        }
        public void Initialize()
        {
            descriptor = GlobalManager.MLevel.GetDescriptor(GlobalManager.MStorage.GalleryLevel);
            //int width = descriptor.init.width;
            //int height = descriptor.init.height;
            float finalRatioXY = descriptor.init.finalXYScale;
            float screenAspect = Camera.main.aspect;

            // load STRESS and SMOOTH textures
            string    stressImage = StressImageCreator.StressedFinalImageFile(descriptor.init.id);
            Texture2D stressTex   = new Texture2D(2, 2, TextureFormat.RGB24, false);

            stressTex.LoadImage(System.IO.File.ReadAllBytes(stressImage));
            imageParams[0].winImage.texture = stressTex;
            Texture2D smoothTex = Resources.Load <Texture2D>(LevelDataManager.SmoothImageResource(descriptor.init.id));

            imageParams[1].winImage.texture = smoothTex;

            // set up scaling and UV rectangles
            CanvasScaler canvasScaler = GetComponent <CanvasScaler>();
            // the size of the canvas excluding margins
            Rect sourceCanvasRect = new Rect(0, 0, canvasScaler.referenceResolution.x * (1 - marginRatio), canvasScaler.referenceResolution.y * (1 - marginRatio));

            sourceCanvasSize = new Vector2(sourceCanvasRect.width, sourceCanvasRect.height);
            // SourceCanvas matches screen by width, so the final height scaling should be adjusted by:
            float heightAdjustFactor = sourceCanvasRect.width / sourceCanvasRect.height / screenAspect;

            for (int i = 0; i < imageParams.Length; i++)
            {
                imageParams[i].imageTransform.localPosition = imageParams[i].originalPosition;
                Vector2 canvasToImageRatio = new Vector2(
                    sourceCanvasRect.width / imageParams[i].originalRect.width,
                    sourceCanvasRect.height * heightAdjustFactor / imageParams[i].originalRect.height
                    );
                imageParams[i].sourceScale = new Vector2(
                    finalRatioXY > screenAspect ? canvasToImageRatio.y * finalRatioXY : canvasToImageRatio.x,
                    finalRatioXY > screenAspect ? canvasToImageRatio.y : canvasToImageRatio.x / finalRatioXY
                    );
                imageParams[i].effectiveSize             = Vector2.Scale(new Vector2(imageParams[i].originalRect.width, imageParams[i].originalRect.height), imageParams[i].sourceScale);
                imageParams[i].imageTransform.localScale = imageParams[i].sourceScale;
                currentScale = new FloatRange
                {
                    min = scaleRange.min,
                    max = scaleRange.min
                };
                // UV-coordinates of the image
                imageParams[i].winImage.uvRect = new Rect(0, 0, 1, 1);
                // positions
                //imageParams[i].originalPosition = imageParams[i].imageTransform.localPosition;
                imageParams[i].movePosition = new Vector2[2]
                {
                    imageParams[i].originalPosition,
                    imageParams[i].originalPosition
                };
            }
            effectFinished = false;
            GenerateNewStep(true);
        }
 public void Init(LevelDataManager.Descriptor descriptor, SelectorPrefab prefab, bool noStatusCheck = false)
 {
     levelDescriptor = descriptor;
     meshRenderer    = GetComponent <MeshRenderer>();
     lightBeacon.SetActive(false);
     if (noStatusCheck || levelDescriptor.state.Revealed)
     {
         // set up height above the world sphere
         string     iconPath    = LevelDataManager.GraphicsResource(levelDescriptor.init.id);
         bool       glow        = false;
         float      iconOpacity = normalIconOpacity;
         Material[] materials   = meshRenderer.materials;
         if (noStatusCheck)
         {
             iconPath    += "/icon";
             materials[0] = prefab.opaqueMaterial;
         }
         else
         {
             if (levelDescriptor.state.Playable)
             {
                 Debug.Log("WorldSelectorController.Init: id=" + levelDescriptor.init.id.ToString() + ", playable=" + levelDescriptor.state.Playable.ToString());
                 iconPath += "/icon";
                 if (levelDescriptor.init.id == GlobalManager.MStorage.SelectedLevel)
                 {
                     materials[0] = prefab.glowMaterial;
                     lightBeacon.SetActive(true);
                     glow = true;
                 }
                 else
                 {
                     materials[0] = prefab.opaqueMaterial;
                 }
             }
             else
             {
                 iconPath    += "/grayicon";
                 iconOpacity  = disabledIconOpacity;
                 materials[0] = prefab.transparentMaterial;
             }
         }
         meshRenderer.materials = materials;
         iconRenderer.sprite    = Resources.Load <Sprite>(iconPath);
         Color c = iconRenderer.color;
         c.a = iconOpacity;
         iconRenderer.color = c;
         if (glow)
         {
             StartFlash();
         }
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
Example #7
0
 private void Awake()
 {
     if (instance == null && instance != this)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #8
0
        void UpdateUI(BindKey bindKey)
        {
            if (bindKey.beatObjectData != null)
            {
                string str = bindKey.beatObjectData.objectTag.ToString();
                _objectTagText.text = LevelDataManager.PropertyNameToString(bindKey.beatObjectData.objectTag);
            }

            if (bindKey.key != KeyCode.None)
            {
                _text.text = bindKey.key.ToString();
            }
        }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
Example #10
0
    //private Dictionary<int, LevelSaveData> savedData = new Dictionary<int, LevelSaveData>();

    void Awake()
    {
        //set up singleton instance, destroy if a LevelDataManager already exists.
        if (manager == null)
        {
            manager = this;
            DontDestroyOnLoad(this);
        }
        else if (manager != this)
        {
            Destroy(gameObject);
        }
        SetupLevelData();
    }
Example #11
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         if (this != _instance)
         {
             Destroy(gameObject);
         }
     }
     if (!levelDataSet)
     {
         levelDataSet = Resources.Load <LevelDataSet>("Level Data Set");
     }
 }
Example #12
0
        void ConstructProperties()
        {
            _itemTag.text = LevelDataManager.PropertyNameToString(_selectedObject.objectTag);

            foreach (var propertiesObject in _propertiesObjects)
            {
                Destroy(propertiesObject.gameObject);
            }
            _propertiesObjects.Clear();

            foreach (var modelInput in _selectedObject.modelInputsData)
            {
                GameObject instanceProperty = GetInstanceProperty(modelInput);

                GameObject propertyObject = Instantiate(instanceProperty, instanceProperty.transform.parent);
                propertyObject.SetActive(true);

                ObjectProperty objectProperty = propertyObject.GetComponent <ObjectProperty>();
                objectProperty.Init(modelInput, this);
                _propertiesObjects.Add(objectProperty);
            }
        }
Example #13
0
 void Awake()
 {
     instance = this;
 }
 static void ClearEditorSave()
 {
     LevelDataManager.DeleteAll();
 }
Example #15
0
        void InitializeDialog(LevelDataManager.Descriptor descriptor)
        {
            // calculate dialog size
            int   adjustmentIndex    = -1;
            float currentScreenRatio = (float)Screen.width / (float)Screen.height;

            for (int i = 0; i < dialogAdjustments.Length; i++)
            {
                if (currentScreenRatio >= dialogAdjustments[i].screenAspect)
                {
                    adjustmentIndex = i;
                    break;
                }
            }
            if (adjustmentIndex < 0)
            {
                return;
            }
            // get level data
            string levelStr = descriptor.init.id.ToString("D3");

            titleText.GetComponent <Text>().text = GlobalManager.MLanguage.Entry(titlePrefix + levelStr);
            GameObject activeImage, inactiveImage;
            GameObject activeText, inactiveText;

            // adjust dialog height
            descriptionDialog.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, dialogAdjustments[adjustmentIndex].dialogHeight);

            bool horizontal = descriptor.init.finalXYScale >= 1f;
            // set up image dimensions and the dialog layout depending on "horizontal" or "vertical" image orientation

            float finalImageWidth;
            float finalImageHeight;

            if (horizontal)
            {
                // the maximum height of the image is fixed
                finalImageHeight = dialogAdjustments[adjustmentIndex].maxHorizontalImageSize.y;
                finalImageWidth  = finalImageHeight * descriptor.init.finalXYScale;
                if (finalImageWidth > dialogAdjustments[adjustmentIndex].maxHorizontalImageSize.x)
                {
                    finalImageWidth  = dialogAdjustments[adjustmentIndex].maxHorizontalImageSize.x;
                    finalImageHeight = finalImageWidth / descriptor.init.finalXYScale;
                }
                activeImage   = hDescriptionImage;
                inactiveImage = vDescriptionImage;
                activeText    = hDescriptionText;
                inactiveText  = vDescriptionText;
                // adjust horizontal description text Y-shift
                RectTransform activeTextRectTransform = activeText.GetComponent <RectTransform>();
                Vector2       activeTextPosition      = activeTextRectTransform.localPosition;
                activeTextPosition.y = dialogAdjustments[adjustmentIndex].descriptionYShift;
                activeTextRectTransform.localPosition = activeTextPosition;
            }
            else
            {
                // the maximum width of the image is fixed
                finalImageWidth  = dialogAdjustments[adjustmentIndex].maxVerticalImageSize.x;
                finalImageHeight = finalImageWidth / descriptor.init.finalXYScale;
                if (finalImageHeight > dialogAdjustments[adjustmentIndex].maxVerticalImageSize.y)
                {
                    finalImageHeight = dialogAdjustments[adjustmentIndex].maxVerticalImageSize.y;
                    finalImageWidth  = finalImageHeight * descriptor.init.finalXYScale;
                }
                activeImage   = vDescriptionImage;
                inactiveImage = hDescriptionImage;
                activeText    = vDescriptionText;
                inactiveText  = hDescriptionText;
            }

            activeTextScript          = activeText.GetComponent <Text>();
            activeTextScript.fontSize = dialogAdjustments[adjustmentIndex].descriptionFontSize;
            // activate active objects
            activeImage.SetActive(true);
            activeText.SetActive(true);
            // load "smooth" image
            activeImage.GetComponent <RawImage>().texture = Resources.Load <Texture>(LevelDataManager.SmoothImageResource(descriptor.init.id));
            // and set up its size
            activeImage.GetComponent <RectTransform>().localScale = new Vector3(finalImageWidth, finalImageHeight, 1.0f);
            // set text objects
            activeText.GetComponent <Text>().text = GlobalManager.MLanguage.Entry(descriptionPrefix + levelStr);
            // deactivate inactive objects
            inactiveImage.SetActive(false);
            inactiveText.SetActive(false);
            okButton.GetComponent <Button>().interactable = true;
            Visualize(flashRange.min);
            // now activate the dialog
            gameObject.SetActive(true);
            StartFlash(true);
        }
        IEnumerator BgStressImage(int level)
        {
            float  startTime             = Time.realtimeSinceStartup;
            string sourceGraphicResource = LevelDataManager.SmoothImageResource(level);

            originalImage = Resources.Load <Texture2D>(sourceGraphicResource);
            //Debug.Log("StressImageCreator.BgStressImage: creating STRESS image from " + sourceGraphicResource + " as " + (originalImage == null ? "null" : originalImage.ToString()));
            int w = originalImage.width;
            int h = originalImage.height;

            //stressedImage = new Texture2D(w, h, originalImage.format, false);
            // only RGBA32 textures are allowed to be written into
            stressedImage = new Texture2D(w, h, TextureFormat.RGBA32, false);
            Color[] ic      = originalImage.GetPixels();
            Color[] oc      = new Color[w * h];
            int     coffset = 0;
            Color   c       = new Color();
            Color   cmin    = c;
            Color   cmax    = c;

            // scan the pixels and calculate the output values
            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++, coffset++)
                {
                    c    = ic[coffset];
                    cmin = c;
                    cmax = c;
                    float   range              = 0f;
                    float   brightness         = 0f;
                    float[] relativeBrightness = new float[4];
                    float[] relativeRange      = new float[4];
                    // compute a pixel value
                    for (int j = 0; j < iterationsCount; j++)
                    {
                        // get minimum and maximum color values from the neighbourhood
                        int smax = samplesCount;
                        for (int i = 0; i < smax;)
                        {
                            int xn = x + nbradii[radiusCount, 0];
                            int yn = y + nbradii[radiusCount, 1];
                            if (xn >= 0 && xn < w && yn >= 0 && yn < h)
                            {
                                Color cnb = ic[yn * w + xn];
                                // loop unwrap
                                cmin.r = Mathf.Min(cmin.r, cnb.r);
                                cmin.g = Mathf.Min(cmin.g, cnb.g);
                                cmin.b = Mathf.Min(cmin.b, cnb.b);
                                cmax.r = Mathf.Max(cmax.r, cnb.r);
                                cmax.g = Mathf.Max(cmax.g, cnb.g);
                                cmax.b = Mathf.Max(cmax.b, cnb.b);

                                /*
                                 * for (int ci = 0; ci < 3; ci++)
                                 * {
                                 *  cmin[ci] = Mathf.Min(cmin[ci], cnb[ci]);
                                 *  cmax[ci] = Mathf.Max(cmax[ci], cnb[ci]);
                                 * }
                                 */
                                i++;
                            }

                            /*else
                             * {
                             *  smax--;
                             * }*/
                            radiusCount++;
                            if (radiusCount >= neighboursCount)
                            {
                                radiusCount = 0;
                            }
                        }
                        // now calculate cumulative brightness and dynamic range for every color component
                        // loop unwrap
                        range      = cmax.r - cmin.r;
                        brightness = 0.5f;
                        if (range > eps)
                        {
                            brightness = (c.r - cmin.r) / range;
                        }
                        relativeBrightness[0] += brightness;
                        relativeRange[0]      += range;
                        range      = cmax.g - cmin.g;
                        brightness = 0.5f;
                        if (range > eps)
                        {
                            brightness = (c.g - cmin.g) / range;
                        }
                        relativeBrightness[1] += brightness;
                        relativeRange[1]      += range;
                        range      = cmax.b - cmin.b;
                        brightness = 0.5f;
                        if (range > eps)
                        {
                            brightness = (c.b - cmin.b) / range;
                        }
                        relativeBrightness[2] += brightness;
                        relativeRange[2]      += range;

                        /*
                         * for (int ci = 0; ci < 3; ci++)
                         * {
                         *  range = cmax[ci] - cmin[ci];
                         *  brightness = 0.5f;
                         *  if (range > eps)
                         *  {
                         *      brightness = (c[ci] - cmin[ci]) / range;
                         *  }
                         *  relativeBrightness[ci] += brightness;
                         *  relativeRange[ci] += range;
                         * }
                         */
                    }
                    // now calculate max and min envelopes
                    // loop unwrap
                    brightness = relativeBrightness[0] / iterationsCount;
                    range      = relativeRange[0] / iterationsCount;
                    cmax.r     = c.r + (1.0f - brightness) * range;
                    cmin.r     = c.r - brightness * range;
                    brightness = relativeBrightness[1] / iterationsCount;
                    range      = relativeRange[1] / iterationsCount;
                    cmax.g     = c.g + (1.0f - brightness) * range;
                    cmin.g     = c.g - brightness * range;
                    brightness = relativeBrightness[2] / iterationsCount;
                    range      = relativeRange[2] / iterationsCount;
                    cmax.b     = c.b + (1.0f - brightness) * range;
                    cmin.b     = c.b - brightness * range;
                    // now calculate the final value
                    float delta = cmax.r - cmin.r;
                    if (delta > eps)
                    {
                        c.r = (c.r - cmin.r) / delta;
                    }
                    else
                    {
                        c.r = 0.5f;
                    }
                    delta = cmax.g - cmin.g;
                    if (delta > eps)
                    {
                        c.g = (c.g - cmin.g) / delta;
                    }
                    else
                    {
                        c.g = 0.5f;
                    }
                    delta = cmax.b - cmin.b;
                    if (delta > eps)
                    {
                        c.b = (c.b - cmin.b) / delta;
                    }
                    else
                    {
                        c.b = 0.5f;
                    }

                    /*
                     * for (int ci = 0; ci < 3; ci++)
                     * {
                     *  brightness = relativeBrightness[ci] / iterationsCount;
                     *  range = relativeRange[ci] / iterationsCount;
                     *  cmax[ci] = c[ci] + (1.0f - brightness) * range;
                     *  cmin[ci] = c[ci] - brightness * range;
                     *  float delta = cmax[ci] - cmin[ci];
                     *  if (delta > eps)
                     *  {
                     *      c[ci] = (c[ci] - cmin[ci]) / delta;
                     *  }
                     *  else
                     *  {
                     *      c[ci] = 0.5f;
                     *  }
                     * }
                     */
                    // fill the output buffer
                    oc[coffset] = c;
                    // every n-th pixel do a break for the next frame
                    if (coffset % breakCycle == breakCycle - 1)
                    {
                        //Debug.Log("STRESS pixel " + coffset.ToString());
                        //yield return new WaitForFixedUpdate();
                        yield return(null);
                    }
                }
            }
            stressedImage.SetPixels(oc);
            stressedImage.Apply();
            float endTime = Time.realtimeSinceStartup;

            Debug.Log("stress time " + level.ToString() + ": " + (endTime - startTime).ToString());
            // now try to save the stressed image into a file
            var    bytes         = stressedImage.EncodeToJPG();
            string imageFileName = StressedFinalImageFile(level);

            Debug.Log("Writing data to file " + imageFileName);
            System.IO.File.WriteAllBytes(imageFileName, bytes);
            hasStressFile[level] = true;
        }