Exemplo n.º 1
0
    public void Setup(ImagesAndUrl iAU)
    {
        gather1.sprite = iAU.sprites[0];
        split1.sprite  = iAU.sprites[0];

        gather2.sprite = iAU.sprites[1];
        split2.sprite  = iAU.sprites[1];

        gather3.sprite = iAU.sprites[2];
        split3.sprite  = iAU.sprites[2];
    }
    void Update()
    {
        if (!imagesAreLoaded && !ImageLoader.Instance.IsLoading)
        {
            Setup();
            imagesAreLoaded = true;
        }

        if (imagesLoaded)
        {
            ImagesAndUrl firstImg = imageLines[0].CurrentSelected;

            bool imageLinesAreSteady = imageLines.Where((iL => iL.IsMoving)).Count() == 0;

            bool isMatching = !matchSurpressed && firstImg == imageLines[1].CurrentSelected && firstImg == imageLines[2].CurrentSelected && imageLinesAreSteady;


            if (isMatching != showingMatchOverlay)
            {
                lastMatch = firstImg;
                ToggleMatchOverlay(isMatching, firstImg);
            }
        }

        if (Input.GetMouseButton(0))
        {
            lastTouchTime = Time.time;
        }

        if (!showingMag && !showingMatchOverlay && Time.time > lastTouchTime + autoDragPeriod && (autoDragSequence == null || !autoDragSequence.IsActive()))
        {
            autoDragSequence = PerformAutoDrags(1f);
        }
        //return from idle viewing in magazine
        if (showingMag && Time.time - lastTouchTime > 300f)
        {
            lastTouchTime = Time.time;
            browserWrap.ForceReturnFromMagazine();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            settingsPanel.onOffGO.SetActive(!settingsPanel.onOffGO.activeSelf);
        }
    }
Exemplo n.º 3
0
    private IEnumerator ParseFilePathToSprites(string filePath, System.Action <ImagesAndUrl> doneCB)
    {
        string wwwUrl = "file://" + filePath;
        WWW    w      = new WWW(wwwUrl);

        yield return(w);

        if (!string.IsNullOrEmpty(w.error))
        {
            Debug.LogWarning("Error loading from path: " + wwwUrl);
            yield break;
        }

        var tempTexture = new Texture2D(4, 4, TextureFormat.RGBA32, false);

        w.LoadImageIntoTexture(tempTexture);

        int thisMiddleSectionHeight = middleSectionHeight * tempTexture.width / 1080;


        int section1 = (tempTexture.height - thisMiddleSectionHeight) / 2;
        int section2 = section1 + thisMiddleSectionHeight;


        Sprite sBottom = Sprite.Create(tempTexture, new Rect(0, 0, tempTexture.width, section1), new Vector2(0.5f, 0.5f));
        Sprite sMiddle = Sprite.Create(tempTexture, new Rect(0, section1, tempTexture.width, thisMiddleSectionHeight), new Vector2(0.5f, 0.5f));
        Sprite sTop    = Sprite.Create(tempTexture, new Rect(0, section2, tempTexture.width, tempTexture.height - section2), new Vector2(0.5f, 0.5f));

        Debug.Log(string.Format("Cropping middle to: ({0},{1}", tempTexture.width, thisMiddleSectionHeight));
        ImagesAndUrl iAU = new ImagesAndUrl();

        iAU.sprites = new Sprite[3] {
            sTop, sMiddle, sBottom
        };

        string fileName = Path.GetFileName(filePath);

        int indexOf_ = fileName.IndexOf("_");

        iAU.magazineName = fileName.Substring(0, indexOf_);
        iAU.magazineId   = fileName.Substring(indexOf_ + 1, fileName.Length - indexOf_ - 1);

        doneCB(iAU);
    }
    private void ToggleMatchOverlay(bool toActive, ImagesAndUrl match)
    {
        if (match != null)
        {
            matchOverlay.ownGO.SetActive(false);
            matchOverlay.magazineTitelText.text    = match.magazineName;
            matchOverlay.magazineTitelTextEng.text = "You have assembled " + match.magazineName;

            matchOverlay.ownGO.SetActive(true);
        }

        showingMatchOverlay = toActive;
        matchOverlay.ownGO.SetActive(true);
        matchOverlay.canvGroup.alpha = toActive ? 0f : 1f;
        Tweener t = matchOverlay.canvGroup.DOFade(toActive ? 1f: 0f, .5f);

        t.OnComplete(() => {
            matchOverlay.ownGO.SetActive(toActive);
        });

        lastTouchTime = Time.time;
    }
Exemplo n.º 5
0
 private void AddImage(ImagesAndUrl iAU)
 {
     images.Add(iAU);
 }