private void CreateInfo(LostChild childToFind) { string childSize; if (childToFind.getSize().ToString() == "ThiccOhhLordHeComing") { childSize = "Thicc"; } else { childSize = childToFind.getSize().ToString(); } var infoText = childToFind.getColor() + "\n" + childSize + "\n" + childToFind.getHat() + "\n" + childToFind.getStolenItem(); info.text = infoText; }
private void setToddlerProperties(GameObject kid, LostChild properties) { var renderers = kid.GetComponentsInChildren <Renderer>(); foreach (var renderer in renderers) { renderer.material.SetColor("_Color", picker.GetColor(properties.getColor())); } var size = picker.GetSize(properties.getSize()); kid.transform.localScale = new Vector3(size, 1, size); var positions = kid.GetComponent <ToddlerPositions>(); var hatParent = positions.hatTransform; var hat = Instantiate(picker.GetHat(properties.getHat())); hat.transform.position = hatParent.transform.position; hat.transform.localScale = new Vector3(size, 1, size); hat.transform.parent = hatParent; var handParent = positions.handTransform; var item = Instantiate(picker.GetItem(properties.getStolenItem())); item.transform.position = handParent.transform.position; item.transform.parent = handParent; }
public bool offerChild(LostChild offeredChild, string playerName) { int matchingAttributes = 0; if (child.getSize() != null && child.getSize() == offeredChild.getSize()) { matchingAttributes = matchingAttributes + 1; } if (child.getHat() != null && child.getHat() == offeredChild.getHat()) { matchingAttributes = matchingAttributes + 1; } if (child.getColor() != null && child.getColor() == offeredChild.getColor()) { matchingAttributes = matchingAttributes + 1; } if (child.getStolenItem() != null && child.getStolenItem() == offeredChild.getStolenItem()) { matchingAttributes = matchingAttributes + 1; } int scoreNeededToPass = random.Next(1, numberOfAttributes + 1); if (matchingAttributes >= scoreNeededToPass) { //Debug.Log("passed"); sounds.AcceptSound(); changeChild(); /* Give player points */ //Debug.Log("Give player: " + playerName + " " + pointsToGive + " points."); gameController.givePoints(playerName, pointsToGive); int newScore = gameController.getPlayerScore(playerName); //Debug.Log("New points: " + newScore); scoreController.GetComponent <ScoresController>().updateStatusText(playerName, newScore); return(true); } Debug.Log("failed"); sounds.RejectSound(); return(false); }
private LostChild getRandomLostChildWithNAttributes(int pNumberOfAttributes) { int numberOfAttributes = pNumberOfAttributes; if (numberOfAttributes < 1) { numberOfAttributes = 1; } else if (numberOfAttributes > 4) { numberOfAttributes = 4; } Array sizeValues = Enum.GetValues(typeof(LostChild.Size)); Array hatValues = Enum.GetValues(typeof(LostChild.Hat)); Array colorValues = Enum.GetValues(typeof(LostChild.Color)); Array stolenItemValues = Enum.GetValues(typeof(LostChild.StolenItem)); LostChild randomChild = new LostChild( (LostChild.Size)sizeValues.GetValue(random.Next(sizeValues.Length)), (LostChild.Hat)hatValues.GetValue(random.Next(hatValues.Length)), (LostChild.Color)colorValues.GetValue(random.Next(colorValues.Length)), (LostChild.StolenItem)stolenItemValues.GetValue(random.Next(stolenItemValues.Length)) ); for (int i = 0; i < 4 - numberOfAttributes; i++) { bool fieldRemoved = false; while (fieldRemoved != true) { int randomInt = random.Next(0, 4); switch (randomInt) { case 0: if (randomChild.getSize() != null) { randomChild.setSize(null); fieldRemoved = true; } break; case 1: if (randomChild.getHat() != null) { randomChild.setHat(null); fieldRemoved = true; } break; case 2: if (randomChild.getColor() != null) { randomChild.setColor(null); fieldRemoved = true; } break; case 3: if (randomChild.getStolenItem() != null) { randomChild.setStolenItem(null); fieldRemoved = true; } break; default: break; } } } /* * Debug.Log(randomChild.getSize()); * Debug.Log(randomChild.getStolenItem()); * Debug.Log(randomChild.getHat()); * Debug.Log(randomChild.getColor()); */ return(randomChild); }