private void UpdateItemPosition(ExplodedItem item) { float angle = (item.Param * 360) + RotationalOffset; angle = angle % 360 - 180; float stagger = Stagger * item.RandomSeed; float margin = Margin; if (Mathf.Abs(angle) > 90) { item.TextMesh.anchor = TextAnchor.MiddleRight; item.transform.parent.localPosition = new Vector3(-margin, 0, 0); item.transform.localPosition = new Vector3(stagger, 0, 0); item.transform.parent.localRotation = Quaternion.Euler(0, Slant, 0); angle += 180; if (angle > 180) { angle = Mathf.Lerp(270, angle, Gap); } else { angle = Mathf.Lerp(-90, angle, Gap); } } else { item.TextMesh.anchor = TextAnchor.MiddleLeft; item.transform.parent.localPosition = new Vector3(margin, 0, 0); item.transform.localPosition = new Vector3(-stagger, 0, 0); item.transform.parent.localRotation = Quaternion.Euler(0, 0 - Slant, 0); angle = Mathf.Lerp(90f, angle % 360, Gap); } item.transform.parent.parent.localRotation = Quaternion.Euler(0, 0, angle); }
private List <ExplodedItem> CreateExplodedItems(SignitureItem[] items) { List <ExplodedItem> ret = new List <ExplodedItem>(); foreach (SignitureItem item in items) { ExplodedItem explodedItem = InitializeExplodedItem(item); ret.Add(explodedItem); } return(ret); }
private void EstablishParams(float totalSize) { float total = 0; for (int i = 0; i < _explodedItems.Count; i++) { ExplodedItem item = _explodedItems[i]; float current = total + (item.Size / 2); total += item.Size; item.Param = current / totalSize; } }
private float EstablishSizes() { float ret = 0; for (int i = 0; i < _explodedItems.Count; i++) { ExplodedItem item = _explodedItems[i]; float rawRank = (float)item.Item.Rank / _itemsCount; item.Size = GetItemHeight(rawRank); ret += item.Size; } return(ret); }
private ExplodedItem InitializeExplodedItem(SignitureItem item) { GameObject pivotA = new GameObject(); pivotA.transform.parent = transform; GameObject pivotB = new GameObject(); pivotB.transform.parent = pivotA.transform; GameObject newObj = Instantiate(TextMeshPrefab); newObj.transform.parent = pivotB.transform; ExplodedItem explodedItem = newObj.GetComponent <ExplodedItem>(); explodedItem.Item = item; explodedItem.RandomSeed = UnityEngine.Random.value; explodedItem.TextMesh.text = GetTextFor(item); explodedItem.Renderer = newObj.GetComponent <MeshRenderer>(); return(explodedItem); }
private void SetSize(ExplodedItem item) { item.transform.localScale = new Vector3(item.Size, item.Size, item.Size); }