// Use this for initialization void Start() { building = GetComponent <Building> (); mod = GetComponent <BuildingModifier> (); if (isServer) { monthManager = GameObject.Find("Clock").GetComponent <MonthManager> (); } }
void Start() { c = GetComponent <Collider> (); modManager = GetComponent <BuildingModifier> (); tenant = GetComponent <Tenant> (); color = c.gameObject.GetComponent <MeshRenderer> ().materials.ElementAt(0).color; type = TYPENUM; if (isServer) { lowestSkill = 0; buildingName = objectNum.ToString(); baseRent = 100; baseCondition = 100; baseSafety = 100; rent = baseRent; condition = baseCondition; safety = baseSafety; cost = rent * 12; //The price AI will ask for the initial sale and the price that repairs are based off of baseCost = cost; upkeep = rent / UPKEEP_PORTION; officeName = "None"; id = objectNum; fire = false; ruin = false; occupied = false; onAuction = false; paying = false; objectNum++; GameObject tmp = getLocalInstance(lot); if (tmp != null) { localLot = tmp.GetComponent <Lot> (); } else if (localLot != null) { lot = localLot.netId; // the lot was set in the inspector, assign the netid localLot.addObject(this.netId); } GameObject tmpRegion = getLocalInstance(region); if (tmpRegion != null) { localRegion = tmpRegion.GetComponent <Region> (); } else if (localRegion != null) { region = localRegion.netId; localRegion.AddItem(this.netId); } updateRent(); } typeName = buildingTypes [type]; }
/// <summary> /// Hits all buildings in the passed mod's radius with the effect. /// </summary> /// <param name="mod">Mod.</param> public void modBomb(Mod mod) { Collider[] colliding = Physics.OverlapSphere(building.c.transform.position, mod.radius); foreach (Collider hit in colliding) { BuildingModifier bm = hit.GetComponent <BuildingModifier> (); if (bm != null) { bm.mods.Add(mod); } } }
/// <summary> /// Removes the mod from all buildings within the mod's radius. /// </summary> /// <param name="mod">Mod.</param> public void removeModBomb(string modName) { float radius = 0; foreach (Mod mod in mods) { if (mod.modName == modName) { radius = mod.radius; break; } } Collider[] colliding = Physics.OverlapSphere(building.c.transform.position, radius); foreach (Collider hit in colliding) { BuildingModifier bm = hit.GetComponent <BuildingModifier> (); if (bm != null) { bm.removeMod(modName); } } removeMod(modName); }
/// <summary> /// Hits all buildings in the radius with a unique mod--will not duplicate /// </summary> /// <param name="mod">Mod.</param> public void modBombUnique(Mod mod) { Collider[] colliding = Physics.OverlapSphere(building.c.transform.position, mod.radius); foreach (Collider hit in colliding) { BuildingModifier bm = hit.GetComponent <BuildingModifier> (); if (bm != null) { bool duplicate = false; foreach (Mod currentMod in bm.mods) { if (mod.modName == currentMod.modName) { duplicate = true; break; } } if (!duplicate) { bm.mods.Add(mod); } } } }
/// <summary> /// Applies effects the tenant triggers on the building /// (bad modifiers, fires, etc) /// </summary> public virtual void applyResidentialEffects() { float damChance = 0; //float criminalChance = 0; bool fireRisk = false; if (residenceBuilding == null) { return; } BuildingModifier mod = residenceBuilding.modManager; months++; if (!leaveResidence()) // do the following only if the tenant is not going to leave the building this turn { foreach (int t in traits) { if (t == 12 || t == 15) //smoker { fireRisk = true; } damChance += residentTraits.ElementAt(t).damageChance; //criminalChance += residentTraits.ElementAt (t).crimeChance; } if (Random.value < damChance) { if (fireRisk) { residenceBuilding.setFire(); residenceBuilding.RpcMessageOwner(residentName + " has accidentally set " + residenceBuilding.buildingName + " on fire!"); } else { int malus = (int)Random.Range(0, 6); switch (malus) { case 0: mod.addMalusUnique("Clogged toilet", .9f, 1, 1, 200, 8); residenceBuilding.RpcMessageOwner(residentName + " has clogged the toilet of " + residenceBuilding.buildingName + "!"); break; case 1: mod.addMalusUnique("Hole in wall", .9f, 1, .8f, 300, 4); residenceBuilding.RpcMessageOwner(residentName + " has punched a hole in the wall of " + residenceBuilding.buildingName + "!"); break; case 2: mod.addMalusUnique("Broken window", .8f, 1, .8f, 400, 42); residenceBuilding.RpcMessageOwner(residentName + " has accidentally broken a window at " + residenceBuilding.buildingName + "!"); break; case 3: mod.addMalusUnique("Cockroach infestation", 1, .8f, 1, 200, 1); residenceBuilding.RpcMessageOwner("Roaches have infested " + residenceBuilding.buildingName + "!"); break; case 4: mod.addMalusUnique("Bedbugs", 1, .8f, 1, 200, 1); residenceBuilding.RpcMessageOwner("Bedbugs have infested " + residenceBuilding.buildingName + "!"); break; case 5: mod.addMalusUnique("Rats", 1, .8f, 1, 300, 1); residenceBuilding.RpcMessageOwner("Rats have infested " + residenceBuilding.buildingName + "!"); break; default: mod.addMalusUnique("Clogged toilet", .9f, 1, 1, 100, 8); residenceBuilding.RpcMessageOwner(residentName + " has clogged the toilet of " + residenceBuilding.buildingName + "!"); break; } } } if ((jobBuilding != null) && !jobBuilding.occupied) { residenceBuilding.RpcMessageOwner(residentName + " has lost their job at " + jobBuilding.buildingName + "."); leaveJob(); } } else { residenceBuilding.tenant.evict(); } }