Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float count = _board.Reinforcements.Count + 1;
- int i = 1;
- float scale = 2;
- foreach (Piece ri in _board.Reinforcements)
- {
- // create new reinforcements
- GameObject s = PieceView.CreatePiece((dynamic)ri);
- // place in Reinforcment panel
- Vector3[] v = new Vector3[4];
- ReinforcementsPanel.GetWorldCorners(v);
- Vector3 bottomLeft = Camera.main.ScreenToWorldPoint(v[0]);
- Vector3 topRight = Camera.main.ScreenToWorldPoint(v[2]);
- float x0 = bottomLeft.x;
- float x1 = topRight.x;
- float y0 = bottomLeft.y;
- float y1 = topRight.y;
- float panelWidth = x1 - x0;
- float panelHeight = y1 - y0;
- Vector3 rect = s.GetComponent<SpriteRenderer>().bounds.size;
- float shipWidth = rect.x*scale;
- float shipHeight = rect.y*scale;
- float x = bottomLeft.x;
- switch (ri.ReinforcementDelay)
- {
- case 0:
- x += shipWidth / 2.0f;
- break;
- case 1:
- x += panelWidth / 2.0f;
- break;
- case 2:
- x += panelWidth - shipWidth / 2.0f;
- break;
- }
- float y = panelHeight * ((float)(i++)) / count + bottomLeft.y;
- s.transform.localPosition = new Vector3(x, y, 0);
- s.transform.localScale = new Vector3(scale, scale, 1);
- s.transform.parent = ReinforcementsPanel.transform;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement