void Start() { revealSize = 6; seed = GameObject.Find("MetaController").GetComponent <meta_script>().GetSeed(); toPC = GameObject.Find("Player").GetComponent <PCtoNPC>(); characterList = gameObject.GetComponent <NPC_Calc>().characterList; size = characterList.Length;//change dependent on number of people NPC_Graph = new Graph <Characters, Relationship>(size, true); for (int i = 0; i < size; i++) { NPC_Graph.addItem(new Characters(characterList[i].name, getSeedDigit(i))); } killer = NPC_Graph.findNode(0); //killer.setKiller(); /* * NPC_Graph.addEdge(0, 2, 100); * NPC_Graph.addEdge(0, 1, 20); * NPC_Graph.addEdge(0, 3, -20); */ double temp = modSeed(seed); //initialize array to 0 int[] tempArr = new int[5]; for (int i = 0; i < 5; i++) { tempArr[i] = 0; } //set each characters role accordingly for (int i = 0; i < 10; i++) { int num = (int)(temp / Mathf.Pow(100, i) % 100); tempArr[num % 5]++; NPC_Graph.findNode(i).getData().setRole(num % 5); } /*go through each edge checking if it's filled yet * if not insert edge with seed determined weight */ for (int i = 0; i < NPC_Graph.getSize(); i++) { for (int j = 0; j < NPC_Graph.getSize(); j++) { if (NPC_Graph.findEdge(i, j) == null && i != j) { //Rating // +/- NPC_Graph.addEdge(i, j, getRelation((int)(100 - temp % 100)) * (int)(temp % 2 * 2 - 1)); temp /= 100; if (temp < 1) { temp = modSeed2(seed); } } } } toPC = GameObject.Find("Player").GetComponent <PCtoNPC>(); /* * //Debugging for items in correct spots * if ("Alpha" != NPC_Graph.getName(0)) throw new System.Exception("KABLOOOEY"); * else Debug.Log("alright"); * * * //names in correct spots * for (int i = 0; i < 4; i++) { * Debug.Log("Name: "+NPC_Graph.getName(i)); * } * Debug.Log(NPC_Graph.findEdge(2, 0).getWeight()); */ }
/// <summary> /// Goes to next node in the graph. /// </summary> public void goToNext() { PCtoNPC temp = GameObject.Find("Player").GetComponent <PCtoNPC>(); //beats quest lose time if (curNode.ToString().Equals("congrat")) { game_scripts gameTemp = GameObject.Find("GameController").GetComponent <game_scripts>(); gameTemp.loseTime(4); } if (curNode.ToString().Equals("end")) { string[] tempArr = { gameObject.name + " is...", "not the killer." }; if (GameObject.Find("GameController").GetComponent <NPC_Calc>().killer.ToString().Equals(gameObject.ToString())) { tempArr[1] = "the killer. Congrats!"; Application.LoadLevel("win"); } GameObject.Find("GameController").GetComponent <game_scripts>().loseLife(); } //special case /* * 0 Quest node * 1 Help node * 2 Busy/Passive * 3 Complain * 4 Congrats */ if (curNode.ToString().Equals("passive")) { int num = 0; if (temp.questing()) { num++; if (temp.getQuestNPC().Equals("Butler")) { num++; } else { num = 2; if (temp.getQuestNPC() == temp.getTalkNPC()) { num++; if (temp.isQuestDone()) { num++; } } } } else if (temp.getTalkNPC().Equals("Butler")) { num = 1; } goToNext(num); } else { goToNext(0); } }