private IEnumerator DestroyEffect() { Debug.Log("DestroyEffect"); KeyValuePair <Shader, int?>[,] tmpShaders = CopyShaderData(); SetShader(whiteShader); yield return(new WaitForSeconds(.1f)); Destroy(Instantiate(debris, transform.position, Quaternion.identity), 3f); // 하얀 큐브에서 원래대로 돌아오기 for (int i = 0; i < tmpShaders.GetLength(0); i++) { for (int j = 0; j < tmpShaders.GetLength(1); j++) { Material material = faceMeshRanders[i].materials[j]; if (material != null) { material.shader = tmpShaders[i, j].Key; material.renderQueue = tmpShaders[i, j].Value ?? 3000; } } } gameObject.SetActive(false); }
//Find method checks whether an edge belongs to a subgroup or not //method solves kruska's minimum spanning tree problem //it returns KeyValuePair which stands for nodes public List <KeyValuePair <int, int> > KruskaMinSpanningTree() { //a list to store key and values //key:edge[i,j].Value , list sorts on key! SortedList <double, KeyValuePair <int, int> > kruskaSet = new SortedList <double, KeyValuePair <int, int> >(new DuplicateKeyHandler <double>()); List <KeyValuePair <int, int> > resultOfKruska = new List <KeyValuePair <int, int> >(); //adding values to the kruskaSet for (int i = 0; i < edges.GetLength(0); i++) { for (int j = i + 1; j < edges.GetLength(1); j++) { kruskaSet.Add(edges[i, j].Value, new KeyValuePair <int, int>(i, j)); } } foreach (var element in kruskaSet.Values) { //if nodes can be joined , accept the pair as a part of minimum spanning tree if (Unify(element.Key, element.Value)) { resultOfKruska.Add(new KeyValuePair <int, int>(element.Key, element.Value)); } } return(resultOfKruska); }
public BSP(FileInfo file) { this.file = file; offsets = new KeyValuePair<int, int>[64]; bsp = new FileStream(file.FullName, FileMode.Open); reader = new BinaryReader(bsp); //gathers an array of of where things are located in the bsp for (int i = 0; i < offsets.GetLength(0); i++) { bsp.Seek(8, SeekOrigin.Current); //skip id and version offsets[i] = new KeyValuePair<int, int>(reader.ReadInt32(), reader.ReadInt32()); } buildEntityList(); buildEntModelList(); buildModelList(); buildEntTextureList(); buildTextureList(); buildEntSoundList(); reader.Close(); bsp.Close(); }
/// <summary> /// Drop rows of tetriminos after clearing. /// </summary> /// <param name="yPos">The position tetriminos were cleared from</param> private void DropPieces(int yPos) { for (int i = yPos + 1; i < board.GetLength(1); i++) { for (int j = 0; j < board.GetLength(0); j++) { if (board[j, i].Value) { // set new positions TetriminoPiece key = board[j, i].Key.GetComponent <TetriminoPiece>(); key.BoardPosition = new Vector2(key.BoardPosition.x, key.BoardPosition.y - 1); key.transform.position = new Vector2(key.transform.position.x, key.transform.position.y - 1); board[j, i - 1] = board[j, i]; // remove old position board[j, i] = new KeyValuePair <GameObject, bool>(null, false); } } } }
// Shader is for shader // int is for render queue // current material is using shader render queue and // default render queue is stored in material // so material render queue is being overwritten by shader one // dont want that private KeyValuePair <Shader, int?>[,] CopyShaderData() { KeyValuePair <Shader, int?>[,] tmpShaders = new KeyValuePair <Shader, int?> [faceMeshRanders.Length, faceMeshRanders[0].materials.Length]; for (int i = 0; i < tmpShaders.GetLength(0); i++) { for (int j = 0; j < tmpShaders.GetLength(1); j++) { Material material = faceMeshRanders[i].materials[j]; Shader shader = null; int? renderQueue = null; if (material != null) { shader = material.shader; renderQueue = material.renderQueue; } tmpShaders[i, j] = new KeyValuePair <Shader, int?>(shader, renderQueue); } } return(tmpShaders); }
public void JsonObjectCopytoFunctionalTest() { int seed = 1; for (int i = 0; i < iterationCount / 10; i++) { seed++; Log.Info("Seed: {0}", seed); Random rndGen = new Random(seed); bool retValue = true; JsonObject sourceJson = SpecialJsonValueHelper.CreateIndexPopulatedJsonObject(seed, arrayLength); KeyValuePair <string, JsonValue>[] destJson = new KeyValuePair <string, JsonValue> [arrayLength]; if (sourceJson != null && destJson != null) { sourceJson.CopyTo(destJson, 0); } else { Log.Info("[JsonObjectCopytoFunctionalTest] sourceJson.ToString() = " + sourceJson.ToString()); Log.Info("[JsonObjectCopytoFunctionalTest] destJson.ToString() = " + destJson.ToString()); Assert.False(true, "[JsonObjectCopytoFunctionalTest] failed to create the source JsonObject object."); return; } if (destJson.Length == arrayLength) { for (int k = 0; k < destJson.Length; k++) { JsonValue temp; sourceJson.TryGetValue(k.ToString(), out temp); if (!(temp != null && destJson[k].Value == temp)) { retValue = false; } } } else { retValue = false; } Assert.True(retValue, "[JsonObjectCopytoFunctionalTest] JsonObject.CopyTo() failed to function properly. destJson.GetLength(0) = " + destJson.GetLength(0)); } }