public void assign() { Material picked = ItsRandom.pickRandom(materials.ToList()); objectToSetMaterial.material = picked; objectToSetMaterial.materialIndex = materialIndex; }
public void assign() { var randomText = ItsRandom.pickRandom(texts.ToList()); objectWithText1.text = randomText; objectWithText2.text = randomText; }
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 void run() { Vector3 chosenScale = ItsRandom.pickRandom(possibleScales.ToList()); BagContentProperties bagContentProperties = this.GetComponent <BagContentProperties>(); bagContentProperties.objectSize = Vector3.Scale(bagContentProperties.objectSize, chosenScale); bagContentProperties.transform.localScale = chosenScale; bagContentProperties.GetComponent <Rigidbody>().mass = chosenScale.magnitude; }
public void assign() { MeshAndPosition randomMeshAndPosition = ItsRandom.pickRandom(meshesAndPositions.ToList()); foreach (AssignMeshAndPositionToObject objectToSetMeshAndPosition in objectsToSetMeshAndPosition) { objectToSetMeshAndPosition.mesh = randomMeshAndPosition.mesh; objectToSetMeshAndPosition.position = randomMeshAndPosition.position; } }
public void reportToAuthorities() { // TODO - was it really a mistake to "report person"? worstMistake = "false arrest"; playVoice(ItsRandom.pickRandom(clips.FindAll(i => i.name.StartsWith("false_arrest-")), personRandom)); bagDefinition.bags.ForEach(bag => bag.bagFinished(false)); passport.animateAndDestroy(); Destroy(walkingMan.gameObject); finishPerson(); }
public Tuple2 <string, string> getRandomBook() { if (books.Count > 0) { Tuple2 <string, string> book = ItsRandom.pickRandom(books, personRandom); int bookIndex = books.IndexOf(book); books.RemoveAt(bookIndex); return(book); } return(null); }
public void putMessageOnQueue(string type, int severity, float delay = 0f) { Debug.Log("Play sound: " + type); AudioClip warningMessage = ItsRandom.pickRandom(clips.FindAll(i => i.name.Contains(type + "-") && i.name.Contains("-severity-" + severity))); Debug.Log("SOUND: " + warningMessage); if (warningMessage != null) { putMessageOnQueue(warningMessage, delay); } else { Debug.LogError("Audio not found for " + type + ", severity " + severity); } }
public void run(bool reverse) { if (!reverse) { videoPlayer.playOnAwake = true; if (!chosenVideoClip) { // Duplicate the material of the screen GameObject videoPlayerGameObject = videoPlayer.gameObject; Renderer componentRenderer = videoPlayerGameObject.GetComponent <Renderer>(); Material copyOfMaterial = new Material(componentRenderer.material); RenderTexture copyOfTexture = new RenderTexture((RenderTexture)copyOfMaterial.mainTexture); copyOfMaterial.mainTexture = copyOfTexture; componentRenderer.material = copyOfMaterial; videoPlayer.targetTexture = copyOfTexture; // Create audio source to play sound through audioSource = videoPlayer.gameObject.AddComponent <AudioSource>(); audioSource.playOnAwake = true; audioSource.volume = 1f; audioSource.spatialBlend = 1f; //Set Audio Output to AudioSource videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource; //Assign the Audio from Video to AudioSource to be played videoPlayer.EnableAudioTrack(0, true); videoPlayer.SetTargetAudioSource(0, audioSource); videoPlayer.controlledAudioTrackCount = 1; // Pick video clip VideoClip videoClip = ItsRandom.pickRandom(videoClips.ToList()); videoPlayer.clip = videoClip; chosenVideoClip = true; } running = true; StartCoroutine(playWhenReady()); } else { running = false; videoPlayer.Stop(); audioSource.Stop(); } }
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 run() { PillsToRandomize chosenPillsConfig = ItsRandom.pickRandom(pillsToRandomize.ToList()); chosenPillsConfig.assign(pillBottle, objectWithMaterial, materialIndex, pillsContainer, pillsContainerXray, liquidContainer, liquidContainerXray, organicMaterialXray); if (!chosenPillsConfig.needsPrescription) { SlideInOtherObjectInspectAction slideInOtherObjectInspectAction = this.gameObject.GetComponent <SlideInOtherObjectInspectAction>(); foreach (SlideInOtherObjectDefinition slideInOtherObjectDefinition in slideInOtherObjectInspectAction.slideInObjectDefinitions) { if (slideInOtherObjectDefinition.gameObjectToSlideIn.name.StartsWith("Doctors Note")) { slideInOtherObjectDefinition.enabled = false; } } } }
// Use this for initialization void Start() { Debug.Log("CONFIG"); Debug.Log(config); // Choose greeting greeting = ItsRandom.pickRandom(clips.FindAll(i => i.name.StartsWith("greetings-")), personRandom); bagDefinition.person = this; currentX = this.transform.position.x; walkingMan.reportPositionX(currentX); walkingMan.setColors(bodyColor, chosenFavoriteColor); PubSub.subscribe("belt_movement", this); // Subscribe to inspection on items in own bags PubSub.subscribe("bag_inspect_item", this); }
private void assignProppertiesBasedOnBagContentProperties(BagContentProperties bagContentProperties) { // Assign paper material Material[] materials = paperMaterialObject.GetComponent <Renderer>().materials; materials[0] = ItsRandom.pickRandom(paperMaterials); paperMaterialObject.GetComponent <Renderer>().materials = materials; // Medicine name string displayName = bagContentProperties.displayName; string pillName = displayName.Substring("Bottle of \"".Length); string medicineNameStr = pillName.Substring(0, pillName.Length - 1); medicineName.text = " - " + medicineNameStr; // Person name Person person = BagHandler.instance.currentBagInspect.bagDefinition.person; string patientNameStr = person.personName; patientName.text = patientNameStr; // Doctor name // TODO - Real logic ("real"/fake names) string doctorNameStr = ItsRandom.pickRandom(new List <string>() { "Nick Riviera", "Julius Hibbert", "Hannibal Lecter", "Saw U Apart", "Genital Fondler", "Pepper" }); doctorName.text = "Dr. " + doctorNameStr; doctorSignature.font = ItsRandom.pickRandom(signatureFonts); doctorSignature.text = doctorNameStr; PillBottle pillBottle = bagContentProperties.gameObject.GetComponent <PillBottle>(); Debug.Log("Color 1: " + pillBottle.colorHalf1.ToString()); Debug.Log("Color 2: " + pillBottle.colorHalf2.ToString()); pillColorHalf1.color = pillBottle.colorHalf1; pillColorHalf2.color = pillBottle.colorHalf2; }
public void run() { // First, try to lookup book author + title in person Person person = GetComponent <BagContentProperties>().person; Tuple2 <string, string> randomBook = person.getRandomBook(); if (randomBook == null) { randomBook = ItsRandom.pickRandom(GenericBookText.books); } foreach (TextMeshPro author in authors) { author.text = randomBook.First; } foreach (TextMeshPro title in titles) { title.text = randomBook.Second; } }
private List <AudioClip> getAdditionalPartsForAudioClip(string clipName) { List <AudioClip> chosenAdditionalParts = new List <AudioClip>(); string additionalClipNames = "voice/announcements/" + voice + "/" + clipName + "/"; Debug.Log("Additional clips path: " + additionalClipNames); List <AudioClip> additionalParts = Resources.LoadAll <AudioClip>(additionalClipNames).ToList(); int part = 2; bool foundMoreParts = true; while (foundMoreParts) { string partStr = part < 10 ? "0" + part : "" + part; List <AudioClip> matchingParts = additionalParts.FindAll(i => i.name.StartsWith("part-" + partStr)); foundMoreParts = matchingParts.Count > 0; if (foundMoreParts) { AudioClip random = ItsRandom.pickRandom(matchingParts); if (new Regex(@"^part-" + partStr + @"_\d+").IsMatch(random.name)) { chosenAdditionalParts.Add(random); } else { List <AudioClip> subAudioClips = null; Regex re = new Regex(@"^part-" + partStr + @"_(.*?)(:?_(.+))?$"); Match reMatch = re.Match(random.name); GroupCollection groups = reMatch.Groups; string subFolder = groups[1].ToString(); string memoryKey = ""; if (groups.Count > 2) { string memorySlot = groups[2].ToString(); if (memorySlot != "") { memoryKey = subFolder + "_" + memorySlot; if (memory.ContainsKey(memoryKey)) { subAudioClips = memory[memoryKey]; } } } if (subAudioClips == null) { subAudioClips = getAdditionalPartsForAudioClip(subFolder); if (memoryKey != "") { memory.Add(memoryKey, subAudioClips); } } chosenAdditionalParts.AddRange(subAudioClips); } } part++; } Debug.Log("Additional parts: " + chosenAdditionalParts.Count); return(chosenAdditionalParts); }
public void assign() { objectWithMaterial.texture = ItsRandom.pickRandom(textures.ToList()); objectWithMaterial.materialIndex = materialIndex; }
public void assign() { objectWithText.text = ItsRandom.pickRandom(texts.ToList()); }
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 void assign() { objectWithMaterial.color = ItsRandom.pickRandom(colors.ToList()); }
IEnumerator placeItemsInBag(BagProperties bagProperties, int amount, List <BagContentProperties> toBePlacedInTrays, Person person, String randomSeed) { int yieldEveryXthItem = 5; int yieldCounter = yieldEveryXthItem; // float lastCycleStart = Time.realtimeSinceStartup; Vector3 bagSize = bagProperties.placingCube.transform.localScale; bagProperties.placingCube.SetActive(true); Bounds bagBounds = bagProperties.placingCube.GetComponent <Collider>().bounds; bagProperties.placingCube.SetActive(false); // Debug.Log(bagBounds); // TODO - Hidden items, make sure to check person config on frequency of putting these items in // TODO - For now, always put one item GameObject hiddenObj = ItsRandom.pickRandom <BagContentType>(bagContentTypesHidden.ToList(), randomSeed).contentObj; GameObject hiddenItem = Instantiate(hiddenObj); hiddenItem.transform.parent = bagProperties.transform; BagContentProperties hiddenItemProperties = hiddenItem.GetComponent <BagContentProperties> (); // Randomize place in bottom of bag findPlaceForItemInBag(hiddenItemProperties, bagProperties, randomSeed, int.MaxValue, true); bagProperties.bagContents.Add(hiddenItemProperties); // TODO - This code block is only made for forcing an illegal item GameObject gunObj = ItsRandom.pickRandom <BagContentType>(bagContentTypesIllegal.ToList(), randomSeed).contentObj; GameObject gun = Instantiate(gunObj); gun.transform.parent = bagProperties.contents.transform; BagContentProperties gunProperties = gun.GetComponent <BagContentProperties> (); // Randomize place in bag findPlaceForItemInBag(gunProperties, bagProperties, randomSeed, int.MaxValue, false); bagProperties.bagContents.Add(gunProperties); // TODO - END for (int i = 0; i < amount; i++) { List <int> weights = bagContentTypesLegal.Select(obj => obj.frequency).ToList(); List <GameObject> gameObjects = bagContentTypesLegal.Select(obj => obj.contentObj).ToList(); // TODO - below are the REAL CODE - NOT ABOVE // List<int> weights = bagContentTypes.Select(obj => obj.frequency).ToList(); // List<GameObject> gameObjects = bagContentTypes.Select(obj => obj.contentObj).ToList(); GameObject randomGameObject = ItsRandom.pickRandomWithWeights(weights, gameObjects, randomSeed); // Check if item should be in tray, or not instantiated by any other reason (eg. not place 3 guns in bag...) bool acceptItem = true; // TODO - Do this! // bool acceptItem = randomGameObject.GetComponent<BagContentInstantiationRules>()(toBePlacedInTrays, person); if (!acceptItem) { i--; continue; } GameObject contentPiece = Instantiate(randomGameObject); contentPiece.transform.parent = bagProperties.contents.transform; // Randomly rotate 90°-angle // TODO - When rotation turned on, objects seem to fall outside bag // contentPiece.transform.localRotation = Quaternion.Euler(0f, 90f * Misc.random.Next(), 0f); BagContentProperties bagContentProperties = contentPiece.GetComponent <BagContentProperties> (); // Randomize place in bag bool itemFitsInBag = findPlaceForItemInBag(bagContentProperties, bagProperties, randomSeed, 10, false); if (itemFitsInBag) { bagContentProperties.person = person; bagProperties.bagContents.Add(bagContentProperties); // Trigger "random"-functions on it RandomInterface[] randomInterfaces = contentPiece.GetComponents <RandomInterface>(); foreach (RandomInterface randomInterface in randomInterfaces) { randomInterface.run(); } } else { Debug.Log("Item removed: " + contentPiece); contentPiece.transform.parent = null; Destroy(contentPiece); } /* * yieldCounter--; * if (yieldCounter == 0) { * yieldCounter = yieldEveryXthItem; * // if (lastCycleStart + MAX_ITEM_PLACE_CYCLE_SECONDS < Time.realtimeSinceStartup) { * Debug.Log("YIELD"); * yield return null; * // // TODO - Compact items by code (move downwards) * // yield return null; * // lastCycleStart = Time.realtimeSinceStartup; * } */ } Debug.Log("Items in bag: " + bagProperties.bagContents.Count()); // Debug.Break(); yield return(null); }
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(); } }