[code]csharpcode:
using UnityEngine;
using System.Collections;
public class MainLogic : MonoBehaviour
{
public GUIText myGuiText;//用于显示消息的ui文字
void Start()
{
EventManager.whenStep_CommonUse += whenStep;
}
//根据命令类型,执行
void whenStep(TypeOfCommands toc)
{
switch (toc)
{
case TypeOfCommands.General:
myGuiText.text = "i'm General,the captain should hear from me";
break;
case TypeOfCommands.Captain:
myGuiText.text = "i'm Captain,every soldier need to obey to me";
break;
case TypeOfCommands.Soldier:
myGuiText.text = "i'm soldier,i need to receive commands";
break;
}
}
void OnGUI()
{
if(GUI.Button(new Rect(0,0,100,30),"General"))
{
EventManager.sendMessage_Common(TypeOfCommands.General);
}
if(GUI.Button(new Rect(0,50,100,30),"Captain"))
{
EventManager.sendMessage_Common(TypeOfCommands.Captain);
}
if(GUI.Button(new Rect(0,100,100,30),"Soldier"))
{
EventManager.sendMessage_Common(TypeOfCommands.Soldier);
}
}
}