/// <summary> /// Will find which tile is like NE corner /// </summary> static public CreatePlane CreatePlanSmartTile(Building spawner, string root, string materialRoot, Vector3 origen = new Vector3(), string name = "", Transform container = null, float raiseFromFloor = 0.09f, Material mat = null, Vector3 scale = new Vector3(), bool isAnInvisiblePlane = false, bool isLoadingFromFile = false) { //root = "Prefab/Mats/SmartTile/Road3D/In"; WAKEUP = true; CreatePlane obj = null; obj = (CreatePlane)Resources.Load(root, typeof(CreatePlane)); obj = (CreatePlane)Instantiate(obj, origen, Quaternion.identity); obj.HType = spawner.HType; obj.transform.name = obj.MyId = obj.Rename(obj.transform.name, obj.Id, obj.HType, name); obj.Scale = scale; //if (mat == null) //{ // obj.Material = (Material)Resources.Load(materialRoot); //} //else obj.Material = mat; obj.RaisedFromFloor = raiseFromFloor; obj.IsAnInVisiblePlane = isAnInvisiblePlane; if (container != null) { obj.transform.SetParent(container); } obj.SpawnerId = spawner.MyId; obj.IsLoadingFromFile = isLoadingFromFile; obj.IsSmartTile = true; return(obj); }
/// <summary> /// Creates the planes of a bridge, The first and last one /// </summary> Trail CreateBridgePlanes(Trail current, RegFile regFile) { if (regFile.DominantSide == H.Vertic) { current.PlanesListVertic.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(regFile.MaterialKey), regFile.TilePosVert[0], scale: regFile.TileScale, container: current.transform)); current.PlanesListVertic.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(regFile.MaterialKey), regFile.TilePosVert[regFile.TilePosVert.Count - 1], scale: regFile.TileScale, container: current.transform)); } else if (regFile.DominantSide == H.Horiz) { current.PlanesListHor.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(regFile.MaterialKey), regFile.TilePosHor[0], scale: regFile.TileScale, container: current.transform)); current.PlanesListHor.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(regFile.MaterialKey), regFile.TilePosHor[regFile.TilePosHor.Count - 1], scale: regFile.TileScale, container: current.transform)); } return(current); }
public void StartExample() { createPlane = GetPlane; CargoPlane plane = createPlane(); // Ковариативность info = ShowInfo; info(plane); // Ковариативность Builder <Client> clientBuilder = GetClient; Builder <Person> personBuilder1 = clientBuilder; // ковариантность Builder <Person> personBuilder2 = GetClient; // ковариантность Person p = personBuilder1("Tomson"); // вызов делегата p.Display(); GetInfo <Person> personInfo = PersonInfo; GetInfo <Client> clientInfo = personInfo; // контравариантность Client client = new Client { Name = "Tomson" }; clientInfo(client); // Client: Tomson }
/// <summary> /// This create or destroy the create plane that the user can see where the new Way is gonna /// be created /// </summary> public void CreateOrKillCursor() { KillCursor(); Control.BuildWayCursor = (BigBoxPrev)CreatePlane.CreatePlan(Root.bigBoxPrev, Root.matGreenSel2); Control.BuildWayCursor.transform.name = "Cursor for:" + Control.CurrentSpawnBuild.MyId; }
/// <summary> /// Called from Update if createSoilNow = true /// Creates all the planes for the farm. Based on initial position and scale /// </summary> /// <param name="pos">The list of initial positions for each tile</param> /// <param name="containerP">The container will hold all tiles. Usually is this.transform</param> void CreatePlanesRoutine(List <Vector3> pos, Transform containerP) { if (loopCounter < pos.Count) { CreatePlane temp = null; if (HType == H.Road) { temp = CreatePlane.CreatePlanSmartTile(this, Root.createPlane, Root.RetMaterialRoot(MaterialKey), pos[loopCounter], scale: Program.gameScene.ScaleSmallRoadUnitFarm, container: containerP); } else { temp = CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(MaterialKey), pos[loopCounter], scale: Program.gameScene.ScaleSmallRoadUnitFarm, container: containerP, hType: HType); } _planesSoil.Add(temp); loopCounter++; } else { createSoilNow = false; AfterLoopRoutine(); } }
//this cretes planes vertically and horizontally List <CreatePlane> CreatePlanesVertAndHor(RegFile regFile, H which, Transform containerP, Trail trail) { List <CreatePlane> res = new List <CreatePlane>(); if (which == H.Vertic) { for (int i = 0; i < regFile.TilePosVert.Count; i++) { res.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(regFile.MaterialKey), regFile.TilePosVert[i], scale: regFile.TileScale, container: containerP)); //to Refine //Trail.AddToCrystals(H.PlanesVertic, i, regFile.TilePosVert[i], regFile.TilePosVert.Count, // regFile.TilePosHor.Count, trail); } } else if (which == H.Horiz) { for (int i = 0; i < regFile.TilePosHor.Count; i++) { res.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(regFile.MaterialKey), regFile.TilePosHor[i], scale: regFile.TileScale, container: containerP)); //to Refine //Trail.AddToCrystals(H.PlanesHor, i, regFile.TilePosHor[i], regFile.TilePosVert.Count, // regFile.TilePosHor.Count, trail); } } return(res); }
static public CreatePlane CreatePlan(string root, string materialRoot, Vector3 origen = new Vector3(), string name = "", Transform container = null, H hType = H.None, float raiseFromFloor = 0.09f, Material mat = null, Vector3 scale = new Vector3(), bool isAnInvisiblePlane = false) { WAKEUP = true; CreatePlane obj = null; obj = (CreatePlane)Resources.Load(root, typeof(CreatePlane)); obj = (CreatePlane)Instantiate(obj, origen, Quaternion.identity); obj.HType = hType; obj.transform.name = obj.MyId = obj.Rename(obj.transform.name, obj.Id, obj.HType, name); obj.Scale = scale; if (mat == null) { obj.Material = (Material)Resources.Load(materialRoot); } else { obj.Material = mat; } obj.RaisedFromFloor = raiseFromFloor; obj.IsAnInVisiblePlane = isAnInvisiblePlane; if (container != null) { obj.transform.SetParent(container); } return(obj); }
private void CreateBasePlane() { var dimen = _fieldFarm.SpaceBtwPlants - 0.5f; var locPoly = UPoly.CreatePolyFromVector3(transform.position, dimen, dimen); var basePlane = CreatePlane.CreatePlan(Root.createPlane, Root.matFarmSoil, raiseFromFloor: 0.08f, container: transform); basePlane.UpdatePos(locPoly); }
/// <summary> /// Defines the sub division block scale value this has to be executed after Mesh is submeshed /// </summary> public void DefineSubDivideBlockScaleForFarm() { CreatePlane cP = new CreatePlane(); //the rectify are added so it looks seamles on terrain the farm _subDivideBlockScale.x = m.SubDivide.XSubStep + cP.RectifyOnX * 2; _subDivideBlockScale.y = _subDivideBlockYVal - 0.01f;//so it doesnt overlap ways like trail _subDivideBlockScale.z = Mathf.Abs(m.SubDivide.ZSubStep) + cP.RectifyOnZ * 2; }
/// <summary> /// Creates the trail. /// </summary> private void BuildWay(string rootPlane, bool makeWayInvisible = false) { Material baseMat = Resources.Load <Material>(Root.RetMaterialRoot(MaterialKey)); if (CurrentLoop == H.PlanesVertic) { if (_counter < _planesDimVertic.Count && _prevWayVertic.Count > 0) { PlanesListVertic.Add(CreatePlane.CreatePlan(rootPlane, Root.matGravilla, m.HitMouseOnTerrain.point, container: transform, mat: baseMat)); //if is the last one or 1st I will show it even if is set to be not seen like I do in bridges if (_counter == _planesDimVertic.Count - 1 || _counter == 0) { makeWayInvisible = false; } PlanesListVertic[_counter].UpdatePos(_planesDimVertic[_counter], makeThisInvisible: makeWayInvisible); //to Refine //AddToCrystals(CurrentLoop, _counter, // PlanesListVertic[_counter].transform.position, _planesDimVertic.Count, _planesDimHor.Count, this); _counter++; } else { _counter = 0; _currentLoop = H.PlanesHor; } } else if (CurrentLoop == H.PlanesHor) { if (_counter < _planesDimHor.Count && _prevWayHor.Count > 0) { PlanesListHor.Add((CreatePlane.CreatePlan(rootPlane, Root.matGravilla, m.HitMouseOnTerrain.point, container: transform, mat: baseMat))); //if is the last one I will show it even if is set to be not seen like I do in bridges if (_counter == _planesDimHor.Count - 1 || _counter == 0) { makeWayInvisible = false; } PlanesListHor[_counter].UpdatePos(_planesDimHor[_counter], makeThisInvisible: makeWayInvisible); //to Refine //AddToCrystals(CurrentLoop, _counter, // PlanesListHor[_counter].transform.position, _planesDimVertic.Count, _planesDimHor.Count, this); _counter++; } else { DoneWithLoop(); } } }
void InitializeBigBoxPrev() { if (verticBigBox == null || horizBigBox == null) { verticBigBox = (BigBoxPrev)CreatePlane.CreatePlan(Root.bigBoxPrev, Root.matGreenSel2); verticBigBox.transform.name = "verticBigBox:" + MyId; horizBigBox = (BigBoxPrev)CreatePlane.CreatePlan(Root.bigBoxPrev, Root.matGreenSel2); horizBigBox.transform.name = "horizBigBox:" + MyId; } }
public override void OnInspectorGUI() { CreatePlane terrainGen = (CreatePlane)target; if (DrawDefaultInspector()) { } if (GUILayout.Button("generate")) { terrainGen.Generate(); } }
void Start() { Cube = gameObject; AboutCreatPlane = GameObject.Find("Manager").GetComponent <CreatePlane>(); _whiteGame = GameObject.Find("whitePoint"); _blackGame = GameObject.Find("blackPoint"); _blackGame0 = GameObject.Find("blackPoint_0"); _blackGame1 = GameObject.Find("blackPoint_1"); _whiteGame0 = GameObject.Find("whitePoint_0"); _whiteGame1 = GameObject.Find("whitePoint_1"); _systemManager = GameObject.Find("SystemManager").GetComponent <SystemManager>(); CreateSub = 1; _systemManager.BeginRecordTime(); }
// Use this for initialization private void Start() { base.Start(); //if is not position fixed alredy we create the preview //when is Position Fixed already here mean that was loaded from file if (!PositionFixed) { farmPrev = (BigBoxPrev)CreatePlane.CreatePlan(Root.bigBoxPrev, Root.matGreenSel2); farmPrev.transform.name = "Farm Preview: " + MyId; } if (HType == H.Road) { maxSizeOfFarm = 500; } }
void Start() { _animator = gameObject.GetComponent <Animator>(); _hover = GetChildCalled("Hover"); _hover.gameObject.SetActive(false); var poly = U2D.FromRectToPoly(Region); buildingPrev = (BigBoxPrev)CreatePlane.CreatePlan(Root.bigBoxPrev, Root.dashedLinedSquare, container: transform); buildingPrev.UpdatePos(poly, .25f); buildingPrev.transform.position = U2D.FromV2ToV3(Region.center); //MeshController.CrystalManager1.CrystalRegions[Index].StartWithAudioReport(); Name = "Buy region"; HType = H.BuyRegion; transform.position += new Vector3(0, 10000, 0); }
Mesh MeshFromImage(Texture2D texture) { // Mesh mesh = CreatePlane.CreateMesh(new Vector2Int(texture.width, texture.height), new Vector2(texture.width, texture.height), CreatePlane.Orientation.Vertical, true); Mesh mesh = CreatePlane.CreateGameObject(Vector3.zero, new Vector2Int(texture.width, texture.height), new Vector2(texture.width, texture.height), CreatePlane.Orientation.Vertical, true).GetComponent <MeshFilter>().sharedMesh; mesh.colors = new Color[mesh.vertexCount]; Color[] colors = texture.GetPixels(); int vertexIndex = 0; for (int x = 0; x < texture.width; x++) { for (int y = 0; y < texture.height; y++) { mesh.colors[vertexIndex] = colors[y * texture.width + x]; vertexIndex++; } } return(mesh); }
/// <summary> /// Creates the plane of pos lineanly /// </summary> List <CreatePlane> CreatePlanes(List <Vector3> pos, Transform containerP, Vector3 scaleP, string materialKey, Building spawner) { List <CreatePlane> res = new List <CreatePlane>(); for (int i = 0; i < pos.Count; i++) { if (spawner.HType == H.Road) { res.Add(CreatePlane.CreatePlanSmartTile(spawner, Root.createPlane, Root.RetMaterialRoot(materialKey), pos[i], scale: scaleP, container: containerP, isLoadingFromFile: true)); } else { res.Add(CreatePlane.CreatePlan(Root.createPlane, Root.RetMaterialRoot(materialKey), pos[i], scale: scaleP, container: containerP)); } } return(res); }
public static Cell Create(Point p, TilerMap tilerMap) { var cellName = GetName(p); var go = new GameObject(cellName); go.isStatic = true; var tr = go.transform; tr.parent = tilerMap.transform; var position = new Vector3 { x = p.X * tilerMap.CellSize + tilerMap.TileSize / 2f, y = 0, z = p.Y * tilerMap.CellSize + tilerMap.TileSize / 2f }; tr.localPosition = position; var mf = go.AddComponent <MeshFilter>(); if (tilerMap.SharedMesh == null) { tilerMap.SharedMesh = CreatePlane.Create("_MESH", tilerMap.CellSize, tilerMap.CellSize); } mf.sharedMesh = tilerMap.SharedMesh; var mr = go.AddComponent <MeshRenderer>(); var bc = go.AddComponent <BoxCollider>(); bc.size = new Vector3(tilerMap.CellSize, 0, tilerMap.CellSize); var t = new Texture2D(tilerMap.TextureResolution, tilerMap.TextureResolution, TextureFormat.ARGB32, true); var texName = cellName + "_TEX"; t.name = texName; t.wrapMode = TextureWrapMode.Clamp; var c = Util.InitilizeArray(tilerMap.TextureResolution, new Color32(205, 205, 205, 0)); t.SetPixels32(c); t.Apply(); var shader = Shader.Find(tilerMap.DefaultShader); var m = new Material(shader); var matName = cellName + "_MAT"; m.name = matName; m.mainTexture = t; m.renderQueue -= tilerMap.Layer; mr.sharedMaterial = m; var cell = go.AddComponent <Cell>(); cell.Setup(tilerMap.TilesPerCell); return(cell); }
/// <summary> /// Creates a Plane for the base of the Strcuture /// </summary> void CreateBasePlane() { var locPoly = UPoly.ScalePoly(Anchors, 0.04f); basePlane = CreatePlane.CreatePlan(Root.createPlane, ReturnMatBase(), raiseFromFloor: 0.08f, container: transform); }
void Start() { CreatePlane = GetComponent <CreatePlane>(); }
public static Cell Create(Vector2 index, MapManager map) { var name = "(" + index.x + "," + index.y + ")"; var go = new GameObject(name); var mf = go.AddComponent <MeshFilter>(); mf.mesh = CreatePlane.Create(name, map.SizeOfCell, map.SizeOfCell, map.NumberOfTiles, map.NumberOfTiles); go.AddComponent <MeshRenderer>(); go.AddComponent <MeshCollider>(); var cell = go.AddComponent <Cell>(); cell.GenerateTiles(map.NumberOfTiles); go.transform.parent = map.transform; // cellPosition is the position in the world of the cell var cellPosition = index; cellPosition *= map.SizeOfCell; cellPosition.x -= map.HalfTileSize; cellPosition.y -= map.HalfTileSize; go.transform.position = new Vector3(cellPosition.x, map.transform.position.y, cellPosition.y); go.layer = LayerMask.NameToLayer("LevelTerrain"); var t = new Texture2D(map.TileResolution * map.NumberOfTiles, map.TileResolution * map.NumberOfTiles); var texName = "TEX" + name; t.name = texName; var transparent = new Color[map.TileResolution * map.NumberOfTiles * map.TileResolution * map.NumberOfTiles]; var c = new Color(0, 0, 0, 0); for (var y = 0; y < map.TileResolution * map.NumberOfTiles; y++) { for (var x = 0; x < map.TileResolution * map.NumberOfTiles; x++) { transparent[y * map.TileResolution * map.NumberOfTiles + x] = c; } } t.SetPixels(transparent); t.wrapMode = TextureWrapMode.Clamp; t.Apply(); var shader = Shader.Find(map.DefaultShader); if (shader == null) { shader = Shader.Find("Diffuse"); } var m = new Material(shader); var matName = "MAT" + name; m.name = matName; m.mainTexture = t; go.GetComponent <Renderer>().sharedMaterial = m; var me = new MapEditing(map); me.UpdateCellFromNeighbours(cell); me.Apply(); return(cell); }
void Start() { CreatePlane = GetComponent <CreatePlane>(); GameObject node = this.gameObject; }