//Find color from bottomLinks public int FindBottomColor(CubeElemController tile, int color) { int result = -1; //check material of each link for (int i = 0; i < tile.BottomLinks.Count; i++) { //Check for same color in links if (tile.BottomLinks[i].ElemMatIndex == color) { //if it's first index if (result == -1) { result = i; } //If second - add up to comboCount else { //If this tile wasn't checked yet if (!comboBuffer.Contains(tile.transform)) { Debug.Log("DOUBLE LINK"); comboCount++; } } } } //Debug.Log("RESULT : " + result); return(result); }
//Check if elem is ref to other sides public void BottomCheck(Transform tile /*, GameObject tmpObj*/) { CubeElemController tmpTile = tile.GetComponent <CubeElemController>(); if (tmpTile.BottomLinks.Count != 0) { //First color pick if (selectedColor == -1) { tile.GetComponent <CubeElemController>().materialInteraction = tmpTile.BottomLinks[0].transform.GetComponent <Renderer>().material; //Remember selection selectedColor = tmpTile.BottomLinks[0].ElemMatIndex; //Check if there's selected color in bottomLinks to add scorecount int bottomColor = FindBottomColor(tmpTile, selectedColor); //Remember color count comboBuffer.Add(tile); //Debug.Log("REE"); comboCount++; //Check buffer if (comboCount >= activeCube.colorCombos[selectedColor].Count) { //Enable clear buffer on character collision tile.GetComponent <CubeElemController>().ClearBufferTrigger = true; //ClearBuffer(); } } else if (selectedColor != 0) { //Check if there's selected color in bottomLinks - grab material from it int bottomColor = FindBottomColor(tmpTile, selectedColor); //Debug.Log(":>: " + bottomColor + " :: " + selectedColor); if (bottomColor >= 0 && tmpTile.BottomLinks[bottomColor].transform.GetComponent <Renderer>().material.color == activeCube.materials[selectedColor].color) { //DEBUG //Debug.Log("~~~~" + tmpTile.BottomLinks[bottomColor].transform.GetComponent<Renderer>().material + " : " + activeCube.materials[selectedColor]); //Paint elem to selectedColor //tile.GetComponent<Renderer>().material = tmpTile.BottomLinks[bottomColor].transform.GetComponent<Renderer>().material; tile.GetComponent <CubeElemController>().materialInteraction = tmpTile.BottomLinks[bottomColor].transform.GetComponent <Renderer>().material; //Remember color count if (!comboBuffer.Contains(tile)) { comboBuffer.Add(tile); //Debug.Log("REEE"); comboCount++; } //else ////{ //// comboCount++; ////} //Debug.Log(selectedColor); //Check buffer if (comboCount >= activeCube.colorCombos[selectedColor].Count) { //Enable clear buffer on character collision tile.GetComponent <CubeElemController>().ClearBufferTrigger = true; //ClearBuffer(); } } else { //Clear selection //Enable clear buffer on character collision //ClearBuffer(); //Debug.Log("BC : " + bottomColor); tile.GetComponent <CubeElemController>().ClearBufferTrigger = true; } } else { //Clear selection //Enable clear buffer on character collision tile.GetComponent <CubeElemController>().ClearBufferTrigger = true; //ClearBuffer(); } } else { //Clear selection //Enable clear buffer on character collision tile.GetComponent <CubeElemController>().ClearBufferTrigger = true; //ClearBuffer(); } }