// pos : 0..2 public void SetOpenBot(int pos, POS_HEX typePos) { this.typePos = typePos; if (pos == 0) { bot1.gameObject.SetActive(false); } else if (pos == 1) { bot2.gameObject.SetActive(false); } else if (pos == 2) { bot3.gameObject.SetActive(false); } Vector3 angle = coreRotHex.eulerAngles; angle.z += Random.Range(0, 6) * 60f; coreRotHex.eulerAngles = angle; }
private void AddNewHex() { GameObject newHex = Instantiate(hexModel.gameObject) as GameObject; newHex.transform.SetParent(parentHex); Hex hexScript = newHex.GetComponent <Hex>(); int optionNewHex = -1; POS_HEX newPosHext = POS_HEX.LEFT; Vector3 newPos = lastHex.transform.localPosition; if (lastHex.typePos == POS_HEX.MIDDLE) { optionNewHex = Random.Range(0, 3); } else if (lastHex.typePos == POS_HEX.LEFT) { optionNewHex = Random.Range(1, 3); } else { optionNewHex = Random.Range(0, 2); } if (optionNewHex == 0) { newPos.x -= 1.67f; newPos.y += 0.98f; lastHex.SetOpenTop(0); if (lastHex.typePos == POS_HEX.MIDDLE) { newPosHext = POS_HEX.LEFT; } else { newPosHext = POS_HEX.MIDDLE; } hexScript.SetOpenBot(2, newPosHext); } else if (optionNewHex == 1) { newPos.y += 1.968f; lastHex.SetOpenTop(1); newPosHext = lastHex.typePos; hexScript.SetOpenBot(1, newPosHext); } else { newPos.x += 1.67f; newPos.y += 0.98f; lastHex.SetOpenTop(2); if (lastHex.typePos == POS_HEX.MIDDLE) { newPosHext = POS_HEX.RIGHT; } else { newPosHext = POS_HEX.MIDDLE; } hexScript.SetOpenBot(0, newPosHext); } hexScript.transform.localPosition = newPos; lastHex = hexScript; listHex.Add(lastHex); }