/// <summary> /// Starts a conversation with a ghost. /// </summary> /// <param name="dialogue">message for the ghost to say</param> /// <param name="focus">camera focus point</param> public void startConversation(GhostMessage dialogue, GameObject focus) { playerMover = PlayerMovement.instance; talker = GhostTalk.instance; // prevent the player from moving and stop them where they are so they can have a nice polite ghost conversation playerMover.enabled = false; playerMover.gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); // set the focus point focusPoint = focus; // create the ghost's lil text bubble textObject = Instantiate(Resources.Load <GameObject>("Prefabs/WorldText"), focus.transform.position, Quaternion.identity); // move the lil text bubble just above both of the ghosts textObject.transform.parent = focus.transform; textObject.transform.localPosition = new Vector2(0, 9); // snatch the text component of the ghost's dialogue bubble so it can be changed dialogueText = textObject.GetComponent <Text>(); textShadow = textObject.GetComponent <Shadow>(); // make the ghost be a polite boye and stop walking talker.ghost.GetComponent <EnemyManager>().StopAllCoroutines(); talker.ghost.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); // actually start the conversation now that we have a text bubble to show what the ghost is saying StartCoroutine(conversationInit(dialogue)); }
// Use this for initialization void Start() { player = GhostTalk.instance; // try to get the trigger collider of choice and make it a trigger if (!useCircle) { try { triggerAreaBox = GetComponent <BoxCollider2D>(); triggerAreaBox.isTrigger = true; } catch { print("error getting circle collider"); } } else { try { triggerAreaCircle = GetComponent <CircleCollider2D>(); triggerAreaCircle.isTrigger = true; } catch { print("error getting box collider"); } } StartExtra(); }
// Use this for initialization void Awake() { instance = this; sr = GetComponent <SpriteRenderer>(); }