Exemplo n.º 1
0
        /**
         * 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;
        }
Exemplo n.º 2
0
        /**
         * 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);
        }
Exemplo n.º 3
0
        /**
         *  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);
        }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
0
 /**
  * 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);
 }