public void Init(ArtProperties property, GalleryVisitor emitter, ArtObject topic, bool opinion) { this.property = property; this.emitter = emitter; this.topic = topic; this.opinion = opinion; transform.position = emitter.transform.position + offset; text = "Hmm..."; textmesh = this.gameObject.GetComponentInChildren <TextMesh> (); textmesh.text = "Hmm..."; transform.localScale = new Vector3(0.0f, 0.0f, 1.0f); repeat = topic.lastPropertyStated == property; topic.lastPropertyStated = property; foreach (Challenge ch in FindObjectsOfType <Challenge> ()) { if (ch.victim == emitter && ch.topic == topic) { Destroy(ch.gameObject); } } if (opinion) { emitter.GetComponent <Speaker> ().playGood(); } else { emitter.GetComponent <Speaker> ().playBad(); } textmesh.gameObject.renderer.sortingLayerID = 3; }
// 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); } } }
public Statement State(ArtProperties property, ArtObject topic, bool opinion) { GameObject bubble = (GameObject)Instantiate(statementPrefab); bubble.GetComponent <Statement> ().Init(property, GetComponent <GalleryVisitor> (), topic, opinion); Statement s = bubble.GetComponent <Statement> (); OnStatementMade(new StatementEventArgs(s)); return(s); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform != null) { art = hit.transform.GetComponent <ArtProperties>(); print(art.url); Application.OpenURL(art.url); } } } }