void Start() { //Debug.Log("Start"); //MessageManager.registerMessageResive(MessageListener_SelectFunction_Fight.className, this); // MessageManager.registerMessageResive(Message_SelectFunction_Fight.sample.GetType().ToString(), this); // 注册事件监听 GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode += new MessageManager_Main.MessageDelegate_MainInterfaceMode(mainInterface_Mode); GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode_Battle += new MessageManager_Main.MessageDelegate_MainInterfaceMode(mainInterface_Mode_Battle); GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode_Equipment += new MessageManager_Main.MessageDelegate_MainInterfaceMode(mainInterface_Mode_Equipment); GameRoot_Main.getSingleton <MessageManager_Equipment>().editEquipment += new MessageManager_Equipment.EquipmentDelegate(mainInterface_Mode_Equipment_EditEquipment); //GameRoot_Main.getSingleton<MessageManager_Equipment>().storehouse // += new MessageManager_Equipment.EquipmentDelegate(mainInterface_Mode_Equipment_Storehouse); GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_TurnBack += new MessageManager_Main.MessageDelegate_MainInterfaceMode(ButtonEvent_TurnBack); GameRoot_Main.getSingleton <MessageManager_Equipment>().equipmentInfoMode += new MessageManager_Equipment.EquipmentItemDelegate(showEquipmentInfo); // 注册“取消监听”消息 //GameRoot_Main.getSingleton<GameManager>().disRegisterMessage // += new GameManager.SceneMessageDelegate(disRegisterMessage); }
void OnDistroy() { // 注册事件监听 GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode -= new MessageManager_Main.MessageDelegate_MainInterfaceMode(mainInterface_Mode); GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode_Battle -= new MessageManager_Main.MessageDelegate_MainInterfaceMode(mainInterface_Mode_Battle); GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode_Equipment -= new MessageManager_Main.MessageDelegate_MainInterfaceMode(mainInterface_Mode_Equipment); GameRoot_Main.getSingleton <MessageManager_Equipment>().editEquipment -= new MessageManager_Equipment.EquipmentDelegate(mainInterface_Mode_Equipment_EditEquipment); //GameRoot_Main.getSingleton<MessageManager_Equipment>().storehouse // -= new MessageManager_Equipment.EquipmentDelegate(mainInterface_Mode_Equipment_Storehouse); GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_TurnBack -= new MessageManager_Main.MessageDelegate_MainInterfaceMode(ButtonEvent_TurnBack); GameRoot_Main.getSingleton <MessageManager_Equipment>().equipmentInfoMode -= new MessageManager_Equipment.EquipmentItemDelegate(showEquipmentInfo); // 注册“取消监听”消息 //GameObject.Find("GameRoot").GetComponent<GameManager>().disRegisterMessage // -= new GameManager.SceneMessageDelegate(disRegisterMessage); }
// 在本脚本所在对象被Destroy之前,要把所有注册的消息接受取消掉时调用 //public void beforeDestory() //{ //messageManager_BattleMap.showBattleMap -= new MessageManager_BattleMap.BattleMapDelegate(showBattleMap); //GameObject.Find("MainInterface_BottomContainer").GetComponent<Event_Main_PanelBottom>().showBattleMap // -= new Event_Main_PanelBottom.BattleMapDelegate(showBattleMap); //} // 显示关卡地图(刚打开此界面时) private void showBattleMap() { //Debug.Log("showBattleMap222222222222222"); StartCoroutine(loadMapCoroutine(GameRoot_Main.getSingleton <Manager_BattleMap>().currentMap)); //loadMap(GameRoot_Main.getSingleton<Manager_BattleMap>().currentMap); }
// Use this for initialization void Awake() { messageManager_BattleMap = GameRoot_Main.getSingleton <MessageManager_BattleMap>(); interface_Stack = new Interface_Stack(); mode_Battle = Resources.Load("Prefabs/MainInterface/Main_Battle/Mode_Battle") as GameObject; mode_Equipment = Resources.Load("Prefabs/MainInterface/Main_Equipment/Interface_Equipment") as GameObject; }
// 反注册事件 private void UnRegisterEvent() { GameRoot_Main.getSingleton <MessageManager_Equipment>().changeWeapon -= new MessageManager_Equipment.EditEquipmentDelegate(ChangeEquipmentMode); GameRoot_Main.getSingleton <MessageManager_Equipment>().selectEquipment -= new MessageManager_Equipment.EquipmentInfoDelegate(changeEquipmentOver); }
// Use this for initialization void Awake() { // 初始化 messageManager_BattleMap = GameRoot_Main.getSingleton <MessageManager_BattleMap>(); //Debug.Log("Event_ModeBattle Register event : showBattleMap"); registerEvent(); }
// Use this for initialization void Start() { PlayerManager.init(); GameRoot_Main.addSingleton <GameManager>(); GameRoot_Main.addSingleton <MessageManager_Main>(); GameRoot_Main.addSingleton <MessageManager_BattleMap>(); GameRoot_Main.addSingleton <Manager_BattleMap>(); GameRoot_Main.addSingleton <MessageManager_Equipment>(); }
public static T getSingleton <T>() where T : Singleton <T> { if (instance == null) { instance = new GameRoot_Main(); } return(instance.rootObj.GetComponent <T>()); }
public static T addSingleton <T>() where T : Singleton <T> { if (instance == null) { instance = new GameRoot_Main(); } T t = instance.rootObj.AddComponent <T>(); t.Init(); return(t); }
// Use this for initialization void Start() { // 注册“功能按键被点选”事件 GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode += new MessageManager_Main.MessageDelegate_MainInterfaceMode(unSelectedAllItem); // 注册“战斗按键被点选”事件 GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode_Battle += new MessageManager_Main.MessageDelegate_MainInterfaceMode(deal_BattleItemEvent); // 注册“装备按键被点选”事件 GameRoot_Main.getSingleton <MessageManager_Main>().mainInterface_Mode_Equipment += new MessageManager_Main.MessageDelegate_MainInterfaceMode(deal_EquipmentItemEvent); }
// 初始化关卡地图 private GameObject initialiseBattleMap(GameObject map) { map.transform.parent = this.transform; map.transform.localScale = Vector3.one; map.transform.localPosition = Vector3.zero; map.GetComponent <UISprite>().width = (int)gameObject.GetComponent <UISprite>().localSize.x; map.GetComponent <UISprite>().height = (int)gameObject.GetComponent <UISprite>().localSize.y; // 在地图内设置关卡 Manager_BattleMap battleMapManager = GameRoot_Main.getSingleton <Manager_BattleMap>(); BattleStage[] stages = battleMapManager.getBattleMapStages(battleMapManager.currentMap); battleMapManager.setStageToMap(map, stages); return(map); }
// 往右翻页事件 private void pageRight() { // 移出 GameObject obj; for (int i = 0; i < transform.childCount; i++) { obj = transform.GetChild(i).gameObject; if (obj.tag == "BattleMap") { moveMap_Out(obj, false); } } // 移入 GameObject newMap = GameRoot_Main.getSingleton <Manager_BattleMap>().getPreviousBattleMap(); initialiseBattleMap(newMap); moveMap_Into(newMap, true); }
void Start() { GameObject topInterface = GameObject.Instantiate(mainInterface_Top) as GameObject; topInterface.transform.parent = uiRoot.transform; topInterface.transform.localScale = Vector3.one; topInterface.GetComponent <UIPanel>().baseClipRegion = new Vector4(0, Screen.height / 2 - (Screen.height / 10), Screen.width, Screen.height / 5); topInterface.SetActive(true); GameObject bottomInterface = GameObject.Instantiate(mainInterface_Bottom) as GameObject; bottomInterface.transform.parent = uiRoot.transform; bottomInterface.transform.localScale = Vector3.one; bottomInterface.GetComponent <UIPanel>().baseClipRegion = new Vector4(0, Screen.height / 2 - (Screen.height / 5 + Screen.height / 5 * 2) + 8, Screen.width, Screen.height / 5 * 4); bottomInterface.SetActive(true); // 监听“开始战斗”消息 //Debug.Log("监听“开始战斗”消息 " + GameRoot_Main.getSingleton<MessageManager_BattleMap>() == null); GameRoot_Main.getSingleton <MessageManager_BattleMap>().startBattle += new MessageManager_BattleMap.BattleStageMessageDelegate(startBattle); }
// 往左翻页事件 private void pageLeft() { // 移出 GameObject obj; for (int i = 0; i < transform.childCount; i++) { obj = transform.GetChild(i).gameObject; if (obj.tag == "BattleMap") { moveMap_Out(obj, true); } } // 移入 GameObject newMap = GameRoot_Main.getSingleton <Manager_BattleMap>().getNextBattleMap(); initialiseBattleMap(newMap); moveMap_Into(newMap, false); //battlePage = battlePage / pageCount + 1; //moveIntoMap(createBattleMap(battlePage), false); }
// 创建载入地图协程 IEnumerator loadMapCoroutine(int mapNumber) //private void loadMap(int mapNumber) { //Debug.Log("coroutine"); // 删除已有子地图 try { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).tag == "BattleMap") { Destroy(transform.GetChild(i)); } } } catch (Exception e) { Debug.Log(e); } // 挪入关卡地图 Manager_BattleMap battleMapManager = GameRoot_Main.getSingleton <Manager_BattleMap>(); GameObject map = battleMapManager.getCurrentBattleMap(); initialiseBattleMap(map); yield return(map); //Debug.Log("Load Map Over"); map.SetActive(true); //Debug.Log("1:" + map.transform.localPosition + " " + mapPosition_Right.transform.localPosition); //map.transform.localPosition = mapPosition_Right.transform.localPosition; //map.transform.localScale = Vector3.one; //Debug.Log("2:" + map.transform.localPosition); moveMap_Into(map, false); yield break; }
// 挪入战斗关卡地图 private void moveMap_Into(GameObject map, bool fromLeft) { map.transform.localPosition = (fromLeft ? mapPosition_Left : mapPosition_Right).transform.localPosition; map.transform.DOMoveX(this.transform.position.x, 0.5f).onComplete = delegate() { messageManager_BattleMap.sendMessage_MapMoveInOver(map); // 改变下面翻页部分显示的页码 pageLabel.text = (GameRoot_Main.getSingleton <Manager_BattleMap>().currentMap + 1) + " / " + GameRoot_Main.getSingleton <Manager_BattleMap>().getBattleMapCount(); }; //map.transform.DOMoveX((fromLeft ? mapPosition_Left : mapPosition_Right).transform.localPosition.x, 0.5f); /** * TweenPosition tween = GameObject.Instantiate(fromLeft ? mapMoveIn_FromLeft : mapMoveIn_FromRight) as TweenPosition; * map.AddComponent(tween); * map.AddComponent() **/ /** * int x = 943; * if (fromLeft) * x = -x; * * //Debug.Log("parent: " + transform.name + " " + transform.position); * //map.transform.localPosition = new Vector3(x, 0, 2); * //map.transform.position = new Vector3(500, 0, 2); * //Debug.Log("map : " + map.transform.position); * //map.transform.SetParent(transform); * //mapCurrent = map; * //iTween.MoveTo(map, new Vector3(0, 0, 2), 2.0f); * //iTween.MoveTo(gameObject, new Vector3(100, 0, 1), 1.0f); * //iTween.moveTo(map, 2.0f, 0f, new Vector3(0, 0, 2), iTween.EasingType.easeInCubic, "destoryMap", "destoryMap"); * //iTween.moveTo(map, 1.0f, 0f, 0, 0, 2, iTween.EasingType.easeInCirc, "destoryMap", map); * //iTween.MoveTo(map, iTween.Hash("position", new Vector3(0, 0, 2), "time", 1.0f, "oncomplete", "destoryMap", "concompletetarget", this)); * //Debug.Log("map : " + map.transform.position); **/ }
// 点击开始按钮 public void ClickStart() { GameRoot_Main.getSingleton <MessageManager_BattleMap>().sendMessage_StartBattleStage(battleStage); }
// (主界面-》战斗模式-》关卡)被点击---》显示战斗信息 public void BattleReady() { GameRoot_Main.getSingleton <MessageManager_BattleMap>().sendMessage_ClickBattleStage(battleStage); }
public void OnEditButtonClick() { //Debug.Log("click"); GameRoot_Main.getSingleton <MessageManager_Equipment>().sendMessage_editEquipment(); }
public void OnClick() { GameRoot_Main.getSingleton <MessageManager_Main>().sendMessage_TurnBack(); }
// 点击“战斗”按钮时调用 public void battleButtonDown() { GameRoot_Main.getSingleton <MessageManager_Main>().sendMessage_BattleButton(); //MessageManager_Main.getInstance().sendMessage_BattleButton(); }
private GameRoot_Main() { rootObj = new GameObject("GameRoot"); instance = this; }
// 点击“选择”装备事件 public void selectEquipmentEvent() { GameRoot_Main.getSingleton <MessageManager_Equipment>().sendMessage_EquipmentInfo_Select(equipment); // 返回 GameRoot_Main.getSingleton <MessageManager_Main>().sendMessage_TurnBack(); }
public void OnStorehouseButtonClick() { GameRoot_Main.getSingleton <MessageManager_Equipment>().sendMessage_Storehouse(); }
public override void Click() { GameRoot_Main.getSingleton <MessageManager_Equipment>().sendMessage_ShowEquipmentInfo(EquipmentInfo_Manager.Mode.ChangeWeapon, manager.equipment); }
// 点击“装备”按钮时调用 public void euqipmentButtonDown() { //Debug.Log(GameRoot_Main.getSingleton<MessageManager_Main>() == null); GameRoot_Main.getSingleton <MessageManager_Main>().sendMessage_EquipmentButton(); //MessageManager_Main.getInstance().sendMessage_EquipmentButton(); }
//void OnDestroy() //{ // UnRegisterEvent(); //} // 注册事件监听 private void RegisterEvent() { GameRoot_Main.getSingleton <MessageManager_Equipment>().selectEquipment += new MessageManager_Equipment.EquipmentInfoDelegate(changeEquipmentOver); }
public void changeWeapon3() { equipmentChanged = PlayerManager.Key_Weapon3; GameRoot_Main.getSingleton <MessageManager_Equipment>().sendMessage_ChangeWeapon(3); }