Example #1
0
 public GoalConstructor(BuildingRender building, Db db, IBuildingService buildingService,
                        ProgressConstructor progressConstructor)
 {
     this.building            = building;
     this.db                  = db;
     this.buildingService     = buildingService;
     this.progressConstructor = progressConstructor;
 }
        /**
         * Load custom object from file into the map
         */
        IEnumerator LoadObjectFromDisk(string customObjectName, int storageType, Vector3 customObjectPos, float customObjectScale,
                                       float customObjectRotation, bool placeWithMouse)
        {
            //check if custom object exists
            if (!FileUtils.IsCustomObjectExist(customObjectName))
            {
                yield break;
            }

            while (!CanRenderCustomObject)
            {
                yield return(new WaitForSeconds(0.1f));
            }
            CanRenderCustomObject = false;

            WWW www = null;

            if (storageType == FileUtils.StorageLocal)
            {
                www = WWW.LoadFromCacheOrDownload(FileUtils.GetFullCustomObjectPath() + customObjectName, 1);
            }
            else if (storageType == FileUtils.StorageNetwork)
            {
                www = WWW.LoadFromCacheOrDownload("https://files.jigg.cz/" + customObjectName, 1);
            }
            yield return(www);

            var assetBundle        = www.assetBundle;
            var assetBundleRequest = assetBundle.LoadAssetAsync(customObjectName, typeof(GameObject));

            yield return(assetBundleRequest);

            BuildingPlacer.customObject = Instantiate(assetBundleRequest.asset) as GameObject;
            //cache transform parameter into variable
            var customObjectTransform = BuildingPlacer.customObject.transform;

            //set position
            customObjectTransform.position = customObjectPos;
            //set rotation
            if (customObjectRotation != RotationDefault)
            {
                customObjectTransform.eulerAngles = new Vector3(0, customObjectRotation, 0);
            }
            //set scale
            customObjectTransform.localScale = new Vector3(customObjectScale, customObjectScale, customObjectScale);
            BuildingRender.Get().ChangeBuildingSurfaceColor(BuildingPlacer.customObject, ColorUtils.DefaultBuilding);
            assetBundle.Unload(false);
            www.Dispose();
            if (!placeWithMouse)
            {
                BuildingPlacer.customObject = null;
            }
            CanRenderCustomObject = true;
        }
        /**
         * Remove building from the map
         */
        private void RemoveBuilding()
        {
            var buildings        = BuildingRender.Get().Buildings;
            var batchedBuildings = BuildingRender.Get().BatchedBuildings;
            var index            = buildings.FindIndex(threeDimObject => threeDimObject.Name.Equals(gameObject.name));

            Main.RemovedObjects.Add(buildings[index]);
            batchedBuildings.Remove(gameObject);
            Destroy(gameObject);
            MenuController.Get().ChangeAddressBarVisibility(false);
        }
        /**
         *  Pokud ukáže myš na objekt, změní objekt barvu
         */
        private void OnMouseEnter()
        {
            var buildingAddress = new AddressObject();

            foreach (var building in BuildingRender.Get().Buildings)
            {
                if (building.Name.Equals(gameObject.name))
                {
                    buildingAddress = building.Address;
                }
            }

            MenuController.Get().SetAddressBarText(buildingAddress);
            MenuController.Get().ChangeAddressBarVisibility(true);
            BuildingRender.Get().ChangeBuildingSurfaceColor(gameObject, ColorUtils.OnMouse);
        }
Example #5
0
 /**
  * Render 3D objects into the scene
  */
 IEnumerator RenderObjects(LatLngObject mapMiddlePoint, List <BuildingObject> buildings, List <RoadObject> roads, List <TreeObject> trees)
 {
     while (!CanRenderObjects)
     {
         yield return(new WaitForSeconds(0.1f));
     }
     //render terrain
     TerrainRender.Get().GenerateTerrain(mapMiddlePoint, transform);
     //render buildings
     BuildingRender.Get().Render(transform, buildings);
     //render roads
     RoadRender.Get().Render(mapMiddlePoint, transform, roads);
     //render trees
     TreeRender.Get().GenerateTrees(mapMiddlePoint, trees);
     //init address info game objects
     MenuController.Get().AddAddressGameObjects(AddressBackground, AddressText);
     CanRenderObjects = false;
 }
Example #6
0
 public BuildingArgs(BuildingRender building, Vector3 position)
 {
     Building = building;
     Position = position;
 }
 /**
  * Pokud myš zmizí z objekty, barva objektu se změní na původní
  */
 private void OnMouseExit()
 {
     MenuController.Get().ChangeAddressBarVisibility(false);
     BuildingRender.Get().ChangeBuildingSurfaceColor(gameObject, ColorUtils.DefaultBuilding);
 }