private void SetScriptFields(TerrainData_Full data, TerrainObject script) { script.cubeUniqueID = data.cubeUniqueID; script.gridLocX = data.gridLocX; script.gridLocZ = data.gridLocZ; script.gridLocY = data.gridLocY; script.cubeLandType = data.cubeLandType; script.cubeList = data.cubeList; script.cubeType = data.cubeType; script.cubeRot = data.cubeRot; script.cubeSlopeType = data.cubeSlopeType; script.objReplaceable = data.objReplaceable; script.objDestructable = data.objDestructable; script.objList = data.objList; script.objType = data.objType; script.objRot = data.objRot; script.health = data.health; script.Growth = data.Growth; script.surfaceTop = data.surfaceTop; script.surfaceBottom = data.surfaceBottom; script.cubeSetActive = data.cubeSetActive; script.inSight = data.inSight; script.neighVects = data.neighVects; script._01 = data._01; script._03 = data._03; script._04 = data._04; script._05 = data._05; script._07 = data._07; script._09 = data._09; script._10 = data._10; script._11 = data._11; script._12 = data._12; script._14 = data._14; script._15 = data._15; script._16 = data._16; script._17 = data._17; script._19 = data._19; script._21 = data._21; script._22 = data._22; script._23 = data._23; script._25 = data._25; script.sunRiseVect = _SunManager.sunRiseVect; script.sunMidVect = _SunManager.sunMidVect; script.sunSetVect = _SunManager.sunSetVect; script.terrainData = data; }
private void AddContainerComponents(GameObject GodNode, TerrainData_Full data) { TerrainObject newTerrainScript = GodNode.AddComponent <TerrainObject>(); SetScriptFields(data, newTerrainScript); foreach (SelectObject script in selectObjects) { script.terrainscript = newTerrainScript; } newTerrainScript.ConnectObjectLinks(); BoxCollider boxColl = GodNode.AddComponent <BoxCollider> (); boxColl.isTrigger = true; Vector3 collPos = new Vector3(0, 0.5f, 0); boxColl.center = collPos; }
public GameObject BuildMeAFuckingCube(TerrainData_Full data) { int landType = 0; //script.cubeLandType; int objList = data.cubeList; int objType = data.cubeType; // GodNode --> Container --> LowPoly --> Static --> StaticContainer01 --> SimpleCube // --> Growers --> GrowerContainer01 --> // --> GrowerContainer02 --> // --> HighPoly --> Static --> StaticContainer01 --> Cube // --> Growers --> GrowerContainer01 --> Cover // --> GrowerContainer02 --> Grass // --> SelectContainer --> CubeSelect //GameObject GodNode = Instantiate (emptyNode, transform, false); GameObject Container = Instantiate(emptyNode, transform, false); Container.name = ("Container"); GameObject CubeSelect = Instantiate(Cube_Select[0], Container.transform, false); // cube Select Object CubeSelect.name = ("CubeSelect"); selectObjects.Add(CubeSelect.GetComponent <SelectObject>()); // Low Polys GameObject LowPoly = Instantiate(emptyNode, Container.transform, false); LowPoly.name = ("LowPoly"); AttachLowPolys(LowPoly, landType, objList, objType); // High Polys GameObject HighPoly = Instantiate(emptyNode, Container.transform, false); HighPoly.name = ("HighPoly"); AttachHighPolys(HighPoly, landType, objList, objType); AddContainerComponents(Container, data); selectObjects.Clear(); return(Container); }
public List <TerrainData_Full> BuildFullData(List <Vector3> list) { List <Vector3> SurfaceDataSimpleList = list; int dataUniqueID = 0; // assign a new Full data object to each simple data object foreach (Vector3 dataLoc in SurfaceDataSimpleList) { TerrainData_Full fullData = ScriptableObject.CreateInstance <TerrainData_Full> (); fullData.cubeUniqueID = dataUniqueID += 1; fullData.gridLocX = (int)dataLoc.x; fullData.gridLocZ = (int)dataLoc.y; fullData.gridLocY = (int)dataLoc.z; Vector3 gridLocToPlace = new Vector3(fullData.gridLocX, fullData.gridLocZ, fullData.gridLocY);; //fullData.cubeLandType = data.landType; // Have to work this out fullData.cubeList = 0; // defaults, just squares fullData.cubeType = 0; // defaults, just squares fullData.surfaceTop = true; RemoveDataFromWorld(gridLocToPlace); _GridManager.GridLocToGridObjLookup.Add(gridLocToPlace, fullData); SurfaceDataFullList.Add(fullData); } _CubeSocial.GetCubeNeighbours(SurfaceDataFullList); _CubeSocial.GetCubeConnections(SurfaceDataFullList); CalculateCubeSlopes(); return(SurfaceDataFullList); }
//////////////////////////////////////// // Making Inner Slope corners private bool CalculateInnerCorners(TerrainData_Full data) { bool replaceCube = false; // flat side facing ---SOUTH WEST if (data._10 == true && data._12 == true && data._22 == false && data._09 == false && data._19 == false && data._21 == false) { data.cubeList = RESLIST_CORNER_INNER_U; data.cubeSlopeType = 0; data.cubeType = -1; data.cubeRot = 3; replaceCube = true; } else if (data._10 == true && data._12 == true && data._04 == false && data._09 == false) { data.cubeList = RESLIST_CORNER_INNER_D; data.cubeSlopeType = 1; data.cubeType = -1; data.cubeRot = 3; replaceCube = true; } // flat side facing ---NORTH WEST else if (data._12 == true && data._16 == true && data._22 == false && data._15 == false && data._21 == false && data._25 == false) { data.cubeList = RESLIST_CORNER_INNER_U; data.cubeSlopeType = 2; data.cubeType = -1; data.cubeRot = 0; replaceCube = true; } else if (data._12 == true && data._16 == true && data._04 == false && data._15 == false) { data.cubeList = RESLIST_CORNER_INNER_D; data.cubeSlopeType = 3; data.cubeType = -1; data.cubeRot = 0; replaceCube = true; } // flat side facing ---NORTH EAST else if (data._14 == true && data._16 == true && data._22 == false && data._17 == false && data._23 == false && data._25 == false) { data.cubeList = RESLIST_CORNER_INNER_U; data.cubeSlopeType = 4; data.cubeType = -1; data.cubeRot = 1; replaceCube = true; } else if (data._14 == true && data._16 == true && data._04 == false && data._17 == false) { data.cubeList = RESLIST_CORNER_INNER_D; data.cubeSlopeType = 5; data.cubeType = -1; data.cubeRot = 1; replaceCube = true; } // flat side facing ---SOUTH EAST else if (data._10 == true && data._14 == true && data._22 == false && data._11 == false && data._19 == false && data._23 == false) { data.cubeList = RESLIST_CORNER_INNER_U; data.cubeSlopeType = 6; data.cubeType = -1; data.cubeRot = 2; replaceCube = true; } else if (data._10 == true && data._14 == true && data._04 == false && data._11 == false) { data.cubeList = RESLIST_CORNER_INNER_D; data.cubeSlopeType = 7; data.cubeType = -1; data.cubeRot = 2; replaceCube = true; } return(replaceCube); }
/////////////////////////////////////////////////// // Making All Slopes private bool CalculateOutterSlopes(TerrainData_Full data) { bool replaceCube = false; // flat side facing // ---SOUTH and DOWN if (data._10 == true && data._16 == false && data._22 == false && data._25 == false) // if cube has front(south) but no back(north) { data.cubeList = RESLIST_SLOPES_U; data.cubeSlopeType = 16; data.cubeType = 0; data.cubeRot = 0; if (data._14 == false && data._19 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 1; data.cubeSlopeType = 17; } if (data._12 == false && data._19 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 3; data.cubeSlopeType = 18; } replaceCube = true; } // --SOUTH and UP else if (data._10 == true && data._16 == false && data._04 == false && data._07 == false) // if cube has top, no bottm, no diag front bottom { data.cubeList = RESLIST_SLOPES_D; data.cubeSlopeType = 19; data.cubeType = 1; data.cubeRot = 0; if (data._14 == false && data._19 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 1; data.cubeSlopeType = 20; } replaceCube = true; } // flat side facing // ---WEST and DOWN else if (data._12 == true && data._14 == false && data._22 == false && data._23 == false) // if cube has front(west) but no back(east) { data.cubeList = RESLIST_SLOPES_U; data.cubeSlopeType = 21; data.cubeType = 0; data.cubeRot = 1; if (data._10 == false && data._21 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 2; data.cubeSlopeType = 22; } replaceCube = true; } // --WEST and UP else if (data._12 == true && data._14 == false && data._04 == false && data._05 == false) // if cube has top, no bottm, no diag front bottom { data.cubeList = RESLIST_SLOPES_D; data.cubeSlopeType = 23; data.cubeType = 1; data.cubeRot = 1; if (data._10 == false && data._21 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 2; data.cubeSlopeType = 24; } replaceCube = true; } // flat side facing //---NORTH and DOWN else if (data._16 == true && data._10 == false && data._22 == false && data._19 == false) // if cube has front(north) but no back(soth) { data.cubeList = RESLIST_SLOPES_U; data.cubeSlopeType = 25; data.cubeType = 0; data.cubeRot = 2; if (data._12 == false && data._25 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 3; data.cubeSlopeType = 26; } replaceCube = true; } // --NORTH and UP else if (data._16 == true && data._10 == false && data._04 == false && data._01 == false) // if cube has top, no bottm, no diag front bottom { data.cubeList = RESLIST_SLOPES_D; data.cubeSlopeType = 27; data.cubeType = 1; data.cubeRot = 2; if (data._12 == false && data._25 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 3; data.cubeSlopeType = 28; } replaceCube = true; } // flat side facing ---EAST // ---EAST and DOWN else if (data._14 == true && data._12 == false && data._22 == false && data._21 == false) // if cube has front(east) but no back(west) { data.cubeList = RESLIST_SLOPES_U; data.cubeSlopeType = 29; data.cubeType = 0; data.cubeRot = 3; if (data._10 == false && data._23 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 0; data.cubeSlopeType = 30; } replaceCube = true; } // --EAST and UP else if (data._14 == true && data._12 == false && data._04 == false && data._03 == false) // if cube has top, no bottm, no diag front bottom { data.cubeList = RESLIST_SLOPES_D; data.cubeSlopeType = 31; data.cubeType = 1; data.cubeRot = 3; if (data._10 == false && data._23 == false) // weird edge case, slopes on ends of rows { data.cubeRot = 0; data.cubeSlopeType = 32; } replaceCube = true; } return(replaceCube); }