private void GenerateSixLines(Vector3 rootPosition) { GameObject table = GameObject.Find("Table"); GameObject sixLinesContainer = new GameObject("SixLines"); sixLinesContainer.transform.parent = table.transform; int number = 1; for (int column = 0; column < 11; column++) { float fieldPosX = rootPosition.x + offset.x / 2 + offset.x * column; float fieldPosY = rootPosition.y + offset.y / 2 + offset.y * 2; Vector3 betPosition = new Vector3(fieldPosX, fieldPosY, 0); GameObject betFieldGO = Instantiate(betFieldPrefab, sixLinesContainer.transform) as GameObject; betFieldGO.name = String.Format("SixLine_{0},{1},{2}", number, number + 1, number + 2); betFieldGO.transform.position = betPosition; BetField betField = betFieldGO.GetComponent <BetField>(); betField.Number = -1; betField.BetType = BetDef.BetType.SixLine; betField.RelatedFields = new List <BetField>(); for (int i = number; i <= number + 5; i++) { betField.RelatedFields.Add(GameObject.Find("Straight_" + i).GetComponent <BetField>()); } number += 3; } }
private void GenerateStraights(Vector3 rootPosition) { GameObject table = GameObject.Find("Table"); GameObject straightsContainer = new GameObject("Straights"); straightsContainer.transform.parent = table.transform; int number = 1; for (int column = 0; column < 12; column++) { for (int row = 0; row < 3; row++) { float fieldPosX = rootPosition.x + offset.x * column; float fieldPosY = rootPosition.y + offset.y * row; Vector3 betPosition = new Vector3(fieldPosX, fieldPosY, 0); GameObject betFieldGO = Instantiate(betFieldPrefab, straightsContainer.transform) as GameObject; betFieldGO.name = "Straight_" + number; betFieldGO.transform.position = betPosition; BetField betField = betFieldGO.GetComponent <BetField>(); betField.Number = number; betField.BetType = BetDef.BetType.Straight; number++; } } }
private void LightUpClosestBetField() { BetField newClosestBetField = FindClosestBetField(); if (newClosestBetField != closestBetField) { if (closestBetField != null) { closestBetField.TurnHighlightsForRelatedFields(false); } closestBetField = newClosestBetField; closestBetField.TurnHighlightsForRelatedFields(true); } }
private BetField FindClosestBetField() { float minDistance = float.PositiveInfinity; BetField currentClosestBetField = null; foreach (BetField betField in betFields) { float distance = Vector2.Distance(betField.transform.position, heldChip.transform.position); if (distance < minDistance) { minDistance = distance; currentClosestBetField = betField; } } return(currentClosestBetField); }
private void GenerateFixedNumberBetFields(BetDef.BetType betType) { GameObject table = GameObject.Find("Table"); Vector2 betFieldPosition = new Vector2(); try { betFieldPosition = table.transform.Find(betType.ToString()).gameObject.transform.position; } catch (NullReferenceException ex) { Debug.LogError("You need to create this BetField in Table: " + betType.ToString()); } GameObject betFieldGO = Instantiate(betFieldPrefab, table.transform) as GameObject; betFieldGO.transform.position = betFieldPosition; betFieldGO.name = betType.ToString(); DestroyImmediate(table.transform.Find(betType.ToString()).gameObject); foreach (BetField bf in betFieldGO.GetComponents <BetField>()) { DestroyImmediate(bf); } BetField betField = betFieldGO.AddComponent <BetField>(); betField.Number = -1; betField.BetType = betType; betField.RelatedFields = new List <BetField>(); foreach (int number in BetDef.betFixedNumbers[betType]) { betField.RelatedFields.Add(GameObject.Find("Straight_" + number).GetComponent <BetField>()); } }
private void GenerateCorners(Vector3 rootPosition) { GameObject table = GameObject.Find("Table"); GameObject cornersContainer = new GameObject("Corners"); cornersContainer.transform.parent = table.transform; int number = 1; for (int column = 0; column < 11; column++) { for (int row = 0; row < 2; row++) { float fieldPosX = rootPosition.x + offset.x / 2 + offset.x * column; float fieldPosY = rootPosition.y + offset.y / 2 + offset.y * row; Vector3 betPosition = new Vector3(fieldPosX, fieldPosY, 0); GameObject betFieldGO = Instantiate(betFieldPrefab, cornersContainer.transform) as GameObject; betFieldGO.name = String.Format("Corner_{0},{1},{2},{3}", number, number + 1, number + 3, number + 4); betFieldGO.transform.position = betPosition; BetField betField = betFieldGO.GetComponent <BetField>(); betField.Number = -1; betField.BetType = BetDef.BetType.Corner; betField.RelatedFields = new List <BetField>(); betField.RelatedFields.Add(GameObject.Find("Straight_" + number).GetComponent <BetField>()); betField.RelatedFields.Add(GameObject.Find("Straight_" + (number + 1)).GetComponent <BetField>()); betField.RelatedFields.Add(GameObject.Find("Straight_" + (number + 3)).GetComponent <BetField>()); betField.RelatedFields.Add(GameObject.Find("Straight_" + (number + 4)).GetComponent <BetField>()); number++; } number++; } }
private void GenerateSplits(Vector3 rootPosition) { GameObject table = GameObject.Find("Table"); // Horizontal lines splits GameObject splitsContainer = new GameObject("HorizontalSplits"); splitsContainer.transform.parent = table.transform; int number = 1; for (int column = 0; column < 12; column++) { for (int row = 0; row < 2; row++) { float fieldPosX = rootPosition.x + offset.x * column; float fieldPosY = rootPosition.y + offset.y / 2 + offset.y * row; Vector3 betPosition = new Vector3(fieldPosX, fieldPosY, 0); GameObject betFieldGO = Instantiate(betFieldPrefab, splitsContainer.transform) as GameObject; betFieldGO.name = String.Format("Split_{0},{1}", number, number + 1); betFieldGO.transform.position = betPosition; BetField betField = betFieldGO.GetComponent <BetField>(); betField.Number = -1; betField.BetType = BetDef.BetType.Split; betField.RelatedFields = new List <BetField>(); betField.RelatedFields.Add(GameObject.Find("Straight_" + number).GetComponent <BetField>()); betField.RelatedFields.Add(GameObject.Find("Straight_" + (number + 1)).GetComponent <BetField>()); number++; } number++; } // Vertical lines splits GameObject verticalSplitsContainer = new GameObject("VerticalSplits"); verticalSplitsContainer.transform.parent = table.transform; number = 1; for (int column = 0; column < 11; column++) { for (int row = 0; row < 3; row++) { float fieldPosX = rootPosition.x + offset.x / 2 + offset.x * column; float fieldPosY = rootPosition.y + offset.y * row; Vector3 betPosition = new Vector3(fieldPosX, fieldPosY, 0); GameObject betFieldGO = Instantiate(betFieldPrefab, verticalSplitsContainer.transform) as GameObject; betFieldGO.name = String.Format("Split_{0},{1}", number, number + 3); betFieldGO.transform.position = betPosition; BetField betField = betFieldGO.GetComponent <BetField>(); betField.Number = -1; betField.BetType = BetDef.BetType.Split; betField.RelatedFields = new List <BetField>(); betField.RelatedFields.Add(GameObject.Find("Straight_" + number).GetComponent <BetField>()); betField.RelatedFields.Add(GameObject.Find("Straight_" + (number + 3)).GetComponent <BetField>()); number++; } } }