Example #1
0
        public GameObject SpawnNewScenery(SceneryTypeEnum sceneryTypeEnum)
        {
            appStateManager.SetAnchorAndContainerIfNull();
            GameObject sceneryObject = null;

            switch (sceneryTypeEnum)
            {
            case SceneryTypeEnum.Tree_TypeOne:
                sceneryObject = Instantiate(generalConfiguration.sceneryItemTreeTypeOnePrefab) as GameObject;
                break;

            case SceneryTypeEnum.Tree_TypeTwo:
                sceneryObject = Instantiate(generalConfiguration.sceneryItemTreeTypeTwoPrefab) as GameObject;
                break;

            default:
                sceneryObject = Instantiate(generalConfiguration.sceneryItemTreeTypeOnePrefab) as GameObject;
                break;
            }

            sceneryObject.AddComponent <Scenery>().sceneryTypeEnum = sceneryTypeEnum;
            sceneryObject.transform.parent = appStateManager.currentSceneryContainer.transform;

            return(sceneryObject);
        }
    private void AddSceneryToContainer(SceneryTypeEnum sceneryTypeEnum)
    {
        GameObject sceneryObject = sceneryUtil.SpawnNewScenery(sceneryTypeEnum);

        sceneryObject.transform.position = appStateManager.placementCursorPose.position;
        sceneryObject.transform.rotation = appStateManager.placementCursorPose.rotation;

        appStateManager.currentOutputMessage = $"Added Scenery.   Move scenery by tapping directly on it, to select it.   Alternatively, press 'Save' to store the current scenery, or 'Restore' to load a previous save..";
    }
 public void PlaceScenery()
 {
     if (appStateManager.currentCloudAnchorState == CloudAnchorStateEnum.NothingHappening)
     {
         // randomly select one of the scenery enums we have available
         SceneryTypeEnum randomSceneryTypeEnum = (SceneryTypeEnum)UnityEngine.Random.Range(0, Enum.GetValues(typeof(SceneryTypeEnum)).Length);
         AddSceneryToContainer(randomSceneryTypeEnum);
     }
 }
        public void ReadParameters(string filename)
        {
            FileName      = filename;
            sceneryFolder = filename.Substring(0, filename.Length - Utility.GetFileNamePart(filename).Length - 4);
            XPathDocument  doc = new XPathDocument(filename);
            XPathNavigator nav = doc.CreateNavigator();

            // Read in the parameters
            this.sceneryType          = ReadSceneryType(nav, "//definition//type", SceneryTypeEnum.Full3D);
            this.DefinitionFile       = ReadString(nav, "//definition//definition", null);
            this.HeightMapFile        = ReadString(nav, "//definition//heightmap", null);
            this.DefaultStartPosition = ReadVector(nav, "//definition//defaultstartposition", new Vector3(0, 0, 0));
            this.WaterStartPosition   = ReadVector(nav, "//definition//waterstartposition", new Vector3(0, 0, 0));
            this.MinimumHeight        = (float)ReadDouble(nav, "//definition//minimumheight", 0.0);
            this.MaximumHeight        = (float)ReadDouble(nav, "//definition//maximumheight", 0.0);
            switch (sceneryType)
            {
            case SceneryTypeEnum.Full3D:
                this.SplatHighFile = nav.SelectSingleNode("//definition//splathigh").Value;
                this.SplatLowFile  = nav.SelectSingleNode("//definition//splatlow").Value;
                this.NormalMapFile = nav.SelectSingleNode("//definition//normalmap").Value;
                this.Texture1File  = nav.SelectSingleNode("//definition//texture1").Value;
                this.Texture2File  = nav.SelectSingleNode("//definition//texture2").Value;
                this.Texture3File  = nav.SelectSingleNode("//definition//texture3").Value;
                this.Texture4File  = nav.SelectSingleNode("//definition//texture4").Value;
                break;

            case SceneryTypeEnum.Photofield:
                this.LeftPhoto           = ReadString(nav, "//definition//left", null);
                this.LeftDepthMap        = ReadString(nav, "//definition//leftdepthmap", null);
                this.RightPhoto          = ReadString(nav, "//definition//right", null);
                this.RightDepthMap       = ReadString(nav, "//definition//rightdepthmap", null);
                this.FrontPhoto          = ReadString(nav, "//definition//front", null);
                this.FrontDepthMap       = ReadString(nav, "//definition//frontdepthmap", null);
                this.BackPhoto           = ReadString(nav, "//definition//back", null);
                this.BackDepthMap        = ReadString(nav, "//definition//backdepthmap", null);
                this.TopPhoto            = ReadString(nav, "//definition//top", null);
                this.TopDepthMap         = ReadString(nav, "//definition//topdepthmap", null);
                this.BottomPhoto         = ReadString(nav, "//definition//bottom", null);
                this.BottomDepthMap      = ReadString(nav, "//definition//bottomdepthmap", null);
                this.HeightMapSize       = ReadInt(nav, "//definition//heightmapsize", 1000);
                this.HeightMapResolution = ReadInt(nav, "//definition//heightmapresolution", 100);
                break;
            }
        }
 private SceneryTypeEnum ReadSceneryType(XPathNavigator nav, string tag, SceneryTypeEnum defaultValue)
 {
     try
     {
         XPathNavigator node = nav.SelectSingleNode(tag);
         if (node.Value.ToLower().Equals("photo"))
         {
             return(SceneryTypeEnum.Photofield);
         }
         else
         {
             return(SceneryTypeEnum.Full3D);
         }
     }
     catch
     {
         return(defaultValue);
     }
 }