コード例 #1
0
        private void AddToSet2(ImageViewWithFrame imageView)
        {
            Vector3 p = new Vector3(Scale(10), Scale(10));

            var startPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckStartLocation.transform.position);
            startPosition.y = Screen.height - startPosition.y;

            var endPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckEndLocation.transform.position);
            endPosition.y = Screen.height - endPosition.y;

            float controlWidth = endPosition.x - startPosition.x;
            float fullSize = controlWidth / 3.6f;

            var framedImage = new ImageViewWithFrame();
            framedImage.BigSize = (int)(fullSize * 0.9f);
            framedImage.ImageTexture = imageView.ImageTexture;
            framedImage.FrameTexture = imageView.FrameTexture;
            framedImage.LeftMargin = p.x + (int)(fullSize * 0.05f) + (fullSize * (x % breakIn));
            framedImage.RightMargin = (int)(fullSize * 0.05f);
            framedImage.TopMargin = p.y + (((p.y * 2) + framedImage.BigSize) * (int)(x / breakIn));
            framedImage.MeasureSize();

            var cancelImage = new ImageView();
            cancelImage.Width = cancelImage.Height = (int)(framedImage.BigSize * 0.12);
            cancelImage.ImageScaleMode = ScaleMode.ScaleToFit;
            cancelImage.LeftMargin = (int)framedImage.LeftMargin + (int)(framedImage.BigSize * 0.85);
            cancelImage.TopMargin = (int)framedImage.TopMargin + Scale(5);
            cancelImage.ImageTexture = MiniCancelTexture;
            cancelImage.MeasureSize();

            selectedCardsImages.Add(framedImage);

            selectedCardsScrollContentHeight = framedImage.TopMargin + framedImage.Rect.height;
            ++x;
        }
コード例 #2
0
        private void AddToSet(ImageViewWithFrame imageView)
        {
            Vector3 p = new Vector3(Scale(10), Scale(10));

            var startPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckStartLocation.transform.position);
            startPosition.y = Screen.height - startPosition.y;

            var endPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckEndLocation.transform.position);
            endPosition.y = Screen.height - endPosition.y;

            float controlWidth = endPosition.x - startPosition.x;
            float fullSize = controlWidth / 3.6f;

            GroupControl item = new GroupControl();

            var framedImage = new ImageViewWithFrame();
            framedImage.BigSize = (int)(fullSize * 0.9f);
            framedImage.ImageTexture = imageView.ImageTexture;
            framedImage.FrameTexture = imageView.FrameTexture;
            framedImage.LeftMargin = 0;
            framedImage.RightMargin = (int)(fullSize * 0.05f);
            framedImage.TopMargin = 0;
            framedImage.MeasureSize();

            item.Items.Add(framedImage);

            Rect rect = new Rect();
            rect.x = (int)(p.x + (int)(fullSize * 0.05f) + (fullSize * (x % breakIn)));
            rect.y = (int)(p.y + (((p.y * 2) + framedImage.BigSize) * (int)(x / breakIn)));
            rect.width = framedImage.Rect.width;
            rect.height = framedImage.Rect.height;
            item.Rect = rect;

            var cancelImage = new ImageView();
            cancelImage.Width = cancelImage.Height = (int)(fullSize * 0.22);
            cancelImage.ImageScaleMode = ScaleMode.ScaleToFit;
            cancelImage.Offset.x = (int)(fullSize * 0.74);
            cancelImage.Offset.y = (int)(fullSize * 0.11);
            cancelImage.ImageTexture = MiniCancelTexture;
            cancelImage.MeasureSize();

            // Revert auto scalling stuff in measure size.
            rect = cancelImage.ImageRect;
            rect.x = cancelImage.Offset.x;
            rect.y = cancelImage.Offset.y;
            rect.width = rect.height = cancelImage.Width;
            cancelImage.ImageRect = rect;

            item.Tag = imageView.Tag;
            item.Items.Add(cancelImage);
            selectedCardsImages.Add(item);

            item.MeasureSize();

            selectedCardsScrollContentHeight = item.Rect.y + item.Rect.height;
            ++x;
        }
