public static Text temporaryText; //临时文本,设置公有静态是为了 方便调用颜色属性,去改变服务员文本颜色 void Start() { Cd = GameObject.Find("MountScript").GetComponent <ChinarDelegate>(); //获取对象 Cd.callNumber += LookScreen; //当 叫号的委托对象中,有多个方法调用时,需要用 += 添加 Cd.someFood += WaitCola; //委托对象添加 顾客3的可乐 temporaryText = transform.Find("Speak/Text").GetComponent <Text>(); }
public static Text temporaryText; //临时文本,设置公有静态是为了 方便调用颜色属性,去改变服务员文本颜色 void Start() { Cd = GameObject.Find("MountScript").GetComponent <ChinarDelegate>(); Cd.callNumber += LookScreen; //2添加委托函数 Cd.someFood += WaitHamburger; temporaryText = transform.Find("Speak/Text").GetComponent <Text>(); }
public static Text temporaryText; //临时文本,设置公有静态是为了 方便调用颜色属性,去改变服务员文本颜色 void Start() { Cd = GameObject.Find("MountScript").GetComponent <ChinarDelegate>(); //赋值 Cd.callNumber += LookScreen; temporaryText = transform.Find("Speak/Text").GetComponent <Text>(); //2添加委托函数 //委托函数的添加方式:可以用 = 号 //如果想添加多个委托 需要用 +=号 //删除委托用: -= }
/// <summary> /// 服务员叫可乐时,委托事件才会触发 /// </summary> public bool WaitCola(string food) { if (food == "可乐") { temporaryText.text = "这里,我要的可乐"; ChinarDelegate.Move(gameObject); StopCoroutine(ClearText()); StartCoroutine(ClearText()); return(true); } return(false); }
/// <summary> /// 服务员叫汉堡时,委托事件才会触发 /// </summary> public bool WaitHamburger(string food) { if (food == "汉堡") { temporaryText.text = "这里,我要汉堡"; ChinarDelegate.Move(gameObject); iTween.MoveTo(GameObject.Find("Hamburger(Clone)"), iTween.Hash("oncomplete", "DestroyHamburger", "oncompletetarget", gameObject, "time", .7f, "x", -13.38, "y", 2.8f, "easetype", iTween.EaseType.easeOutCubic, "delay", 2.4f)); iTween.ScaleTo(GameObject.Find("Hamburger(Clone)"), iTween.Hash("time", .7f, "scale", new Vector3(0, 0, 0), "easetype", iTween.EaseType.easeOutCubic, "delay", 2.4f)); StopCoroutine(ClearText()); StartCoroutine(ClearText()); return(true); } return(false); }