protected override Building InternalCreateBuilding() { Barracks barracks = new Barracks(context); barracks.CreatePlacebleModel(); return(barracks); }
public HQ() { ControlCenter = new MainBase(); Wall = new Wall(); Fields = new Fields(); Barracks = new Barracks(); }
public static Barracks GenerateBarracks(GenerationRandom genRan, Barracks barr, out BuildingVoxels vox, BuildingGenerationPlan plan) { vox = new BuildingVoxels(barr.Width, World.ChunkHeight, barr.Height); ChooseWallBounds(genRan, barr); BuildingGenerator.ConnectBoundingWall(vox, barr.BoundingWall, Voxel.stone); Tile[,] tileMap = new Tile[barr.Width, barr.Height]; BuildingGenerator.ChooseEntrancePoint(genRan, vox, barr, plan); BuildingGenerator.SetTiles(tileMap, 0, 0, barr.Width / 2, barr.Height - 1, Tile.STONE_FLOOR); BuildingGenerator.SetTiles(tileMap, barr.Width / 2, 0, barr.Width / 2 - 1, barr.Height - 1, Tile.DIRT); List <NPCJob> jobs = new List <NPCJob>(); for (int x = 2; x < barr.Height; x += 3) { Vector3 pos = new Vector3(barr.Width - 2, 0, x); float rotation = Vec2i.Angle(Vec2i.Forward, BuildingGenerator.GetWallPointDirection(barr, new Vec2i(barr.Width - 2, x))); TrainingDummy obj = new TrainingDummy().SetPosition(pos).SetRotation(rotation) as TrainingDummy; if (BuildingGenerator.AddObject(barr, vox, obj)) { jobs.Add(new NPCJobSoldier(barr)); } } WorkBuildingData wbd = new WorkBuildingData(jobs.ToArray()); barr.SetWorkBuildingData(wbd); barr.SetBuilding(tileMap); return(barr); }
public static float TotalBarracksPool(StaticInstance staticInstance) { float fKerbals = 0f; foreach (StaticInstance instance in StaticDatabase.GetAllStatics()) { //if ((string)obj.model.getSetting("DefaultFacilityType") == "None") continue; if (instance.FacilityType != "Barracks") { if (instance.model.DefaultFacilityType != "Barracks") { continue; } } var dist = Vector3.Distance(staticInstance.position, instance.position); if (dist > 5000f) { continue; } Barracks foundBarracks = instance.gameObject.GetComponent <Barracks>(); fKerbals = fKerbals + foundBarracks.StaffAvailable; } return(fKerbals); }
private void AssertWeapons(Barracks barracks, WeakReference weaponReference) { barracks.Weapon.Should().BeOfType <Sword>(); barracks.Warrior.Weapon.Should().BeOfType <Dagger>(); barracks.Weapon.Should().BeSameAs(weaponReference.Target); barracks.Weapon = null; }
public void Show(Barracks barracks) { this.barracks = barracks; barracksMenu.SetActive(true); gameObject.SetActive(true); transform.position = barracks.transform.position; //RefreshRangeVisual(); }
public static Unit Create(Vector3 position, Barracks barracks) { Transform unitTransform = Instantiate(GameAssets.instance.unit, position, Quaternion.identity, barracks.transform); Unit unitHandler = unitTransform.GetComponent <Unit>(); unitHandler.SetBarracks(barracks); unitHandler.SetBase(barracks.GetBase()); return(unitHandler); }
private static void ChooseWallBounds(GenerationRandom genRan, Barracks bar) { Vec2i[] wallPoints = new Vec2i[4]; wallPoints[0] = new Vec2i(0, 0); wallPoints[1] = new Vec2i(bar.Width / 2, 0); wallPoints[2] = new Vec2i(bar.Width / 2, bar.Height - 1); wallPoints[3] = new Vec2i(0, bar.Height - 1); bar.BoundingWall = wallPoints; }
public void ChangeBarracks(AllyController other) { barrack = other.barrack; ChangeTarget(other); if (other.barrack != null) { other.barrack.Occupy(this); } availability = false; }
private void Construct(Barracks objToConstruct, Vector3 position) { CharacterStats instance = Instantiate(objToConstruct).GetComponent <CharacterStats>(); instance.transform.position = position; instance.transform.rotation = constructionRotation; isBuilding = false; agent.isStopped = true; StartCoroutine(Build(instance)); }
public void SetBarrack(Barracks b) { if (barrack != null) { barrack.DesOccupy(); } b.Occupy(this); barrack = b; }
void HandleBarracksInput(Barracks barracks) { if (Input.GetKeyDown(Barracks.makeWarriorKey)) // TODO: || { barracks.CreateWarrior(); } else if (Input.GetKeyDown(Barracks.makeSoldierKey)) { barracks.CreateSoldier(); } }
public void SetConstruction(Barracks objToConstruct, Transform t) { AllyController a = GetComponent <AllyController>(); a.SetPrioirityPoint(t.position); constructPosition = t.position; constructionRotation = t.rotation; isBuilding = true; objAssignedToConstruct = objToConstruct; home = transform.position; }
public Barracks Build(string name) { Barracks bar = new Barracks(); bar.cost = new List <IResource>(); bar.cost.Add(new Ore(100)); bar.name = name; bar.isDestroyed = false; bar.level = 1; bar.numPeople = 2; return(bar); }
//called when drone is requested to be built public void QueueFinished(Barracks home, DroidType type) { switch (type) { case DroidType.Base: SpawnDroid(type, new Vector3(home.gameObject.GetComponent <Transform>().position.x + 8, 2, home.gameObject.GetComponent <Transform>().position.z)); break; default: Debug.Log("ERROR: DROID TYPE INVALID"); break; } }
void AddUnit() { Barracks script = barracks.GetComponent <Barracks>(); if (isMelee) { script.AddUnitMeleeCount(1); } else if (!isMelee) { script.AddUnitRangedCount(1); } print("unit added"); }
public void ShowBarracksInfoPanel(Barracks barracks) { if (!barracks) { barracksInfoPanel.SetActive(false); return; } barracksInfoPanel.SetActive(true); GameObject.FindGameObjectWithTag("SoldierSpawner").GetComponent <SoldierSpawner>().SetBarracks(barracks); powerPlantInfoPanel.SetActive(false); }
/// <summary> /// Creates a building object and returns that object. If specified type does not exists returns null. /// </summary> /// <param name="unitType"></param> /// <returns></returns> public UnitBase Create(UnitType unitType) { UnitBase unitBase = null; switch (unitType) { case UnitType.Barrack: unitBase = new Barracks(new UnitSpawnTileSelector()) { XDimension = 4, YDimension = 4, MoveableUnitPrototypes = { CreateMoveableUnit("soldier") } }; break; case UnitType.PowerPlant: unitBase = new PowerPlants() { XDimension = 2, YDimension = 3 }; break; case UnitType.Camp: unitBase = new Camp(new UnitSpawnTileSelector()) { XDimension = 3, YDimension = 2, MoveableUnitPrototypes = { CreateMoveableUnit("camper"), CreateMoveableUnit("soldier") } }; break; default: Debug.LogError("This type of product is not specified."); break; } return(unitBase); }
public static void Main(string[] args) { var barracks = new Barracks(); Archer archer; archer = barracks.ProduceArcher(); Console.WriteLine("new archer : {0}", archer.Characteristics()); barracks.Upgrade(); Console.WriteLine("Barracks upgraded to 17 century"); archer = barracks.ProduceArcher(); Console.WriteLine("new archer : {0}", archer.Characteristics()); /* * new archer : I am a 16th century archer * Barracks upgraded to 17 century * new archer : I am a 17th century archer */ }
void buildHandler(int button, int building) { switch(building) { case 0: buildings[button] = new Barracks(currentTurn, this); buttonDescriptions[button] = buildings[button].getBuildingInfo(); break; case 1: buildings[button] = new Factory(currentTurn, this); buttonDescriptions[button] = buildings[button].getBuildingInfo(); break; case 2: buildings[button] = new Hangar(currentTurn, this); buttonDescriptions[button] = buildings[button].getBuildingInfo(); break; } }
public void dragBuilding(int buildingID) { _buildingID = buildingID; if (_buildingID == 1) { _tempBuilding = new Farm(this, Vector2.Zero, BuildingAndUnit.faction.Human); } else if (_buildingID == 2) { _tempBuilding = new Barracks(this, Vector2.Zero, BuildingAndUnit.faction.Human); } else { _tempBuilding = null; } }
public void EnableMainUI(bool active, GameObject structure) { m_BarracksRef = structure.GetComponent <Barracks>(); UIManager.Instance.AddTimerToUI(m_BarracksRef.BarracksTimer.m_Timer, c_NameOfUIObjectInScene); UIManager.Instance.SetStructureStatsInfo(m_Data); if (active) { BindBarracksButtons(); } m_Image.SetActive(active); m_Info.SetActive(active); if (!active) { MenuButtons.Instance.UnBindMenuButtons(); } }
public override bool LevelUp() { bool canBeUpgraded = false; if (currentLevel >= maxLevel) { EventLog.Instance.AddAction(LogType.Error, objectName.ToString() + " is already max level: " + currentLevel + "/" + maxLevel, transform.position); return(canBeUpgraded); } else if (!Manager.Instance.HasEnoughMana(upgradeCost)) { EventLog.Instance.AddAction(LogType.Error, "You need " + upgradeCost + " " + Manager.Instance.CurrencyName + " to upgrade " + objectName, transform.position); return(canBeUpgraded); } else if (isUpgrading) { EventLog.Instance.AddAction(LogType.Error, Messages.AlreadyUpgradingBuilding, transform.position); return(canBeUpgraded); } else if (behaviour is Forge) { Forge forge = (Forge)behaviour; if (forge.IsDoingResearch) { EventLog.Instance.AddAction(LogType.Error, Messages.CantUpgradeWhileResearching, transform.position); return(canBeUpgraded); } } else if (behaviour is Barracks) { Barracks barracks = (Barracks)behaviour; if (barracks.Alreadytraining) { EventLog.Instance.AddAction(LogType.Error, Messages.CantUpgradingWhileTraining, transform.position); return(canBeUpgraded); } } canBeUpgraded = true; SpawnDustParticles(upgradeTime); StartCoroutine(DoUpgrade(upgradeTime)); return(canBeUpgraded); }
private void ExecuteBuildCommand(string[] commandArgs) { switch (commandArgs[1]) { case "barracks": var barracks = new Barracks(); // factory should do this this.database.AddBuilding(barracks); this.ExecuteTurnsPassed(barracks); break; case "archery": var archery = new Archery(); this.database.AddBuilding(archery); this.ExecuteTurnsPassed(archery); break; default: throw new InvalidOperationException("There is no such building."); } }
public Structure FactoryMethod(Structures structureType) { Structure structure = null; Barracks b = new Barracks(); PowerPlant p = new PowerPlant(); switch (structureType) { case Structures.Barracks: structure = b.createBarracks(); break; case Structures.PowerPlant: structure = p.createPowerplant(); break; default: return(null); } return(structure); }
void Start() { //Initialise health = healthMax; //Add appropriate building script switch (type) { case Type.Barracks: barracks = gameObject.AddComponent <Barracks>(); break; case Type.Granary: granary = gameObject.AddComponent <Granary>(); break; case Type.Workshop: workshop = gameObject.AddComponent <Workshop>(); break; } }
static void Main(string[] args) { Werewolf newPlayer = new Werewolf("Bozo"); Vampire otherPlayer = new Vampire(); Werewolf wolfie = new Werewolf("Wolfie"); Skeleton skelz = new Skeleton("Skelly"); wolfie.Attack(skelz, 5); skelz.Attack(wolfie, 500); Barracks homeBase = new Barracks(); homeBase.AddRecruit(newPlayer); homeBase.AddRecruit(otherPlayer); homeBase.AddRecruit(wolfie); homeBase.AddRecruit(skelz); skelz.Attack(homeBase, 3); homeBase.Rally(); }
public static Building CreateBuilding(GenerationRandom genRan, out BuildingVoxels vox, BuildingGenerationPlan plan) { Vec2i zero = new Vec2i(0, 0); int maxWidth = (plan.DesiredSize == null || plan.DesiredSize == zero) ?Mathf.Min(plan.BuildingPlan.MaxSize, plan.MaxWidth): plan.DesiredSize.x; int maxHeight = (plan.DesiredSize == null || plan.DesiredSize == zero)? Mathf.Min(plan.BuildingPlan.MaxSize, plan.MaxHeight) : plan.DesiredSize.z; int width = genRan.RandomInt(plan.BuildingPlan.MinSize, maxWidth); int height = genRan.RandomInt(plan.BuildingPlan.MinSize, maxHeight); if (plan.BuildingPlan == Building.BLACKSMITH) { Blacksmith smith = BlacksmithGenerator.GenerateBlacksmith(genRan, new Blacksmith(width, height), out vox, plan); return(smith); } if (plan.BuildingPlan == Building.BARACKS) { Barracks barr = BarracksGenerator.GenerateBarracks(genRan, new Barracks(width, height), out vox, plan); return(barr); } if (plan.BuildingPlan == Building.TAVERN) { return(TavernGenerator.GenerateTavern(genRan, new Tavern(width, height), out vox, plan)); } if (plan.BuildingPlan == Building.VEGFARM) { Farm farm = FarmGenerator.GenerateVegFarm(genRan, new Farm(width, height), out vox, plan); return(farm); } if (plan.BuildingPlan == Building.WHEATFARM) { Farm farm = FarmGenerator.GenerateWheatFarm(genRan, new Farm(width, height), out vox, plan); return(farm); } House house = HouseGenerator.GenerateHouse(genRan, new House(width, height), out vox, plan); return(house); //return GenerateHouse(out vox, width, height); }
public void OnTrainBarracks(int unitType) { if (SelectionManager.Instance.PrimarySelectable.type == EntityType.Barracks) { foreach (SelectableObject obj in SelectionManager.Instance.SelectedObjects) { if (obj.type == EntityType.Barracks) { switch (unitType) { case 1: Barracks temp = (Barracks)obj; temp.OnTrainRequest(); break; default: Debug.Log("ERROR UNIT TYPE MISSING"); break; } } } } }
public static void ProductionInterface(StaticInstance selectedFacility, string sFacilityType) { if (selectedFacility.myFacilities.Count == 0) { return; } Type facField; if (sFacilityType == "Research") { facField = typeof(Research); } else { facField = typeof(Business); } Barracks allFacs = selectedFacility.myFacilities[0] as Barracks; Research myResearch = selectedFacility.myFacilities[0] as Research; //if (sFacilityType == "Research") Business myBusiness = selectedFacility.myFacilities[0] as Business; DeadButton = new GUIStyle(GUI.skin.button); DeadButton.normal.background = null; DeadButton.hover.background = null; DeadButton.active.background = null; DeadButton.focused.background = null; DeadButton.normal.textColor = Color.white; DeadButton.hover.textColor = Color.white; DeadButton.active.textColor = Color.white; DeadButton.focused.textColor = Color.white; DeadButton.fontSize = 14; DeadButton.fontStyle = FontStyle.Bold; DeadButtonRed = new GUIStyle(GUI.skin.button); DeadButtonRed.normal.background = null; DeadButtonRed.hover.background = null; DeadButtonRed.active.background = null; DeadButtonRed.focused.background = null; DeadButtonRed.normal.textColor = Color.red; DeadButtonRed.hover.textColor = Color.yellow; DeadButtonRed.active.textColor = Color.red; DeadButtonRed.focused.textColor = Color.red; DeadButtonRed.fontSize = 12; DeadButtonRed.fontStyle = FontStyle.Bold; BoxNoBorder = new GUIStyle(GUI.skin.box); BoxNoBorder.normal.background = null; BoxNoBorder.normal.textColor = Color.white; Yellowtext = new GUIStyle(GUI.skin.box); Yellowtext.normal.textColor = Color.yellow; Yellowtext.normal.background = null; LabelInfo = new GUIStyle(GUI.skin.label); LabelInfo.normal.background = null; LabelInfo.normal.textColor = Color.white; LabelInfo.fontSize = 13; LabelInfo.fontStyle = FontStyle.Bold; LabelInfo.padding.left = 3; LabelInfo.padding.top = 0; LabelInfo.padding.bottom = 0; ButtonSmallText = new GUIStyle(GUI.skin.button); ButtonSmallText.fontSize = 12; ButtonSmallText.fontStyle = FontStyle.Normal; float fStaffing = 0; float fProductionRate = 0; float fLastCheck = 0; fStaffing = (float)facField.GetField("StaffCurrent").GetValue(selectedFacility.myFacilities[0]); fProductionRate = (float)facField.GetField("ProductionRateCurrent").GetValue(selectedFacility.myFacilities[0]) * (fStaffing / 2f); if (fProductionRate < 0.01f) { float fDefaultRate = 0.01f; if (sFacilityType == "Business") { fDefaultRate = 0.10f; } facField.GetField("ProductionRateCurrent").SetValue(selectedFacility.myFacilities[0], fDefaultRate); fProductionRate = fDefaultRate * (fStaffing / 2f); } fLastCheck = (float)facField.GetField("ProductionRateCurrent").GetValue(selectedFacility.myFacilities[0]); if (fLastCheck == 0) { fLastCheck = (float)Planetarium.GetUniversalTime(); facField.GetField("LastCheck").SetValue(selectedFacility.myFacilities[0], fLastCheck); } if (sFacilityType == "Research" || sFacilityType == "Business") { string sProduces = ""; float fMax = 0f; float fCurrent = 0f; if (sFacilityType == "Research") { sProduces = "Science"; fMax = myResearch.ScienceOMax; if (fMax < 1) { fMax = (float)selectedFacility.model.DefaultScienceOMax; if (fMax < 1) { fMax = 10f; } myResearch.ScienceOMax = fMax; } fCurrent = myResearch.ScienceOCurrent; } if (sFacilityType == "Business") { sProduces = "Funds"; fMax = myBusiness.FundsOMax; if (fMax < 1) { fMax = selectedFacility.model.DefaultFundsOMax; if (fMax < 1) { fMax = 10000f; } myBusiness.FundsOMax = fMax; } fCurrent = myBusiness.FundsOCurrent; } double dTime = Planetarium.GetUniversalTime(); // Deal with revert exploits if (fLastCheck > (float)dTime) { facField.GetField("LastCheck").SetValue(selectedFacility.myFacilities[0], (float)dTime); } if ((float)dTime - fLastCheck > 43200) { float fDays = (((float)dTime - fLastCheck) / 43200); float fProduced = fDays * fProductionRate; fCurrent = fCurrent + fProduced; if (fCurrent > fMax) { fCurrent = fMax; } if (sFacilityType == "Research") { myResearch.ScienceOCurrent = fCurrent; } if (sFacilityType == "Business") { myBusiness.FundsOCurrent = fCurrent; } facField.GetField("LastCheck").SetValue(selectedFacility.myFacilities[0], (float)dTime); } GUILayout.BeginHorizontal(); GUILayout.Label("Produces: " + sProduces, LabelInfo); GUILayout.FlexibleSpace(); GUILayout.Label("Current: " + fCurrent.ToString("#0") + " | Max: " + fMax.ToString("#0"), LabelInfo); GUILayout.EndHorizontal(); if (sFacilityType == "Research") { if (GUILayout.Button("Transfer Science to KSC R&D", ButtonSmallText, GUILayout.Height(20))) { ResearchAndDevelopment.Instance.AddScience(fCurrent, TransactionReasons.Cheating); myResearch.ScienceOCurrent = 0f; } } if (sFacilityType == "Business") { if (GUILayout.Button("Transfer Funds to KSC Account", ButtonSmallText, GUILayout.Height(20))) { Funding.Instance.AddFunds((double)fCurrent, TransactionReasons.Cheating); myBusiness.FundsOCurrent = 0f; } } GUILayout.Space(5); GUILayout.BeginHorizontal(); { GUILayout.Label("Production Rate: Up to " + fProductionRate.ToString("#0.00") + " per 12 hrs", LabelInfo); GUILayout.FlexibleSpace(); //if (GUILayout.Button(" Upgrade ", ButtonSmallText, GUILayout.Height(20))) //{ } } GUILayout.EndHorizontal(); GUILayout.Space(3); } }
internal static void CityProduction(City city) { if (city == null || city.Size == 0 || city.Tile == null) { return; } Player player = Game.GetPlayer(city.Owner); IProduction production = null; // Create 2 defensive units per city if (player.HasAdvance <LaborUnion>()) { if (city.Tile.Units.Count(x => x is MechInf) < 2) { production = new MechInf(); } } else if (player.HasAdvance <Conscription>()) { if (city.Tile.Units.Count(x => x is Riflemen) < 2) { production = new Riflemen(); } } else if (player.HasAdvance <Gunpowder>()) { if (city.Tile.Units.Count(x => x is Musketeers) < 2) { production = new Musketeers(); } } else if (player.HasAdvance <BronzeWorking>()) { if (city.Tile.Units.Count(x => x is Phalanx) < 2) { production = new Phalanx(); } } else { if (city.Tile.Units.Count(x => x is Militia) < 2) { production = new Militia(); } } // Create city improvements if (production == null) { if (!city.HasBuilding <Barracks>()) { production = new Barracks(); } else if (player.HasAdvance <Pottery>() && !city.HasBuilding <Granary>()) { production = new Granary(); } else if (player.HasAdvance <CeremonialBurial>() && !city.HasBuilding <Temple>()) { production = new Temple(); } else if (player.HasAdvance <Masonry>() && !city.HasBuilding <CityWalls>()) { production = new CityWalls(); } } // Create Settlers if (production == null) { if (city.Size > 3 && !city.Units.Any(x => x is Settlers) && player.Cities.Length < 10) { production = new Settlers(); } } // Create some other unit if (production == null) { if (city.Units.Length < 4) { if (player.Government is Republic || player.Government is Democratic) { if (player.HasAdvance <Writing>()) { production = new Diplomat(); } } else { if (player.HasAdvance <Automobile>()) { production = new Armor(); } else if (player.HasAdvance <Metallurgy>()) { production = new Cannon(); } else if (player.HasAdvance <Chivalry>()) { production = new Knights(); } else if (player.HasAdvance <TheWheel>()) { production = new Chariot(); } else if (player.HasAdvance <HorsebackRiding>()) { production = new Cavalry(); } else if (player.HasAdvance <IronWorking>()) { production = new Legion(); } } } else { if (player.HasAdvance <Trade>()) { production = new Caravan(); } } } // Set random production if (production == null) { IProduction[] items = city.AvailableProduction.ToArray(); production = items[Common.Random.Next(items.Length)]; } city.SetProduction(production); }
void MouseClickListener.OnMouseClick(MouseEvent me) { if (me.button == MouseEvent.MOUSE_BUTTON_1) { if (drawResourcesText || drawBarracksText || drawFactoryText || drawFortressText) { Building b; if (drawResourcesText) { b = new ResourceGather(this.p, this.c); } else if (drawBarracksText) { b = new Barracks(this.p, this.c); } else //if (drawFactoryText) { b = new Factory(this.p, this.c); } //else if (drawFortressText) //{ // b = new Fortress(this.p, this.c); //} foreach (Building build in p.buildings) { if (build.state == Building.BuildState.Preview) { build.Dispose(); break; } } p.buildings.AddLast(b); } foreach (Building b in p.buildings) { if (b.state == Building.BuildState.Preview && !this.DefineRectangle().Contains(new Rectangle(me.location.X, me.location.Y, 1, 1))) { foreach (Engineer e in p.getSelectedUnits()) { e.setWaypoint(me.location.X, me.location.Y); } b.state = Building.BuildState.Constructing; } } } }