コード例 #3
0
ファイル: ShowDecks.cs プロジェクト: phicuong08/memorymatch
    private IEnumerator LoadDecks()
    {
        deckControls.Clear();
        scrollViewVector = Vector2.zero;

        Vector3 p = Camera.main.WorldToScreenPoint(SpawnObject.transform.position);
        p.y = Screen.height - p.y;

        Vector3 e = Camera.main.WorldToScreenPoint(SpawnEndObject.transform.position);
        e.y = Screen.height - e.y;

        BigSize = (int)(((e.y - p.y) * 0.8f) - Scale(14));
        BigScale = BigSize / (float)Scale(120);

        //Debug.Log(e.y + "-" + p.y + "-" + Scale(14) + "=" + BigSize + "  =>  BigScale = " + BigScale);

        SmallSize = BigSize / 3;
        SmallScale = SmallSize / (float)Scale(40);

        p.y = 10;

        float scaledBigFrameOffsetX = Scale(14) * BigScale;

        float scaledSmallFrameOffsetX = Scale(5) * SmallScale;
        float scaledSmallFrameOffsetY = Scale(5) * SmallScale;

        float firstImageOffsetY = p.y + (Scale(7) * BigScale);
        float secondImageOffsetY = p.y + SmallSize + (Scale(13 + 7) * BigScale);

        p.x -= scaledBigFrameOffsetX - scaledSmallFrameOffsetX;

        if (size > 0)
        {
            DataMessenger.SelectedDeck = decks[0];
        }

        size = decks.Count;
        for (int i = 0; i < size; ++i)
        {
            bool isInResources = decks[i].ImageLocation == "Resources";
            List<CardData> cards = new List<CardData>(decks[i].Cards).OrderBy(o => Guid.NewGuid()).ToList();

            string path = isInResources
                              ? "Decks/" + decks[i].ResourceName + "/" + Path.GetFileNameWithoutExtension(cards[0].Image)
                              : string.Empty;

            var groupControl = new GroupControl();
            var frame = new ImageViewWithFrame();

            yield return StartCoroutine(ImageViewWithFrame(cards[0], frame, BigSize, path, rightMargin: 30));
            groupControl.Items.Add(frame);

            path = isInResources
                       ? "Decks/" + decks[i].ResourceName + "/" + Path.GetFileNameWithoutExtension(cards[1].Image)
                       : string.Empty;
            float leftMargin = scaledBigFrameOffsetX - Scale(9) - scaledSmallFrameOffsetX;
            float topMargin = firstImageOffsetY - scaledSmallFrameOffsetY;

            frame = new ImageViewWithFrame();
            yield return StartCoroutine(ImageViewWithFrame(cards[1], frame, SmallSize, path, leftMargin, topMargin));
            groupControl.Items.Add(frame);

            path = isInResources
                       ? "Decks/" + decks[i].ResourceName + "/" + Path.GetFileNameWithoutExtension(cards[2].Image)
                       : string.Empty;
            topMargin = secondImageOffsetY - scaledSmallFrameOffsetY;

            frame = new ImageViewWithFrame();
            yield return StartCoroutine(ImageViewWithFrame(cards[2], frame, SmallSize, path, leftMargin, topMargin));
            groupControl.Items.Add(frame);

            leftMargin = scaledBigFrameOffsetX + Scale(8);
            topMargin = BigSize - Scale(10);

            GUIStyle style = new GUIStyle
                                 {
                                     fontSize = (int)(24 * Initialize.Scale),
                                     font = DefaultFont,
                                     clipping = TextClipping.Clip,
                                 };

            int textWidth = 200;

            TextView textView = new TextView();
            textView.Content = new GUIContent(FontColorUtils.Shadow(decks[i].Title));
            textView.Style = style;
            textView.Rect = new Rect(leftMargin + 2, topMargin + 2, Scale(textWidth), 100);
            groupControl.Items.Add(textView);

            textView = new TextView();
            textView.Content = new GUIContent(FontColorUtils.DeckTitle(decks[i].Title));
            textView.Style = style;
            textView.Rect = new Rect(leftMargin, topMargin, Scale(textWidth), 100);
            groupControl.Items.Add(textView);

            ImageView imageView = new ImageView();
            imageView.LeftMargin = BigSize - Scale(25);
            imageView.TopMargin = (int)scaledSmallFrameOffsetY + Scale(15);
            imageView.ImageTexture = SelectedTexture;
            imageView.ImageRect = new Rect(0, 0, SelectedTexture.width, SelectedTexture.height);
            imageView.Scale = i == 0 ? 0.3f : 0;
            imageView.Tag = "selected";
            imageView.MeasureSize();
            groupControl.Items.Add(imageView);

            groupControl.Tag = decks[i];
            deckControls.Add(groupControl);

            if (i == 0)
            {
                UpdateDifficultyAvailability();
            }
        }

        p = Camera.main.WorldToScreenPoint(SpawnObject.transform.position);
        p.y = Screen.height - p.y;

        int fullItemWidth = BigSize + Spacing;
        float scaledBigFrameHeight = BigSize + (Scale(27) * BigScale);
        float width = (fullItemWidth * size) + p.x + (Screen.width - e.x - Spacing);

        scrollViewRect = new Rect(0, p.y - 20, Screen.width, scaledBigFrameHeight + Scale(25));
        scrollViewContentRect = new Rect(0, 0, width, scaledBigFrameHeight);

        NextState();
    }