示例#1
0
    private void ShowScore(string scoreText, int player, GUIStyle style)
    {
        Vector3 p = Camera.main.WorldToScreenPoint(ScoreDisplay.transform.position);

        p.y = Screen.height - p.y;

        GUIContent content = new GUIContent(scoreText);

        float min;
        float max;

        style.CalcMinMaxWidth(content, out min, out max);
        float height = style.CalcHeight(content, max);

        max += 50;

        if (PlayersPlaying > 1)
        {
            if (player == 0)
            {
                p.x -= max;
            }
            else
            {
                p.x += max * 0.15f;
            }
        }
        else
        {
            p.x -= max / 2.0f;
        }

        GUI.BeginGroup(new Rect(p.x, p.y - (height / 2.0f), max, 100));

        if (player == CurrentPlayer)
        {
            // #FFAD14
            FontColorUtils.DrawTextWithShadow(scoreText, "#ffad14", max, height, style, 6, 6);
        }
        else
        {
            FontColorUtils.DrawText(scoreText, max, height, style);
        }

        GUI.EndGroup();
    }
示例#2
0
        private void OnGUI()
        {
            GUIStyle style = new GUIStyle();

            style.richText  = true;
            style.wordWrap  = true;
            style.fontSize  = (int)(32 * Initialize.Scale);
            style.fontStyle = FontStyle.Bold;
            style.font      = DefaultFont;

            Vector3 p = Camera.main.WorldToScreenPoint(SpawnLocation.transform.position);

            p.y = Screen.height - p.y;

            GUI.BeginGroup(new Rect(p.x, p.y, 500, 50));
            FontColorUtils.DrawTextWithShadow(Title, 500, 50, style);
            GUI.EndGroup();
        }
示例#3
0
    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();
    }
        private void ShowScore(GameObject obj, Transform offsetX, GUIStyle style, string score)
        {
            Vector3 rawPosition = obj.transform.position;

            rawPosition.x = offsetX.position.x;

            Vector3 start = Camera.main.WorldToScreenPoint(rawPosition);

            start.y = Screen.height - start.y;

            float      minWidth, maxWidth;
            string     text    = TextFormatting.AddSpacingBetweenCharacters(score);
            GUIContent content = new GUIContent(text);

            style.CalcMinMaxWidth(content, out minWidth, out maxWidth);
            float height = style.CalcHeight(content, maxWidth);

            height /= 2.0f;

            float halfWidth = maxWidth / 2.0f;

            GUI.Label(new Rect(start.x - halfWidth - 3, start.y + 2 - height, maxWidth, 120), FontColorUtils.Shadow(text), style);
            GUI.Label(new Rect(start.x - halfWidth, start.y - height, maxWidth, 120), FontColorUtils.MainGameScore(text), style);
        }