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); }