public string compareImportance(CharFuncs other) { // Hamlet is most important, GraveDigger1, GraveDigger2, Horatio switch (thisChar.name) { case "Hamlet": return "More"; break; case "Horatio": return "Less"; break; case "GraveDigger1": switch (other.thisChar.name) { case "Hamlet": return "Less"; break; default: return "More"; break; } break; case "GraveDigger2": switch (other.thisChar.name) { case "Horatio": return "More"; break; default: return "Less"; break; } break; default: return "Other"; break; } }
public FQueueObj(Vector3 p, GameObject t, int n, bool f, actiontype a, GameObject ac) { target = t; targetpt = p; msgnum = n; following = f; action = a; actorObj = ac; if (a != actiontype.intermission) { actorFunc = GlobalObjs.getCharFunc(actorObj); } }
public QueueObj(GameObject a, GameObject t, Vector3 tp, actiontype at) { actorObj = a; targetObj = t; target = tp; action = at; if (at != actiontype.intermission) { actorFunc = GlobalObjs.getCharFunc(actorObj); } msgNum = curMsg; curMsg++; }
// Use this for initialization void Start() { if (!doInit) { doInit = true; // #if UNITY_EDITOR Material m = Resources.Load("Materials/BLUEMat") as Material; m = Resources.Load("Materials/PURPLEMat") as Material; m = Resources.Load("Materials/REDMat") as Material; m = Resources.Load("Materials/GREENMat") as Material; m = Resources.Load("Materials/BROWNMat") as Material; m = Resources.Load("Materials/CYANMat") as Material; m = Resources.Load("Materials/ORANGEMat") as Material; m = Resources.Load("Materials/PEACHMat") as Material; m = Resources.Load("Materials/PINKMat") as Material; m = Resources.Load("Materials/PURPLEMat") as Material; m = Resources.Load("Materials/YELLOWMat") as Material; //#endif } //Debug.Log("Starting Coloring for "+whichChar+"!!!!"); if (whichChar == "") { whichChar = this.name; //Debug.Log("Changed name to:"+this.name); } string findWhichMaterial = "BLUEMat"; GameObject mbody = this.gameObject; if (!mbody) { Debug.Log("Couldn't find body for " + whichChar); } // use bodycolor on this object to set findWhichMaterial CharFuncs cf = (CharFuncs)mbody.GetComponent(typeof(CharFuncs)); findWhichMaterial = cf.bodycolor; foreach (Material myMaterial in Resources.FindObjectsOfTypeAll(typeof(Material))) { //Debug.Log ("Material="+myMaterial.name); if (myMaterial.name == findWhichMaterial) { mbody.renderer.material = myMaterial; //Debug.Log ("Found "+findWhichMaterialmb1); } } }
public QueueObj(GameObject a, GameObject t, Vector3 tp, actiontype at) { actorObj = a; if (at != actiontype.intermission) { Debug.Log("actor obj=" + a.name); } targetObj = t; target = tp; action = at; if (at != actiontype.intermission) { actorFunc = GlobalObjs.getCharFunc(actorObj); //Debug.Log ("actor func="+actorFunc.thisChar.name); } msgNum = curMsg; curMsg++; }
// Use this for initialization void Start() { if (!doInit) { doInit = true; #if UNITY_EDITOR Material m = AssetDatabase.LoadAssetAtPath("Assets/Materials/BLUEMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/PURPLEMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/REDMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/GREENMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/BROWNMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/CYANMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/ORANGEMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/PEACHMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/PINKMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/PURPLEMat.mat", typeof(Material)) as Material; m = AssetDatabase.LoadAssetAtPath("Assets/Materials/YELLOWMat.mat", typeof(Material)) as Material; #endif } //Debug.Log("Starting Coloring for "+whichChar+"!!!!"); if (whichChar == "") { whichChar = this.name; //Debug.Log("Changed name to:"+this.name); } string findWhichMaterial = "BLUEMat"; GameObject mbody = this.gameObject; if (!mbody) { Debug.Log("Couldn't find body for " + whichChar); } // calculate the material name to be searched for /*switch (whichChar) { * case "GraveDigger": * findWhichMaterial = "PURPLEMat"; * //Debug.Log ("Changed GraveDigger coloring"); * break; * case "GraveDiggerTwo": * findWhichMaterial = "REDMat"; * //Debug.Log ("Changed GraveDiggerTwo coloring"); * break; * case "Hamlet": * findWhichMaterial = "BLUEMat"; * //Debug.Log ("Changed Hamlet coloring"); * break; * case "Horatio": * findWhichMaterial = "GREENMat"; * //Debug.Log ("Changed Horatio coloring"); * break; * default: * // do nothing * Debug.Log ("No match!"); * break; * * }*/ // use bodycolor on this object to set findWhichMaterial CharFuncs cf = (CharFuncs)mbody.GetComponent(typeof(CharFuncs)); findWhichMaterial = cf.bodycolor; foreach (Material myMaterial in Resources.FindObjectsOfTypeAll(typeof(Material))) { //Debug.Log ("Material="+myMaterial.name); if (myMaterial.name == findWhichMaterial) { mbody.renderer.material = myMaterial; //Debug.Log ("Found "+findWhichMaterialmb1); } } }
public static void checkUpstaging(CharFuncs who, float targetx2, float targety2, GameObject g, bool following) { // check if my target is closer to audience // checkmovetarget for move -- if upstage, adjust based on precedence -- check all chars movements, not just current position!! foreach (CharFuncs c in GlobalObjs.listOfChars) { if (c.onstage() && c.thisChar.name != who.thisChar.name) { // only check onstage chars and non-same chars switch (who.compareImportance(c)) { case "More": // make sure who is closer to audience -- consider target, not current loc if (targety2 < c.getLastMovePostn().z) { // change targety2 Debug.Log ("Moving "+who.thisChar.name+" closer to audience"); targety2 = c.getLastMovePostn().z + 1; } break; case "Less": // make sure who is further from audience -- consider target, not current loc if (targety2 > c.getLastMovePostn().z) { // change targety2 Debug.Log ("Moving "+who.thisChar.name+" farther from audience"); targety2 = c.getLastMovePostn().z - 1; } break; default: // error, leave as-is break; } } // if not onstage, do nothing } Vector3 curtarget = new Vector3(targetx2, 0, targety2); Vector3 heading = curtarget - who.thisChar.transform.position; heading.y = 0; float distance = heading.magnitude; Vector3 direction = heading/distance; // check to be sure not too close to another character first foreach (CharFuncs c in GlobalObjs.listOfChars) { if (c.onstage() && c.thisChar.name != who.thisChar.name) { if (who.getDist(c.getLastMovePostn()) < 3) { // is this really the distance??? // move apart Debug.Log ("NEED TO SEPARATE!!!"); if (who.getDist (curtarget) > who.getDist (c.getLastMovePostn ())) { // if it is closer to me than target, then go further curtarget = curtarget + (direction * (2.8f)); } else { // else go shorter curtarget = curtarget - (direction * (2.8f)); } } } } // go ahead and walk to new target who.doWalk(targetx2, targety2, g, following); // for each char onstage // if char = actor do nothing // else // if actor precedence < char precedence & char diet to aud < actor diet to aud // move actor target closer to audience // if actor precedence > char precedence & actor diet < char diet to aud // move actor target farther from audience // end for // for each char onstage // if char = actor do nothing // else // if diet from actor to char < 3 feet, then move apart in opposite path of where they are // end for // move actor // should I be tracking this for the non-actors too?? }
public void getNextInMiniQueue() { miniQueueObj pulled = (miniQueueObj)genQueue.Dequeue(); workingNum = pulled.msgnum; Debug.Log ("*********************Dequeued "+workingNum+" for "+thisChar.name); switch (pulled.action) { case miniQueueObj.actiontype.move: moving = true; rotateToObj = null; following = pulled.following; if (pulled.getTargetType() == "Vector3") { moveTo = pulled.targetpt; moveToObj = null; moveToObjFunc = null; } else { moveToObj = pulled.target; moveTo = calculateObjPostn(moveToObj); if (following) { moveToObjFunc = (CharFuncs)moveToObj.GetComponent(typeof(CharFuncs)); moveToObjFunc.beingfollowed = true; } else { moveToObjFunc = null; } } break; case miniQueueObj.actiontype.rotate: rotating = true; if (pulled.getTargetType() == "Vector3") { rotateTo = pulled.targetpt; rotateToObj = null; rotateDir = getDirection (rotateTo); } else { rotateToObj = pulled.target; rotateTo = new Vector3(rotateToObj.transform.position.x, 0, rotateToObj.transform.position.z); rotateDir = getDirection(rotateTo); } break; case miniQueueObj.actiontype.pickup: if (pulled.target.name.ToLower() != "skull1" && pulled.target.name.ToLower() != "skull2" && pulled.target.name.ToLower() != "lantern" && pulled.target.name.ToLower () != "shovel") { // not valid command - ignore GlobalObjs.removeOne(pulled.msgnum); } else { shrinking = true; rotateToObj = null; manipObj = pulled.target; pickup = true; curscalesize = pulled.target.transform.localScale; switch (thisChar.transform.childCount) { case 0: break; case 1: if (thisChar.transform.GetChild (0).gameObject.name != "ArmPrefab") { extraObj = thisChar.transform.GetChild (0).gameObject; } break; case 2: if (thisChar.transform.GetChild (0).gameObject.name != "ArmPrefab") { extraObj = thisChar.transform.GetChild (0).gameObject; } else if (thisChar.transform.GetChild (1).gameObject.name != "ArmPrefab") { extraObj = thisChar.transform.GetChild (1).gameObject; } break; default: Debug.Log ("ERROR - too many children"); break; } } break; case miniQueueObj.actiontype.putdown: rotateToObj = null; if (thisChar.transform.GetChildCount () == 0) { // do nothing since not holding anything GlobalObjs.removeOne(pulled.msgnum); } else { // figure out what object we are carrying if (thisChar.transform.childCount == 1) { if (thisChar.transform.GetChild(0).gameObject.name == "ArmPrefab") { // no children Debug.Log ("Only child is an arm!"); GlobalObjs.removeOne(pulled.msgnum); } else { //workingNum = pulled.msgnum; //Debug.Log ("Changed working num in doPutDown to "+workingNum+ " for " +thisChar.name); if (thisChar.transform.GetChild (0).gameObject.name == pulled.target.name) { shrinking = true; manipObj = thisChar.transform.GetChild (0).gameObject; } else { GlobalObjs.removeOne(pulled.msgnum); } } } else { // assume if there is two, one is definitely the object to putdown //workingNum = pulled.msgnum; //Debug.Log ("Changed working num in doPutDown to "+workingNum+ " for " +thisChar.name); shrinking = true; if (thisChar.transform.GetChild (0).gameObject.name == "ArmPrefab") { if (thisChar.transform.GetChild (1).gameObject.name == pulled.target.name) { manipObj = thisChar.transform.GetChild (1).gameObject; } else { // invalid object shrinking = false; GlobalObjs.removeOne(pulled.msgnum); } } else { if (thisChar.transform.GetChild (0).gameObject.name == pulled.target.name) { manipObj = thisChar.transform.GetChild (0).gameObject; } else { shrinking = false; GlobalObjs.removeOne(pulled.msgnum); } } } //manipObj = thisChar.transform.GetChild(0).gameObject; pickup = false; if (manipObj != null) { Vector3 curpostn = manipObj.transform.position; Quaternion currot = manipObj.transform.rotation; //manipObj.transform.position = new Vector3(curpostn.x, carrydropheight, curpostn.z);//curpostn; manipObj.transform.rotation = currot;//thisChar.transform.rotation; curscalesize = manipObj.transform.localScale; } } break; default: // do nothing break; } }
public void doWalk(float x, float y, GameObject towhatobj, bool tofollow) { // add to global queue GlobalObjs.printQueue("Start Walk "+thisChar.name); QueueObj temp = new QueueObj(thisChar, towhatobj, (towhatobj == null)?(new Vector3(x, 0, y)):(towhatobj.transform.position), QueueObj.actiontype.move); GlobalObjs.globalQueue.Add(temp); Debug.Log ("*********************Added "+temp.msgNum+" for "+thisChar.name); // do something Debug.Log("In doWalk for "+thisChar.name); if (moving || rotating || shrinking || growing) { // wait & try again when done moving Debug.Log ("Already doing something for "+thisChar.name); putInMiniQueue(x, y, towhatobj, temp.msgNum, tofollow, miniQueueObj.actiontype.move); } else { rotateToObj = null; workingNum = temp.msgNum; moving = true; following = tofollow; if (towhatobj == null) { moveToObj = null; moveTo = new Vector3(x, 0, y); moveToObjFunc = null; } else { moveToObj = towhatobj; moveTo = calculateObjPostn(towhatobj); if (tofollow) { moveToObjFunc = (CharFuncs)moveToObj.GetComponent(typeof(CharFuncs)); moveToObjFunc.beingfollowed = true; } else { moveToObjFunc = null; } } Debug.Log ("Starting walk to " + towhatobj + " for " + this.name); } GlobalObjs.printQueue("End Walk "+thisChar.name); }
public Node(String n, String m, String t, float a, float b, FVertex f, CharFuncs g) { name = n; calledby = m; type = t; x = a; y = b; if (f == null) { fvert = new FVertex(this); } else { fvert = f; } origObj = g; switch (type) { case "char": disp = new Vector2(0f,0f); pos = new Vector2(x,y); ismoveable = true; // add to char list & all //Forces.g.characters.Add (fvert); // how do I get this vertex to add here? Forces.g.AddVertex(fvert); // really should have this as the vertex - maybe put the logic to add to char list when do vertex? // add audience FVertex aud2 = Forces.g.AddVertex (new Node(this.name+"A", this.name+"A", "audience", this.x, Forces.L+5, null)); aud = aud2.Data; // add audience link Forces.g.AddEdge (fvert, aud2,"audience"); // add links to all other chars Forces.LinkToAllChars(fvert); // create center or link to center if (Forces.g.center == null && (Forces.g.characters.Count + Forces.g.humans.Count >=2)) { Debug.Log("CREATED CENTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); new Node("CENTER", "CENTER", "center", this.x, this.y, null); Forces.LinkToAllChars(Forces.g.center); } else if (Forces.g.center != null) { Forces.g.AddEdge (Forces.g.center, fvert, "center"); } // recalculate center Forces.recalcCenter(); break; case "target": disp = new Vector2(0f,0f); pos = new Vector2(x,y); ismoveable = false; // add to all Forces.g.AddVertex (fvert); break; case "human": calledby = "HUMAN"; disp = new Vector2(0f,0f); pos = new Vector2(x,y); ismoveable = false; // capture original as x&y? orig.x = x; orig.y = y; // add to all Forces.g.AddVertex (fvert); // add to humans - done above //add audience FVertex haud = Forces.g.AddVertex (new Node(this.name+"A", this.name+"A", "audience", this.x, Forces.L+5, null)); aud = haud.Data; // add audience link Forces.g.AddEdge (fvert, haud,"audience"); // add links to all other chars Forces.LinkToAllChars(fvert); // create center or link to center if (Forces.g.center == null && Forces.g.characters.Count + Forces.g.humans.Count >=2) { new Node("CENTER", "CENTER", "center", this.x, this.y, null); Forces.LinkToAllChars(Forces.g.center); } else if (Forces.g.center != null) { Forces.g.AddEdge (Forces.g.center, fvert, "center"); } // recalculate center Forces.recalcCenter(); break; case "center": // calculate x & y using chars and humans (sum them then divide by count of two groups) calledby = "CENTER"; disp = new Vector2(0f,0f); pos = new Vector2(x,y); ismoveable = true; // add to all Forces.g.AddVertex (fvert); // duplicates the center vertex - don't do!! Forces.g.center = fvert; // add to chars??? // create link to self for all chars & humans // create audience FVertex caud = Forces.g.AddVertex (new Node(this.name+"A", this.name+"A", "audience", this.x, Forces.L+5, null)); aud = caud.Data; // create link audience Forces.g.AddEdge (fvert, caud, "audience"); break; case "audience": disp = new Vector2(0f,0f); pos = new Vector2(x,y); ismoveable = false; // add to all Forces.g.AddVertex (fvert); break; default: disp = new Vector2(0f,0f); pos = new Vector2(x,y); ismoveable = false; break; } }
public Node(String n, String m, String t, float a, float b, FVertex f, CharFuncs g) { name = n; calledby = m; type = t; x = a; y = b; if (f == null) { fvert = new FVertex(this); } else { fvert = f; } origObj = g; switch (type) { case "char": disp = new Vector2(0f, 0f); pos = new Vector2(x, y); ismoveable = true; // add to char list & all //Forces.g.characters.Add (fvert); // how do I get this vertex to add here? Forces.g.AddVertex(fvert); // really should have this as the vertex - maybe put the logic to add to char list when do vertex? // add audience FVertex aud2 = Forces.g.AddVertex(new Node(this.name + "A", this.name + "A", "audience", this.x, Forces.L + 5, null)); aud = aud2.Data; // add audience link Forces.g.AddEdge(fvert, aud2, "audience"); // add links to all other chars Forces.LinkToAllChars(fvert); // create center or link to center if (Forces.g.center == null && (Forces.g.characters.Count + Forces.g.humans.Count >= 2)) { Debug.Log("CREATED CENTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); new Node("CENTER", "CENTER", "center", this.x, this.y, null); Forces.LinkToAllChars(Forces.g.center); } else if (Forces.g.center != null) { Forces.g.AddEdge(Forces.g.center, fvert, "center"); } // recalculate center Forces.recalcCenter(); break; case "target": disp = new Vector2(0f, 0f); pos = new Vector2(x, y); ismoveable = false; // add to all Forces.g.AddVertex(fvert); break; case "human": calledby = "HUMAN"; disp = new Vector2(0f, 0f); pos = new Vector2(x, y); ismoveable = false; // capture original as x&y? orig.x = x; orig.y = y; // add to all Forces.g.AddVertex(fvert); // add to humans - done above //add audience FVertex haud = Forces.g.AddVertex(new Node(this.name + "A", this.name + "A", "audience", this.x, Forces.L + 5, null)); aud = haud.Data; // add audience link Forces.g.AddEdge(fvert, haud, "audience"); // add links to all other chars Forces.LinkToAllChars(fvert); // create center or link to center if (Forces.g.center == null && Forces.g.characters.Count + Forces.g.humans.Count >= 2) { new Node("CENTER", "CENTER", "center", this.x, this.y, null); Forces.LinkToAllChars(Forces.g.center); } else if (Forces.g.center != null) { Forces.g.AddEdge(Forces.g.center, fvert, "center"); } // recalculate center Forces.recalcCenter(); break; case "center": // calculate x & y using chars and humans (sum them then divide by count of two groups) calledby = "CENTER"; disp = new Vector2(0f, 0f); pos = new Vector2(x, y); ismoveable = true; // add to all Forces.g.AddVertex(fvert); // duplicates the center vertex - don't do!! Forces.g.center = fvert; // add to chars??? // create link to self for all chars & humans // create audience FVertex caud = Forces.g.AddVertex(new Node(this.name + "A", this.name + "A", "audience", this.x, Forces.L + 5, null)); aud = caud.Data; // create link audience Forces.g.AddEdge(fvert, caud, "audience"); break; case "audience": disp = new Vector2(0f, 0f); pos = new Vector2(x, y); ismoveable = false; // add to all //Forces.g.AddVertex (fvert); break; default: disp = new Vector2(0f, 0f); pos = new Vector2(x, y); ismoveable = false; break; } }