private void Awake() { if (Interactions == null) { Interactions = GetComponent <InteractionSet>().graph; } var originalName = name; var appendedName = $"{SceneManager.GetActiveScene().buildIndex}_{originalName}"; if (GameObject.Find(appendedName) == null) { name = appendedName; } else { for (int i = 0; i < 9999; i++) { var attempt = $"{appendedName}_{i}"; if (GameObject.Find(attempt) == null) { name = attempt; break; } } } }
public bool generateConflict() { GameObject controller = GameObject.Find("ControllerObject"); Controller controllerScript = (Controller)controller.GetComponent(typeof(Controller)); employeeRelationships = controllerScript.getGraph(); List <InteractionGraph.Relationship> edges = employeeRelationships.getEdges(); int numEmployees = employeeRelationships.numNodes(); /* number of conflicts checked = to numEmployees */ for (int i = 0; i < numEmployees; i++) { conflictEdge = edges[Random.Range(0, edges.Count)]; //Debug.Log(conflictEdge.source.name + " -> " + conflictEdge.target.name); /* disposition is in range 0-25 */ int prob = conflictEdge.getDisposition(); // higher disposition means less likely to have a conflict //Debug.Log("Prob = " + conflictEdge.source.name + " -> " + conflictEdge.target.name + prob); int rand = Random.Range(0, 26); //Debug.Log("rand = " + rand); if (rand > prob) { int invProb = 25 - prob; int mult = Random.Range(50, 101); cost = invProb * mult; // cost for option 1 //Debug.Log("25 - prob = " + invProb); //Debug.Log("Mult = " + mult); //Debug.Log("Cost = "+ cost); // Set conflict popup transform.Find("Context").GetComponent <Text>().text = conflictEdge.source.name + " and " + conflictEdge.target.name + " are having a conflict.\n" + conflictEdge.source.name + conflictReasons[Random.Range(0, conflictReasons.Length)] + conflictEdge.target.name; transform.Find("OptionsText").GetComponent <Text>().text = "Option 1: " + resolutionOptions[Random.Range(0, resolutionOptions.Length)] + "\n\t(Costs: $" + cost + " but " + conflictEdge.source.name + " and " + conflictEdge.target.name + " like each other more so overall happiness increases)"; return(true); // only one popup per occurence, more chances to get one with a larger workforce. } } return(false); }
void Start() { InteractionNode n0 = new InteractionNode("Have we met before?", "I don't know...have we!?!?!", 2); InteractionNode n1 = new InteractionNode(".............", "Just kidding, we've never met. I'm Gob -- you may recognize me from the cover of " + "Poof magazine. I'm a ~magician~", 0); InteractionNode n2 = new InteractionNode("Oh...right, hey, um, you!", "Just kidding, we've never met. I'm Gob -- you may recognize me from the cover of " + "Poof magazine. I'm a ~magician~", 0); InteractionNode n3 = new InteractionNode("How do you know Jon Hannity?", "We worked together for a while after college, but have sort of lost" + " touch since then. I hope I haven't made a huge mistake by coming here tonight...", 0); n0.Adj [0] = n1; n0.Adj [1] = n2; InteractionNode[] OriginalList = new InteractionNode[2]; OriginalList[0] = n0; OriginalList [1] = n3; Graph = new InteractionGraph(OriginalList); }