Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        GalleryWanderer gw = GetComponent <GalleryWanderer> ();

        if (gw.IsMoving() || gw.observing == null || observed == gw.observing)
        {
            return;
        }

        if (!observing)
        {
            observing       = true;
            observationTime = Random.Range(minObservationTime, maxObservationTime);
        }

        if (GetComponent <GalleryVisitor> ().CanTalk() && FindObjectOfType <Challenge> () == null)
        {
            observationTime -= Time.deltaTime;

            if (observationTime <= 0)
            {
                gw.WaitUntilMove(postObservationWait);
                observed = gw.observing;
                List <ArtProperties> ps = (opinions[observed] ? observed.goodProperties : observed.badProperties);
                ArtProperties        commentProperty = ps[Random.Range(0, ps.Count)];
                if (preventRepeats)
                {
                    commentProperty = ps[(ps.IndexOf(observed.lastPropertyStated) + 1) % ps.Count];
                }
                Statement st = GetComponent <StatementMaker> ().State(commentProperty, observed, opinions[observed]);
                gw.WaitUntilMove(st.lifespan);
            }
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (!GetComponent <GalleryVisitor> ().CanTalk() || FindObjectOfType <Challenge> () != null)
        {
            return;
        }

        GalleryWanderer gw = GetComponent <GalleryWanderer> ();
        GalleryVisitor  gv = GetComponent <GalleryVisitor> ();

        if (gw.IsMoving())
        {
            return;
        }

        GalleryVisitor pgv = GameObject.FindWithTag("Player").GetComponent <GalleryVisitor> ();

        if (gv.reputation > pgv.reputation + maxMoreReputation)
        {
            return;
        }

        if (Random.Range(0.0f, 1.0f) > Time.deltaTime * askChancePerSecond)
        {
            return;
        }

        if ((transform.position - pgv.transform.position).sqrMagnitude <= maxPlayerDist * maxPlayerDist)
        {
            ArtObject ao = nearbyArt(pgv);
            if (ao != null)
            {
                GetComponent <Speaker> ().playAsk();
                GameObject cho = (GameObject)Instantiate(challengePrefab);
                cho.GetComponent <Challenge>().Init(ao, pgv);
                cho.transform.position = transform.position;
                gw.WaitUntilMove(cho.GetComponent <Challenge>().remainingTime);
            }
        }
    }