public HousingOnSaleItem(HouseArea _area, int _slot, int _id, HouseSize _size, int _price, bool _status) { Area = _area; Slot = _slot + 1; Id = _id + 1; Size = _size; Price = _price; AddTime = DateTime.Now; ExistenceTime = DateTime.Now; CurrentStatus = _status; }
/// <summary> /// 通过数据包获取房屋信息 /// </summary> /// <param name="buffer">数据包Buffer</param> public HousingItem(HousingSlotSnapshot snapshot, int id, byte[] buffer) { Snapshot = snapshot; Id = id; /* * struct HouseInfoEntry * { * uint32_t housePrice; * uint8_t infoFlags; * Common::HousingAppeal houseAppeal[3]; * char estateOwnerName[32]; * } */ var nameHeader = buffer.SubArray(0, 8); Price = BitConverter.ToInt32(nameHeader, 0); Size = (Price > 30000000) ? HouseSize.L : ((Price > 10000000) ? HouseSize.M : HouseSize.S); //读取房屋信息 Flags = new HouseFlags(nameHeader[4]); //读取房屋展示信息 for (var i = 0; i < 3; i++) { Tags[i] = (HouseTagsDefine)nameHeader[5 + i]; } //读取房主姓名 Owner = DecodeOwnerName(buffer.SubArray(8, 32)); //获取所有者信息 if (Flags.IsEstateOwned) { if (Flags.IsFreeCompanyEstate) { OwnerType = HouseOwnerType.GUILD; } else { OwnerType = HouseOwnerType.PERSON; } } else { OwnerType = HouseOwnerType.EMPTY; } //获取访问权限 if (Flags.IsPublicEstate) { Access = HouseAccess.PUBLIC; } else { Access = HouseAccess.LOCKED; } }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + EnergyIntensityType.GetHashCode(); hash = hash * 23 + HouseholdList.GetHashCode(); hash = hash * 23 + HouseSize.GetHashCode(); hash = hash * 23 + MaximumHouseSize.GetHashCode(); return(hash * 23 + Number.GetHashCode()); } }
public static string GetHouseSizeStr(HouseSize size) { switch (size) { case HouseSize.S: return("S"); case HouseSize.M: return("M"); case HouseSize.L: return("L"); default: return("未知"); } }
void buildHouse(HouseSize size) { switch (size) { case HouseSize.Small: if (enoughResources(ResourceType.Wood, 50)) { setQuantity(ResourceType.Wood, -50); this.population++; this.houseQuantity++; } break; case HouseSize.Medium: Debug.Log("Entro a medium antes de comprobar"); if (enoughResources(ResourceType.Wood, 25) && enoughResources(ResourceType.Stone, 50)) { Debug.Log("Entro a medium después de comprobar"); setQuantity(ResourceType.Wood, -25); setQuantity(ResourceType.Stone, -50); this.population += 2; this.houseQuantity++; } break; case HouseSize.Large: if (enoughResources(ResourceType.Wood, 50) && enoughResources(ResourceType.Stone, 50) && enoughResources(ResourceType.Gold, 25)) { setQuantity(ResourceType.Wood, -50); setQuantity(ResourceType.Stone, -50); setQuantity(ResourceType.Gold, -25); this.population = this.population + 4; this.houseQuantity++; } break; default: break; } }