public void ReleaseNPC() { NpcApproacher npc = mainNPC.GetComponent <NpcApproacher>(); npc.Finish(); inProgress = false; }
public void AttractNPC(string greeting) { if (inProgress) { // already active, don't get another NPC's attention SynthesizeSpeech(greeting); return; } NpcApproacher npc = mainNPC.GetComponent <NpcApproacher>(); inProgress = npc.Approach(); if (inProgress) // if we were able to succesfully get an NPC's attention { SynthesizeSpeech(greeting); } }
public string Directions(string json) { Transform dest = GetDestination(json); if (dest == null) { return("もう一度言ってください"); } Transform cur = player; Transform prev = player; Transform next = player; string output = ""; bool pointing = false; float xdestdist = Math.Abs(cur.position.x - dest.position.x); float zdestdist = Math.Abs(cur.position.z - dest.position.z); // can the player simply go straight to the destination? if (xdestdist < THRESH || zdestdist < THRESH) { next = dest; } while (next != dest) { prev = cur; cur = next; float best = 99999999f; // find the first node to go to (may just be go straight to destination) for (int i = 0; i < map.childCount; i++) { Transform node = map.GetChild(i); float xdist = Math.Abs(cur.position.x - node.position.x); float zdist = Math.Abs(cur.position.z - node.position.z); // check that this node is on the same street as the player if (xdist < THRESH || zdist < THRESH) { float dist = Vector3.Distance(node.position, dest.position); if (dist < best) { best = dist; next = node; } } } print(cur.name); output += translateDirections(prev, cur, next, dest) + "、"; if (!pointing) { pointing = true; NpcApproacher npc = mainNPC.GetComponent <NpcApproacher>(); npc.Point(next.position); } } output += translateDirections(prev, dest, null, dest); return(output); }