Beispiel #1
0
 public static void CheckValidPlacement(
     Building building, Position position, Vector3 location, bool invalidUnderFog)
 {
     if (!IsValidPlacement(building, position, location, invalidUnderFog))
     {
         throw new InvalidOperationException(building.obj + "'s building placement location is invalid");
     }
 }
Beispiel #2
0
        public static BuildingController InstantiateFinishedBuilding(
            Building building, GameObject finishedBuildingPrefab, Vector3 transformPosition, int loc, int factionIndex)
        {
            var obj    = Object.Instantiate(finishedBuildingPrefab, transformPosition, Quaternion.identity);
            var script = obj.GetComponent <BuildingController>();

            script.building = building;
            script.loc      = loc;
            ChangeBuildingFaction(script, factionIndex);
            return(script);
        }
Beispiel #3
0
        public static BuildingController InstantiateProgressBuilding(
            Building building, GameObject buildingPrefab, int factionIndex, Position position, Quaternion rotation)
        {
            // Placement validation is done redundantly twice, because this can be called directly too
            var location = PositionHelper.PositionToLocation(position);

            try
            {
                CheckValidPlacement(building, position, location, false);
            }
            catch (Exception)
            {
                // Visualizing the error placement
                building.ClosePoints(GameManager.Instance.Grid, position.PointLocation);
                throw;
            }
            building.ClosePoints(GameManager.Instance.Grid, position.PointLocation);
            return(InstantiateFinishedBuilding(
                       building, buildingPrefab, location, position.PointLocation, factionIndex));
        }
Beispiel #4
0
 public static bool IsValidPlacement(
     Building building, Position position, Vector3 location, bool invalidUnderFog)
 {
     return(building.CheckPoints(GameManager.Instance.Grid, position.PointLocation) &&
            (!invalidUnderFog || GameManager.Instance.Fog.CheckLocation(location)));
 }