/// <summary> /// 点击标题的回调函数,显示喵分组 /// </summary> /// <param name="sender">Sender.</param> private void showItem(GameObject sender) { // 如果不显示按钮,则显示按钮 if (!MoveBtn.activeInHierarchy) { MoveBtn.SetActive(true); } //当点击toggle的时候,无论是选中还是取消选中都会调用这里,所以需要判断 if (sender.GetComponent <UIToggle>().value) { buildingType = (BuildingBlueprintType)sender.GetComponent <GroupInfo>().GroupId; if (buildingType == BuildingBlueprintType.Blueprint) { SellBtn.SetActive(false); MoveBtn.GetComponentInChildren <UILabel>().text = "购入"; SelectedItem.Clear(); showBuildingBlueprint(); } else if (buildingType == BuildingBlueprintType.Building) { MoveBtn.GetComponentInChildren <UILabel>().text = "建造"; SellBtn.SetActive(true); SellBtn.GetComponentInChildren <UILabel>().text = "出售"; AppFacade.GetInstance().SendNotification(NotiConst.GET_BUILDING_DATA); } else if (buildingType == BuildingBlueprintType.status) { SellBtn.SetActive(false); MoveBtn.GetComponentInChildren <UILabel>().text = "拆除"; removeAllGridChildren(); } } }
public void Login() { tempData = new TempLogRegDataVO(); tempData.UserName = UserName.value; tempData.Password = PassWord.value; AppFacade.GetInstance().SendNotification(NotiConst.LOGIN_REQUEST, tempData); }
void OnBtnClick(GameObject go) { if (go == CatGroupBtn) { Debug.Log(" CatGroupBtn"); AppFacade.getInstance.SendNotification(NotiConst.GET_CAT_GROUP_DATA); CatGroupMenuMediator catGroupMediator = AppFacade.getInstance.RetrieveMediator(CatGroupMenuMediator.NAME) as CatGroupMenuMediator; // catGroupMediator.catGroupMenuView.catGroupMenuGameObject.SetActive(true); //0107 lgx 修改 显示猫分组不能这就草草的显示界面就行需要准备 catGroupMediator.catGroupMenuView.menutype = EnumGlobal.MenuType.CatGroupMenu; catGroupMediator.catGroupMenuView.showCatGroup(); } else if (go == PromoteBtn) { CustomerMediator customerMediator = AppFacade.GetInstance().RetrieveMediator(CustomerMediator.NAME) as CustomerMediator; (customerMediator.ViewComponent as CustomerView).RemoveCustomer(); //AppFacade.getInstance.SendNotification(NotiConst.CAT_LEAVE_ADD_GOLD); //StartCoroutine(SpawnCats()); } else if (go == PromoteBtn_Exp) { SetExp(Exp + 1000); } else if (go == BattleBtn) { (AppFacade.getInstance.RetrieveMediator(SceneMediator.NAME) as SceneMediator).LoadScene(SceneConst.BattleScene); } }
void OnBtnClick(GameObject go) { if (go == CancelBtn && menutype == EnumGlobal.MenuType.CatGroupMenu) { Debug.Log("+++++++++++++"); AppFacade.GetInstance().SendNotification(NotiConst.CAT_GROUP_CLOSE); Debug.Log("-------------"); catGroupMenuGameObject.SetActive(false); menutype = EnumGlobal.MenuType.Null; } else if (go == DeleteCloseBtn && menutype == EnumGlobal.MenuType.CatGroupMenu) { DeleteCancelButton(); ConfirmPanel.SetActive(false); } else if (go == DeleteOkBtn && menutype == EnumGlobal.MenuType.CatGroupMenu) { DeleteOkButton(); ConfirmPanel.SetActive(false); } else if (go == moveButton && menutype == EnumGlobal.MenuType.CatGroupMenu) { Debug.Log("测试1"); OnMoveButtonChicked(go); } }
/// <summary> /// 确定 解雇猫 /// </summary> private void DeleteOkButton() { for (int i = 0; i < catGrid.transform.childCount; i++) { Destroy(catGrid.transform.GetChild(i).gameObject); } JsonData deleteCat = new JsonData(); deleteCat["count"] = selectedItems.Count; for (int i = 0; i < selectedItems.Count; i++) { var obj = selectedItems[i] as GameObject; if (obj != null) { var cat = obj.GetComponent <CatInfo>(); if (cat == null) { Debug.LogError("错误 组件错误"); return; } if (i == 0) { deleteCat["group"] = cat.GroupId; } deleteCat[i.ToString()] = cat.Id; } } selectedItems.Clear(); AppFacade.GetInstance().SendNotification(NotiConst.CAT_DELETE, deleteCat); moveButton.gameObject.SetActive(true); }
/// <summary> /// 蓝图界面点击购买 /// </summary> /// <param name="go">Go.</param> void onClickPurchase() { if (SelectedItem.Count > 0) { AppFacade.GetInstance().SendNotification(NotiConst.PURCHASE_BLUEPRINT, SelectedItem); } }
/// <summary> /// 根据数据库获取的数据,实例化标签列表 /// </summary> public void ShowCatsItem(GameObject sender) { if (!moveButton.activeInHierarchy) { moveButton.SetActive(true); } if (sender.GetComponent <UIToggle>().value) { //对比一下当前列表的第一个子对象,如果groupId等于sender的groupId, //如果不同就全清除掉,并且清除掉已经选择的数据 if (catGrid.transform.childCount != 0 && catGrid.transform.GetChild(0).GetComponent <CatInfo>().GroupId != sender.GetComponent <GroupInfo>().GroupId) { for (int i = 0; i < catGrid.transform.childCount; i++) { Destroy(catGrid.transform.GetChild(i).gameObject); } } int id = sender.GetComponent <GroupInfo>().GroupId; // 请求分组数据 JsonData data = new JsonData(); data["id"] = id; AppFacade.GetInstance().SendNotification(NotiConst.GET_CAT_GROUP_INFO, data); } ShowCatInfo(null); selectedItems.Clear(); //避免存放选择失效 }
/// <summary> /// 得到猫分组信息 /// </summary> void GetCatCurrentGroupData() { JsonData data = new JsonData(); data["id"] = ++CurrentGroupInfo; //对应索引相差1; Debug.Log("当前选择组" + CurrentGroupInfo); AppFacade.GetInstance().SendNotification(NotiConst.GET_BATTLE_CAT_GROUP_INFO, data); }
/// <summary> /// 猫删除完成 重新请求 猫分组数据 /// </summary> /// <param name="data"></param> public void CatDeleteFinsh(object data) { JsonData group = (JsonData)data; JsonData groupData = new JsonData(); groupData["id"] = group["group"]; AppFacade.GetInstance().SendNotification(NotiConst.GET_CAT_GROUP_INFO, groupData); }
public override void Execute(INotification notification) { UserInfoProxy user = AppFacade.GetInstance().RetrieveProxy(UserInfoProxy.NAME) as UserInfoProxy; BuildModelVo vo = notification.Body as BuildModelVo; user.setfacility(vo); //设置模型与位置信息; }
public override void Execute(INotification notification) { LoginVO loginVo = new LoginVO(); loginVo = notification.Body as LoginVO; UserLoginProxy userLoginProxy = (UserLoginProxy)AppFacade.GetInstance().RetrieveProxy(UserLoginProxy.NAME); userLoginProxy.LoginToData(loginVo.Id, loginVo.Pwd); }
void OnEnable() { mainMenuGameObject.SetActive(true); UIEventListener.Get(BattleBtn).onClick += OnBtnClick; UIEventListener.Get(CatGroupBtn).onClick += OnBtnClick; UIEventListener.Get(CatHRBtn).onClick += OnBtnClick; UIEventListener.Get(PromoteBtn).onClick += OnBtnClick; UIEventListener.Get(PromoteBtn_Exp).onClick += OnBtnClick; UIEventListener.Get(LeftBtn).onClick += OnBtnClick; UIEventListener.Get(RightBtn).onClick += OnBtnClick; AppFacade.GetInstance().SendNotification(NotiConst.GET_USER_INFO_VALUE); }
private void onBtnClick(GameObject go) { Debug.Log("onclick onBtnClick BuildingBluepointCtrl"); BuildingBlueprintMediator mediator = AppFacade.GetInstance().RetrieveMediator(BuildingBlueprintMediator.NAME) as BuildingBlueprintMediator; mediator.buldingBlueprint.isBulid = isBuild; mediator.buldingBlueprint.modeltrsid = modeltrsID; // mediator.buldingBlueprint.foodBowID = foodBowID; // mediator.buldingBlueprint.gameObject.SetActive(true); // mediator.buldingBlueprint.showBulidingTitle(); mediator.buldingBlueprint.showBuildingBlueprint(foodBowID); mediator.buldingBlueprint.menutype = EnumGlobal.MenuType.BuildingBlueprintMenu; }
/// <summary> /// 取消删除猫 重新请求数据列表 /// </summary> private void DeleteCancelButton() { for (int i = 0; i < catGrid.transform.childCount; i++) { Destroy(catGrid.transform.GetChild(i).gameObject); } JsonData data = new JsonData(); data["id"] = (selectedItems[0] as GameObject).GetComponent <CatInfo>().GroupId; selectedItems.Clear(); AppFacade.GetInstance().SendNotification(NotiConst.GET_CAT_GROUP_INFO, data); moveButton.gameObject.SetActive(true); }
/// <summary> /// 移动按钮响应 /// </summary> /// <param name="sender"></param> public void OnMoveButtonChicked(GameObject sender) { if (selectedItems.Count != 0) { sender.SetActive(false); for (int i = 0; i < catGrid.transform.childCount; i++) { catGrid.transform.GetChild(i).gameObject.SetActive(false); } // 服务器请求 猫分组列表 JsonData data = new JsonData(); data["type"] = CatGroupMenuMediator.CAT_MOVE_GROUP_TITLE; AppFacade.GetInstance().SendNotification(NotiConst.GET_CAT_GROUP_TITLE, data); } }
/// <summary> /// 购买蓝图 , 花费经验和钻石,获取建筑 /// </summary> public void purchaseBlueprint(System.Object data) { List <int> selectedItems = (List <int>)data; int needEXP = 0; int needDiamond = 0; StringBuilder build = new StringBuilder(userInfoProxy.getBlueprintsbudin()); bool isRemoveFirstChar = false; if (build.Length <= 0) { isRemoveFirstChar = true; } foreach (int id in selectedItems) { stat_blueprintRow blueprint = mBuildBlueprintDict[id]; needEXP += blueprint.cost_exp; needDiamond += blueprint.cost_diamond; build.AppendFormat(",{0}", id); } //移除第一个分号 if (build.Length > 0 && isRemoveFirstChar) { build.Remove(0, 1); } int ownExp = userInfoProxy.getEXP(); int ownDiamond = userInfoProxy.getDiamond(); if (needEXP <= ownExp && needDiamond <= ownDiamond) { userInfoProxy.SetDiamond(ownDiamond - needDiamond); userInfoProxy.setEXP(ownExp - needEXP); userInfoProxy.setBlueprintsbudin(build.ToString()); //刷新宝石,建筑信息 AppFacade.GetInstance().SendNotification(NotiConst.GET_USER_INFO_VALUE); SendNotification(BuildingBlueprintMediator.PURCHASE_BLUEPRINT_RESULT, true); } else { SendNotification(BuildingBlueprintMediator.PURCHASE_BLUEPRINT_RESULT, false); } }
public void RemoveCustomer() { if (currentCustomer > 0) { customerLists[0].GetComponent <CustomerCtl>().LeaveManor(); int Money = customerLists[0].GetComponent <CustomerInfo>().Money; customerLists.RemoveAt(0); AppFacade.getInstance.SendNotification(NotiConst.SET_CURRENT_CUSTOMER, currentCustomer - 1); //补齐显示的顾客 if (currentCustomer >= visibleCustomer) { SendRandomAddCustomerCommand(); } MainMenuUIMediator mainMenuUIMediator = (MainMenuUIMediator)AppFacade.GetInstance().RetrieveMediator(MainMenuUIMediator.NAME); MainMenuUIView mainMenuUIView = (MainMenuUIView)mainMenuUIMediator.ViewComponent; mainMenuUIView.SetGold(mainMenuUIView.Gold + Money); } }
/// <summary> /// 给猫换组的点击响应, /// </summary> public void OnGroupItemButton(GameObject sender) { Debug.Log("&&&&&&"); int groupId = sender.GetComponent <GroupInfo>().GroupId; JsonData catMoveData = new JsonData(); catMoveData["newId"] = groupId; catMoveData["count"] = selectedItems.Count; for (int i = 0; i < selectedItems.Count; i++) { var obj = selectedItems[i] as GameObject; if (obj != null) { var cat = obj.GetComponent <CatInfo>(); if (cat == null) { Debug.LogError("错误 组件错误"); return; } if (groupId == cat.GroupId) { return; } catMoveData["oldId"] = cat.GroupId; catMoveData[i.ToString()] = cat.Id; } } selectedItems.Clear(); AppFacade.GetInstance().SendNotification(NotiConst.CAT_SWITCH_GROUP, catMoveData); }
public override void Execute(INotification notification) { var porxy = AppFacade.GetInstance().RetrieveProxy(BuildBlueprintProxy.NAME) as BuildBlueprintProxy; switch (notification.Name) { case NotiConst.GET_BUILDINGBLUEPRINT_DATA: //发送蓝图信息 porxy.sendBuildingBlueprintData(); break; case NotiConst.GET_STATBUILD_DATA: //发送静态建筑信息 porxy.sendBuildStatData(); break; case NotiConst.GET_BUILDING_DATA: // 发送建筑信息 porxy.sendBuildData(); break; case NotiConst.PURCHASE_BLUEPRINT: //购买蓝图 porxy.purchaseBlueprint(notification.Body); Debug.Log("+++" + notification.Body); break; case NotiConst.GET_BUILDING_MODEL_DATA: Debug.Log("GET_BUILDING_MODEL_DATA~~~~~~~~~~~"); porxy.sendBulidModeldata(); //发送模型初始值信息 break; case NotiConst.GET_CHNAGE_MODEL_DATA: BuildModelVo vo = notification.Body as BuildModelVo; porxy.sendchangemodeldata(vo); //发送模型改变信息 break; } }
void Start() { AppFacade.GetInstance().RegisterMediator(new LoginMediator(gameObject)); }
public void SetExp(int count) { AppFacade.GetInstance().SendNotification(NotiConst.SET_EXP, count); }
public void SetGold(int count) { AppFacade.GetInstance().SendNotification(NotiConst.SET_GOLD, count); }
public void OnBtnClick(GameObject go) { if (go == LoginBtn) { Login(); } else if (go == RegisterBtn) { // 清空密码输入框 需要重新输入密码 PassWord.value = ""; ConfirmPassWord.value = ""; ChangeState(LoginViewMediator.ELoginViewState.REGISTER); } else if (go == OKBtn) { Message.text = ""; string errorInfo = "Registration error"; if (string.IsNullOrEmpty(UserName.value)) { errorInfo = "The user name cannot be empty"; } else if (string.IsNullOrEmpty(PassWord.value)) { errorInfo = "Password cannot be empty"; } else if (PassWord.value.Length < 6) { errorInfo = "Password length cannot be less than 6"; } else if (string.IsNullOrEmpty(ConfirmPassWord.value)) { errorInfo = "Please input the password again"; } else if (PassWord.value != ConfirmPassWord.value) { errorInfo = "Two entered passwords do not match"; } else { tempData = new TempLogRegDataVO(); tempData.UserName = UserName.value; tempData.Password = PassWord.value; AppFacade.GetInstance().SendNotification(NotiConst.REGISTER_REQUEST, tempData); return; } Message.text = errorInfo; // JsonData data2 = new JsonData(); // data2[MessageView.MessageType] = MessageView.TwoParameters; // data2[MessageView.OneParameters] = errorInfo; // data2[MessageView.TwoParameters] = gameObject.GetComponent<UIPanel>().depth; // AppFacade.GetInstance().SendNotification(NotiConst.MessageMediator, data2); // Debug.LogError("注册信息有误!"); } else if (go == ReturnBtn) { // 清空密码输入框 需要重新输入密码 PassWord.value = ""; ConfirmPassWord.value = ""; ChangeState(LoginViewMediator.ELoginViewState.LOGIN); } else if (go == QuitBtn) { //退出游戏 Application.Quit(); } }
/// <summary> /// 获取建筑的信息,在获取信息之后展示数据 /// </summary> public void getBuildingData() { AppFacade.GetInstance().SendNotification(NotiConst.GET_BUILDINGBLUEPRINT_DATA); AppFacade.GetInstance().SendNotification(NotiConst.GET_STATBUILD_DATA); }