public void RemoveEffectMat(MAT_TYPE type) { List <int> remove_list = new List <int>(); int i = 0; foreach (var info in m_MatList) { if (info.type == type) { remove_list.Add(i); } i++; } for (i = remove_list.Count - 1; i >= 0; --i) { m_MatList.RemoveAt(i); } if (remove_list.Count > 0) { OnMatListChange(); } }
/// <summary> /// Returns the OpenCV type that corresponds to a given ZED Mat type. /// </summary> private static int SLMatType2CVMatType(MAT_TYPE zedmattype) { switch (zedmattype) { case sl.MAT_TYPE.MAT_32F_C1: return(OpenCvSharp.MatType.CV_32FC1); case sl.MAT_TYPE.MAT_32F_C2: return(OpenCvSharp.MatType.CV_32FC2); case sl.MAT_TYPE.MAT_32F_C3: return(OpenCvSharp.MatType.CV_32FC3); case sl.MAT_TYPE.MAT_32F_C4: return(OpenCvSharp.MatType.CV_32FC4); case sl.MAT_TYPE.MAT_8U_C1: return(OpenCvSharp.MatType.CV_8UC1); case sl.MAT_TYPE.MAT_8U_C2: return(OpenCvSharp.MatType.CV_8UC2); case sl.MAT_TYPE.MAT_8U_C3: return(OpenCvSharp.MatType.CV_8UC3); case sl.MAT_TYPE.MAT_8U_C4: return(OpenCvSharp.MatType.CV_8UC4); default: return(-1); } }
public void setMaterial(MAT_TYPE material) { if (!value) { value = gameObject.GetComponentInParent <Transform>().Find("Value").gameObject; } switch (material) { case MAT_TYPE.WOOD: value.GetComponent <UnityEngine.UI.Text>().text = "wood (2.:.)"; break; case MAT_TYPE.GLASS: value.GetComponent <UnityEngine.UI.Text>().text = "glass (3.:.)"; break; case MAT_TYPE.STONE: value.GetComponent <UnityEngine.UI.Text>().text = "stone (5.:.)"; break; case MAT_TYPE.STEEL: value.GetComponent <UnityEngine.UI.Text>().text = "brick (7.:.)"; break; default: value.GetComponent <UnityEngine.UI.Text>().text = "error"; break; } }
/// <summary> /// Creates an OpenCV version of a ZED Mat. /// </summary> /// <param name="zedmat">Source ZED Mat.</param> /// <param name="zedmattype">Type of ZED Mat - data type and channel number. /// <returns></returns> private static OpenCvSharp.Mat SLMat2CVMat(ref sl.Mat zedmat, MAT_TYPE zedmattype) { int cvmattype = SLMatType2CVMatType(zedmattype); OpenCvSharp.Mat cvmat = new OpenCvSharp.Mat(zedmat.GetHeight(), zedmat.GetWidth(), cvmattype, zedmat.GetPtr()); return(cvmat); }
//constructor for the material, this is the base which won't likely be called public Material() { //initiallizes things as unimportant values cost = 0; durability = 10f; forceTransfer = 0.0f; type = MAT_TYPE.NONE; weakness = SHOT_TYPE.NONE; resistance = SHOT_TYPE.NONE; neighbors = new List <Material>(); }
/// <summary> /// 添加材质特效 /// </summary> /// <param name="time"></param> /// <param name="type"></param> /// <param name="pri"></param> /// <returns></returns> public MatInfo AddEffectMat(float time, MAT_TYPE type, Priority pri) { MatInfo m = new MatInfo(); m.startTime = Time.time; m.endTime = m.startTime + time; m.type = type; m.priority = (int)pri; m_MatList.Add(m); OnMatListChange(); return(m); }
public void StartCode() { //Grid grid = new Grid(21, 9, 1f); testBlockPrivate = TestBlockPublic; blockList = new List <GameObject>(); debugList = new List <GameObject>(); currentState = EditorState.Painting; Mouse.GetComponent <MouseModeManager>().setMode(currentState); currentMaterial = MAT_TYPE.WOOD; Material.GetComponent <MaterialLabelManager>().setMaterial(currentMaterial); remainingComponents = 50; Components.GetComponent <CostLabelManager>().setNumber(remainingComponents); }
/// <summary> /// Allocates memory for the Mat. /// </summary> /// <param name="resolution">Size of the image/matrix in pixels.</param> /// <param name="matType">Type of matrix (data type and channels; see sl.MAT_TYPE)</param> /// <param name="mem">Where the buffer will be stored - CPU memory or GPU memory.</param> public void Alloc(sl.Resolution resolution, MAT_TYPE matType, MEM mem = MEM.MEM_CPU) { dllz_mat_alloc(_matInternalPtr, (int)resolution.width, (int)resolution.height, (int)matType, (int)mem); }
/// <summary> /// Allocates memory for the Mat. /// </summary> /// <param name="width">Width of the image/matrix in pixels.</param> /// <param name="height">Height of the image/matrix in pixels.</param> /// <param name="matType">Type of matrix (data type and channels; see sl.MAT_TYPE)</param> /// <param name="mem">Where the buffer will be stored - CPU memory or GPU memory.</param> public void Alloc(uint width, uint height, MAT_TYPE matType, MEM mem = MEM.MEM_CPU) { dllz_mat_alloc(_matInternalPtr, (int)width, (int)height, (int)matType, (int)mem); }
/// <summary> /// Creates a Mat with a given width and height. /// </summary> /// <param name="width">Width of the new Mat.</param> /// <param name="height">Height of the new Mat.</param> /// <param name="type">Data type and number of channels the Mat will hold. /// Depends on texture type: see sl.VIEW and sl.MEASURE in ZEDCommon.cs.</param> /// <param name="mem">Whether Mat should exist on CPU or GPU memory. /// Choose depending on where you'll need to access it from.</param> public ZEDMat(uint width, uint height, MAT_TYPE type, MEM mem = MEM.MEM_CPU) { _matInternalPtr = dllz_mat_create_new(new sl.Resolution(width, height), (int)(type), (int)(mem)); }
/// <summary> /// Creates a Mat with a given resolution. /// </summary> /// <param name="resolution">Resolution for the new Mat.</param> /// <param name="type">Data type and number of channels the Mat will hold. /// Depends on texture type: see sl.VIEW and sl.MEASURE in ZEDCommon.cs.</param> /// <param name="mem">Whether Mat should exist on CPU or GPU memory. /// Choose depending on where you'll need to access it from.</param> public ZEDMat(sl.Resolution resolution, MAT_TYPE type, MEM mem = MEM.MEM_CPU) { _matInternalPtr = dllz_mat_create_new(resolution, (int)(type), (int)(mem)); }
public void GridModeActive() { Cleanup(); if (currentState == EditorState.Painting) { PainterMode(); } else if (currentState == EditorState.Deleting) { DeleterMode(); } else if (currentState == EditorState.Connecting) { ConnectorMode(); } //checks if anything is being done now if (Input.anyKey) { //input checking for changing the drawing mode. if (Input.GetKeyDown(KeyCode.A)) { currentState = EditorState.Painting; CancelConnecting(); Debug.Log("Now Painting"); } if (Input.GetKeyDown(KeyCode.S)) { currentState = EditorState.Connecting; Debug.Log("Now Connecting"); } if (Input.GetKeyDown(KeyCode.D)) { currentState = EditorState.Deleting; CancelConnecting(); Debug.Log("Now Deleting"); } Mouse.GetComponent <MouseModeManager>().setMode(currentState); //input checking for changing the material. (Temporarily number buttons, could be permanent as a secondary option to clicking if (Input.GetKeyDown(KeyCode.Alpha1)) { currentMaterial = MAT_TYPE.WOOD; Debug.Log("Wood"); } if (Input.GetKeyDown(KeyCode.Alpha2)) { currentMaterial = MAT_TYPE.GLASS; Debug.Log("Glass"); } if (Input.GetKeyDown(KeyCode.Alpha3)) { currentMaterial = MAT_TYPE.STONE; Debug.Log("Stone"); } if (Input.GetKeyDown(KeyCode.Alpha4)) { currentMaterial = MAT_TYPE.STEEL; Debug.Log("Brick"); } Material.GetComponent <MaterialLabelManager>().setMaterial(currentMaterial); /*if (Input.GetKeyDown(KeyCode.Alpha5)) * { * currentMaterial = MAT_TYPE.MAGIC; * Debug.Log("Magic"); * }*/ } }
void ConnectorMode() { RaycastHit2D hit = Physics2D.Raycast(gameCam.ScreenToWorldPoint(Input.mousePosition), Vector3.forward); if (Input.GetMouseButtonDown(0)) { //code for merging blocks if (hit.collider != null && hit.collider.gameObject.tag == "destructible") { if (debugList.Count == 0) { debugList.Add(hit.collider.gameObject); blockList.Remove(hit.collider.gameObject); Debug.Log(debugList); hit.collider.gameObject.transform.GetChild(0).gameObject.SetActive(true); hit.collider.gameObject.transform.GetChild(0).GetComponent <SpriteRenderer>().color = new Color(255, 0, 0); hit.transform.position = new Vector3(hit.transform.position.x, hit.transform.position.y, -0.1f); //sets the type of this set of connected objects, checks this before adding it to the group connectorMaterial = hit.collider.gameObject.GetComponent <Material>().Type; } else if (debugList.Count < 5 && debugList.Count > 0 && connectorMaterial == hit.collider.gameObject.GetComponent <Material>().Type&& !debugList.Contains(hit.collider.gameObject)) { for (int i = 0; i < debugList.Count; i++) { float dist = Vector3.Distance(debugList[i].transform.position, hit.collider.gameObject.transform.position); Debug.Log(dist); if (dist <= 1.2f) { debugList.Add(hit.collider.gameObject); blockList.Remove(hit.collider.gameObject); Debug.Log("Adjacent"); hit.collider.gameObject.transform.GetChild(0).gameObject.SetActive(true); hit.collider.gameObject.transform.GetChild(0).GetComponent <SpriteRenderer>().color = new Color(255, 0, 0); hit.transform.position = new Vector3(hit.transform.position.x, hit.transform.position.y, -0.1f); break; } Debug.Log("Adjacency was checked"); } } else if (debugList.Count == 5) { } } } if (Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2) || Input.GetMouseButtonDown(3) || Input.GetMouseButtonDown(4)) { if (debugList == null) { Debug.Log("The group is empty"); } else if (debugList.Count > 0) { //merge into parent and shit GameObject parentObject = new GameObject(); parentObject.name = "block group"; parentObject.transform.parent = GameManager.Instance.levelObjects.transform.GetChild(2); List <GameObject> childList = new List <GameObject>(); childList = debugList; debugList = new List <GameObject>(); //sets the parent's material up switch (connectorMaterial) { case MAT_TYPE.WOOD: parentObject.AddComponent <Wood>(); break; case MAT_TYPE.GLASS: parentObject.AddComponent <Glass>(); break; case MAT_TYPE.STONE: parentObject.AddComponent <Stone>(); break; case MAT_TYPE.STEEL: parentObject.AddComponent <Steel>(); break; case MAT_TYPE.MAGIC: parentObject.AddComponent <Magic>(); break; } float children = 0.0f; foreach (GameObject g in childList) { g.transform.GetChild(0).GetComponent <SpriteRenderer>().color = new Color(255, 255, 0); g.transform.parent = parentObject.transform; Destroy(g.GetComponent <Material>()); Debug.Log("Child has been connected"); g.tag = "childBlock"; children += 1.0f; } //multiplies the durability by either 1 or the number of children / 1.75 parentObject.GetComponent <Material>().MultiplyDurability(Mathf.Max(1.0f, (children / 1.75f))); parentObject.tag = "destructible"; blockList.Add(parentObject); Debug.Log("Parent has been made"); } } }
public void SetTileMat(MAT_TYPE type) { myRenderer.material = allMaterials[(int)type]; }