private void NewFigure() { int rand = Random.Range(0, dfig.Length); queueFigures.Enqueue(rand); if (queueFigures.Count == 1) { rand = Random.Range(0, dfig.Length); queueFigures.Enqueue(rand); } hintFig.DrawFigure(dfig[queueFigures.ElementAt(1)]); DataFigure currentFig = dfig[queueFigures.Dequeue()]; //sprawdzanie czy jest zajęte miejsce Block[] bls = new Block[currentFig.v.Length]; int i = 0; foreach (Vector2 v2 in currentFig.v) { bls[i] = new Block(v2, currentFig.col); i++; } fig = new Figure(bls, currentFig.center); fig.Set(new Vector2(_downCenter.x, _downCenter.y + _height)); }
public void DrawFigure(DataFigure df) { Clear(); foreach (Vector2 v in df.v) { var result = from a in poshints where a.v2 == v select a; foreach (PositionOfHint pos in result) { //pos.gObject.GetComponent<Image>().color = new Color32(255, 255, 0, 255); pos.gObject.GetComponent <Image>().color = df.col; } } }
private void NewFigure(float partOfWindowX) { AnimationCurve fad = fader; if (GameManager.instance.currentPosMenu == GameManager.stateMenu.Ingame) { fad = faderDuringPlay; } int rand = Random.Range(0, GameManager.instance.board.dfig.Length); DataFigure currentFig = GameManager.instance.board.dfig[rand]; Block[] bls = new Block[currentFig.v.Length]; int i = 0; GameObject parent = new GameObject(); float x = Random.Range(Mathf.Clamp01(partOfWindowX - (0.48f / number)), Mathf.Clamp01(partOfWindowX + (0.48f / number))); float xTo255 = partOfWindowX * 255f; foreach (Vector2 v2 in currentFig.v) { Color32 col = new Color32((byte)(currentFig.col.r * 255), (byte)(currentFig.col.g * 255), (byte)(currentFig.col.b * 255), (byte)(fad.Evaluate(partOfWindowX) * 255)); bls[i] = new Block(v2, col, effect); bls[i].obj.transform.SetParent(parent.transform, true); bls[i].obj.GetComponent <SpriteRenderer>().sortingOrder = -10; i++; } lastPos = x; Vector3 v3 = GameManager.instance.MainCamera.ViewportToWorldPoint(new Vector3(x, 1f, 1f)); v3 = new Vector3(v3.x, v3.y + 2f, 3); parent.transform.position = v3; figs.Add(parent); }