public string GetBuildingNameByType(BuildingType type) { int configID = GetConfigIDByBuildingType(type); BUILDING data = GetBuildingConfigDataByConfigID(configID); return(data.BldgName); }
void FirstSetting() { switch (buildingType) { case BUILDING.VILLAGE: if (owner != null) { buildingType = BUILDING.CITY; return; } if(!BuildingManager.Instance().BuildingRuleOne(gameObject.transform.position.x, gameObject.transform.position.z)) { return; } GameManager.Instance().onPlayer.GetComponent<Player>().AddBuilding(gameObject); break; case BUILDING.STREET: if (owner != null) { return; } break; } owner = GameManager.Instance().onPlayer; GetComponent<Renderer>().material = owner.GetComponent<Player>().playerColor; GameManager.Instance().SettingDone(); }
void ProcessBuildingInfo(InvadeResultInfo info, out string resStr) { if (info.Id == -1) { resStr = string.Format("[960000]大门破损不堪,僵尸毫不费力就闯入了庄园![-]"); return; } //sanctuaryPackage NBuildingInfo buildingInfo = sanctuaryPackage.GetBuildingInfo(info.Id); BuildingFunc func = sanctuaryPackage.GetBuildingFuncByConfigID(buildingInfo.configID); if (func == BuildingFunc.Defence) //Gate { if (info.Blood <= 0) { resStr = string.Format("[960000]僵尸攻破了大门,开始疯狂破坏![-]"); } else { resStr = string.Format("[960000]僵尸开始攻击大门![-]"); } } else //Turret { BUILDING config = sanctuaryPackage.GetBuildingConfigDataByConfigID(buildingInfo.configID); resStr = string.Format("{0}击杀了{1}只僵尸", config.BldgName, info.Num); } }
public List <NItemInfo> GetBuildingUpgradeCost(NDictionary args) { if (args == null) { return(null); } int fromConfigID = args.Value <int>("configID"); List <NItemInfo> costInfoList = new List <NItemInfo>(); var buildingConfigDataMap = ConfigDataStatic.GetConfigDataTable("BUILDING"); BUILDING buildingConfigData = buildingConfigDataMap[fromConfigID] as BUILDING; for (int i = 0; i < buildingConfigData.CostTableCount; i++) { var costData = buildingConfigData.GetCostTable(i); int configID = costData.CostId; if (configID == 0) { continue; } int number = costData.CostQty; NItemInfo info = new NItemInfo(); info.configID = configID; info.number = number; costInfoList.Add(info); } return(costInfoList); }
public void Initialize(NDictionary args) { SanctuaryPackage sanctuaryPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage; int configID = args.Value <int>("id"); bool isUnlock = args.Value <bool>("isunlock"); UILabel label = transform.Find("label").GetComponent <UILabel>(); BUILDING config = ConfigDataStatic.GetConfigDataTable("BUILDING")[configID] as BUILDING; if (isUnlock == true) { label.text = string.Format("{0} Lv.{1}", config.BldgName, sanctuaryPackage.GetBulidingLevelByConfigID(configID)); } else { UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; int curLevel = userPackage.GetManorLevel(); int requireLevel = config.BldgLvLim; if (curLevel >= requireLevel) { label.text = string.Format("[90FF15]可解锁[-]"); } else { label.text = string.Format("庄园Lv.{0} 解锁", requireLevel); } } name = config.BldgName; }
void InitView() { NBuildingInfo info = sanctuarytPackage.GetBuildingInfo(selecttionBuilding.BuildingID); var buildingDataMap = ConfigDataStatic.GetConfigDataTable("BUILDING"); BUILDING buildingData = buildingDataMap[info.configID] as BUILDING; int level = sanctuarytPackage.GetBulidingLevelByConfigID(info.configID); titleLabel.text = string.Format("{0} Lv.{1}", buildingData.BldgName, level); contentLable.text = buildingData.BldgInfo; //render 3d model string prefabName = buildingData.PrefabName; if (!string.IsNullOrEmpty(prefabName)) { NDictionary data = new NDictionary(); prefabName = prefabName.Substring(0, prefabName.IndexOf(".")); GameObject prefab = Resources.Load <GameObject>("Prefabs/Building/" + prefabName); if (prefab != null) { data.Add("model", prefab); modelGo = FacadeSingleton.Instance.InvokeService("OpenSubRenderer", ConstVal.Service_Sanctuary, data) as GameObject; } } //get attribute data int count = sanctuarytPackage.GetBuildingAttribute(selecttionBuilding, level); tableView.DataCount = count; tableView.TableChange(); }
void OnGetSceneInfo(NetMsgDef msg) { TSCGetSceneInfo sceneInfo = TSCGetSceneInfo.ParseFrom(msg.mBtsData); for (int i = 0; i < sceneInfo.BuildingInfosCount; i++) { BuildingInfo info = sceneInfo.BuildingInfosList[i]; BUILDING config = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.ConfigId); //print(string.Format("{0}, {1}", config.BldgName, info.Number)); sanctuaryPackage.AddBuilding(info); } userPackage.SetTotalContribution(sceneInfo.TotalContribution); for (int i = 0; i < sceneInfo.UserInfosCount; i++) { userPackage.AddUserInfo(sceneInfo.GetUserInfos(i)); manors[i].SetUserID(sceneInfo.GetUserInfos(i).Uid); manors[i].gameObject.SetActive(true); } userPackage.SetGroupName(sceneInfo.GroupName); SendEvent("RefreshManorLevel"); SendEvent("RefreshBuildingView"); SendEvent("RefreshZombieSpawner"); SendEvent("RefreshProduceBar"); InitManor(); }
public static Building Get(BUILDING building) { return(new Building { Id = building.ID, Number = building.NUMBER }); }
void InitView() { NBuildingInfo info = sanctuaryPackage.GetSelectionBuildingInfo(); BUILDING configData = null; BUILDING nextConfigData = null; if (info == null) //unlock { Building building = sanctuaryPackage.GetSelectionBuilding(); int configID = sanctuaryPackage.GetConfigIDByBuildingType(building.buildingType); nextConfigData = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); titleLabel.text = string.Format("{0} 升级", nextConfigData.BldgName); preLevelLabel.text = string.Format("Lv.{0}", 0); nextLevelLabel.text = string.Format("Lv.{0}", sanctuaryPackage.GetBulidingLevelByConfigID(configID)); } else { configData = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); nextConfigData = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID + 1); titleLabel.text = string.Format("{0} 升级", configData.BldgName); preLevelLabel.text = string.Format("Lv.{0}", sanctuaryPackage.GetBulidingLevelByConfigID(info.configID)); nextLevelLabel.text = string.Format("Lv.{0}", sanctuaryPackage.GetBulidingLevelByConfigID(info.configID + 1)); } titleLabel.text = string.Format("{0} 升级", configData.BldgName); preLevelLabel.text = string.Format("Lv.{0}", sanctuaryPackage.GetBulidingLevelByConfigID(info.configID)); nextLevelLabel.text = string.Format("Lv.{0}", sanctuaryPackage.GetBulidingLevelByConfigID(info.configID + 1)); //set icon preIcon.spriteName = configData.IconName; nextIcon.spriteName = nextConfigData.IconName; //show cost int level = nextConfigData.BldgLvLim; levelLabel.text = string.Format("庄园等级限制: {0}", level); int curLevel = userPackage.GetManorLevel(); if (level > curLevel) { levelLabel.color = Color.red; } else { levelLabel.color = Color.white; } //levelLabel.text ShowCost(nextConfigData); //show upgrade effect ShowUpgradeEffect(info); //set point if (info.building.CanUnlockOrUpgrade) { pointGo.SetActive(true); } else { pointGo.SetActive(false); } }
public JsonResult PostBuild(BUILDING build) { ApiResult result = new ApiResult(); if (build is null) { result.Message = "Vui lòng điền đầy đủ thông tin bên trên"; return(Json(result.Data)); } using (BDSEntities db = new BDSEntities()) { BUILDING b = new BUILDING(); if (build.idBuild > 0) { b = db.BUILDINGs.Where(x => x.idBuild == build.idBuild).FirstOrDefault(); } if (b is null) { result.Message = "Vui lòng thử lại"; return(Json(result)); } var huong = db.HUONGs.Where(x => x.idHuong == build.idHuong).FirstOrDefault(); b.nameBuild = build.nameBuild; b.floor = build.floor; b.floorarea = build.floorarea; b.idHuong = build.idHuong; b.nameManager = build.nameManager; b.phoneManager = build.phoneManager; b.conent = build.conent; b.street = build.street; b.deposits = build.deposits; b.depositDate = build.depositDate; b.idUser = build.idUser; b.idWard = build.idWard; b.idType = build.idType; b.idStatus = build.idStatus; b.price = build.price; b.idHuong = build.idHuong; if (build.idBuild == 0) { db.BUILDINGs.Add(b); } try { db.SaveChanges(); result.Success = true; result.Message = b.idBuild + ""; } catch (Exception ex) { result.Message = ex.Message; } } return(Json(result)); }
public static Building GetWithSquareAndImagePath(BUILDING building) { return(new Building { Id = building.ID, Number = building.NUMBER, Square = (float)building.SQUARE, ImagePath = AddressModel.GetBuildingImageForCustomerDetailsView(building.ID) }); }
public BUILDING Save(BUILDING building) { if (building.ID == 0) { context.BUILDINGs.Add(building); } else { context.Entry(building).State = EntityState.Modified; } context.SaveChanges(); return(building); }
//reload prefab of building public void ReloadModel() { GameObject prefab = null; if (mState == BuildingState.Locked) { prefab = Resources.Load <GameObject>("Prefabs/Building/lock"); } else { NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(buildingID); if (info == null) { return; } BUILDING configData = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); string prefabName = configData.PrefabName; prefabName = prefabName.Substring(0, prefabName.IndexOf(".")); prefab = Resources.Load <GameObject>("Prefabs/Building/model/" + prefabName); } if (prefab == null) { return; } if (buildingGo != null) { buildingGo.SendMessage("ClearHud", SendMessageOptions.DontRequireReceiver); DestroyImmediate(buildingGo); } buildingGo = Instantiate(prefab); buildingGo.transform.parent = transform; buildingGo.transform.localPosition = Vector3.zero; buildingGo.transform.localRotation = Quaternion.identity; hudBinder = buildingGo.AddComponent <HudBinder>(); Transform pos = buildingGo.transform.Find("pos"); if (pos != null) { hudBinder.SetTarget(pos.gameObject); } NEventListener listener = buildingGo.AddComponent <NEventListener>(); listener.AddClick(OnClick); }
void GetBuildingAttributeNew(Building building, int level) { if (level >= 20) { return; } NBuildingInfo info = GetBuildingInfo(building.BuildingID); BuildingFunc func = GetBuildingFuncByConfigID(info.configID); BUILDING buildingConfig = GetBuildingConfigDataByConfigID(info.configID); string funcName = buildingConfig.BldgFuncTableName; object funcConfig = ConfigDataStatic.GetConfigDataTable(funcName)[level]; //reflection get properties if (func == BuildingFunc.Collect) { } }
public bool IsAbleToUnlockOrUpgrade(int configID) { int requireVal; double curVal; ItemPackage itemPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage; UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; BUILDING config = GetBuildingConfigDataByConfigID(configID); //level requireVal = config.BldgLvLim; curVal = userPackage.GetManorLevel(); if (curVal < requireVal) { return(false); } //gold cost requireVal = config.GoldCost; curVal = itemPackage.GetGoldNumber(); if ((double)requireVal > curVal) { return(false); } //item for (int i = 0; i < config.CostTableCount; i++) { var cost = config.GetCostTable(i); if (cost.CostId == 0) { continue; } requireVal = cost.CostQty; NItemInfo info = itemPackage.GetItemInfo(cost.CostId); // ITEM_RES itemConfig = itemPackage.GetItemDataByConfigID(cost.CostId); // if(itemConfig == null) // { // Debug.Log(string.Format("configID = {0} missing!!!", cost.CostId)); // continue; // } if (info == null || info.number < cost.CostQty) { return(false); } } return(true); }
public void CalculateBuildingCost(int configID) { BUILDING configData = GetBuildingConfigDataByConfigID(configID); if (configData == null) { return; } buildingCostList.Clear(); //level, gold, elec NCostDef cost = new NCostDef(); cost.configID = 1; cost.value = configData.BldgLvLim; buildingCostList.Add(cost); if (configData.GoldCost > 0) { cost = new NCostDef(); cost.configID = 2; cost.value = configData.GoldCost; buildingCostList.Add(cost); } if (configData.ElecCost > 0) { cost = new NCostDef(); cost.configID = 3; cost.value = configData.ElecCost; buildingCostList.Add(cost); } //res cost for (int i = 0; i < configData.CostTableCount; i++) { cost = new NCostDef(); int itemConfigID = configData.GetCostTable(i).CostId; if (itemConfigID == 0) { continue; } int num = configData.GetCostTable(i).CostQty; cost.configID = itemConfigID; cost.value = num; buildingCostList.Add(cost); } }
public int GetTotalProEfficiency() { UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; double sum = 0; foreach (var pair in mBuildingInfoMap) { if (GetBuildingFuncByConfigID(pair.Value.configID) != BuildingFunc.Collect) { continue; } BUILDING buildingConfig = GetBuildingConfigDataByConfigID(pair.Value.configID); string name = buildingConfig.BldgFuncTableName; name = name.ToUpper(); int level = GetBulidingLevelByConfigID(pair.Value.configID); var configMap = ConfigDataStatic.GetConfigDataTable(name); var funcConfig = configMap[level]; Type type = Type.GetType("com.nkm.framework.resource.data." + name); string propertyName = name[0] + name.Substring(1).ToLower(); PropertyInfo spdInfo = type.GetProperty(propertyName + "Spd"); int spd = (int)spdInfo.GetValue(funcConfig, null); sum += spd; } //add number buff int personNum = userPackage.GetManorPersonNumber(); if (personNum == 2) { sum *= 1.6f; } if (personNum == 3) { sum *= 2.2f; } if (personNum == 4) { sum *= 2.8f; } return((int)((double)sum * userPackage.GetPlayerInterest())); }
public bool IsBuildingVisible(BuildingType type) { UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; float progress; int level = userPackage.GetManorLevel(out progress); int configID = GetConfigIDByBuildingType(type); BUILDING data = GetBuildingConfigDataByConfigID(configID); if (type == BuildingType.ConcreteFactory) { Debug.Log(string.Format("name{0} level{1}", data.BldgName, data.BldgVisible)); } if (level >= data.BldgVisible) { return(true); } else { return(false); } }
public void SetCollect(bool isCollect) { if (isCollect) { NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(buildingID); if (info == null) { return; } BUILDING config = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); NDictionary args = new NDictionary(); args.Add("id", config.ProId); hudBinder.AddHud(HudType.Collect, args); mState = BuildingState.Collect; } else { hudBinder.RemoveHud(HudType.Collect); mState = BuildingState.Idle; } }
void InitView() { int configID = sanctuaryPackage.GetConfigIDByBuildingType(sanctuaryPackage.GetSelectionBuilding().buildingType); BUILDING configData = sanctuaryPackage.GetBuildingConfigDataByConfigID(configID); titleLabel.text = string.Format("{0} 解锁", configData.BldgName); descLabel.text = configData.BldgInfo; //set icon iconSprite.spriteName = configData.IconName; ShowCost(configData); //set point Building building = sanctuaryPackage.GetSelectionBuilding(); if (building.CanUnlockOrUpgrade) { pointGo.SetActive(true); } else { pointGo.SetActive(false); } }
public void GetProAttribute(int configID, out float speed, out float cap) { BUILDING buildingConfig = GetBuildingConfigDataByConfigID(configID); string funcName = buildingConfig.BldgFuncTableName; int level = GetBulidingLevelByConfigID(configID); funcName = funcName.ToUpper(); var configMap = ConfigDataStatic.GetConfigDataTable(funcName); var funcConfig = configMap[level]; Type type = Type.GetType("com.nkm.framework.resource.data." + funcName); string propertyName = funcName[0] + funcName.Substring(1).ToLower() + "Spd"; PropertyInfo spdInfo = type.GetProperty(propertyName); int configSpeed = (int)spdInfo.GetValue(funcConfig, null); propertyName = funcName[0] + funcName.Substring(1).ToLower() + "Cap"; spdInfo = type.GetProperty(propertyName); int configCap = (int)spdInfo.GetValue(funcConfig, null); speed = (float)configSpeed / 3600f; cap = (float)configCap; }
public void Delete(BUILDING building) { context.BUILDINGs.Remove(building); context.SaveChanges(); }
public bool PayBuilding(BUILDING building) { switch(building) { case BUILDING.VILLAGE: if(cardDic[RESOURCE.BRICK].Count < 1) { //UI return false; } if (cardDic[RESOURCE.WOOD].Count < 1) { //UI return false; } if(cardDic[RESOURCE.WHEAT].Count < 1) { //UI return false; } if (cardDic[RESOURCE.SHEEP].Count < 1) { //UI return false; } Destroy(cardDic[RESOURCE.BRICK][0]); cardDic[RESOURCE.BRICK].RemoveAt(0); Destroy(cardDic[RESOURCE.WOOD][0]); cardDic[RESOURCE.WOOD].RemoveAt(0); Destroy(cardDic[RESOURCE.WHEAT][0]); cardDic[RESOURCE.WHEAT].RemoveAt(0); Destroy(cardDic[RESOURCE.SHEEP][0]); cardDic[RESOURCE.SHEEP].RemoveAt(0); break; case BUILDING.CITY: if (cardDic[RESOURCE.WHEAT].Count < 2) { //UI return false; } if (cardDic[RESOURCE.ROCK].Count < 3) { //UI return false; } for (int i = 0; i < 2; ++i ) { Destroy(cardDic[RESOURCE.WHEAT][0]); cardDic[RESOURCE.WHEAT].RemoveAt(0); } for (int i = 0; i < 3; ++i) { Destroy(cardDic[RESOURCE.ROCK][0]); cardDic[RESOURCE.ROCK].RemoveAt(0); } break; case BUILDING.STREET: if (cardDic[RESOURCE.WOOD].Count < 1) { //UI return false; } if (cardDic[RESOURCE.BRICK].Count < 1) { //UI return false; } Destroy(cardDic[RESOURCE.BRICK][0]); cardDic[RESOURCE.BRICK].RemoveAt(0); Destroy(cardDic[RESOURCE.WOOD][0]); cardDic[RESOURCE.WOOD].RemoveAt(0); break; } SettingCard(); return true; }
internal static HandleRef getCPtr(BUILDING obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
void InitView() { NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(selectionBuilding.BuildingID); var buildingDataMap = ConfigDataStatic.GetConfigDataTable("BUILDING"); BUILDING buildingData = buildingDataMap[info.configID] as BUILDING; int level = sanctuaryPackage.GetBulidingLevelByConfigID(info.configID); long remainTime = 0; //check if is crafting isCrafting = false; isCollect = false; if (GlobalFunction.GetRemainTime(info.processFinishTime, out remainTime)) { isCrafting = true; } else if (info.number > 0) { isCollect = true; } toConfigID = buildingData.ProId; fromConfigID = buildingData.ConId; //item name var itemDataMap = ConfigDataStatic.GetConfigDataTable("ITEM_RES"); ITEM_RES itemData = itemDataMap[fromConfigID] as ITEM_RES; fromItemName.text = itemData.MinName; fromSprite.spriteName = itemData.IconName; ratio = buildingData.ConPro; itemData = itemDataMap[toConfigID] as ITEM_RES; toItemName.text = itemData.MinName; describeLabel.text = itemData.Desc; toSprite.spriteName = itemData.IconName; descSprite.spriteName = itemData.IconName; // set number NItemInfo itemInfo = itemPackage.GetItemInfo(fromConfigID); craftNum = 0; slider.value = 0f; if (itemInfo == null) { craftMax = 0; } else { int toItemMax = (int)Mathf.Floor((float)itemInfo.number / (float)ratio); craftMax = toItemMax * ratio; slider.numberOfSteps = (int)Mathf.Ceil((float)craftMax / (float)ratio) + 1; } //check if is self if (info.processUID == userPackage.UserID) { isSelf = true; } else { isSelf = false; } //text title.text = string.Format("{0} Lv.{1}", buildingData.BldgName, level); collectButton.gameObject.SetActive(false); cancelButton.gameObject.SetActive(false); //stop timer if (TimerCo != null) { timeLabel.text = "00:00"; StopCoroutine(TimerCo); } if (isCrafting) { //check if is self if (isSelf) { stateLabel.text = "你正在使用"; cancelButton.gameObject.SetActive(true); } else { stateLabel.text = string.Format("玩家Uid{0}正在使用", info.processUID); } //set time if (remainTime > 0) { TimerCo = StartCoroutine(Timer(remainTime)); } } else if (isCollect) { if (isSelf) { stateLabel.text = string.Format("可以领取{0}", info.number); collectButton.gameObject.SetActive(true); } timeLabel.text = "00:00"; } else { stateLabel.text = "该工厂处于空闲状态"; collectButton.gameObject.SetActive(false); cancelButton.gameObject.SetActive(false); } UpdateNumView(); }
/// <summary>指令处理</summary> public ASObject Switch(int moduleNumber, int commandNumber, TGGSession session, ASObject data) { #if DEBUG var sw = Stopwatch.StartNew(); #endif if (!CommonHelper.IsOpen(session.Player.Role.Kind.role_level, (int)OpenModelType.一夜)) { return(CommonHelper.ErrorResult(ResultType.BASE_PLAYER_LEVEL_ERROR)); } var aso = new ASObject(); //指令匹配 switch (commandNumber) { case (int)BuildingCommand.ENTER: { aso = ENTER.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.GET_WOOD: { aso = GET_WOOD.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.TORCH: { aso = TORCH.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.MAKE_BUILD: { aso = MAKE_BUILD.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.BUILDING: { aso = BUILDING.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.FIRE: { aso = FIRE.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.EXIT: { aso = EXIT.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.MOVING: { aso = MOVING.getInstance().CommandStart(session, data); break; } case (int)BuildingCommand.KILL_BOSS: { aso = KILL_BOSS.GetInstance().CommandStart(session, data); break; } case (int)BuildingCommand.BACK_POINT: { aso = BACK_POINT.GetInstance().CommandStart(session, data); break; } } #if DEBUG sw.Stop(); XTrace.WriteLine("指令 {1} 运行总耗时:{0} 毫秒", sw.ElapsedMilliseconds.ToString(), GetType().Namespace); #endif return(aso); }
private float CalculateReward(BUILDING building) { float reward = 0.1f; if (building == BUILDING.road) // The selected index is a road { // Check horizontal and vertical foreach (int neighbor in neighbors) { if (neighbor == (int)building) { reward += 0.25f; } } // Check diagonals foreach (int neighbor in diagonal_neighbors) { if (neighbor == (int)building) { reward -= 0.5f; } } } else // The selected index is a building { int index = (int)building; // Check if the building is right for this zone bool wrong_zone_building; if (currentZone == ZONE.inner_zone) // inner zone { wrong_zone_building = (index > inner_zone_range); } else if (currentZone == ZONE.middle_zone) // middle zone { wrong_zone_building = (index > middle_zone_range || index <= inner_zone_range); } else // Outer zone { wrong_zone_building = (index <= middle_zone_range); } if (wrong_zone_building) { reward -= 1; // Wrong building for this zone } else { reward += 0.5f; // Right building for this zone } // Check building next of this one if (neighbors[0] == index) { reward -= 0.25f; // Building on the left } if (neighbors[2] == index) { reward -= 0.25f; // Building on the right } // Check if there is at least one road adjacent bool found = false; int i = 0; while (!found && i < diagonal_neighbors.Length) { if (diagonal_neighbors[i] == (int)BUILDING.road) { found = true; } i++; } i = 0; while (!found && i < diagonal_neighbors.Length) { if (diagonal_neighbors[i] == (int)BUILDING.road) { found = true; } i++; } if (found) { reward += 0.5f; } // Check buildings above int buildings_found = 0; if (neighbors[1] != (int)BUILDING.road && neighbors[1] >= 0) { buildings_found++; } if (diagonal_neighbors[0] != (int)BUILDING.road && neighbors[1] >= 0) { buildings_found++; } if (diagonal_neighbors[1] != (int)BUILDING.road && neighbors[1] >= 0) { buildings_found++; } // All items above this one are buildings if (buildings_found == 3) { reward -= 0.5f; } } return(Mathf.Clamp(reward, -1, 1)); }
public void SetBuildingType(int type_index) { type = (BUILDING)type_index; }
void ShowCost(BUILDING configData) { int count = 0; //show gold & elec if (configData.GoldCost > 0) { int costNum = configData.GoldCost; double curNum = itemPackage.GetGoldNumber(); costCellList[count].title.text = "黄金消耗: "; costCellList[count].value.text = string.Format("{0} / {1}", GlobalFunction.NumberFormat(costNum), GlobalFunction.NumberFormat(curNum)); costCellList[count].go.SetActive(true); if ((double)costNum > curNum) { costCellList[count].title.color = Color.red; costCellList[count].value.color = Color.red; } else { costCellList[count].title.color = Color.white; costCellList[count].value.color = Color.white; } count++; } if (configData.ElecCost > 0) { int costNum = configData.ElecCost; double curNum = itemPackage.GetElecNumber(); costCellList[count].title.text = "电力消耗: "; costCellList[count].value.text = string.Format("{0} / {1}", GlobalFunction.NumberFormat(costNum), GlobalFunction.NumberFormat(curNum)); costCellList[count].go.SetActive(true); if ((double)costNum > curNum) { costCellList[count].title.color = Color.red; costCellList[count].value.color = Color.red; } else { costCellList[count].title.color = Color.white; costCellList[count].value.color = Color.white; } count++; } for (int i = 0; i < configData.CostTableCount; i++) { int itemConfigId = configData.GetCostTable(i).CostId; if (itemConfigId == 0) { continue; } int num = configData.GetCostTable(i).CostQty; ITEM_RES itemData = itemPackage.GetItemDataByConfigID(itemConfigId); NItemInfo itemInfo = itemPackage.GetItemInfo(itemConfigId); int curNum = itemInfo == null ? 0 : itemInfo.number; costCellList[count].title.text = itemData.MinName + ": "; costCellList[count].value.text = string.Format("{0} / {1}", num.ToString(), curNum); costCellList[count].go.SetActive(true); if (itemInfo == null || itemInfo.number < num) { costCellList[count].title.color = Color.red; costCellList[count].value.color = Color.red; } else { costCellList[count].title.color = Color.white; costCellList[count].value.color = Color.white; } count++; } for (; count < 5; count++) { costCellList[count].go.SetActive(false); } }
public void RefreshHud() { if (buildingGo == null || hudBinder == null) { return; } if (hudBinder == null) { return; } hudBinder.ClearHud(); NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(buildingID); // check if can unlock or upgrade CheckIfCanUnlockOrUpgrade(); // int configID = 0; // if(info != null) // { // configID = info.configID; // if(sanctuaryPackage.GetBulidingLevelByConfigID(configID) < 20) // if(sanctuaryPackage.IsAbleToUnlockOrUpgrade(configID + 1)) // hudBinder.AddHud(HudType.Exmind); // } // else // { // configID = sanctuaryPackage.GetConfigIDByBuildingType(buildingType); // if(sanctuaryPackage.IsAbleToUnlockOrUpgrade(configID)) // hudBinder.AddHud(HudType.Exmind); // } if (info == null) { return; } BUILDING config = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); BuildingFunc func = sanctuaryPackage.GetBuildingFuncByConfigID(info.configID); if (mState == BuildingState.Collect) { // NDictionary args = new NDictionary(); // args.Add("id", config.ProId); // hudBinder.AddHud(HudType.Collect, args); } else if (mState == BuildingState.Upgrade) { NDictionary args = new NDictionary(); //NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(buildingID); args.Add("finishtime", info.upgradeFinishTime); hudBinder.AddHud(HudType.CountDown, args); } if (func == BuildingFunc.Collect) { NDictionary args = new NDictionary(); var configMap = ConfigDataStatic.GetConfigDataTable("BAR_TIME"); BAR_TIME barConfig = configMap[sanctuaryPackage.GetBulidingLevelByConfigID(info.configID)] as BAR_TIME; args.Add("interval", (float)barConfig.BarTime / 1000f); // float speed = (float)sanctuaryPackage.GetProSpeed(info.configID) / 3600; // args.Add("speed", speed); // args.Add("num", info.number); args.Add("building", this); hudBinder.AddHud(HudType.ProduceBar, args); } //collect hud if (mState == BuildingState.Idle) { if (info.number > 0) { SetCollect(true); mState = BuildingState.Collect; } if (func == BuildingFunc.Collect) { if (collectCo != null) { StopCoroutine(collectCo); } collectCo = StartCoroutine(CollectTimer()); } } }
void ShowCost(BUILDING configData) { sanctuaryPackage.CalculateBuildingCost(configData.Id); tableView.DataCount = sanctuaryPackage.GetBuildingCostList().Count; tableView.TableChange(); }
public void RefreshState() { NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(buildingID); long remainTime = 0; if (info == null) { mState = BuildingState.Locked; Building building = sanctuaryPackage.GetTypeBuilding(buildingType); if (building == null) { return; } //if under building's min visible level, hide the building if (!sanctuaryPackage.IsBuildingVisible(buildingType)) { building.gameObject.SetActive(false); } else { building.gameObject.SetActive(true); } } else { BuildingFunc func = sanctuaryPackage.GetBuildingFuncByConfigID(info.configID); info.building.gameObject.SetActive(true); if (info.upgradeFinishTime > 0 && GlobalFunction.GetRemainTime(info.upgradeFinishTime, out remainTime)) { mState = BuildingState.Upgrade; } else if (info.processUID != 0 && info.number > 0) { if (GlobalFunction.GetRemainTime(info.processFinishTime, out remainTime)) { mState = BuildingState.Craft; } else { mState = BuildingState.Collect; } } else { mState = BuildingState.Idle; } //store number and update number if (func == BuildingFunc.Collect) { proNumber = info.number; BUILDING config = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); //print(string.Format("Buidlin={0}, number={1}", config.BldgName, info.number)); sanctuaryPackage.GetProAttribute(info.configID, out proSpeed, out proCap); EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage; UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage; BUILDING buildingConfig = sanctuaryPackage.GetBuildingConfigDataByConfigID(info.configID); string buildingName = buildingConfig.BldgFuncTableName; buildingName = Char.ToUpper(buildingName[0]) + buildingName.Substring(1).ToLower(); var eventList = eventPackage.GetCurEventList(); foreach (var eventInfo in eventList) { WORLD_EVENTS eventConfig = eventPackage.GetEventConfigDataByConfigID(eventInfo.configID); if (eventConfig == null) { continue; } Type type = Type.GetType("com.nkm.framework.resource.data.WORLD_EVENTS"); PropertyInfo propertyInfo = type.GetProperty(buildingName + "Bldgcap"); PropertyInfo hasPropertyInfo = type.GetProperty("Has" + buildingName + "Bldgcap"); bool isHave = (bool)hasPropertyInfo.GetValue(eventConfig, null); if (isHave) { int effect = (int)propertyInfo.GetValue(eventConfig, null); if (effect != 0) { proSpeed *= (float)effect / 100f; } } } //add person num int personNum = userPackage.GetManorPersonNumber(); if (personNum == 2) { proSpeed *= 1.6f; } else if (personNum == 3) { proSpeed *= 2.2f; } else if (personNum == 4) { proSpeed *= 2.8f; } if (proTimer != null) { StopCoroutine(proTimer); } proTimer = StartCoroutine(ProduceTimer()); } } }