public void DestroyRandom() { //uu tien destroy ganh dropjewel(); if (PLayerInfo.MODE == 1) { if (!isStar) { List <CellObj> listeff = getListCellEffect(); if (listeff.Count > 0) { CellObj tmp = listeff[Random.Range(0, listeff.Count)]; tmp.RemoveEffect(); EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.cell.CellPosition.x, (int)tmp.cell.CellPosition.y].transform.position); } else { destroynotempty(); } } else { Vector2 vtmp = posUnderStar(); JewelObj tmp = JewelSpawner.spawn.JewelGribScript[(int)vtmp.x, (int)vtmp.y]; if (tmp != null && tmp != JewelStar) { tmp.Destroy(); EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.jewel.JewelPosition.x, (int)tmp.jewel.JewelPosition.y].transform.position); } } } }
public void DestroyAdjacentJewel(JewelObj jewelObj, bool firstTime = true) { if (jewelObj == null || jewelObj.jewel == null) { print("NULL"); return; } Jewel centerJewel = jewelObj.jewel; Vector2 centerJewel_Pos = centerJewel.JewelPosition; Vector2[] directions = GetAdjacentVectors(centerJewel_Pos); foreach (Vector2 direction in directions) { if (CheckOutOfBounds(direction)) { JewelObj obj = JewelSpawner.spawn.JewelGribScript[(int)direction.x, (int)direction.y]; if (obj != null) { obj.Destroy(); } } } if (firstTime) { StartCoroutine(DestroyAdjacentJewel_Again(centerJewel_Pos)); } }
// 消除相同类型对象 IEnumerator DestroyType(int type, Vector3 pos) { // 激活禁选框 NoSelect.SetActive(true); // 开启滑落检测 dropjewel(); // 遍历宝石列表 for (int x = 0; x < 7; x++) { for (int y = 0; y < 9; y++) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript[x, y]; if (tmp != null && tmp.jewel.JewelType == type) { // 播放特效 EffectSpawner.effect.MGE(pos, JewelSpawner.spawn.JewelGrib[x, y].transform.position); // 销毁宝石对象 tmp.Destroy(); } } } // 等0.2s yield return(new WaitForSeconds(0.2f)); // 隐藏禁选框 NoSelect.SetActive(false); }
IEnumerator WheelEffect_Async(Vector2 startpos, MotionDirection motionDirection) { int boundCol = GameController.HEIGHT; int boundRow = GameController.WIDTH; List <Vector2> dirs = new List <Vector2>(); switch (motionDirection) { case MotionDirection.RIGHT: for (int i = (int)startpos.x; i < boundRow; i++) { dirs.Add(new Vector2((float)i, startpos.y)); } break; case MotionDirection.LEFT: for (int i = (int)startpos.x; i > -1; i--) { dirs.Add(new Vector2((float)i, startpos.y)); } break; case MotionDirection.UP: for (int i = (int)startpos.y; i < boundCol; i++) { dirs.Add(new Vector2(startpos.x, (float)i)); } break; case MotionDirection.DOWN: for (int i = (int)startpos.y; i > -1; i--) { dirs.Add(new Vector2(startpos.x, (float)i)); } break; } for (int i = 1; i < dirs.Count; i++) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript [(int)dirs[i].x, (int)dirs[i].y]; if (tmp != null) { if (i < 4) { int random = Random.Range(6, 8); Supporter.sp.SpawnJewelPower(tmp.jewel.JewelType, random, tmp.jewel.JewelPosition, true); } else { tmp.Destroy(); } } } yield return(new WaitForSeconds(1f)); GameController.action.dropjewel(); }
private void hammerSelect() { if (Input.GetMouseButtonUp(0) && (isDoHammer || isExChange || isMagic)) { //锤子道具销毁宝石 if (isDoHammer) { GameObject pointer = JewelTouchChecker(Input.mousePosition); if (pointer != null) { JewelObj JewelScript = pointer.GetComponent <JewelObj>(); Supporter.sp.StopSuggestionAnim(); if (JewelScript != null && JewelScript.jewel.JewelType != 99) { JewelScript.Destroy(); dropjewel(); } } } //魔法道具 if (isMagic) { GameObject pointer = JewelTouchChecker(Input.mousePosition); if (pointer != null) { JewelObj JewelScript = pointer.GetComponent <JewelObj>(); Supporter.sp.StopSuggestionAnim(); if (JewelScript != null && JewelScript.jewel.JewelType != 99) { Vector3 v = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y); StartCoroutine(SpawnJewelPower(JewelScript.jewel.JewelType, (int)Power.BOOM, v)); } } } #if IPHONE || ANDROID if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) #else if (EventSystem.current.IsPointerOverGameObject()) #endif { //点击UI if (EventSystem.current.currentSelectedGameObject == null || !EventSystem.current.currentSelectedGameObject.name.Contains("prop_")) { Debug.Log("---点击UI 不为道具"); isDoHammer = false; isExChange = false; isMagic = false; prop_bg.SetActive(false); JewelSpawner.spawn.transform.position = new Vector3(0, 0, 0); JewelSpawner.spawn.transform.SetAsLastSibling(); } } } }
IEnumerator Endgame() { GameController.action.dropjewel(); yield return(new WaitForSeconds(2f)); int movesLeft = GameController.action.MoveLeft; int spawnPerMove = 2; int[] validPowers = new int[] { 6, //STRIPED_VERTICAL 7, //STRIPED_HORIZONTAL 5, //WRAPPER }; int availableSlots = NormalJewelCount(); //measure to prevent stack overflow.Happens when there is no more available jewel for (int i = 0; i < movesLeft; i++) { for (int j = 0; j < spawnPerMove; j++) { if (availableSlots > 0) //measure to prevent stack overflow { Vector2 location = GetRandomLocation(); int rand = Random.Range(0, validPowers.Length); Supporter.sp.SpawnJewelPower(JewelSpawner.spawn.JewelGribScript [(int)location.x, (int)location.y].jewel.JewelType, validPowers[rand], location, true); availableSlots--; } } yield return(new WaitForSeconds(0.5f)); } yield return(new WaitForSeconds(2f)); for (int x = 0; x < GameController.WIDTH; x++) { for (int y = 0; y < GameController.HEIGHT; y++) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y]; if (tmp != null && tmp.jewel != null) { if (tmp.jewel.JewelPower != 0) { tmp.Destroy(); yield return(new WaitForSeconds(0.5f)); } } } } yield return(new WaitForSeconds(1.5f)); Timer.timer.Win(); }
public IEnumerator DestroyAdjacentJewel_Again(Vector2 jewelPos) { yield return(new WaitForSeconds(GameController.DROP_DELAY + 1.5f)); JewelObj obj = JewelSpawner.spawn.JewelGribScript[(int)jewelPos.x, (int)jewelPos.y]; DestroyAdjacentJewel(obj, false); if (obj != null) { obj.Destroy(); } GameController.action.dropjewel(); }
//Destroy a specific type of jewel IEnumerator DestroyJewelType(int type) { for (int x = 0; x < GameController.WIDTH; x++) { for (int y = 0; y < GameController.HEIGHT; y++) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y]; if (tmp != null && tmp.jewel.JewelType == type) { EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.jewel.JewelPosition.x, (int)tmp.jewel.JewelPosition.y].transform.position); tmp.Destroy(); yield return(new WaitForSeconds(0.1f)); } } } GameController.action.dropjewel(); }
// 随机消除一个宝石 public void DestroyRandom() { //uu tien destroy ganh dropjewel();// 开启下落检查 // 如果是街机模式 if (PLayerInfo.MODE == 1) { // 如果没有星星宝石 if (!isStar) { // 获取有特效的格子列表 List <CellObj> listeff = getListCellEffect(); // 如果有这样的格子 if (listeff.Count > 0) { // 从列表中随机获取一个格子 CellObj tmp = listeff[Random.Range(0, listeff.Count)]; // 播放并移除特效 tmp.RemoveEffect(); // 播放火球特效 EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.cell.CellPosition.x, (int)tmp.cell.CellPosition.y].transform.position); } else { // 从特殊格子中随机一个消除 destroynotempty(); } } else { // 星星下方随机一个图块坐标 Vector2 vtmp = posUnderStar(); // 根据坐标获取宝石对象 JewelObj tmp = JewelSpawner.spawn.JewelGribScript[(int)vtmp.x, (int)vtmp.y]; // 如果该宝石对象不为空且不是星星宝石 if (tmp != null && tmp != JewelStar) { // 销毁该对象 tmp.Destroy(); // 播放火球特效 EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.jewel.JewelPosition.x, (int)tmp.jewel.JewelPosition.y].transform.position); } } } }
//Destroy all stripes IEnumerator ActivateStripes(float delay) { yield return(new WaitForSeconds(delay)); for (int x = 0; x < GameController.WIDTH; x++) { for (int y = 0; y < GameController.HEIGHT; y++) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y]; if (tmp != null) { if (tmp.jewel.JewelPower == 6 || tmp.jewel.JewelPower == 7) { tmp.Destroy(); } } } } }
IEnumerator DestroyType(int type, Vector3 pos) { NoSelect.SetActive(true); dropjewel(); for (int x = 0; x < 7; x++) { for (int y = 0; y < 9; y++) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript[x, y]; if (tmp != null && tmp.jewel.JewelType == type) { EffectSpawner.effect.MGE(pos, JewelSpawner.spawn.JewelGrib[x, y].transform.position); tmp.Destroy(); } } } yield return(new WaitForSeconds(0.2f)); NoSelect.SetActive(false); }
IEnumerator ComboWrapped_Wrapped(Vector2 centerPos) { Vector2[] directions = Supporter.sp.GetAdjacentVectors_x2(centerPos); JewelObj centerPosJewelObj = JewelSpawner.spawn.JewelGribScript [(int)centerPos.x, (int)centerPos.y]; foreach (Vector2 direction in directions) { if (Supporter.sp.CheckOutOfBounds(direction)) { JewelObj tmp = JewelSpawner.spawn.JewelGribScript [(int)direction.x, (int)direction.y]; if (tmp != null && tmp.jewel != null) { tmp.Destroy(); } } } Supporter.sp.Boom(centerPosJewelObj.transform.position); yield return(new WaitForSeconds(3f)); GameController.action.dropjewel(); }