private IEnumerator reactOnAction(string action) { yield return(new WaitForSeconds(ItsRandom.randomRange(0.5f, 1.5f, personRandom))); List <AudioClip> reactionAudioClips = clips.FindAll(i => i.name.Contains(action + "-")); yield return(playVoice(ItsRandom.pickRandom(reactionAudioClips, personRandom))); }
public static K pickRandomKey <K, V>(Dictionary <K, V> dict, string type = DEFAULT_TYPE) { if (dict.Count > 0) { return(dict.ElementAt(ItsRandom.randomRange(0, dict.Count, type)).Key); } return(default(K)); }
// Start is called before the first frame update void Awake() { AudioSource audioSource = GetComponent <AudioSource>(); audioSource.time = ItsRandom.randomRange(0, audioSource.clip.length - 1); // Debug.Log(audioSource.time); // Debug.Log(audioSource.clip.length); }
public Generic.CONSEQUENCE getConsequence() { if (consequences.Length > 0) { return(consequences[ItsRandom.randomRange(0, consequences.Length)]); } return(Generic.CONSEQUENCE.NOTHING); }
public static T pickRandom <T>(List <T> list, string type = DEFAULT_TYPE) { if (list.Count > 0) { return(list[ItsRandom.randomRange(0, list.Count, type)]); } return(default(T)); }
public void reportPositionX(float positionX) { targetPositionX = positionX; if (targetPositionX > transform.position.x && timeLeftToMoveTowardsBag == 0f && !isWalking) { timeLeftToMoveTowardsBag = ItsRandom.randomRange(MAX_TIME_TO_WAIT_TO_CATCHUP - 0.5f, MAX_TIME_TO_WAIT_TO_CATCHUP + 0.5f); } }
public void Start() { ClockPositions clockPositions = GetComponent <ClockPositions>(); if (setRandomPosition) { clockPosition = ItsRandom.randomRange(0, clockPositions.positions.Length); } ClockPosition clockPositionObj = clockPositions.positions[clockPosition]; setClockPosition(clockPositionObj); StartCoroutine(calculateTime()); }
public void createBag(Vector3 bagDropPosition, String randomSeed) { // TODO - Random bag - Some distribution factor? Maybe not plastic tray except for certain content? int randomBagIndex = ItsRandom.randomRange(0, bags.Length, randomSeed); GameObject bagGameObject = Instantiate(bags [randomBagIndex], bagDropPosition, Quaternion.identity); BagProperties bagProperties = bagGameObject.GetComponent <BagProperties> (); bagGameObject.transform.position = new Vector3(bagDropPosition.x, bagDropPosition.y + bagProperties.halfBagHeight, bagDropPosition.z); currentBagPlacing = bagProperties; activeBags.Add(bagProperties); if (bagProperties.lid != null) { bagProperties.lid.SetActive(false); } }
public static GameObject pickRandomWithWeights(List <int> weights, List <GameObject> gameObjects, string type = DEFAULT_TYPE) { int weightSum = weights.Sum(); int random = ItsRandom.randomRange(0, weightSum, type); int index; int accumulatedSum; for (index = 0, accumulatedSum = 0; index <= weights.Count; accumulatedSum += weights[index], index++) { if (accumulatedSum + weights[index] > random) { break; } } return(gameObjects[index]); }
private IEnumerator reactOnItemInspection(BagContentProperties item) { // Get applicable audio clips string coroutineKey = "inspect-reaction-" + item.id; List <AudioClip> itemAudioClips = clips.FindAll(i => i.name.Contains(item.category + "-")); yield return(new WaitForSeconds(ItsRandom.randomRange(4f, 8f, personRandom))); while (Misc.HasCoroutine(coroutineKey)) { if (ItsRandom.randomRange(0, 100, personRandom) < 25) { yield return(playVoice(ItsRandom.pickRandom(itemAudioClips, personRandom))); } yield return(new WaitForSeconds(ItsRandom.randomRange(3f, 5f, personRandom))); } }
public void registerMistake(string mistake, bool shouldPlaySpeakerSound = false) { Debug.Log("Register mistake: " + mistake); // TODO - Do something the other mistakes, that doesn't result in a speaker sound (warning, false arrest) if (!mistakeSeverity.ContainsKey(mistake)) { mistakeSeverity.Add(mistake, 0); } mistakeSeverity[mistake]++; if (shouldPlaySpeakerSound) { loudspeaker.putMessageOnQueue(mistake, mistakeSeverity[mistake], ItsRandom.randomRange(7f, 15f)); } // Refresh score screen pauseTVContent.GetComponent <ScoreScreen>().update(mistakeSeverity, points); }
public void assign(PillBottle pillBottle, PerRendererShaderTexture objectWithMaterial, int materialIndex, GameObject pillsContainer, GameObject pillsContainerXray, GameObject liquidContainer, GameObject liquidContainerXray, Material organicMaterialXray) { objectWithMaterial.texture = texture; objectWithMaterial.materialIndex = materialIndex; // Set the name (and label - for inspect) on the pill bottle pillBottle.gameObject.name = "Bottle of '" + pillLabel + "'"; pillBottle.gameObject.GetComponent <BagContentProperties>().displayName = "Bottle of '" + pillLabel + "'"; liquid = specifiedAsLiquid; amount = specifiedAmount; organic = specifiedAsOrganic; // Random "wrongness" - pill type int randomType = ItsRandom.randomRange(0, 100); if (randomType <= FACTOR_FOR_WRONG_PILL_TYPE) { bool wrongSubstanceLiquid = ItsRandom.randomBool(); if (wrongSubstanceLiquid && !specifiedAsLiquid) { amount = 0; liquid = true; } else if (wrongSubstanceLiquid && specifiedAsLiquid) { liquid = false; } else { organic = !specifiedAsOrganic; } } // Random "wrongness" - amount of pills int randomAmount = ItsRandom.randomRange(0, 100); if (!liquid && (randomAmount <= FACTOR_FOR_WRONG_PILL_AMOUNT || specifiedAsLiquid)) { amount = ItsRandom.randomRange(1, (!specifiedAsLiquid ? specifiedAmount : RANDOM_BASE_AMOUNT_PILLS) + 3); } if (liquid) { amount = 0; } if (amount > 0) { // Decide color pair for pills Color[] chosenColor = organic ? new[] { ORGANIC_PILL_COLOR } : ItsRandom.pickRandom(NON_ORGANIC_PILL_COLORS); for (int i = amount; i < pillsContainer.transform.childCount; i++) { pillsContainer.transform.GetChild(i).gameObject.SetActive(false); pillsContainerXray.transform.GetChild(i).gameObject.SetActive(false); } // TODO - Maybe make > some < of the pills organic (if wrong that should be detected) for (int i = 0; i < amount; i++) { if (organic) { Material[] organicMaterials = new [] { organicMaterialXray, organicMaterialXray }; // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials.Length); // Debug.Log(organicMaterialXray.name); // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[0].name); // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[1].name); // pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[0] = organicMaterialXray; // pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[1] = organicMaterialXray; pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent <Renderer>().materials = organicMaterials; // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[0].name); // Debug.Log(pillsContainerXray.transform.GetChild(i).GetChild(0).GetComponent<Renderer>().materials[1].name); } PerRendererShader[] perRendererShaders = pillsContainer.transform.GetChild(i).GetChild(0).GetComponents <PerRendererShader>(); // Debug.Log("Colors: " + chosenColor[0].ToString() + ", " + (chosenColor.Length > 1 ? chosenColor[1] : chosenColor[0]).ToString()); perRendererShaders[0].color = chosenColor[0]; perRendererShaders[1].color = chosenColor.Length > 1 ? chosenColor[1] : chosenColor[0]; perRendererShaders[0].enabled = true; perRendererShaders[1].enabled = true; pillBottle.colorHalf1 = chosenColor[0]; pillBottle.colorHalf2 = chosenColor.Length > 1 ? chosenColor[1] : chosenColor[0]; } // Remove liquid from gameObject GameObject.Destroy(liquidContainer); GameObject.Destroy(liquidContainerXray); } else { // // Show the liquid container // liquidContainer.SetActive(true); // liquidContainerXray.SetActive(true); // Remove pills from gameObject GameObject.Destroy(pillsContainer); GameObject.Destroy(pillsContainerXray); pillBottle.liquidPrepared = true; // // Fill bottle with liquid // pillBottle.fillLiquid(); } }
private void addGenericAnnouncementAfterDelay() { queue.Add(new Tuple2 <float, AudioClip>(ItsRandom.randomRange(MIN_SECONDS_BETWEEN_LOUDSPEAKER_ANNOUNCEMENTS, MAX_SECONDS_BETWEEN_LOUDSPEAKER_ANNOUNCEMENTS), ItsRandom.pickRandom(clips.FindAll(i => i.name.StartsWith(GENERIC_ANNOUNCEMENT_PREFIX))))); }
public static object randomTime(string type = DEFAULT_TYPE) { return(ItsRandom.randomRange(0, 23, type) + ":" + ItsRandom.randomRange(0, 59, type)); }
public static float randomPlusMinus(float medium, float plusMinus, string type = DEFAULT_TYPE) { return(ItsRandom.randomRange(medium - plusMinus, medium + plusMinus, type)); }