/// <summary> /// 设置模型建筑与位置信息 /// </summary> /// <param name="vo"></param> public void setfacility(BuildModelVo vo) { switch (vo.ModeltrsId) { case 1: Data.facility1 = vo.Modelid; break; case 2: Data.facility2 = vo.Modelid; break; case 3: Data.facility3 = vo.Modelid; break; case 4: Data.facility4 = vo.Modelid; break; default: break; } consumeBlueprint(vo.Modelid); if (!AppConst.USER_CACHE) { DbAccess dbAccess = new DbAccess(); dbAccess.UpdateInto("info_users", new string[] { "blueprints_budin", "facility1", "facility2", "facility3", "facility4" }, new string[] { Data.Blueprint, Data.facility1.ToString(), Data.facility2.ToString(), Data.facility3.ToString(), Data.facility4.ToString() }, "id", Data.Id.ToString()); dbAccess.CloseSqlConnection(); } RefreshUserInfoValue(); setbuildmodedic(); }
/// <summary> /// 加载时更新模型 /// </summary> /// <param name="foodbowid"></param> public void InitBuilt(BuildModelVo vo, int foodbow) { if (tempmodel != null && !tempmodel.ContainsKey(vo.ModeltrsId)) { if (vo.Modelid != 0) { setmodelfalse(vo); } List <GameObject> list = new List <GameObject>(); for (int i = 1; i < 7; i++) { GameObject Model = BulitPool.GetInstance().GetBulitPool(i).CreateObject(Buildspts[vo.ModeltrsId].position); BuildingBluepointCtrl bl = Model.AddComponent <BuildingBluepointCtrl>(); bl.modeltrsID = vo.ModeltrsId; bl.isBuild = true; bl.foodBowID = foodbow; list.Add(Model); if (i == vo.Modelid) { Model.SetActive(true); } else { Model.SetActive(false); } } tempmodel.Add(vo.ModeltrsId, list); } }
public override void Execute(INotification notification) { UserInfoProxy user = AppFacade.GetInstance().RetrieveProxy(UserInfoProxy.NAME) as UserInfoProxy; BuildModelVo vo = notification.Body as BuildModelVo; user.setfacility(vo); //设置模型与位置信息; }
private void setmodelfalse(BuildModelVo vo) { foreach (GameObject temp in Model) { BuildingBluepointCtrl cl = temp.GetComponent <BuildingBluepointCtrl>(); if (cl.modeltrsID == vo.ModeltrsId) { temp.SetActive(false); } } }
private void setbuildmodedic() { for (int i = 1; i < 5; i++) { if (!BuildModelVoDic.ContainsKey(i)) { BuildModelVo Vo = new BuildModelVo(); Vo.ModeltrsId = i; switch (i) { case 1: Vo.Modelid = Data.facility1; break; case 2: Vo.Modelid = Data.facility2; break; case 3: Vo.Modelid = Data.facility3; break; case 4: Vo.Modelid = Data.facility4; break; } BuildModelVoDic.Add(i, Vo); } else { switch (i) { case 1: BuildModelVoDic[i].Modelid = Data.facility1; break; case 2: BuildModelVoDic[i].Modelid = Data.facility2; break; case 3: BuildModelVoDic[i].Modelid = Data.facility3; break; case 4: BuildModelVoDic[i].Modelid = Data.facility4; break; } } } }
public void onButtonClick(GameObject go) { if (go == CancelBtn && menutype == EnumGlobal.MenuType.BuildingBlueprintMenu) { BuildingBlueprintGameObject.SetActive(false); menutype = EnumGlobal.MenuType.Null; } else if (go == MoveBtn && menutype == EnumGlobal.MenuType.BuildingBlueprintMenu) { if (buildingType == BuildingBlueprintType.Blueprint) { Debug.Log("购买"); onClickPurchase(); } else if (buildingType == BuildingBlueprintType.Building) { BuildModelVo vo = new BuildModelVo(); vo.Modelid = buildingSelectItem; vo.foodbowid = foodBowID; vo.ModeltrsId = modeltrsid; AppFacade.getInstance.SendNotification(NotiConst.SET_BUILDING_MODEL_DATA, vo); AppFacade.getInstance.SendNotification(NotiConst.GET_CHNAGE_MODEL_DATA, vo); BuildingBlueprintGameObject.SetActive(false); menutype = EnumGlobal.MenuType.Null; } else if (buildingType == BuildingBlueprintType.status) { DeleteOkBtn.GetComponentInChildren <UILabel>().text = "是"; DeleteCloseBtn.GetComponentInChildren <UILabel>().text = "否"; ConfirmPanel.transform.GetChild(0).GetComponentInChildren <UILabel>().text = "是否拆除该设施?"; ConfirmPanel.SetActive(true); } } else if (go == SellBtn && menutype == EnumGlobal.MenuType.BuildingBlueprintMenu) { DeleteOkBtn.GetComponentInChildren <UILabel>().text = "是"; DeleteCloseBtn.GetComponentInChildren <UILabel>().text = "否"; ConfirmPanel.transform.GetChild(0).GetComponentInChildren <UILabel>().text = "是否出售该蓝图?"; ConfirmPanel.SetActive(true); } else if (go == DeleteOkBtn && menutype == EnumGlobal.MenuType.BuildingBlueprintMenu) { } else if (go == DeleteCloseBtn && menutype == EnumGlobal.MenuType.BuildingBlueprintMenu) { ConfirmPanel.SetActive(false); } }
public override void HandleNotification(INotification notification) { switch (notification.Name) { case BuildingModelMediator.INITBUILTMODEL: { buildchangeModel.showinitmodel(notification.Body); } break; case BuildingModelMediator.CHANGEMODEL: { BuildModelVo vo = new BuildModelVo(); vo = notification.Body as BuildModelVo; buildchangeModel.ChangeBulit(vo); } break; } }
/// <summary> /// 建造模型 /// </summary> /// <param name="vo"></param> public void ChangeBulit(BuildModelVo vo) { Debug.Log(vo.Modelid + " " + vo.ModeltrsId); setmodelfalse(vo); if (tempmodel.ContainsKey(vo.ModeltrsId)) { for (int i = 1; i < 7; i++) { if (i == vo.Modelid) { tempmodel[vo.ModeltrsId][i - 1].SetActive(true); } else { tempmodel[vo.ModeltrsId][i - 1].SetActive(false); } } } /* GameObject model = BulitPool.GetInstance().GetBulitPool(vo.Modelid).CreateObject(Buildspts[vo.ModeltrsId].position); * BuildingBluepointCtrl bl = model.AddComponent<BuildingBluepointCtrl>(); * bl.modeltrsID = vo.ModeltrsId; * bl.foodBowID = vo.foodbowid; * if (vo.Modelid == 1) * { * bl.isBuild = false; * } * else * bl.isBuild = true; * if (Model[vo.ModeltrsId - 1] != null) * { * Model[vo.ModeltrsId - 1].SetActive(false); * } * * */ }
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; } }
/// <summary> /// 发送改变模型的信息 /// </summary> public void sendchangemodeldata(BuildModelVo _vo) { BuildModelVo vo = userInfoProxy.getmodeldata(_vo.ModeltrsId); SendNotification(BuildingModelMediator.CHANGEMODEL, vo); }