Commit 5b34e3c8 authored by Luke A Smith's avatar Luke A Smith

Merge branch 'Dialogue' into 'master'

Added Dialogue Manager

See merge request !31
parents 1c7ec77e 146736c1
using UnityEngine;
using System.Collections;
public class CodecPoint : MonoBehaviour {
public enum CommType { codec, burst };
public bool isOn;
public CommType thisCommType;
public string[] codecText;
public float[] codecWaitTimes;
public int[] codecSpeaker;
}
using UnityEngine;
using System.Collections;
public class PlayerCodecInteraction : MonoBehaviour
{
public GameObject player;
public Collider2D DialoguePoint;
// Use this for initialization
void Awake()
{
player = this.gameObject;
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "DialoguePoint")
{
print("got dialogue point");
if (other.gameObject.GetComponent<CodecPoint>().isOn)
{
print("dialogue point is on");
if (other.gameObject.GetComponent<CodecPoint>().thisCommType == CodecPoint.CommType.codec)
{
print("dialogue point is dialogue");
GameObject thisGam = GameObject.FindGameObjectWithTag("GameManager");
thisGam.GetComponent<UIManager>().CodecIncoming(other.gameObject);
}
else if (other.gameObject.GetComponent<CodecPoint>().thisCommType == CodecPoint.CommType.burst)
{
print("dialogue point is text");
GameObject thisGam = GameObject.FindGameObjectWithTag("GameManager");
thisGam.GetComponent<UIManager>().BurstIncoming(other.gameObject);
}
}
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) {
print("space pressed");
DialogueCheck(DialoguePoint);
}
}
public void DialogueCheck(Collider2D other) {
if (other.gameObject.tag == "DialoguePoint")
{
print("got dialogue point");
if (other.gameObject.GetComponent<CodecPoint>().isOn)
{
print("dialogue point is on");
if (other.gameObject.GetComponent<CodecPoint>().thisCommType == CodecPoint.CommType.codec)
{
print("dialogue point is dialogue");
GameObject thisGam = GameObject.FindGameObjectWithTag("GameManager");
thisGam.GetComponent<UIManager>().CodecIncoming(other.gameObject);
}
else if (other.gameObject.GetComponent<CodecPoint>().thisCommType == CodecPoint.CommType.burst)
{
print("dialogue point is text");
GameObject thisGam = GameObject.FindGameObjectWithTag("GameManager");
thisGam.GetComponent<UIManager>().BurstIncoming(other.gameObject);
}
}
}
}
}
\ No newline at end of file
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class UIManager : MonoBehaviour {
/// <summary>
/// Text and Image Objects
/// Player GameObjects
/// Ints and Bools for modal windows
/// </summary>
public GameObject player;
public GameObject worldCanvas;
public Text codecIncomingImage;
public Text codecConvoText;
public Text burstText;
public Image burstBackground;
public Image codecPortrait;
public Image codecBackground;
public Sprite[] charPortraits;
public Image codecPortrait2;
public Image codecConsole;
public Text speakerText;
/// <summary>
///
/// </summary>
public IEnumerator InContinue() {
yield return new WaitForSeconds(1);
}
public void CodecIncoming(GameObject codecPoint){
StartCoroutine (CodecIn (codecPoint));
}
public void BurstIncoming(GameObject codecPoint){
StartCoroutine(BurstIn(codecPoint));
}
public IEnumerator CodecIn(GameObject codecPoint){
Color thisColor;
thisColor = codecIncomingImage.GetComponent<Text>().color;
thisColor = new Vector4 (255, 0, 0, 1);
codecIncomingImage.color = thisColor;
yield return new WaitForSeconds (1);
thisColor = codecIncomingImage.GetComponent<Text>().color;
thisColor = new Vector4 (255, 0, 0, 0);
codecIncomingImage.color = thisColor;
yield return new WaitForSeconds (1);
thisColor = codecIncomingImage.GetComponent<Text>().color;
thisColor = new Vector4 (255, 0, 0, 1);
codecIncomingImage.color = thisColor;
yield return new WaitForSeconds (1);
thisColor = codecIncomingImage.GetComponent<Text>().color;
thisColor = new Vector4 (255, 0, 0, 0);
codecIncomingImage.color = thisColor;
yield return new WaitForSeconds (1);
StartCoroutine(Codec(codecPoint));
}
public IEnumerator BurstIn(GameObject codecPoint) {
yield return new WaitForSeconds(0);
Color thisColor;
thisColor = burstBackground.GetComponent<Image>().color;
thisColor = new Vector4(0, 0, 0, 1);
burstBackground.color = thisColor;
Color textColor;
textColor = burstText.color;
textColor = new Vector4(1, 1, 1, 1);
burstText.color = textColor;
StartCoroutine(Burst(codecPoint));
}
public IEnumerator Burst(GameObject codecPoint) {
for (int i = 0; i < codecPoint.GetComponent<CodecPoint>().codecText.Length; i++)
{
burstText.text = codecPoint.GetComponent<CodecPoint>().codecText[i];
//codecPortrait.sprite = codec
yield return new WaitForSeconds(codecPoint.GetComponent<CodecPoint>().codecWaitTimes[i]);
}
Color thisColor;
thisColor = burstBackground.GetComponent<Image>().color;
thisColor = new Vector4(0, 0, 0, 0);
burstBackground.color = thisColor;
Color textColor;
textColor = burstText.color;
textColor = new Vector4(1, 1, 1, 0);
burstText.color = textColor;
yield return new WaitForSeconds(2);
//End the burst
}
public IEnumerator Codec(GameObject codecPoint) {
Color thisColor;
thisColor = codecBackground.color;
thisColor = new Vector4(0, 0, 0, 1);
codecBackground.color = thisColor;
Color textColor;
textColor = codecConvoText.color;
textColor = new Vector4(1, 1, 1, 1);
speakerText.color = textColor;
codecPortrait.color = textColor;
codecPortrait2.color = textColor;
codecConsole.color = textColor;
codecConvoText.color = textColor;
for (int i = 0; i < codecPoint.GetComponent<CodecPoint>().codecText.Length; i++) {
codecConvoText.text = codecPoint.GetComponent<CodecPoint>().codecText[i];
codecPortrait.sprite = charPortraits[codecPoint.GetComponent<CodecPoint>().codecSpeaker[i]];
switch (codecPoint.GetComponent<CodecPoint>().codecSpeaker[i]) {
case 1:
speakerText.text = "Snake";
break;
case 2:
speakerText.text = "Big Boss";
break;
default:
break;
}
yield return new WaitForSeconds(codecPoint.GetComponent<CodecPoint>().codecWaitTimes[i]);
}
print("done with codec");
yield return new WaitForSeconds(4);
textColor = new Vector4(1, 1, 1, 0);
codecConvoText.color = textColor;
yield return new WaitForSeconds(1);
thisColor = new Vector4(0, 0, 0, 0);
codecBackground.color = thisColor;
codecPortrait.color = thisColor;
codecPortrait2.color = thisColor;
codecConsole.color = thisColor;
speakerText.color = thisColor;
codecPoint.GetComponent<CodecPoint>().isOn = false;
yield return new WaitForSeconds(1);
print("codec elements out");
//codecPoint.GetComponent<CodecPoint>().isOn = false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment