private void LookAtCube(cube lookingAtCube) { // look at cube according to the enum lookingAtCube // maybe should have done this with a switch statement if (lookingAtCube == cube.blue) { mouseYaw = 0f; //reset camera for mouse look if you don't do this the camera will pop/rotate back to the last rotation before you let off the L key transform.rotation = Quaternion.Euler(0f, 0f, 0f); } if (lookingAtCube == cube.green) { mouseYaw = -90f; //reset camera for mouse look if you don't do this the camera will pop/rotate back to the last rotation before you let off the L key transform.rotation = Quaternion.Euler(0f, 270f, 0f); } if (lookingAtCube == cube.yellow) { mouseYaw = 180f; //reset camera for mouse look if you don't do this the camera will pop/rotate back to the last rotation before you let off the L key transform.rotation = Quaternion.Euler(0f, 180f, 0f); } if (lookingAtCube == cube.red) { mouseYaw = 90f; //reset camera for mouse look if you don't do this the camera will pop/rotate back to the last rotation before you let off the L key transform.rotation = Quaternion.Euler(0f, 90f, 0f); } mousePitch = 0f; // reset the cameras pitch after mouse look }
public void UnGrab() { if (_isGrab == false) { return; } if (_grabObj == null) { return; } _isGrab = false; _grabObj.transform.parent = null; Rigidbody2D r = _grabObj.GetComponent <Rigidbody2D>(); _grabObj.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; r.simulated = true; _grabObj.GetComponent <Animator>().enabled = false; cube cube = _grabObj.GetComponent <cube>(); if (cube != null) { cube._grab = false; } _grabObj = null; }
private void GetPlayerInput() { if (Input.GetKey(KeyCode.L)) { // calling mouse look if the L key is down MouseLook(); } if (!Input.GetKey(KeyCode.L)) { // if the L key is NOT down set the camera back to the cube we were looking at. // there may be a better way to do this. LookAtCube(lookingAtCube); } // set the cube we want to look at if (Input.GetKeyDown(KeyCode.UpArrow)) { // look at blue cube LookAtCube(lookingAtCube = cube.blue); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { // look at green cube LookAtCube(lookingAtCube = cube.green); } if (Input.GetKeyDown(KeyCode.DownArrow)) { // look at yellow cube LookAtCube(lookingAtCube = cube.yellow); } if (Input.GetKeyDown(KeyCode.RightArrow)) { // look at red cube LookAtCube(lookingAtCube = cube.red); } }
//水平順時變換名稱 private void horizontalMoveLeftChangename(cube cubeID, GameObject tmpGame) { string cubeObjectName = ""; if (cubeID.idx >= max && cubeID.idy < max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, ++cubeID.idy, cubeID.idz); } else if (cubeID.idx < max && cubeID.idy < max) { cubeObjectName = string.Format(cubeKey, ++cubeID.idx, cubeID.idy, cubeID.idz); Debug.Log(cubeObjectName); } else if (cubeID.idx == max && cubeID.idy == max) { cubeObjectName = string.Format(cubeKey, --cubeID.idx, cubeID.idy, cubeID.idz); } else if (cubeID.idx < max && cubeID.idy == max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, --cubeID.idy, cubeID.idz); } tmpGame.name = cubeObjectName; }
static void Main(string[] args) { for (int i = 1; i > 0;) { int a = 0; Console.WriteLine("Obliczanie powierzchni i objętości : 1 - stożka, 2 - prostopadłościanu"); a = Convert.ToInt32(Console.ReadLine()); if (a == 2) { Console.WriteLine("Podaj po kolei wymiary prostopadłościanu"); cube c1 = new cube((Convert.ToInt32(Console.ReadLine())), (Convert.ToInt32(Console.ReadLine())), (Convert.ToInt32(Console.ReadLine()))); Console.WriteLine("objętość"); Console.WriteLine(c1.vol()); Console.WriteLine("powierzchnia"); Console.WriteLine(c1.pow()); } if (a == 1) { Console.WriteLine("Podaj po kolei wymiary stożka - promień, potem wysokość"); stozek s1 = new stozek((Convert.ToInt32(Console.ReadLine())), (Convert.ToInt32(Console.ReadLine()))); Console.WriteLine("objętość"); Console.WriteLine(s1.vol()); Console.WriteLine("powierzchnia"); Console.WriteLine(s1.pow()); } } }
private void verticaMoveFORNTChangename(cube cubeID, GameObject tmpGame) { string cubeObjectName = ""; if (cubeID.idy < max && cubeID.idz < max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, cubeID.idy, ++cubeID.idz); } else if (cubeID.idy < max && cubeID.idz == max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, ++cubeID.idy, cubeID.idz); } else if (cubeID.idy == max && cubeID.idz == max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, cubeID.idy, --cubeID.idz); } else if (cubeID.idy == max && cubeID.idz < max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, --cubeID.idy, cubeID.idz); } tmpGame.name = cubeObjectName; }
//垂直右時變換名稱 private void verticaMoveLeftChangename(cube cubeID, GameObject tmpGame) { string cubeObjectName = ""; if (cubeID.idx < max && cubeID.idz < max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, cubeID.idy, ++cubeID.idz); Debug.Log("cubeID.idx == max" + cubeObjectName); } else if (cubeID.idz == max && cubeID.idx < max) { cubeObjectName = string.Format(cubeKey, ++cubeID.idx, cubeID.idy, cubeID.idz); } else if (cubeID.idx == max && cubeID.idz == max) { cubeObjectName = string.Format(cubeKey, cubeID.idx, cubeID.idy, --cubeID.idz); } else if (cubeID.idx == max && cubeID.idz < max) { cubeObjectName = string.Format(cubeKey, --cubeID.idx, cubeID.idy, cubeID.idz); Debug.Log("cubeID.idx <= max" + cubeObjectName); } tmpGame.name = cubeObjectName; }
public CubePosition(cube Cube) { stats = new float[3]; stats[0] = Cube.xPos; stats[1] = Cube.yPos; stats[2] = Cube.zPos; }
void OnTriggerExit(Collider collider) { // set it back to false if the object leaves the area before OnMouseUp if (collider.gameObject.name == "cube") { cube obj = collider.gameObject.GetComponent <cube>(); obj.areaReached = false; } }
void OnTriggerEnter(Collider collider) { // detect if the object enters the area if (collider.gameObject.name == "cube") { // get object's script and modify its variable cube obj = collider.gameObject.GetComponent <cube>(); obj.areaReached = true; } }
void Start() { Floor_object = GameObject.Find("floor1"); Floor_script = Floor_object.GetComponent <Floor>(); root1_object = GameObject.Find("root1"); root1_script = root1_object.GetComponent <root1>(); root2_object = GameObject.Find("root2"); root2_script = root2_object.GetComponent <root2>(); cube_object = GameObject.Find("Cube"); cube_script = cube_object.GetComponent <cube>(); }
static void Process4dCycles(string[] _input_grid, _4d_cube_container _container, int _cycles) { _container.SetBoundaries(0, 0, 0, 0, _input_grid.Length - 1, _input_grid[0].Length - 1, 0, 0); for (var x = 0; x < _input_grid.Length; x++) { for (var y = 0; y < _input_grid[x].Length; y++) { _container[x, y, 0, 0] = new cube(_input_grid[x][y] == '#' ? true : false); } } for (var cycle = 0; cycle < _cycles; cycle++) { // add a 4d layer around the existing hypercubes _container.Expand(); // transform the cubes according to these rules: // 1. if a cube is active and exactly 2 or 3 of its neighbors are also active, the cube remains active. Otherwise, the cube becomes inactive. // // 2. if a cube is inactive but exactly 3 of its neighbors are active, the cube becomes active. Otherwise, the cube remains inactive. for (var x = _container.min_x; x <= _container.max_x; x++) { for (var y = _container.min_y; y <= _container.max_y; y++) { for (var z = _container.min_z; z <= _container.max_z; z++) { for (var w = _container.min_w; w <= _container.max_w; w++) { if (_container[x, y, z, w].state == true) { if (_container[x, y, z, w].active_neighbors != 2 && _container[x, y, z, w].active_neighbors != 3) { _container[x, y, z, w].Transform(false); } } else if (_container[x, y, z, w].active_neighbors == 3) { _container[x, y, z, w].Transform(true); } } } } } // apply transforms to each cube _container.Update(); } }
void CubesInit() { for (int i = 0; i < 8; i++) { Cubes[i] = new cube(GameObject.FindWithTag("corner" + i), "corner"); } for (int i = 0; i < 12; i++) { Cubes[i + 8] = new cube(GameObject.FindWithTag("edge" + i), "edge"); } for (int i = 0; i < 6; i++) { Cubes[i + 20] = new cube(GameObject.FindWithTag("center" + i), "center"); } }
public static void savePostion(cube Cube) { // Create BinaryFormater BinaryFormatter bf = new BinaryFormatter(); // Create file to save to FileStream stream = new FileStream(Application.persistentDataPath + "/position.cav", FileMode.Create); // Set data to be stored CubePosition data = new CubePosition(Cube); // Serialize data bf.Serialize(stream, data); stream.Close(); }
//for initialization void Start() { targetpos_object = GameObject.Find("target"); targetpos_script = targetpos_object.GetComponent <TargetPos>(); targetpos2_object = GameObject.Find("target2"); targetpos2_script = targetpos2_object.GetComponent <TargetPos2>(); root2_object = GameObject.Find("root2"); root2_script = root2_object.GetComponent <root2>(); Floor_object = GameObject.Find("floor1"); Floor_script = Floor_object.GetComponent <Floor>(); Goal_object = GameObject.Find("goal"); Goal_script = Goal_object.GetComponent <Goal>(); cube_object = GameObject.Find("Cube"); cube_script = cube_object.GetComponent <cube>(); x = 10; }
void Start() { root2_object = GameObject.Find("root2"); root2_script = root2_object.GetComponent <root2>(); root1_object = GameObject.Find("root1"); root1_script = root1_object.GetComponent <root1>(); Floor_object = GameObject.Find("floor1"); Floor_script = Floor_object.GetComponent <Floor>(); cube_object = GameObject.Find("Cube"); cube_script = cube_object.GetComponent <cube>(); goal_object = GameObject.Find("goal"); goal_script = goal_object.GetComponent <Goal>(); goal2_object = GameObject.Find("goal2"); goal2_script = goal2_object.GetComponent <Goal2>(); goal3_object = GameObject.Find("goal3"); goal3_script = goal3_object.GetComponent <Goal3>(); }
public bool ThoseCubesAreIntersected(int dimensionC1, int x1, int y1, int z1, int dimensionC2, int x2, int y2, int z2) { cube cube1 = new cube(); cube1.dimension = dimensionC1; cube1.xCoord = x1; cube1.yCoord = y1; cube1.zCoord = z1; cube cube2 = new cube(); cube2.dimension = dimensionC2; cube2.xCoord = x2; cube2.yCoord = y2; cube2.zCoord = z2; return(_IADCube.thereIsIntersection(cube1, cube2)); }
public int GetIntersectionVolume(int dimensionC1, int x1, int y1, int z1, int dimensionC2, int x2, int y2, int z2) { cube cube1 = new cube(); cube1.dimension = dimensionC1; cube1.xCoord = x1; cube1.yCoord = y1; cube1.zCoord = z1; cube cube2 = new cube(); cube2.dimension = dimensionC2; cube2.xCoord = x2; cube2.yCoord = y2; cube2.zCoord = z2; return(_IADCube.IntersectionVolume(cube1, cube2)); }
public void pipeTurnOn() { gameObject.GetComponent <BoxCollider2D>().enabled = false; if (_cubeCount < _cubeCountMax) { GameObject CubePrefab = Resources.Load("cube") as GameObject; GameObject cube = Instantiate(CubePrefab); Vector2 pipePos = gameObject.transform.position; CubePrefab.transform.position = new Vector2(pipePos.x, pipePos.y); _cubeCount++; cube c = cube.GetComponent <cube>(); TrapManager.Instance._cubes.Add(c); } //TrapManager의 리스트에 넣어주기 // cube c = cube.GetComponent<cube>(); //TrapManager.Instance._cubes.Add(c); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); cube cube = (cube)target; GUILayout.BeginHorizontal(); if (GUILayout.Button("Generate Color")) { cube.GenerateColor(); } if (GUILayout.Button("Reset")) { cube.Reset(); } GUILayout.EndHorizontal(); }
static void Main(string[] args) { cube c1 = new cube(); c1.x = 10; c1.y = 12; c1.x = 14; // ProcessCube(c1); Cube c2; c2 = c1; c2.x = 1000; Console.WriteLine(c2.x); // classes are ref types c1 ref place in memory. c1 is a pointer. c2 now equals a pointer. Console.WriteLine(c1.x); Console.WriteLine("Hello World!"); Console.ReadLine(); }
IEnumerator checkTouch() { while (true) { if (Input.GetMouseButtonDown(0)) { // Input.mousePosition Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, 1 << LayerMask.NameToLayer("myCube"))) { cube myCube = hit.collider.GetComponent <cube>(); nowSelectCubeID = myCube.idx; indexArray[0] = myCube.idx; indexArray[1] = myCube.idy; indexArray[2] = myCube.idz; Debug.Log("id:" + myCube.idx + "," + myCube.idy + "," + myCube.idz); } } yield return(null); } }
void Start() { root2_object = GameObject.Find("root2"); root2_script = root2_object.GetComponent <root2>(); root1_object = GameObject.Find("root1"); root1_script = root1_object.GetComponent <root1>(); Floor_object = GameObject.Find("floor1"); Floor_script = Floor_object.GetComponent <Floor>(); cube_object = GameObject.Find("Cube"); cube_script = cube_object.GetComponent <cube>(); goal_object = GameObject.Find("goal"); goal_script = goal_object.GetComponent <Goal>(); goal2_object = GameObject.Find("goal2"); goal2_script = goal2_object.GetComponent <Goal2>(); goal3_object = GameObject.Find("goal3"); goal3_script = goal3_object.GetComponent <Goal3>(); Vector3 pos = transform.position; pos.x = slider.sld_x1; pos.z = slider.sld_y1; transform.position = pos; }
private void verticaFBlMoveToPoint() { int x = indexArray[0]; int y = indexArray[1]; int z = indexArray[2]; int index = 0; GameObject[] tmpGames = new GameObject[4]; for (int i = 1; i <= max; i++) { for (int j = 1; j <= max; j++) { string cubeObjectName = string.Format(cubeKey, x, i, j); GameObject tmpGame = GameObject.Find(cubeObjectName); tmpGames[index] = tmpGame; index++; Debug.Log(cubeObjectName); tmpGame.transform.parent = this.transform; } } foreach (GameObject tmpGame in tmpGames) { cube cubeID = tmpGame.GetComponent <cube>(); if (rotaeDrication == ROTATE_DRICATION_ENUM.V_BREAK) { //向後轉 Debug.Log("V_BREAK"); verticaMoveBreakChangename(cubeID, tmpGame); } else { //向前轉 Debug.Log("FORNT"); verticaMoveFORNTChangename(cubeID, tmpGame); } } }
private void verticaRLlMoveToPoint() { int x = indexArray[0]; int y = indexArray[1]; int z = indexArray[2]; GameObject[] tmpGames = new GameObject[4]; int index = 0; for (int i = 1; i <= max; i++) { for (int j = 1; j <= max; j++) { string cubeObjectName = string.Format(cubeKey, i, y, j); GameObject tmpGame = GameObject.Find(cubeObjectName); tmpGames[index] = tmpGame; index++; Debug.Log(cubeObjectName); tmpGame.transform.parent = this.transform; } } foreach (GameObject tmpGame in tmpGames) { cube cubeID = tmpGame.GetComponent <cube>(); if (rotaeDrication == ROTATE_DRICATION_ENUM.V_RIGHT) { //逆時鐘 verticaMoveRightChangename(cubeID, tmpGame); } else { //順順時 verticaMoveLeftChangename(cubeID, tmpGame); } } }
public void run() { while (true) { int count1 = twodimlist.Count; int count2 = threedimlist.Count; Console.WriteLine("\n\nTwoDim Shape : " + count1); Console.WriteLine("ThreeDim Shape : " + count2); Console.WriteLine("input len and shape"); int Len = 0; try { Len = Int32.Parse(Console.ReadLine()); } catch (FormatException ex1) { Console.WriteLine(ex1.Message); continue; } if (Len == 0) { break; } string shape = Console.ReadLine(); int num = 0; foreach (var i in twodimlist) { if (i.name == shape && i.len == Len) { Console.WriteLine("이미 존재함"); num = 1; break; } } foreach (var i in threedimlist) { if (i.name == shape && i.len == Len) { Console.WriteLine("이미 존재함"); num = 1; break; } } if (num == 1) { continue; } if (shape == "정삼각형") { TwoDim Triangle = new triangle(); Triangle.name = shape; Triangle.len = Len; Triangle.Calarea(); Triangle.Calperimeter(); Triangle.print(Triangle.Area, Triangle.perimeter); twodimlist.Add(Triangle); } else if (shape == "정사각형") { TwoDim Square = new square(); Square.name = shape; Square.len = Len; Square.Calarea(); Square.Calperimeter(); Square.print(Square.Area, Square.perimeter); twodimlist.Add(Square); } else if (shape == "원") { TwoDim Circle = new circle(); Circle.name = shape; Circle.len = Len; Circle.Calarea(); Circle.Calperimeter(); Circle.print(Circle.Area, Circle.perimeter); twodimlist.Add(Circle); } else if (shape == "구") { ThreeDim Sphere = new sphere(); Sphere.name = shape; Sphere.len = Len; Sphere.Calarea(); Sphere.Calvolume(); Sphere.print(Sphere.Area, Sphere.volume); threedimlist.Add(Sphere); } else if (shape == "정육면체") { ThreeDim Cube = new cube(); Cube.name = shape; Cube.len = Len; Cube.Calarea(); Cube.Calvolume(); Cube.print(Cube.Area, Cube.volume); threedimlist.Add(Cube); } else { Console.WriteLine("Wrong input"); } } }
public void addCube(cube newCube) { all.Add(newCube); }
public void OnErase(cube cubes) { _cubes.Remove(cubes); }
static void Main1016(string[] args) { List <int[]> rtype = new List <int[]> { new int[] { 0, 1, 2, 3, 4, 5 }, new int[] { 0, 1, 4, 5, 2, 3 }, new int[] { 0, 1, 3, 4, 5, 2 }, new int[] { 0, 1, 5, 2, 3, 4 }, new int[] { 1, 0, 2, 5, 4, 3 }, new int[] { 1, 0, 3, 2, 5, 4 }, new int[] { 1, 0, 4, 3, 2, 5 }, new int[] { 1, 0, 5, 4, 3, 2 }, new int[] { 2, 4, 0, 5, 1, 3 }, new int[] { 2, 4, 1, 3, 0, 5 }, new int[] { 2, 4, 3, 0, 5, 1 }, new int[] { 2, 4, 5, 1, 3, 0 }, new int[] { 3, 5, 0, 2, 1, 4 }, new int[] { 3, 5, 1, 4, 0, 2 }, new int[] { 3, 5, 2, 1, 4, 0 }, new int[] { 3, 5, 4, 0, 2, 1 }, new int[] { 4, 2, 0, 3, 1, 5 }, new int[] { 4, 2, 1, 5, 0, 3 }, new int[] { 4, 2, 3, 1, 5, 0 }, new int[] { 4, 2, 5, 0, 3, 1 }, new int[] { 5, 3, 0, 4, 1, 2 }, new int[] { 5, 3, 1, 2, 0, 4 }, new int[] { 5, 3, 2, 0, 4, 1 }, new int[] { 5, 3, 4, 1, 2, 0 }, }; int[,] type = new int[, ] { { 0, -1 }, { 0, 1 }, { 1, 0 }, { -1, 0 } }; //TBRL int[,] rotatetype = new int[4, 6] { { 2, 4, 1, 3, 0, 5 }, //down { 4, 2, 0, 3, 1, 5 }, //up { 0, 1, 5, 2, 3, 4 }, //right { 0, 1, 3, 4, 5, 2 }, //left }; while (true) { string input = Console.ReadLine(); string[] split = input.Split(' '); string start = split[0]; string end = split[1]; point sp = new point { X = start[0] - 'a', Y = start[1] - '1' }; point ep = new point { X = end[0] - 'a', Y = end[1] - '1' }; int near = int.Parse(split[2]); int far = int.Parse(split[3]); int top = int.Parse(split[4]); int right = int.Parse(split[5]); int bottom = int.Parse(split[6]); int left = int.Parse(split[7]); string letter = "abcdefgh"; int[] incube = new int[6] { near, far, top, right, bottom, left }; int[,,] dis = new int[8, 8, 24]; for (int i = 0; i < dis.GetLength(0); i++) { for (int j = 0; j < dis.GetLength(1); j++) { for (int k = 0; k < dis.GetLength(2); k++) { dis[i, j, k] = int.MaxValue; } } } dis[sp.X, sp.Y, 0] = incube[4]; cube[,,] prev = new cube[8, 8, 24]; PriorityQueue <cube> queue = new PriorityQueue <cube>(new DinoComparer()); queue.Push(new cube(sp.X, sp.Y, incube[4], 0)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(start + " "); cube position = new cube(sp.X, sp.Y, incube[4], 0); DinoComparer comparer = new DinoComparer(); while (position.X != ep.X || position.Y != ep.Y) { cube next = queue.Pop(); position = next; if (next.Len <= dis[next.X, next.Y, next.Rtype]) { for (int i = 0; i < type.GetLength(0); i++) { point pr = new point { X = next.X + type[i, 0], Y = next.Y + type[i, 1] }; if (pr.X < 0 || pr.Y < 0 || pr.X > 7 || pr.Y > 7) { continue; } int[] ncube = new int[] { rtype[next.Rtype][rotatetype[i, 0]], rtype[next.Rtype][rotatetype[i, 1]], rtype[next.Rtype][rotatetype[i, 2]], rtype[next.Rtype][rotatetype[i, 3]], rtype[next.Rtype][rotatetype[i, 4]], rtype[next.Rtype][rotatetype[i, 5]] }; int ntype = rtype.FindIndex(new Predicate <int[]>(delegate(int[] x) { int o = 0; while (o < x.Length && x[o] == ncube[o]) { o++; } return((o == x.Length) ? true : false); })); int newlen = next.Len + incube[rtype[ntype][4]]; if (dis[pr.X, pr.Y, ntype] <= newlen) { continue; } dis[pr.X, pr.Y, ntype] = newlen; prev[pr.X, pr.Y, ntype] = next; queue.Push(new cube(pr.X, pr.Y, newlen, ntype)); } } } Stack <point> path = new Stack <point>(); cube endcube = new cube(ep.X, ep.Y, 0, position.Rtype); while (endcube.X != sp.X || endcube.Y != sp.Y || endcube.Rtype != 0) { endcube = prev[endcube.X, endcube.Y, endcube.Rtype]; path.Push(new point { X = endcube.X, Y = endcube.Y }); } Console.Write(dis[ep.X, ep.Y, position.Rtype] + " "); foreach (var q in path.ToArray()) { string p = letter[q.X].ToString() + (q.Y + 1); Console.Write(p + " "); } Console.Write(end); //break; } }
set => set(cube, position, value);
// Start is called before the first frame update void Start() { // set the cube to start looking LookAtCube(lookingAtCube = cube.blue); }
void Start () { floor = new cube(); }