本文整理汇总了C#中Building类的典型用法代码示例。如果您正苦于以下问题:C# Building类的具体用法?C# Building怎么用?C# Building使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Building类属于命名空间,在下文中一共展示了Building类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateBuildings
public static void UpdateBuildings(ushort[] newBuildingIDS, Building[] newBuildings)
{
for (int i = 0; i < newBuildingIDS.Length; i++)
{
CreateBuilding(newBuildingIDS[i], newBuildings[i]);
}
}
示例2: UI_Init
/**
* Initialise the building view.
*/
override public void UI_Init(Building building) {
base.UI_Init(building);
// Position animators
if (building.Type is BuildingDataWithUnitAnimations)
{
allocatedSpots = new Dictionary<OccupantData, int>();
// Position animators
for (int i = 0 ; i < animators.Count; i++) {
animators[i].gameObject.SetActive(false);
if (((BuildingDataWithUnitAnimations)building.Type).animationPositions.Count > i) {
animators[i].gameObject.transform.localPosition = new Vector3(((BuildingDataWithUnitAnimations)building.Type).animationPositions[i].x,
((BuildingDataWithUnitAnimations)building.Type).animationPositions[i].y, 0.0f);
}
animators[i].gameObject.SetActive(false);
animators[i].Hide();
}
// Position static sprites
for (int i = 0 ; i < staticUnits.Count; i++) {
if (((BuildingDataWithUnitAnimations)building.Type).staticPositions.Count > i) {
staticUnits[i].gameObject.transform.localPosition = new Vector3(((BuildingDataWithUnitAnimations)building.Type).staticPositions[i].x,
((BuildingDataWithUnitAnimations)building.Type).staticPositions[i].y, 0.0f);
}
staticUnits[i].gameObject.SetActive(false);
}
}
UpdateOccupants();
}
示例3: CancelBuildingPlacement
public void CancelBuildingPlacement()
{
findingPlacement = false;
Destroy(tempBuilding.gameObject);
tempBuilding = null;
tempCreator = null;
}
示例4: CalculateOwnVehicles
protected void CalculateOwnVehicles(ushort buildingID, ref Building data, TransferManager.TransferReason material, ref int count, ref int cargo, ref int capacity, ref int outside)
{
VehicleManager instance = Singleton<VehicleManager>.instance;
ushort num = data.m_ownVehicles;
int num2 = 0;
while (num != 0)
{
if ((TransferManager.TransferReason)instance.m_vehicles.m_buffer [(int)num].m_transferType == material)
{
VehicleInfo info = instance.m_vehicles.m_buffer [(int)num].Info;
int a;
int num3;
info.m_vehicleAI.GetSize (num, ref instance.m_vehicles.m_buffer [(int)num], out a, out num3);
cargo += Mathf.Min (a, num3);
capacity += num3;
count++;
if ((instance.m_vehicles.m_buffer [(int)num].m_flags & (Vehicle.Flags.Importing | Vehicle.Flags.Exporting)) != Vehicle.Flags.None)
{
outside++;
}
}
num = instance.m_vehicles.m_buffer [(int)num].m_nextOwnVehicle;
if (++num2 > 16384)
{
CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
}
示例5: getLazyEmplo
private Employee getLazyEmplo(Building build)
{
Employee emplo = build.Employees.getLazyEmploye();
if (emplo.Share == true) return null;
else return emplo;
}
示例6: CheckBuilding
private bool CheckBuilding( Building b )
{
// Only check for power traders
var p = b.TryGetComp<CompPowerTrader>();
if( p == null )
return false;
// That are connected to a power network
if( p.PowerNet == null )
return false;
// Which aren't powered on
if( p.PowerOn == true )
return false;
// Which want to be powered on
if( p.DesirePowerOn == false )
return false;
/*
// Batteries on network, don't worry about it for now
if( p.PowerNet.CurrentStoredEnergy() >= 1 )
return false;
// Where the network power is too low
var netEnergy = p.PowerNet.CurrentEnergyGainRate() / CompPower.WattsToWattDaysPerTick;
if( netEnergy > -p.EnergyOutputPerTick )
return false;
*/
// And return this building is under powered
return true;
}
示例7: LateUpdate
//Late update so units can move before checking building position
private void LateUpdate()
{
if (_selectedBuilding == null || _buildingPreview == null)
return;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 200, LayerMask.GetMask("Ground")))
{
_buildingPreview.transform.position = hit.point;
if (hit.point != _lastPosition)
{
_lastPosition = hit.point;
_canBuild = _selectedBuilding.isBuildPositionValid;
if (_canBuild)
_selectedBuilding.SetModelColor(Color.green);
else
_selectedBuilding.SetModelColor(Color.red);
}
if (Input.GetMouseButtonUp(0) && _canBuild)
{
//Take resources
//Send signal to other player(s)
_selectedBuilding.Place();
_selectedBuilding = null;
_buildingPreview = null;
}
}
}
示例8: BuildingIsFinished
public bool BuildingIsFinished(Building building)
{
var value = building.PercentComplete >= 100;
//&& !building.IsCompleted; // TODO: Remove if not needed
return value;
}
示例9: AddBuilding
public void AddBuilding(Building building)
{
if (!buildings.Contains (building))
{
buildings.Add (building);
}
}
示例10: FillSprite
public float FillSprite(Building build)
{
//Debug.Log("Oryginal: " + (float)(build.InConstruction.Oryginalspan.TotalSeconds));
//Debug.Log("Sub: " + build.InConstruction.getTotalSecondSub());
//Debug.Log("TIME: " + (float)(build.InConstruction.getTotalSecondSub() / build.InConstruction.Oryginalspan.TotalSeconds));
return (float)(build.InConstruction.getTotalSecondSub() / build.InConstruction.Oryginalspan.TotalSeconds);
}
示例11: Place
//Place a building on specific location
public void Place(Building building, int x, int y, int rotation, int lastCollection)
{
Vector3 newPosition = building.transform.localPosition;
newPosition.x = x*squareSize.x + building.size.x/2;
newPosition.z = y*squareSize.y + building.size.y/2;
building.transform.localPosition = newPosition;
building.setConflict(!isFree ());
building.setCoordinates (x, y);
building.rotation = rotation;
building.lastCollection = lastCollection;
buildingManager.addBuilding (building);
//rotate
//print ("The rotation is " + rotation.ToString());
for (int i=0; i<rotation; i++) {
building.rotate();
}
//mark ground taken
for (int i = 0; i < building.size.x/squareSize.x; i++) {
for (int j = 0; j < building.size.y/squareSize.y; j++) {
grid[x+i,y+j] = true;
highlightGrid[x+i, y+j].renderer.material = redMat;
}
}
HashSet<int> unlocks = building.getUnlockSet ();
foreach (BuildingButton b in buttons) {
if (unlocks.Contains(b.prefab.buildingType)) {
b.prefab.locked = false;
}
}
}
示例12: GetCitizenIncome
public void GetCitizenIncome(CitizenUnit.Flags flags, Building buildingData, ref int income, ref int tourists)
{
int level = 0;
UnlockManager um = Singleton<UnlockManager>.instance;
if (!um.Unlocked(ItemClass.SubService.PublicTransportMetro))
{
level += 1;
if (!um.Unlocked(ItemClass.Service.PublicTransport))
{
level += 1;
if (!um.Unlocked(ItemClass.Service.HealthCare))
{
level += 1;
}
}
}
CitizenManager instance = Singleton<CitizenManager>.instance;
uint num = buildingData.m_citizenUnits;
int num2 = 0;
while (num != 0u)
{
if ((ushort)(instance.m_units.m_buffer[(int)((UIntPtr)num)].m_flags & flags) != 0)
{
GetCitizenIncome(instance.m_units.m_buffer[(int)((UIntPtr)num)], level, ref income, ref tourists);
}
num = instance.m_units.m_buffer[(int)((UIntPtr)num)].m_nextUnit;
if (++num2 > 524288)
{
CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
}
示例13: RenderInstance
public static void RenderInstance(ref Building b, RenderManager.CameraInfo cameraInfo, ushort buildingID,
int layerMask)
{
if ((b.m_flags & (Building.Flags.Created | Building.Flags.Deleted | Building.Flags.Hidden)) != Building.Flags.Created)
return;
BuildingInfo info = b.Info;
//begin mod
if (info == null)
{
return;
}
var ai = info.m_buildingAI;
if ((layerMask & 1 << info.m_prefabDataLayer) == 0 && !(ai is PlayerBuildingAI || ai is DecorationBuildingAI/* || ai is DummyBuildingAI*/)) //TODO(earalov): do we need to uncomment that?
//end mod
return;
Vector3 point = b.m_position;
float radius = info.m_renderSize + (float)b.m_baseHeight * 0.5f;
point.y += (float)(((double)info.m_size.y - (double)b.m_baseHeight) * 0.5);
if (!cameraInfo.Intersect(point, radius))
return;
RenderManager instance = Singleton<RenderManager>.instance;
uint instanceIndex;
if (!instance.RequireInstance((uint)buildingID, 1U, out instanceIndex))
return;
RenderInstance(ref b, cameraInfo, buildingID, layerMask, info, ref instance.m_instances[(uint)instanceIndex]);
}
示例14: Serialize
public static void Serialize(string filename, Configuration config)
{
var xmlSerializer = new XmlSerializer(typeof(Configuration));
try
{
using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(filename))
{
var configCopy = new Configuration();
foreach (var building in config.buildings)
{
var newBuilding = new Building(building.name);
foreach (var variation in building.variations.Where(variation => !building.isBuiltIn || !variation.isBuiltIn))
{
newBuilding.variations.Add(variation);
}
if (!building.isBuiltIn || newBuilding.variations.Count > 0)
{
configCopy.buildings.Add(newBuilding);
}
}
xmlSerializer.Serialize(streamWriter, configCopy);
}
}
catch (Exception e)
{
Debug.Log("Couldn't create configuration file at \"" + Directory.GetCurrentDirectory() + "\"");
throw e;
}
}
示例15: drawOutlines
private void drawOutlines(Building<int> result)
{
if (result == null) return;
int c = result.Data.Count;
for (int i = 0; i < c - 2; i = i + 2)
{
if (i == 0)
{
System.Windows.Point p1 = new System.Windows.Point(result[i], 0);
System.Windows.Point p2 = new System.Windows.Point(result[i], result[i + 1]);
System.Windows.Point p3 = new System.Windows.Point(result[i + 2], result[i + 1]);
drawingLine(p1, p2, Colors.Red, true);
drawingLine(p2, p3, Colors.Red, true);
}
else
{
System.Windows.Point p1 = new System.Windows.Point(result[i], result[i - 1]);
System.Windows.Point p2 = new System.Windows.Point(result[i], result[i + 1]);
System.Windows.Point p3 = new System.Windows.Point(result[i + 2], result[i + 1]);
drawingLine(p1, p2, Colors.Red, true);
drawingLine(p2, p3, Colors.Red, true);
}
}
if (c > 0)
{
System.Windows.Point p1 = new System.Windows.Point(result[c - 2], result[c - 3]);
System.Windows.Point p2 = new System.Windows.Point(result[c - 2], 0);
drawingLine(p1, p2, Colors.Red, true);
}
}