// Copy Constructor for ClueInfo public ClueInfo(ref ClueInfo clue) { id = clue.id; rating = clue.rating; clueName = clue.clueName; description = clue.description; }
//Adds ClueItem and its ClueInfo passed from ClueItemInspector's raycasted ClueItem public void AddClue(ref ClueItem hitClue) { //Check if this ClueItem has already been found if (!hitClue.isCollected) { hitClue.isCollected = true; // Objects are not staying in this list between scenes _cluesCollected.Add(hitClue); ClueItem objectHit = hitClue; ClueInfo objectInfo = new ClueInfo(ref hitClue); _clueInfoOfCollected.Add(objectInfo); print("Last collected clue: " + _clueInfoOfCollected[_clueInfoOfCollected.Count - 1].clueName); PopulateYarnVars(); //Call for CanvasManager to enable "Gather Crew" buttons ONLY when enough clues are collected //TODO: Make sure this works even if cluesLeftToChoose changes. Might want to make a default int for the clues to get if (_cluesCollected.Count == AccusationManager.S.cluesLeftToChoose) { CanvasManager.S.enableGatherButtons(); } //Creates a new button in the Clue Inventory UI if (UI_ButtonManager.S != null) { GameObject button = UI_ButtonManager.S.CreateButton(ref hitClue);; Button_ClueList buttonInfo = button.AddComponent <Button_ClueList>(); Button buttonScript = button.GetComponent <Button>(); //Be careful, setup dependent. Image clueIcon = button.GetComponent <Image>(); //Button creation //Add Components and parameters that are specific to Clue Item buttonInfo.clueInfo = objectInfo; buttonScript.onClick.AddListener(buttonInfo.SelectClue); clueIcon.sprite = Resources.Load("Sprites\\" + objectInfo.clueName, typeof(Sprite)) as Sprite; } //Gives the player a notification that the clue was added if (UI_ButtonManager.S.addedClueNotification.transform.parent.gameObject.activeSelf) { clueCount++; UI_ButtonManager.S.addedClueNotif(true); Clues.setValue(clueCount); Debug.Log("Set the value!"); } } else if (UI_ButtonManager.S.addedClueNotification.transform.parent.gameObject.activeSelf) { UI_ButtonManager.S.addedClueNotif(false); Loyalty.setValue(0); } }
//For reordering the clue button and visually flagging it as a clue for accusation public void AddButtonToAccusation(ClueInfo clueInfo) { foreach (GameObject button in buttonsInGroup) { if (button.GetComponent <Button_ClueList>().clueInfo.clueName == clueInfo.clueName) { button.GetComponent <Image>().color = new Color(1, .2f, 0); return; } } }
public ClueInfo(ClueInfo clue, bool b_Yarn) { id = clue.id; rating = clue.rating; clueName = clue.clueName; description = clue.description; clueOwner1 = clue.clueOwner1; clueOwner2 = clue.clueOwner2; location = clue.location; isClue = clue.isClue; addedToYarn = b_Yarn; }
void RaycastForClues() { // On Mouse Button Up Collect the object you have raycasted against if it is indeed a clue if (Input.GetMouseButtonUp(0)) { // Make sure function is firing print("ClueManager MouseUpAsButton function entered."); Vector3 mousePosition; RaycastHit hit; Ray ray; //Update ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); mousePosition = Input.mousePosition; //The raycast works but in scene view it points towards canvas Debug.DrawRay(transform.position, mousePosition, Color.green); if (Physics.Raycast(ray, out hit, 100.0f, _clueLayer)) { print("hit on Clue Layer"); // If object hit is a piece of evidence if (hit.collider.gameObject.tag == "Evidence") { Debug.Log("You have selected the " + hit.transform.GetComponent <ClueItem> ().ClueName); // Objects are not staying in this list between scenes _cluesCollected.Add(hit.collider.gameObject.GetComponent <ClueItem>()); ClueItem objectHit = hit.collider.gameObject.GetComponent <ClueItem> (); ClueInfo objectInfo = new ClueInfo(ref objectHit); _clueInfoOfCollected.Add(objectInfo); // Set the object hit setActive value to false hit.collider.gameObject.SetActive(false); } } } }
public ClueItem(Noun n1, Noun n2, Verb v, string sprite, string desc) { info = new ClueInfo(n1, n2, v); description = desc; spriteName = sprite; }
public static void AddClue(ClueInfo c) { SentenceHistory h = new SentenceHistory(c.GetSentence(), -1); sSentences.Add(h); }
private void StartStage(GameStage stage) { Debug.Log("starting stage " + stage); mCurrentStage = stage; if (stage == GameStage.SEARCH_1) { // NEVER COMMIT THESE LINES // mArrestedPerson = Player; // stage = GameStage.CLOSURE; } if (stage == GameStage.SEARCH_1 || stage == GameStage.SEARCH_2 || stage == GameStage.SEARCH_3) { if (stage == GameStage.SEARCH_1) { PlayerJournal.AddListen(VictimId, mStartingClue.GetSentence()); // wait until after the dialogue is over to add this to the player journal } UIController.Get().ShowJournalButton(); UIController.Get().ShowMusicButton(); // assign npcs to rooms (for now, ensure they go to different rooms) int[] roomChoices = Utilities.RandomList(clueRooms.Length, 2); for (int i = 0, j = 0; i < 3; ++i) { mRoundClues[i] = null; if (i != PlayerId) { string npcRoom = clueRooms[roomChoices[j++]]; MoveToRoom(i, npcRoom); // npcs pick up a clue in the room they move to if (mCluesInRooms.ContainsKey(npcRoom)) { List <ClueItem> cluesInRoom = mCluesInRooms[npcRoom]; if (cluesInRoom.Count > 0) { int clueIdx = Random.Range(0, cluesInRoom.Count); ClueItem clue = cluesInRoom[clueIdx]; cluesInRoom.RemoveAt(clueIdx); ClueInfo info = clue.info; mPeople[i].knowledge.AddKnowledge(info.GetSentence()); mRoundClues[i] = info; } } } } MoveToRoom(PlayerId, mCurrentRoom); // hack to reload room with npcs gone } else if (stage == GameStage.COMMUNAL_1 || stage == GameStage.COMMUNAL_2 || stage == GameStage.COMMUNAL_3) { for (int i = 0; i < 3; ++i) { MoveToRoom(i, openingScene); } } else if (stage == GameStage.POLICE) { MoveToRoom(PlayerId, "EndScene"); } else if (stage == GameStage.REVEAL) { DialogBlock discussion = new DialogBlock(mPeople, OnDialogueDismissed); // check each accusation int[] votes = { 0, 0, 0 }; int highestVoteIdx = -1; int majority = -1; int mostVotes = 0; int totalVotes = 0; for (int i = 0; i < 3; ++i) { if (mAccusations[i] >= 0 && mAccusations[i] < 3) { votes[mAccusations[i]]++; totalVotes++; if (votes[mAccusations[i]] > mostVotes) { mostVotes = votes[mAccusations[i]]; highestVoteIdx = mAccusations[i]; } if (votes[mAccusations[i]] >= 2) { majority = mAccusations[i]; } } } if (majority >= 0) { discussion.QueueDialogue(Police, new Sprite[] { }, "So it was the " + mPeople[majority].AttributeMap[NounType.HairColor] + "?"); discussion.QueueDialogue(Police, new Sprite[] { mPeople[majority].HeadSprite }, "You're under arrest, ma'am."); discussion.QueueDialogue(Police, new Sprite[] { mPeople[(majority + 1) % 3].HeadSprite, mPeople[(majority + 2) % 3].HeadSprite }, "You two, come along and we'll get official statements."); mWasAllArrested = false; mArrestedPerson = mPeople[majority]; } else { // no one got a majority Sprite[] allThree = new Sprite[] { mPeople[0].HeadSprite, mPeople[1].HeadSprite, mPeople[2].HeadSprite }; discussion.QueueDialogue(Police, allThree, "You can't agree on what happened?"); discussion.QueueDialogue(Police, allThree, "I'm going to have to take you all in to the station."); mWasAllArrested = true; } discussion.Start(); } else if (stage == GameStage.CLOSURE) { blackFade.SetTrigger("FadeOut"); // Give me closure please! // TODO - tell more of the story. // TODO - typing sound if (mWasAllArrested) { mEpilogueLines.Add("Because you could not come to a decision as a group, all three of you were arrested."); if (Player.IsKiller) { mEpilogueLines.Add("You were the killer."); } else { mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer."); } } else { if (mArrestedPerson.IsKiller && mArrestedPerson.IsPlayer) { mEpilogueLines.Add("You were the killer, and you were caught."); } else if (!mArrestedPerson.IsKiller && mArrestedPerson.IsPlayer) { mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer, but you were the one arrested."); } else if (mArrestedPerson.IsKiller && !mArrestedPerson.IsPlayer) { mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer, and was correctly arrested."); } else if (!mArrestedPerson.IsKiller && !mArrestedPerson.IsPlayer) { mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer, but " + mArrestedPerson.AttributeMap[NounType.HairColor].AsSubject() + " was arrested instead."); } else if (!mArrestedPerson.IsKiller && Player.IsKiller) { mEpilogueLines.Add("You were the killer, and you escaped because " + mArrestedPerson.AttributeMap[NounType.HairColor].AsSubject() + " was arrested instead."); } else { // I dont think this is possible. But just in case... if (Player.IsKiller) { mEpilogueLines.Add("You were the killer"); } else { mEpilogueLines.Add(mPeople[KillerId].AttributeMap[NounType.HairColor].AsSubject() + " was the killer"); } if (mArrestedPerson.IsPlayer) { mEpilogueLines.Add("You were arrested"); } else { mEpilogueLines.Add(mArrestedPerson.AttributeMap[NounType.HairColor].AsSubject() + " was arrested"); } } } mEpilogueLines.Add("The killer " + mPeople[KillerId].AttributeMap[NounType.Identity].AsObject()); mEpilogueLines.Add("The killer " + mPeople[KillerId].AttributeMap[NounType.Motive].AsObject()); for (int j = 0; j < 3; j++) { mEpilogueLines.Add(mPeople[j].AttributeMap[NounType.HairColor].AsSubject() + " " + mPeople[j].AttributeMap[NounType.Name].AsObject()); mEpilogueLines.Add(mPeople[j].AttributeMap[NounType.HairColor].AsSubject() + " " + mPeople[j].AttributeMap[NounType.Identity].AsObject()); } InvokeRepeating("UpdateEpilogueText", 1.5f, 0.5f); // after 1 seconds start the epilogue text, and do a new line every 0.3 seconds } }
public void PopulateYarnVars() { for (int i = 0; i < _clueInfoOfCollected.Count; i++) { //Checking if clueInfo we're loading has a tag of "Clue" (set in ClueItem), and making sure it has NOT been added to Yarn's list yet. if (_clueInfoOfCollected[i].isClue && !_clueInfoOfCollected[i].addedToYarn) { // Set the Clue Name in Yarn string yarnClueVariableName = "$Clue" + yarnIndex.ToString(); string yarnClueFoundVariableName = yarnClueVariableName + "Found"; // Add the Clue#Owner1 and Clue#Owner2 variables string yarnClueOwner1VariableName = yarnClueVariableName + "Owner1"; string yarnClueOwner2VariableName = yarnClueVariableName + "Owner2"; string yarnClueLocationVariableName = yarnClueVariableName + "Location"; foreach (ExampleVariableStorage.DefaultVariable c in yarnVarRef.defaultVariables) { //TODO make this a switch statement Yarn.Value yarnVal; // Checks for the yarn variable name (Clue#) and sets the appropriate value if (c.name == yarnClueVariableName) { c.value = _clueInfoOfCollected[i].clueName; } // Checks for the yarn variable name related to Clue#Found and sets it to the appropriate value if (c.name == yarnClueFoundVariableName) { c.value = "true"; } // Checks if the yarn variable name related to Clue#Owner1 and sets it to the appropriate value if (c.name == yarnClueOwner1VariableName) { //c.value = "Cook"; c.value = _clueInfoOfCollected[i].clueOwner1; } // Checks for the yarn variable name related to Clue#Owner2 and sets it to the appropriate value if (c.name == yarnClueOwner2VariableName) { c.value = _clueInfoOfCollected[i].clueOwner2; } // Checks for the yarn variable name related to Clue#Location and sets it to the appropriate value if (c.name == yarnClueLocationVariableName) { c.value = _clueInfoOfCollected[i].location; } if (c.value == "true") { yarnVarRef.SetValue(c.name, new Yarn.Value(true)); } else { yarnVarRef.SetValue(c.name, new Yarn.Value(c.value)); } } // Yarn.Value yarnClueValue = new Yarn.Value(_clueInfoOfCollected[i].clueName); // yarnClueValue.variableName = yarnClueVariableName; //yarnVarRef.SetValue(yarnClueValue.variableName, yarnClueValue); //// Set the ClueFound variable in Yarn //string yarnClueFound = yarnClueVariableName + "Found"; //Yarn.Value yarnClueFoundValue = new Yarn.Value("true"); //yarnClueValue.variableName = yarnClueFound; //yarnVarRef.SetValue(yarnClueFoundValue.variableName, yarnClueFoundValue); yarnIndex++; _clueInfoOfCollected[i] = new ClueInfo(_clueInfoOfCollected[i], true); // F**K THIS LINE!!!!!! } } }
public void Continue() { if (mDialogEntries.Count == 0) { if (mDismissedCallback != null) { mDismissedCallback(0); mDismissedCallback = null; } return; } DialogEntry entry = mDialogEntries[0]; mDialogEntries.RemoveAt(0); AudioPlayer.PlaySound(entry.audio); if (entry.isInfoExchangeRequest) { UIController.Get().ShowMessage( entry.speaker, entry.sprites, entry.message, new string[] { "Yes", "No" }, new UIButtonCallback[] { buttonIndex => { InsertInformationExchange(0); Continue(); }, buttonIndex => { InsertDialogue(0, entry.speaker, entry.sprites, "Alright. Let's talk more later."); Continue(); }, }); } else if (entry.isInfoExchange) { if (entry.speaker.IsPlayer) { // Show prompt, and share the result with other participants of this dialog UIController.Get().AskForSentence(entry.sprites, sentence => { ShareInfo(GameState.Get().Player, sentence); Continue(); }); } else { // The GameState round-clues is guaranteed to be a recent clue that is not the result of combining multiple clues ClueInfo clueInfo = GameState.Get().mRoundClues[entry.speaker.PersonId]; string message; if (clueInfo != null) { Sentence newInfo = clueInfo.GetSentence(); message = "I found out " + entry.speaker.Speak(newInfo); // TODO: Announce the room where it was found if (newInfo.Subject.Type() == NounType.Unique) { message = "I found " + entry.speaker.Speak(newInfo); // TODO: Announce the room where it was found } ShareInfo(entry.speaker, newInfo); PlayerJournal.AddListen(entry.speaker.PersonId, newInfo); } else { message = "I found nothing."; } UIController.Get().ShowMessage(entry.speaker, entry.sprites, message, new string[] { "Continue" }, new UIButtonCallback[] { buttonIndex => Continue() }); } } else if (entry.isCustomSentence) { UIController.Get().AskForSentence(new Sprite[] { }, sentence => { if (entry.customSentenceCallback != null) { entry.customSentenceCallback(sentence); } Continue(); }, entry.subjectOverrides, entry.objectOverrides); } else // a regular message, just show it { UIController.Get().ShowMessage(entry.speaker, entry.sprites, entry.message, new string[] { "Continue" }, new UIButtonCallback[] { buttonIndex => Continue() }); } }
public static void Generate(out PersonState[] people, out ClueInfo startingClue, out List <ClueItem> cluesToScatter) { cluesToScatter = new List <ClueItem>(); // Randomly determine the world // The player is going to have some natural questions, and we should // create clues that answer them, otherwise they're going to be unsatisfied. // questions: // who's the killer? // why don't we remember anything? // where are we? // who is each person? // why are we here? // what's the story? what events led to where we are now? // TODO - have predermined pairings between backstory / motive / identity // Generate people by shuffling a list of indexes for each attribute type. Noun[][] attributeLists = { appearances, identities, names }; int[][] shuffledLists = { Utilities.RandomList(3, 3), Utilities.RandomList(3, 3), Utilities.RandomList(3, 3), // Don't randomize backstories and motives // Utilities.RandomList(backstories.Length, 3), // Utilities.RandomList(3, 3), }; people = new PersonState[3]; for (int i = 0; i < names.Length; ++i) { people[i] = new PersonState(i); Dictionary <NounType, Noun> attributes = people[i].AttributeMap; for (int attrIndex = 0; attrIndex < attributeLists.Length; attrIndex++) { Noun playerAttr = attributeLists[attrIndex][shuffledLists[attrIndex][i]]; attributes.Add(playerAttr.Type(), playerAttr); } Noun[] depNouns = mDependentNouns[attributes[NounType.Identity]]; for (int nounI = 0; nounI < depNouns.Length; nounI++) { attributes.Add(depNouns[nounI].Type(), depNouns[nounI]); } } // Each player knows the existence of the hair-colors of the other players for (int i = 0; i < names.Length; i++) { for (int j = 0; j < names.Length; j++) { if (i != j) { people[i].knowledge.KnownWords.Add(people[j].AttributeMap[NounType.HairColor]); } } } // Pick a killer GameState.Get().KillerId = Random.Range(0, 3); people[GameState.Get().KillerId].IsKiller = true; // Pick a person to have no motive int innocentId = Random.Range(0, 2); // two possible values if (innocentId >= GameState.Get().KillerId) { innocentId += 1; } // Generate an additional clue for the killer // starting: victim wrote a name in blood Noun killerName = people[GameState.Get().KillerId].AttributeMap[NounType.Name]; ClueInfo deathClue = new ClueInfo(Noun.SuspectedName, killerName); startingClue = deathClue; // Generate clues for everything else // this is probably too many, and we want to strategically // omit certain clues (so that we don't have an immediate person -> name clue) for (int i = 0; i < names.Length; ++i) { Noun hair = people[i].AttributeMap[NounType.HairColor]; Noun identity = people[i].AttributeMap[NounType.Identity]; Noun name = people[i].AttributeMap[NounType.Name]; Noun motive = people[i].AttributeMap[NounType.Motive]; Noun backstory = people[i].AttributeMap[NounType.Backstory]; ClueItem appearanceToIdentity = ClueManifest.GetClue(hair, identity); if (appearanceToIdentity != null) { cluesToScatter.Add(appearanceToIdentity); } else { Debug.Log("No clue for " + hair + " <-> " + identity + "!"); } ClueItem identityToName = ClueManifest.GetClue(identity, name); if (identityToName != null) { cluesToScatter.Add(identityToName); } else { Debug.Log("No clue for " + hair + " <-> " + identity + "!"); } if (i != innocentId) { // Connect identity to motive (for thematic and mechanical reasons) ClueItem motiveClue = ClueManifest.GetClue(identity, motive); if (motiveClue != null) { cluesToScatter.Add(motiveClue); } else { Debug.Log("No clue for " + identity + " <-> " + motive + "!"); } } // Generate a clue connecting something to backstory Noun identityOrName = Random.Range(0, 2) == 0 ? identity : name; ClueItem backstoryClue = ClueManifest.GetClue(identityOrName, backstory); if (backstoryClue != null) { cluesToScatter.Add(backstoryClue); } else { Debug.Log("No clue for " + identityOrName + " <-> " + backstory + "!"); } } // Unique clues ClueItem potion = ClueManifest.GetClue(Noun.Potion, Noun.MemoryLoss); if (potion != null) { cluesToScatter.Add(potion); } else { Debug.Log("No clue for " + Noun.Potion + " <-> " + Noun.MemoryLoss + "!"); } }