public void SetStats(string name) { Id = BuildingBase.Get (name).Id; Name = name; Description = BuildingBase.Get (name).Description; auraAWE = BuildingBase.Get (name).auraAWE; auraACH = BuildingBase.Get (name).auraACH; auraTHG = BuildingBase.Get (name).auraTHG; buildingType = BuildingBase.Get (name).buildingType; costPerSquare = BuildingBase.Get (name).costPerSquare; }
public static BuildingBase CreateBuilding(BuildingTypes building, GameServer server, Player player) { switch (building) { default: case BuildingTypes.Base: return CreateBuilding("base", server, player); break; case BuildingTypes.Supply: return CreateBuilding("supply", server, player); break; case BuildingTypes.GlueFactory: return CreateBuilding("gluefactory", server, player); break; } }
/// <summary> /// Gets the resources generated by a building location. Ignores the robber. /// </summary> public ResourceCollection GetResourcesForBuilding(HexPoint location, BuildingTypes type) { var result = new ResourceCollection(); foreach (var hex in location.GetHexes()) { if (_resourceTiles.ContainsKey(hex)) { var tile = _resourceTiles[hex]; int count = (type == BuildingTypes.Settlement) ? 1 : 2; result[tile.Resource] += count; } } return result; }
public void CreateBuilding(BuildingTypes type) { this._currentBlueprint = Prefabs.Instance.Constructions._blueprints.Find((BuildingBlueprint bp) => bp._type == type); if (this._currentBlueprint == null) { Debug.LogError("Building blueprint not found on Create script for " + type); } else { this.InitPlacer(this._currentBlueprint); if (!BoltNetwork.isRunning || !this._currentBlueprint._ghostPrefabMP) { this._currentGhost = UnityEngine.Object.Instantiate <GameObject>(this._currentBlueprint._ghostPrefab); } else { this._currentGhost = UnityEngine.Object.Instantiate <GameObject>(this._currentBlueprint._ghostPrefabMP); } this._currentGhost.transform.parent = this._buildingPlacer.transform; this._currentGhost.transform.localRotation = Quaternion.identity; Transform transform = this._currentGhost.transform.Find("Trigger"); Craft_Structure component = transform.GetComponent <Craft_Structure>(); if (component) { this.CraftStructures.Add(component); } transform.gameObject.SetActive(false); Renderer component2 = this._currentGhost.GetComponent <Renderer>(); if (component2) { component2.enabled = false; base.StartCoroutine(this.EnableRendererAfterDelay(component2)); } Transform transform2 = this._currentGhost.transform.Find("LastBuiltLocation"); if (transform2) { transform2.gameObject.SetActive(false); } this._currentGhost.transform.localPosition = this.GetGhostOffsetWithPlacer(this._currentGhost); this._buildingPlacer.TreeStructure = this._currentBlueprint._allowInTree; this._buildingPlacer.IgnoreLookAtCollision = this._currentBlueprint._ignoreLookAtCollision; this._buildingPlacer.IgnoreBlock = this._currentBlueprint._ignoreBlock; this._buildingPlacer.AllowFoundation = this._currentBlueprint._allowFoundation; this._buildingPlacer.Airborne = this._currentBlueprint._airBorne; IAnchorValidation component3 = this._currentGhost.GetComponent <IAnchorValidation>(); if (component3 != null) { this._buildingPlacer.ValidateAnchor = new Func <Transform, bool>(component3.ValidateAnchor); } this._buildingPlacer.ShowAnchorArea.SetActive(this._currentBlueprint._showAnchors); this._buildingPlacer.ShowSupportAnchorArea.SetActive(this._currentBlueprint._showSupportAnchor); if (this._currentBlueprint._waterborne) { this._buildingPlacer.SetWaterborne(this._currentBlueprint._waterborneExclusive); } if (this._currentBlueprint._hydrophobic) { this._buildingPlacer.SetHydrophobic(); } this.BeginCoolDown(); this.CreateMode = true; this.LockPlace = true; this.ShouldOpenBook = false; this.Inventory.EquipPreviousUtility(true); } }
/// <summary> /// Creates a Building of a given race and type from a prefab in a certain position and rotation /// </summary> /// <param name="race">Race of the Building</param> /// <param name="type">Type of the Building</param> /// <param name="position">Building position</param> /// <param name="rotation">Building rotation</param> /// <returns>The created GameObject</returns> public GameObject createBuilding(Races race, BuildingTypes type, Vector3 position, Quaternion rotation, BuildingVariant variant = BuildingVariant.REAL) { string prefab = getPrefab(race, type, (int)variant); return(UnityEngine.Object.Instantiate((GameObject)Resources.Load(prefab, typeof(GameObject)), position, rotation) as GameObject); }
/// <summary> /// function to trigger a sound when building is created /// </summary> /// <param name="bType"></param> public void onBuildingCreated(BuildingTypes bType) { _buildingsAudioPool.Play(Sounds.get.Clip(bType, Sounds.SoundType.CREATION)); }
public void DestroyBuilding(BuildingTypes type) { PlayerScore += BuildingValues[type]; SpecialCharge += BuildingValues[type] * .025f; }
public int GetBuildingGoldCost(BuildingTypes type) { return(BuildingCosts.Get()[(int)type]); }
public SettlementBuildings(Settlement settlement) { _settlement = settlement; _allBuildings = Globals.Instance.BuildingTypes; }
private GameObject GetBuildingPrefab(BuildingTypes type) { return(_buildingSettings.FirstOrDefault(b => b.Type == type).BuildingPrefab); }
/// <summary> /// Creates a new building /// </summary> public Building(int player, BuildingTypes type) { Player = player; Type = type; }
// Call terrain generator and cache useful info void Init() { var sw = System.Diagnostics.Stopwatch.StartNew(); var terrainGenerator = FindObjectOfType <TerrainGenerator> (); terrainData = terrainGenerator.Generate(); tileCentres = terrainData.tileCentres; walkable = terrainData.walkable; size = terrainData.size; int numSpecies = System.Enum.GetNames(typeof(Species)).Length; int numBuldings = System.Enum.GetNames(typeof(BuildingTypes)).Length; preyBySpecies = new Dictionary <Species, List <Species> > (); predatorsBySpecies = new Dictionary <Species, List <Species> > (); // Init maps speciesMaps = new Dictionary <Species, Map <LivingEntity> > (); buildingMaps = new Dictionary <BuildingTypes, Map <Building> >(); objectPools = new Dictionary <Species, GenericPool <LivingEntity> >(); for (int i = 0; i < numSpecies; i++) { Species species = (Species)(1 << i); speciesMaps.Add(species, new Map <LivingEntity> (size, mapRegionSize)); preyBySpecies.Add(species, new List <Species> ()); predatorsBySpecies.Add(species, new List <Species> ()); } for (int i = 0; i < numBuldings; ++i) { BuildingTypes buildingTypes = (BuildingTypes)(1 << i); buildingMaps.Add(buildingTypes, new Map <Building>(size, mapRegionSize)); } // Store predator/prey relationships for all species for (int i = 0; i < initialPopulations.Length; i++) { if (initialPopulations[i].prefab is Animal) { Animal hunter = (Animal)initialPopulations[i].prefab; Species diet = hunter.diet; for (int huntedSpeciesIndex = 0; huntedSpeciesIndex < numSpecies; huntedSpeciesIndex++) { int bit = ((int)diet >> huntedSpeciesIndex) & 1; // this bit of diet mask set (i.e. the hunter eats this species) if (bit == 1) { int huntedSpecies = 1 << huntedSpeciesIndex; preyBySpecies[hunter.species].Add((Species)huntedSpecies); predatorsBySpecies[(Species)huntedSpecies].Add(hunter.species); } } } } //LogPredatorPreyRelationships (); SpawnTrees(); walkableNeighboursMap = new Coord[size, size][]; // Find and store all walkable neighbours for each walkable tile on the map for (int y = 0; y < terrainData.size; y++) { for (int x = 0; x < terrainData.size; x++) { if (walkable[x, y]) { List <Coord> walkableNeighbours = new List <Coord> (); for (int offsetY = -1; offsetY <= 1; offsetY++) { for (int offsetX = -1; offsetX <= 1; offsetX++) { if (offsetX != 0 || offsetY != 0) { int neighbourX = x + offsetX; int neighbourY = y + offsetY; if (neighbourX >= 0 && neighbourX < size && neighbourY >= 0 && neighbourY < size) { if (walkable[neighbourX, neighbourY]) { walkableNeighbours.Add(new Coord(neighbourX, neighbourY)); } } } } } walkableNeighboursMap[x, y] = walkableNeighbours.ToArray(); } } } // Generate offsets within max view distance, sorted by distance ascending // Used to speed up per-tile search for closest water tile List <Coord> viewOffsets = new List <Coord> (); int viewRadius = Animal.maxViewDistance; int sqrViewRadius = viewRadius * viewRadius; for (int offsetY = -viewRadius; offsetY <= viewRadius; offsetY++) { for (int offsetX = -viewRadius; offsetX <= viewRadius; offsetX++) { int sqrOffsetDst = offsetX * offsetX + offsetY * offsetY; if ((offsetX != 0 || offsetY != 0) && sqrOffsetDst <= sqrViewRadius) { viewOffsets.Add(new Coord(offsetX, offsetY)); } } } viewOffsets.Sort((a, b) => (a.x * a.x + a.y * a.y).CompareTo(b.x * b.x + b.y * b.y)); Coord[] viewOffsetsArr = viewOffsets.ToArray(); // Find closest accessible water tile for each tile on the map: closestVisibleWaterMap = new Coord[size, size]; for (int y = 0; y < terrainData.size; y++) { for (int x = 0; x < terrainData.size; x++) { bool foundWater = false; if (walkable[x, y]) { for (int i = 0; i < viewOffsets.Count; i++) { int targetX = x + viewOffsetsArr[i].x; int targetY = y + viewOffsetsArr[i].y; if (targetX >= 0 && targetX < size && targetY >= 0 && targetY < size) { if (terrainData.shore[targetX, targetY]) { if (EnvironmentUtility.TileIsVisibile(x, y, targetX, targetY)) { closestVisibleWaterMap[x, y] = new Coord(targetX, targetY); foundWater = true; break; } } } } } if (!foundWater) { closestVisibleWaterMap[x, y] = Coord.invalid; } } } Debug.Log("Init time: " + sw.ElapsedMilliseconds); }
public Recipe(BuildingTypes type, ResourceTypes[] resources, int[] numberOfResources) { this.resources = resources; this.numberOfResources = numberOfResources; this.type = type; }
/// <summary> /// Returns a success result if this is a valid placement for a building. /// </summary> public ActionResult ValidateBuildingPlacement(int player, BuildingTypes buildingType, HexPoint point, bool startOfGame) { if (!IsPointInBoard(point)) { return new ActionResult(false, string.Format("The location {0} is out of bounds.", point)); } if (_buildings.ContainsKey(point)) { if (_buildings[point].Player != player) return new ActionResult(false, string.Format("The location {0} is already used by another player.", point)); // If this play has something here, make sure that it's not a city, which can't be upgraded. if (_buildings[point].Type == BuildingTypes.City) return new ActionResult(false, string.Format("The location {0} already contains a city.", point)); // If the existing building is a settlement, make sure the building being placed is not a settlement. if (buildingType == BuildingTypes.Settlement) return new ActionResult(false, string.Format("The location {0} already contains a settlement.", point)); } // Check that there isn't a neighboring building. var buildingNearby = point.GetNeighborPoints().Any(b => _buildings.ContainsKey(b)); if (buildingNearby) { return new ActionResult(false, string.Format("The location {0} is too close to another settlement or city.", point)); } if (!startOfGame) { // Make sure the player has a road nearby. bool roadNearby = point.GetNeighborEdges().Any(r => IsPlayerRoadHere(player, r)); if (!roadNearby) { return new ActionResult(false, string.Format("The location {0} is not touching a road.", point)); } } return ActionResult.CreateSuccess(); }
/// <summary> /// Translates type to structuretype /// </summary> /// <param name="type"></param> /// <returns></returns> public Vector3 getPositionForBuildingType(BuildingTypes type) { StructureType buildingType = StructureType.RESOURCE_BUILDING; buildingAngle = 0; switch (type) { case BuildingTypes.FARM: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.MINE: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.SAWMILL: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.ARCHERY: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.BARRACK: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.STABLE: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.ARTILLERY: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.WORKSHOP: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.ENT: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.GRYPHON: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.WALL: if (avaliablePositions[StructureType.HORIZONTALL_WALL].Count > 0) { buildingType = StructureType.HORIZONTALL_WALL; if (ai.race == Races.MEN) { buildingAngle = 0f; } } else { buildingType = StructureType.VERTICALL_WALL; buildingAngle = 90f; } break; case BuildingTypes.WALLCORNER: buildingType = StructureType.CORNER_WALL; break; case BuildingTypes.WATCHTOWER: buildingType = StructureType.TOWER; break; default: //In case that something new has entered return 0 return(Vector3.zero); } return(getPositionForStructureType(buildingType)); }
/// <summary> /// Places a building for the given player at the given location. /// If it's the start of the game, the building is free. /// Otherwise, resources will be removed from the player. /// </summary> public ActionResult PlayerPlaceBuilding(int playerId, BuildingTypes type, HexPoint location) { var validation = ValidatePlayerAction(PlayerTurnState.PlacingBuilding, playerId); if (validation.Failed) return validation; var pr = GetPlayerFromId(playerId); if (pr.Failed) return pr; var player = pr.Data; bool startOfGame = (_gameState == GameStates.InitialPlacement); // Make sure the player doesn't place too many buildings in the intial placement phase if (startOfGame) { if (type != BuildingTypes.Settlement) return ActionResult.CreateFailed("Can only place settlements during the initial placement phase."); var buildingCount = _gameBoard.GetBuildingCountForPlayer(playerId); var maxBuildingCount = (LastPlayerHasPlaced) ? 2 : 1; if (buildingCount >= maxBuildingCount) return ActionResult.CreateFailed("Cannot place any more settlements during the initial placement phase."); } var placementValidation = _gameBoard.ValidateBuildingPlacement(playerId, type, location, startOfGame); if (placementValidation.Failed) return placementValidation; PurchasableItems itemToBuy = (type == BuildingTypes.City) ? PurchasableItems.City : PurchasableItems.Settlement; var purchaseResult = player.Purchase(itemToBuy, startOfGame); if (purchaseResult.Failed) return purchaseResult; // We'll assume this succeeds because we already validated it. var placement = _gameBoard.PlaceBuilding(player.Id, type, location, startOfGame); System.Diagnostics.Debug.Assert(placement.Succeeded); // Update game and player states. if (_gameState == GameStates.InitialPlacement) { var buildingCount = _gameBoard.GetBuildingCountForPlayer(playerId); if (buildingCount == 2) { // We've played the second building during the setup phase. Collect resources. var resources = _gameBoard.GetResourcesForBuilding(location, BuildingTypes.Settlement); player.ResourceCards.Add(resources); } _playerTurnState = PlayerTurnState.PlacingRoad; } else if (_gameState == GameStates.GameInProgress) { _playerTurnState = PlayerTurnState.TakeAction; } return ActionResult.CreateSuccess(); }
/// <summary> /// This this method in order to maintain the base, when someone destroys our buildings /// </summary> /// <param name="obj"></param> public void onDestroy(System.Object obj) { GameObject gob = (GameObject)obj; Vector3 position = gob.transform.position; float yRot = gob.transform.rotation.eulerAngles.y; BuildingTypes type = gob.GetComponent <IGameEntity>().getType <BuildingTypes>(); //Add back the building to the queue in order to reconstruct it as soon as it is possible buildingPrefs.Add(type); constructionGrid.liberatePosition(constructionGrid.discretizeMapCoords(position)); //We need to inform the architect that new positions are avaliable StructureType buildingType = StructureType.RESOURCE_BUILDING; switch (type) { case BuildingTypes.FARM: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.MINE: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.SAWMILL: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.ARCHERY: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.BARRACK: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.STABLE: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.ARTILLERY: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.WORKSHOP: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.ENT: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.GRYPHON: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.WALL: if (Mathf.Round(yRot) == 90f) { buildingType = ai.race == Races.MEN ? StructureType.HORIZONTALL_WALL : StructureType.VERTICALL_WALL; } else { buildingType = ai.race == Races.MEN ? StructureType.VERTICALL_WALL : StructureType.HORIZONTALL_WALL; } break; case BuildingTypes.WALLCORNER: buildingType = StructureType.CORNER_WALL; break; case BuildingTypes.WATCHTOWER: buildingType = StructureType.TOWER; break; default: Debug.Log("AIArchitect: Unknown type maibe there are new buildings?"); break; } avaliablePositions[buildingType].Add(position); }
public void CreateBuilding(BuildingTypes btype, Vector3 position, Quaternion rotation, AIArchitect architect) { GameObject g = Info.get.createBuilding(_selfRace, btype, position, rotation); IGameEntity entity = g.GetComponent<IGameEntity>(); entity.registerFatalWounds(architect.onDestroy); OnBuildingCreated(entity); }
public IBuilding CreateBuilding(BuildingTypes buildingType) { return(new Building(buildingType)); }
public LXFMLBuildingConstruction(BuildingTypes pType) : base() { buildingType = pType; extrusionDepth = GetExtrusionByType(); }
public static BuildingGameObject CreateBuilding(Tile tile, PlayerIndex index, BuildingTypes type) { IBuildingGameObject bgo = null; if (type == BuildingTypes.TrainingZone) { bgo = new TrainingzoneFactory(); } else if (type == BuildingTypes.BarracksCavalry) { bgo = new BarracksCavalryFactory(); } else if (type == BuildingTypes.BarracksMelee) { bgo = new BarracksMeleeFactory(); } else if (type == BuildingTypes.BarracksRange) { bgo = new BarracksRangeFactory(); } else if (type == BuildingTypes.Castle) { bgo = new CastleFactory(); } GameObject obj = bgo.CreateBuilding(index); return(ConfigBuildingAndTile(tile, obj)); }
public abstract void Construct(BuildingTypes bt, Tile t, GameManager gm);
public static Vector3 FindNearestBuildSpot(BuildingTypes forBuildingTyope, Transform transform) { return(Vector3.zero); }
/// <summary> /// Creates a Building of a given race and type from a prefab /// </summary> /// <param name="race">Race of the Building</param> /// <param name="type">Type of the Building</param> /// <returns>The created GameObject</returns> public GameObject createBuilding(Races race, BuildingTypes type, BuildingVariant variant = BuildingVariant.REAL) { string prefab = getPrefab(race, type, (int)variant); return(UnityEngine.Object.Instantiate((GameObject)Resources.Load(prefab, typeof(GameObject)))); }
public void updateBuildings() { if (buildings.Count == 0) { return; } int numOfDrills = 0; int numOfRefineries = 0; int numOfBarracks = 0; maxNumberOfHumans = 0; foreach (BuildingTypes building in buildings) { if (building == BuildingTypes.drill) { numOfDrills++; } else if (building == BuildingTypes.researchFacility) { if (Random.Range(0f, 100f) < discoverAstroidChance) { discoverNewAstroid(); } } else if (building == BuildingTypes.house) { maxNumberOfHumans += 5; } else if (building == BuildingTypes.refinery) { numOfRefineries++; } else if (building == BuildingTypes.barrack) { numOfBarracks++; } } instability += 1f / (3f + numOfBarracks) * 2; if (instability >= 100) { BuildingTypes type = buildings[Random.Range(0, buildings.Count)]; for (int i = 0; i < transform.GetComponentsInChildren <BuildingHandler>().Length; i++) { BuildingHandler bh = transform.GetComponentsInChildren <BuildingHandler>()[i]; if (bh.type == type) { Destroy(bh.gameObject); break; } } buildings.Remove(type); instability = Mathf.Pow(1f / 2f, numOfBarracks + 1 - Mathf.Log(100) / Mathf.Log(2)); } if (numberOfHumans < maxNumberOfHumans / 5) { numberOfHumans = maxNumberOfHumans / 5; } localResources[(int)resource] += (int)((vainSize * Mathf.Pow(numOfDrills, 2f / 3f)) * Mathf.Max(numberOfHumans / 3, 1) * Mathf.Pow(3, numOfRefineries)); localResources[(int)ResourceTypes.rock] += (int)((Mathf.Pow(numOfDrills, 1f / 2f)) * Mathf.Max(numberOfHumans / 3, 1) * numOfRefineries / 2); if (humanTimer > timeBetweenHumans) { humanTimer -= timeBetweenHumans; numberOfHumans++; } //Resources.resources[(int)ResourceTypes.fuel] -= numberOfHumans/5; }
private IEnumerator PlaceGhostRoutine(bool chain) { BuildingTypes bType = this.CurrentBlueprint._type; yield return(null); if (this.CreateMode) { this.ShownPlace = false; this.CreateMode = false; if (!this.ToolsShown) { base.SendMessage("BuildToolsTut"); this.ToolsShown = true; } TreeStructure ts = this._currentGhost.GetComponentInChildren <TreeStructure>(); if (ts && this.TargetTree) { if (this.TargetTree.CompareTag("conTree")) { ts.TreeId = this.TargetTree.parent.GetComponent <TreeHealth>().LodTree.GetComponentInChildren <CoopTreeId>().Id; } else { ts.TreeId = this.TargetTree.GetComponent <TreeHealth>().LodTree.GetComponentInChildren <CoopTreeId>().Id; } ts.enabled = true; if (!BoltNetwork.isRunning) { Scene.ActiveMB.StartCoroutine(ts.OnDeserialized()); } } CoopConstructionEx coopEx = this._currentGhost.GetComponent <CoopConstructionEx>(); WallArchitect wallArch = this.CurrentGhost.GetComponent <WallArchitect>(); ICoopTokenConstruction tokenConstruction = this._currentGhost.GetComponent <ICoopTokenConstruction>(); this.ParentEntity = this.GetParentEntity(this._currentGhost); if (BoltNetwork.isRunning && !wallArch) { BoltEntity component = this._currentGhost.GetComponent <BoltEntity>(); if (tokenConstruction != null) { PlaceFoundationEx placeFoundationEx = PlaceFoundationEx.Create(GlobalTargets.OnlyServer); placeFoundationEx.Position = this._currentGhost.transform.position; placeFoundationEx.Rotation = this._currentGhost.transform.rotation; placeFoundationEx.Prefab = component.prefabId; placeFoundationEx.Token = tokenConstruction.CustomToken; placeFoundationEx.Parent = this.ParentEntity; placeFoundationEx.Send(); UnityEngine.Object.Destroy(this._currentGhost); } else if (coopEx) { coopEx.SendMessage("OnSerializing"); CoopConstructionExToken coopConstructionExToken = this.GetCoopConstructionExToken(coopEx, this.ParentEntity); PlaceFoundationEx placeFoundationEx2 = PlaceFoundationEx.Create(GlobalTargets.OnlyServer); placeFoundationEx2.Parent = this.ParentEntity; placeFoundationEx2.Position = this._currentGhost.transform.position; placeFoundationEx2.Rotation = this._currentGhost.transform.rotation; placeFoundationEx2.Prefab = component.prefabId; placeFoundationEx2.Token = coopConstructionExToken; placeFoundationEx2.Send(); UnityEngine.Object.Destroy(this._currentGhost); } else if (!this._currentGhost.GetComponent(typeof(IAnchorableStructure)) && component) { this._currentGhost.AddComponent <CoopDestroyPredictedGhost>(); this._currentGhost.AddComponent <destroyAfter>().destroyTime = 2f; PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer); placeConstruction.Parent = this.ParentEntity; placeConstruction.PrefabId = component.prefabId; placeConstruction.Position = this._currentGhost.transform.position; placeConstruction.Rotation = this._currentGhost.transform.rotation; if (ts) { placeConstruction.TreeIndex = ts.TreeId; } placeConstruction.Send(); this._currentGhost.SendMessage("OnPlacingRemotely", SendMessageOptions.DontRequireReceiver); } else { this._currentGhost.SendMessage("OnPlaced", false, SendMessageOptions.DontRequireReceiver); } } else { this._currentGhost.SendMessage("OnPlaced", false, SendMessageOptions.DontRequireReceiver); this._currentGhost.transform.Find("Trigger").gameObject.SetActive(true); Transform transform = this._currentGhost.transform.Find("LastBuiltLocation"); if (transform) { transform.gameObject.SetActive(true); } if (this.ParentEntity) { DynamicBuilding component2 = this.ParentEntity.GetComponent <DynamicBuilding>(); this._currentGhost.transform.parent = ((!component2 || !component2._parentOverride) ? this.ParentEntity.transform : component2._parentOverride); } } this.ClearReferences(!chain); LocalPlayer.Sfx.PlayPlaceGhost(); this.RefreshGrabber(); yield return(YieldPresets.WaitPointFiveSeconds); if (chain) { this.MultiPlaceAction(bType); } } yield break; }
public Building(int x, int y, BuildingTypes type) { this.x = x; this.y = y; this.type = type; }
/// <summary> /// Gets the number of buildings on the board for a player. /// </summary> public int GetBuildingCountForPlayer(int player, BuildingTypes type) { return _buildings.Count(c => c.Value.Player == player && c.Value.Type == type); }
public SerializableBuilding(BuildingTypes type, int x, int y) { Type = type; X = x; Y = y; }
/// <summary> /// Places a new building onto the board. A player is allowed to upgrade a settlement to a city. /// </summary> public ActionResult PlaceBuilding(int player, BuildingTypes buildingType, HexPoint point, bool startOfGame) { var validationResult = ValidateBuildingPlacement(player, buildingType, point, startOfGame); if (validationResult.Failed) return validationResult; _buildings[point] = new Building(player, buildingType); return ActionResult.CreateSuccess(); }
public Building() { Type = BuildingTypes.None; Values = new ValueGroup(); Upgrades = new List<Upgrade>(); }
public static Building SelectRandomBuilding(BuildingTypes btNeeded, int intDepth) { int intFail = 0; string[] strFrequencyList = { "very common", "common", "average", "rare", "very rare" }; int intFrequency = RandomHelper.RandomWeightedNumber(new int[] { 9, 8, 7, 6, 5 }); int intBuilding = 0; bool booValid; do { if (++intFail >= 100) { intFrequency = RandomHelper.RandomWeightedNumber(new int[] { 9, 8, 7, 6, 5 }); intFail = 0; } intBuilding = RandomHelper.Next(_AllBuildings.GetLength(0)); booValid = _AllBuildings[intBuilding].btThis == btNeeded; if (booValid) { if (btNeeded == BuildingTypes.MineshaftSection) { booValid = _AllBuildings[intBuilding].strFrequencyMineshaft[intDepth] == strFrequencyList[intFrequency]; } else { booValid = _AllBuildings[intBuilding].strFrequency == strFrequencyList[intFrequency]; } } } while (!booValid); return _AllBuildings[intBuilding]; }
/// <summary> /// Translates type to structuretype /// </summary> /// <param name="type"></param> /// <returns></returns> public Vector3 getPositionForBuildingType(BuildingTypes type) { StructureType buildingType = StructureType.RESOURCE_BUILDING; buildingAngle = 0; switch (type) { case BuildingTypes.FARM: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.MINE: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.SAWMILL: buildingType = StructureType.RESOURCE_BUILDING; break; case BuildingTypes.ARCHERY: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.BARRACK: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.STABLE: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.ARTILLERY: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.WORKSHOP: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.ENT: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.GRYPHON: buildingType = StructureType.MILITARY_BUILDING; break; case BuildingTypes.WALL: if (avaliablePositions[StructureType.HORIZONTALL_WALL].Count > 0) { buildingType = StructureType.HORIZONTALL_WALL; if (ai.race == Races.MEN) buildingAngle = 0f; } else { buildingType = StructureType.VERTICALL_WALL; buildingAngle = 90f; } break; case BuildingTypes.WALLCORNER: buildingType = StructureType.CORNER_WALL; break; case BuildingTypes.WATCHTOWER: buildingType = StructureType.TOWER; break; default: //In case that something new has entered return 0 return Vector3.zero; } return getPositionForStructureType(buildingType); }
public float GetBuildingMaxHealth(BuildingTypes type) { return(BuildingMaxHealths.Get()[(int)type]); }