private void DistributeOnPath(Vector3[] pos) { var side = Random.Range(-1, 1); if (Mathf.Abs(_lastSide + side) > 3) { side *= -1; } for (int i = 0; i < pos.Length; i++) { var outPos = _trail.TrailMath(pos[i]); var split = Mathf.Abs(outPos[0].z - outPos[1].z) > 3f; outPos[0].z = Mathf.Floor(outPos[0].z / _gridSystem.Widith) * _gridSystem.Widith; outPos[0].z += (_lastSide + side) * _gridSystem.Widith; outPos[0].y = _infGrid.YGraph(outPos[0]); _coins[_currentCoin + i * 2].transform.position = outPos[0]; _coins[_currentCoin + i * 2].gameObject.SetActive(true); if (split) { outPos[1].z = Mathf.Floor(outPos[1].z / _gridSystem.Widith) * _gridSystem.Widith; outPos[1].z += (_lastSide + side) * _gridSystem.Widith; outPos[1].y = _infGrid.YGraph(outPos[1]); _coins[_currentCoin + i * 2 + 1].transform.position = outPos[1]; _coins[_currentCoin + i * 2 + 1].gameObject.SetActive(true); } } _lastSide = _lastSide + side; _currentCoin = (_currentCoin + _mul) % CoinPool * _mul; }
private void DebugCoins() { var cam = Camera.current; var gr = (InfiniteHexGrid)_self.GridSystem.Grid; if (gr == null) { return; } var view = cam.transform.TransformPoint(Vector3.forward * 5); var w = 5f; var x = ((int)(view.x - w * 30) / w) * w; var z = ((int)(view.z - w * 5) / w) * w; var y = gr.YGraph(new Vector3(x, 0, z)); var color = Handles.color; Handles.color = Color.green; for (int ix = 0; ix < 20; ix++) { var oz = z; var nx = (int)((x + w) / w) * w; for (int iy = 0; iy < 10; iy++) { var px = new Vector3(x, gr.YGraph(new Vector3(x, 0, z)), z); var nz = (int)((z + w) / w) * w; var coinPos = _self.TrailMath(px); for (int i = 0; i < coinPos.Length; i++) { Handles.color = new Color(i % 2, (i + 1) % 2, 0.5f, 1); coinPos[i].y = 0; Handles.DrawLine(coinPos[i], coinPos[i] + Vector3.forward); Handles.DrawLine(coinPos[i], coinPos[i] + Vector3.right); Handles.DrawLine(coinPos[i], coinPos[i] - Vector3.forward); Handles.DrawLine(coinPos[i], coinPos[i] - Vector3.right); } z = nz; } z = oz; x = nx; } Handles.color = color; }
void Draw(Vector3 p) { if (p.x < 500) { return; } p.x += Offset; var space = GetSpace(); var pos = new Vector3[] { new Vector3(p.x, 0, Mathf.Floor(p.z / space) * space), new Vector3(p.x, 0, Mathf.Floor(p.z / space) * space + _trail.Step), new Vector3(p.x, 0, Mathf.Floor(p.z / space) * space - _trail.Step), }; var offset = Random.Range(-1, 1); var rot = Random.Range(0, 360); for (int i = 0; i < pos.Length; i++) { var outPos = _trail.TrailMath(pos[i]); var split = Mathf.Abs(outPos[0].z - outPos[1].z) > 1f; outPos[0].z = Mathf.Floor(outPos[0].z / _gridSystem.Widith) * _gridSystem.Widith; outPos[0].z += offset * _gridSystem.Widith; outPos[0].y = _infGrid.YGraph(outPos[0]); _pool[_currentCoin + i * 2].transform.eulerAngles = new Vector3(0, rot, 0); _pool[_currentCoin + i * 2].transform.position = outPos[0]; _pool[_currentCoin + i * 2].gameObject.SetActive(true); if (split) { outPos[1].z = Mathf.Floor(outPos[0].z / _gridSystem.Widith) * _gridSystem.Widith; outPos[1].z += offset * _gridSystem.Widith; outPos[1].y = _infGrid.YGraph(outPos[1]); _pool[_currentCoin + i * 2 + 1].transform.eulerAngles = new Vector3(0, rot, 0); _pool[_currentCoin + i * 2 + 1].transform.position = outPos[1]; _pool[_currentCoin + i * 2 + 1].gameObject.SetActive(true); } } _currentCoin = (_currentCoin + _mul) % PoolSize * _mul; }