void RemoveGemstone(Gemstone c) //删除宝石 { c.Dispose(); GetComponent <AudioSource>().PlayOneShot(match3Clip); for (int i = c.rowIndex + 1; i < rowNum; i++) { Gemstone temGemstone = GetGemstone(i, c.columnIndex); temGemstone.rowIndex--; SetGemstone(temGemstone.rowIndex, temGemstone.columnIndex, temGemstone); temGemstone.TweenToPostion(temGemstone.rowIndex, temGemstone.columnIndex); } Gemstone newGemstone = AddGemstone(rowNum, c.columnIndex); newGemstone.rowIndex--; SetGemstone(newGemstone.rowIndex, newGemstone.columnIndex, newGemstone); newGemstone.TweenToPostion(newGemstone.rowIndex, newGemstone.columnIndex); UpdateScore(10); }
void RemoveGemstone(Gemstone c) { //删除宝石 c.Dispose(); audio.PlayOneShot(match3Clip); for (int i = c.rowIndex + 1; i < rowNum; i++) { Gemstone temGemstone = GetGemstone(i, c.columnIndex); temGemstone.rowIndex--; SetGemstone(temGemstone.rowIndex, temGemstone.columnIndex, temGemstone); temGemstone.TweenToPostion(temGemstone.rowIndex, temGemstone.columnIndex); } Gemstone newGemstone = AddGemstone(rowNum, c.columnIndex); newGemstone.rowIndex--; SetGemstone(newGemstone.rowIndex, newGemstone.columnIndex, newGemstone); newGemstone.TweenToPostion(newGemstone.rowIndex, newGemstone.columnIndex); }
/// <summary> /// 消除一个宝石 /// </summary> /// <param name="g"></param> private void RemoveGemstone(Gemstone g) { g.Dispose(); //消除并下降 for (int i = g.rowIndex + 1; i < rowNum; i++) { Gemstone tempGemstone = GetGemstone(i, g.columIndex); tempGemstone.rowIndex--; SetGemStone(tempGemstone.rowIndex, tempGemstone.columIndex, tempGemstone); tempGemstone.TweenToPosition(tempGemstone.rowIndex, tempGemstone.columIndex); } //生成新的宝石 Gemstone newGemstone = AddGemstone(rowNum, g.columIndex); newGemstone.rowIndex--; SetGemStone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone); newGemstone.TweenToPosition(newGemstone.rowIndex, newGemstone.columIndex); }
void RemoveGemstone(Gemstone c) //消除寶石 { Debug.Log("消除寶石!"); c.Dispose(); GetComponent <AudioSource>().PlayOneShot(match3Clip); for (int i = c.rowIndex + 1; i < rowNum; i++) { Gemstone temGemstone = GetGemstone(i, c.columnIndex); temGemstone.rowIndex--; SetGemstone(temGemstone.rowIndex, temGemstone.columnIndex, temGemstone); //temGemstone.UpdatePosition (temGemstone.rowIndex,temGemstone.columnIndex); temGemstone.TweenToPostion(temGemstone.rowIndex, temGemstone.columnIndex); } Gemstone newGemstone = AddGemstone(rowNum, c.columnIndex); newGemstone.rowIndex--; SetGemstone(newGemstone.rowIndex, newGemstone.columnIndex, newGemstone); //newGemstone.UpdatePosition (newGemstone.rowIndex, newGemstone.columnIndex); newGemstone.TweenToPostion(newGemstone.rowIndex, newGemstone.columnIndex); }
/// <summary> /// 删除宝石 /// </summary> /// <param name="c">要删除的宝石</param> void RemoveGemstone(Gemstone c) { if (c == null) { return; } c.Dispose(); gameObject.GetComponent <AudioSource>().PlayOneShot(match3Clip); for (int i = c.rowIndex + 1; i < rowNum; i++) { Gemstone temGemstone = GetGemstone(i, c.columIndex); temGemstone.rowIndex--; SetGemstone(temGemstone.rowIndex, temGemstone.columIndex, temGemstone); temGemstone.UpdatePosition(temGemstone.rowIndex, temGemstone.columIndex); } Gemstone newGemstone = AddGemstone(rowNum, c.columIndex); newGemstone.rowIndex--; SetGemstone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone); newGemstone.UpdatePosition(newGemstone.rowIndex, newGemstone.columIndex); }
//very important: this function is: REMOVE+ GENERATE new gemstones //only responsible for individual spawning, should not know anything about the chain number, RemoveMatches() should know the chain number //the prioerSpawnContainer has the highest spawn priority void RemoveGemstone(Gemstone c) //删除宝石 //Debug.Log("删除宝石"); { c.Dispose(); //play sound this.gameObject.GetComponent <AudioSource> ().PlayOneShot(match3Clip); //all the gemstones fall for (int i = c.rowIndex + 1; i < rowNum; i++) { Gemstone temGemstone = GetGemstone(i, c.columIndex); temGemstone.rowIndex--; SetGemstone(temGemstone.rowIndex, temGemstone.columIndex, temGemstone); //temGemstone.UpdatePosition(temGemstone.rowIndex,temGemstone.columIndex); temGemstone.TweenToPosition(temGemstone.rowIndex, temGemstone.columIndex); } //START SPAWNING Gemstone newGemstone; //check the priorSpawninfo, if has anything, spawn upgraded gems first if (priorSpawnInfo.Count != 0) { //Debug.Log ("has prior spawns " + priorSpawnInfo.Count); //Debug.Log ("the chain is : " + matchesGemstone.Count); newGemstone = AddUpgradedGemstone(rowNum, c.columIndex, matchesGemstone.Count, priorSpawnInfo[0]); priorSpawnInfo.RemoveAt(0); //Debug.Log ("remove complete "+ priorSpawnInfo.Count); } else { newGemstone = AddRegularGemstone(rowNum, c.columIndex); } newGemstone.rowIndex--; SetGemstone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone); //newGemstone.UpdatePosition (newGemstone.rowIndex, newGemstone.columIndex); newGemstone.TweenToPosition(newGemstone.rowIndex, newGemstone.columIndex); }
void Remove(int row, int col) //移除某个row col坐标的宝石 { Gemstone g = GetGem(row, col); g.Dispose(); //消除后上面的宝石往下移动填补 for (int rowIndex = row + 1; rowIndex < rowNum; rowIndex++) { gem = GetGem(rowIndex, col); SetGem(rowIndex - 1, col, gem); gem.rowIndex = rowIndex - 1; gem.TweenToPos(); } //上面继续生成新的宝石 Gemstone newGem = CreateGemAtPoint(rowNum, col); newGem.rowIndex = rowNum - 1; newGem.columnIndex = col; SetGem(rowNum - 1, col, newGem); newGem.TweenToPos(); }