对话Dialog

using UnityEngine;
using System.Collections;

public class StoryCamera_19 : MonoBehaviour {

    // Use this for initialization
    public Camera camera;
    public GameObject MainCamera;
    public GUISkin Story_01;
    
    
    private string[] DialogText_0;
    private string[] DialogText_1;
    
    private int[] DialogNum;
    private bool[] StepAllow;
    private float[] AddTime;
    
    private float Timer=0;
    
    public Texture back;
    public Texture DialogGround;
    public Texture NextStep;
    
    public Data datascript;
    
    private float Dialog_0 = -430;
    void Start () 
    {
        if(Screen.width==1136)
        {
            Dialog_0 = -520;
        }
        if(Screen.width==960)
        {
            Dialog_0 = -430;
        }
        AddTime=new float[]{0,0,0,0,0,0,0,0,0,0,0};
        StepAllow=new bool[]{true,false,false,false,false,false,false,false,false}; 
        DialogNum=new int[]{0,0,0,0};
        DialogText_0=new string[]{"Alex:","Alex:","Null"};
        DialogText_1=new string[]{"The old Mutu is in somewhere of the coast. ","Let`s find it as soon as possible!","Null"};
    }
    
    // Update is called once per frame
    void Update () 
    {
        Timer+=Time.deltaTime;
        Debug.Log("Time"+Timer);
    }
    void OnGUI()
    {
        if(Timer>6)
        {
            GUI.DrawTexture(new Rect(0,0,Screen.width,Mathf.Lerp(0,Screen.height/8,(AddTime[0]+=Time.deltaTime)/2) ),back);
            GUI.DrawTexture(new Rect(0,Mathf.Lerp(Screen.height,Screen.height*7/8,(AddTime[1]+=Time.deltaTime)/2),Screen.width,Screen.height/5),back);
        }
        if(Timer>7&&!StepAllow[1])
        {
            GUI.skin=Story_01;
            GUI.DrawTexture(new Rect(0,Screen.height*4/5,Screen.width,Screen.height/5),DialogGround);
            GUI.DrawTexture(new Rect(Screen.width-35,Screen.height-30,28,19),NextStep);
            if(DialogText_0[DialogNum[0]]!="Null")
            {
                if(GUI.Button(new Rect(Dialog_0,Screen.height*3/5,Screen.width,Screen.height/2.1f),DialogText_0[DialogNum[0]]))
                {
                    DialogNum[0]++;
                }
            }
            if(DialogText_1[DialogNum[0]]!="Null")
            {
                if(GUI.Button(new Rect(0,Screen.height*4/5,Screen.width,Screen.height/4),DialogText_1[DialogNum[0]]))
                {
                    DialogNum[0]++;
                }
            }
            else 
            {
                //datascript.data.is_beach_ok=true;
                GUI.DrawTexture(new Rect(0,0,Screen.width,Mathf.Lerp(0,Screen.height/8,(AddTime[0]+=Time.deltaTime)/2) ),back);
                GUI.DrawTexture(new Rect(0,Mathf.Lerp(Screen.height,Screen.height*7/8,(AddTime[1]+=Time.deltaTime)/2),Screen.width,Screen.height/5),back);
                datascript.data.is_beach_ok = true;
                StepAllow[1]=true;
                datascript.Save();
                ConstantData.whereToGo= "Coast_1";
                Application.LoadLevel("LoadingV2");
                //Timer=10;
                
                //StepAllow[2]=true;
            }
        }
    }
}
原文地址:https://www.cnblogs.com/xiao-wei-wei/p/3372438.html