void OnTriggerEnter2D(Collider2D collision) { // Debug.Log(collision.name); if (!coliderWithWall(collision.gameObject.name) && collision.tag.Equals("Bubble")) { if (collision.gameObject.GetComponent <Bubble>().state == STATE_BUBBLE_SHOOT) { if (isMoveThrough) { destroyAfterAnim(); LevelManager.bubbleList.Remove(this.gameObject); // Debug.Log("bbb :"+LevelManager.bubbleList.Count); LevelManager.bubbleTableArray[indexY, indexX] = null; } else if (value == BubbleType.BUBBLE_TYPE_SPECIAL_ROCK)//41 // cuc da. rot nhanh { destroyAfterAnim(); LevelManager.bubbleList.Remove(this.gameObject); LevelManager.bubbleTableArray[indexY, indexX] = null; LevelManager.speedOffSet = LevelManager.SPEED_OFFSET_DOWN; BubbleListParent.speedY = LevelManager.speedOffSet; LevelManager.moveOffSet = 0; // Bubble bubble = collision.gameObject.GetComponent<Bubble>(); // bubble.destroyAfterAnim(); // BubbleListParent.setLastObject(); } } else if (state == STATE_BUBBLE_SHOOT)//boom xuyen phai xet vi no se ko goi lai colider de check { SoundEngine.getInstance().PlayOneShot(SoundEngine.getInstance()._soundDestroy); Bubble bubble = collision.gameObject.GetComponent <Bubble>(); bubble.destroyAfterAnim(); LevelManager.bubbleList.Remove(bubble.gameObject); LevelManager.bubbleTableArray[bubble.indexY, bubble.indexX] = null; LevelManager.FindAllBubbleDrop(); BubbleListParent.setLastObject(); Debug.Log("Day ne 1111111111111"); if (LevelManager.checkWin()) { BubbleDrop(); } } } }
//lastObject void CheckCollisionEnter2D(Collision2D collision) { isPlaySpecial = false; Effect.CountBeginBubble(LevelManager.currentBubble.transform.position.y); calIndexXY(); // se nhan dc indexx va index y ung voi so o trong bang state = STATE_BUBBLE_IDE; LevelManager.currentBubble.layer = 0; // da dinh tren do GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); if (value == BubbleType.BUBBLE_TYPE_SHOOT_FROZEN) { SoundEngine.getInstance().PlayOneShot(SoundEngine.getInstance()._soundPush); GameObject.Destroy(this.gameObject); GamePlay.instance.effectIce.anim.Play("Effect_ICE_BEGIN"); LevelManager.isMoveWall = false; Effect.timeIceEffect = 0; // BubbleListParent.setLastObject(); //return; } else if (value == BubbleType.BUBBLE_TYPE_SHOOT_BOOM_CICLE) { GameObject.Destroy(this.gameObject); GamePlay.instance.effectSpecial.anim.Play("Effect_BOOM"); LevelManager.DestroyAllNeighborsWhenBoom(indexY, indexX); GamePlay.instance.effectSpecial.anim.transform.parent.transform.position = transform.position; isPlaySpecial = true; SoundEngine.getInstance().PlayOneShot(SoundEngine.getInstance()._soundBoom); } else { LevelManager.bubbleTableArray[indexY, indexX] = GetComponent <Bubble>(); // LevelManager.currentBubble.GetComponent<Bubble>(); //LevelManager.currentBubble.transform.parent = GamePlay.instance.BubbleListParentObject.transform; //LevelManager.currentBubble.rigidbody2D.isKinematic = true; //if (LevelManager.currentBubble != null) // LevelManager.bubbleList.Add(LevelManager.currentBubble); transform.parent = GamePlay.instance.BubbleListParentObject.transform; GetComponent <Rigidbody2D>().isKinematic = true; LevelManager.bubbleList.Add(this.gameObject); LevelManager.AllBubbleStickEffect(); if (LevelManager.bubbleTableArray[indexY, indexX].value == BubbleType.BUBBLE_TYPE_SHOOT_MATCH_1) { GetNearBubbleWhenRaiwBound1(indexY, indexX); bool isOK = true; for (int i = 0; i < LevelManager.bubbleListEffect.size; i++) { LevelManager.setDefauldBeforeCheck(); if (LevelManager.getAllNeighborsSameValue(LevelManager.bubbleListEffect[i])) { LevelManager.bubbleListNeighboursSameValue.Remove(LevelManager.bubbleTableArray[indexY, indexX]); isOK = false; LevelManager.checkSetAnimDestroyAllMatch2(); } } if (!isOK) { //LevelManager.bubbleList.Remove(LevelManager.currentBubble); LevelManager.bubbleList.Remove(this.gameObject); LevelManager.bubbleTableArray[indexY, indexX].destroyAfterAnim(); LevelManager.bubbleTableArray[indexY, indexX] = null; } } else if (LevelManager.bubbleTableArray[indexY, indexX].value == BubbleType.BUBBLE_TYPE_SHOOT_MATCH_2) { if (collision.gameObject.tag.Equals("Bubble")) { GetAllBubbleWhenRaiwBound2(collision.gameObject.GetComponent <Bubble>().value); LevelManager.bubbleListNeighboursSameValue.Add(LevelManager.bubbleTableArray[indexY, indexX]); LevelManager.checkSetAnimDestroyAllMatch2(); } if (LevelManager.bubbleTableArray[indexY, indexX] != null) { LevelManager.bubbleList.Remove(this.gameObject); LevelManager.bubbleTableArray[indexY, indexX].destroyAfterAnim(); LevelManager.bubbleTableArray[indexY, indexX] = null; } } else if (LevelManager.getAllNeighborsSameValue(this.gameObject)) { //SoundEngine.playSound("SoundMatch"); LevelManager.checkSetAnimDestroyAllMatch2(); } else { //if(value == BubbleType.BUBBLE_TYPE_SHOOT_FROZEN) BubbleListParent.setLastObject(this.gameObject); // animScore.Play("BUBBLE_ANIM_STICK"); //LevelManager.AllBubbleStickEffect(); SoundEngine.getInstance().PlayOneShot(SoundEngine.getInstance()._soundStick); PlayeBubbleEffect(collision.gameObject.GetComponent <Bubble>()); //setPos(); } } //Debug.Log(LevelManager.bubbleList.size); LevelManager.FindAllBubbleDrop(); BubbleListParent.setLastObject(); Effect.PlayEffectText(); if (LevelManager.bubbleList.size > 0) { LevelManager.getBubbleListStillAliveIndex(); // LevelManager.createNewBubble(); } // Debug.Log("Day ne 22222222222222222222"); LevelManager.checkWin(); setPos(); }