Пример #1
0
    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??
    }