public bool __Gen_Delegate_Imp0(BubbleScript p0, float p1) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.rawL; int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference); ObjectTranslator translator = luaEnv.translator; translator.Push(L, p0); LuaAPI.lua_pushnumber(L, p1); PCall(L, 2, 1, errFunc); bool __gen_ret = LuaAPI.lua_toboolean(L, errFunc + 1); LuaAPI.lua_settop(L, errFunc - 1); return(__gen_ret); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
void OnTriggerEnter2D(Collider2D bubble) { if (GetComponent <Rigidbody2D>().gravityScale <= 0) { BubbleScript bubbleScript = bubble.gameObject.GetComponent <BubbleScript> (); if (bubbleScript != null) { if (bubbleScript.isMinusBubble) { var_player_power_hold_time = player_power_hold_time; Helper.show_power_time = true; Helper.power_hold_time_disp = var_player_power_hold_time; bubble_collided = minus_bubble; increasePlayerSize(); } if (bubbleScript.isPlusBubble) { var_player_power_hold_time = player_power_hold_time; Helper.show_power_time = true; Helper.power_hold_time_disp = var_player_power_hold_time; bubble_collided = plus_bubble; decreasePlayerSize(); } if (bubbleScript.isShieldBubble) { var_player_shield_hold_time = player_shield_hold_time; Helper.show_power_time = true; Helper.power_hold_time_disp = var_player_shield_hold_time; bubble_collided = shield_bubble; isShieldPresent = true; } } Destroy(bubble.gameObject); } Debug.Log("bubble name: " + bubble.ToString()); }
public void CheckSwapBubble() { if (_gamePhase != eGamePhase.PLAYER_TURN || _pressdBubble == null) { return; } Ray ray = UICamera.currentCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 10f, _bubbleLayerMask)) { BubbleScript bubble = hit.collider.gameObject.GetComponent <BubbleScript>(); if (bubble == null) { return; } if (bubble.TargetMapTile.IsNearbyMapTile(_pressdBubble.TargetMapTile) == true) { if (SwapBubble(_pressdBubble, bubble) == true) { BubbleSwap(_pressdBubble, bubble); OnClickBubble(null, false); } else { _missSwap = eMissAniPhase.Begin; BubbleSwap(_pressdBubble, bubble); _swapTargetBubble = bubble; _swapSourceBubble = _pressdBubble; } _gamePhase = eGamePhase.UPDATE_BUBBLE; } } }
void MakeUselessBubbles() { for (int i = 0; i < _liveBubbleList.Count; ++i) { _liveBubbleList[i].transform.localPosition = new Vector3(10000f, 0, 0); _uselessBubbles.Enqueue(_liveBubbleList[i]); _liveBubbleList[i].ClearBubble(); } _liveBubbleList.Clear(); int createItemCount = TileWidth * TileHeight - _uselessBubbles.Count; for (int i = 0; i < createItemCount; ++i) { GameObject bubbleObj = Instantiate(_bubbleRes) as GameObject; bubbleObj.transform.parent = _bubblePanel.transform; bubbleObj.transform.localScale = Vector3.one; bubbleObj.transform.localPosition = new Vector3(10000f, 0, 0); BubbleScript bubble = bubbleObj.GetComponent <BubbleScript>(); _uselessBubbles.Enqueue(bubble); bubble.Init(); } }
void MergeBubbles() { if (!IsMovingToMergeBubble) { BubblesToMove.Clear(); BubbleScript.BubbleValue targetValue = CurrentBubbleValue; BubblesToMove.Add(BubbleToMergeInto); bool FirstCheck = BubbleToMergeInto.GetNeighBorsOfvalue(targetValue, ref BubblesToMove); if (FirstCheck) { for (int i = 0; i < BubblesToMove.Count; i++) { BubblesToMove[i].GetNeighBorsOfvalue(targetValue, ref BubblesToMove); } BubbleToMergeInto = BubblesToMove[BubblesToMove.Count - 1]; if ((int)(BubbleToMergeInto.ThisValue) + BubblesToMove.Count >= (int)BubbleScript.BubbleValue.Count) { BubblesToMove.Remove(BubbleToMergeInto); BubblesToMove.TrimExcess(); IsMovingToMergeBubble = true; } else { int NewNearbyMerges = 0; for (int i = 0; i < BubblesToMove.Count; i++) { List <BubbleScript> valid = new List <BubbleScript>(); BubblesToMove[i].GetNeighBorsOfvalue((BubbleScript.BubbleValue)((int)(BubbleToMergeInto.ThisValue) + BubblesToMove.Count - 1), ref valid); if (valid.Count > NewNearbyMerges) { NewNearbyMerges = valid.Count; BubbleToMergeInto = BubblesToMove[i]; } } BubblesToMove.Remove(BubbleToMergeInto); BubblesToMove.TrimExcess(); IsMovingToMergeBubble = true; } } else { currentState = ShootState.RemovingfloatingBubbles; } } else { bool allArrived = true; for (int i = 0; i < BubblesToMove.Count; i++) { if (!BubbleToMergeInto.transform.position.Equals(BubblesToMove[i].transform.position)) { allArrived = false; BubblesToMove[i].transform.position = Vector3.MoveTowards(BubblesToMove[i].transform.position, BubbleToMergeInto.transform.position, BubbleSpeed * Time.deltaTime * 5); } } if (allArrived) { if ((int)(BubbleToMergeInto.ThisValue) + BubblesToMove.Count >= (int)BubbleScript.BubbleValue.Count) { BubbleToMergeInto.SetValue(BubbleScript.BubbleValue.TwoK); } else { BubbleToMergeInto.SetValue((BubbleScript.BubbleValue)((int)BubbleToMergeInto.ThisValue + BubblesToMove.Count)); } if (BubbleToMergeInto.ThisValue == BubbleScript.BubbleValue.TwoK) { for (int i = 0; i < BubblesToMove.Count; i++) { BubblesToMove[i].Pop(); } SetNeighborBubbles(); BubbleToMergeInto.Explode(); currentState = ShootState.RemovingfloatingBubbles; IsMovingToMergeBubble = false; } else { for (int i = 0; i < BubblesToMove.Count; i++) { BubblesToMove[i].Pop(); } BubblesToMove.Clear(); if (BubbleToMergeInto.GetNeighBorsOfvalue(BubbleToMergeInto.ThisValue, ref BubblesToMove)) { IsMovingToMergeBubble = false; CurrentBubbleValue = BubbleToMergeInto.ThisValue; } else { currentState = ShootState.RemovingfloatingBubbles; IsMovingToMergeBubble = false; } } } } }
public void AddBubbleToGlobalList(BubbleScript b) { allBubbles.Add(b); }
public bool CheckExistBubbleFusionList(BubbleScript b) { return(bubblesToFusion.Contains(b)); }
public void AddBubbleFusionList(BubbleScript b) { bubblesToFusion.Add(b); }
bool checksurround(GameObject core) { int val = 0; while (true) { BubbleScript bs = core.GetComponent <BubbleScript>(); for (var i = 0; i < 8; i++) { Vector2 dir = Vector2.zero; switch (i) { case 0: dir = Vector2.up; break; case 1: dir = Vector2.down; break; case 2: dir = Vector2.left; break; case 3: dir = Vector2.right; break; case 4: dir = Vector2.up + Vector2.right; break; case 5: dir = Vector2.up + Vector2.left; break; case 6: dir = Vector2.down + Vector2.right; break; case 7: dir = Vector2.down + Vector2.left; break; default: Debug.Log("Something went wrong here"); break; } var bbm = Physics2D.OverlapCircle((Vector2)core.transform.position + dir, 0.3f, _bubbleMask); if (bbm != null) { if (!Bubbles.Contains(bbm.gameObject)) { if (bbm.GetComponent <BubbleScript>().TypeID == bs.TypeID) { Bubbles.Add(bbm.gameObject); } } } } if (Bubbles.Count - 1 > val) { val++; core = Bubbles[val]; } else { if (Bubbles.Count > 3) { for (var i = 0; i < Bubbles.Count; i++) { GameObject sprk = Instantiate(SparklePrefab); sprk.transform.position = Bubbles[i].transform.position; Sparkles.Add(sprk); } return(true); } if (Bubbles.Count < 3) { //prevent a lockout Active = false; for (var del = 0; del < 3; del++) { Destroy(GameObject.FindGameObjectsWithTag("Bubbles")[0]); } return(true); } } } }
private void OnNewBubbleConnected() { AudioManager.Instance.Play(SoundList.Connect, Random.Range(0.9f, 1.2f)); UpdateDisconnectedBubbles(); if (IsLastRowHasBubble()) { GameController.Instance.GameOver(); return; } UpdateBubblesPosition(); //- Merge bubbles CheckMatchesForBubbles(_newBubble); //make a tmp copy var initialList = new List <BubbleScript>(this._matchBubblesList); this._matchBubblesList.Clear(); if (initialList.Count < 2) { if (shouldAddNewLine) { AddNewLine(null); } Subscribe(); return; } AudioManager.Instance.Play(SoundList.Merge, Random.Range(1.3f, 1.5f)); var startType = _newBubble.currentType; var newType = GameController.Instance.GetNewTypeIndex(startType, initialList.Count); var targetIndex = -1; var maxBubble = 1; for (var i = 0; i < initialList.Count; i++) { var b = initialList[i]; b.SetType(newType, false); CheckMatchesForBubbles(b); var possibility = new List <BubbleScript>(this._matchBubblesList); this._matchBubblesList.Clear(); if (possibility.Count > maxBubble) { maxBubble = possibility.Count; targetIndex = i; //store the index of the biggest Possibility! } b.SetType(startType, false); } _matchBubblesList.Clear(); BubbleScript finalBubble = null; var index = 0; _nbCombo++; if (_nbCombo > 1) { var comboPitch = 1f; switch (_nbCombo) { case 2: comboPitch = Random.Range(0.9f, 1.1f); break; case 3: comboPitch = Random.Range(1.2f, 1.4f); break; case 4: comboPitch = Random.Range(1.5f, 1.7f); break; default: comboPitch = Random.Range(1.5f, 1.7f); break; } AudioManager.Instance.Play(SoundList.Combo, comboPitch); } if (targetIndex == -1) { //- highest bubble Then biggest neighbors count switch (GameController.Instance.mergeBehaviour) { case MergeBubbleBehaviours.Highest_Bubble: finalBubble = initialList.FirstOrDefault(bubble => bubble.neighbors.GetEnabledNeighborsList().Count == initialList.Max(b => b.neighbors.GetEnabledNeighborsList().Count) ); break; case MergeBubbleBehaviours.Biggest_Neighbors_Count: finalBubble = initialList.FirstOrDefault(bubble => bubble.neighbors.GetEnabledNeighborsList().Count == initialList.Max(b => b.neighbors.GetEnabledNeighborsList().Count) ); break; case MergeBubbleBehaviours.Highest_Bubble_Then_Biggest_Neighbors_Count: var topBubbles = initialList.Where( bubble => bubble.gridPosition.rows == initialList.Min(b => b.gridPosition.rows) ).ToList(); finalBubble = topBubbles.FirstOrDefault(bubble => bubble.neighbors.GetEnabledNeighborsList().Count == topBubbles.Max(b => b.neighbors.GetEnabledNeighborsList().Count) ); break; case MergeBubbleBehaviours.Biggest_Neighbors_Count_Then_Highest_Bubble: var biggestNeighbors = initialList.Where( bubble => bubble.neighbors.GetEnabledNeighborsList().Count == initialList.Max(b => b.neighbors.GetEnabledNeighborsList().Count) ).ToList(); finalBubble = biggestNeighbors.FirstOrDefault( bubble => bubble.gridPosition.rows == biggestNeighbors.Min(b => b.gridPosition.rows) ); break; } if (finalBubble == null) { throw new Exception("Error : final bubble is null !"); } finalBubble.ConvertToNewType(newType, OnConnectAfterMerge); foreach (var b in initialList) { if (b == finalBubble) { continue; } index++; if (index >= 5) { b.Explode(false); } else { b.MoveToAndExplode(finalBubble.gameObject.transform.position); } } } else { finalBubble = initialList[targetIndex]; finalBubble.ConvertToNewType(newType, OnConnectAfterMerge); foreach (var b in initialList) { if (b == finalBubble) { continue; } index++; if (index >= 5) { b.Explode(false); } else { b.MoveToAndExplode(finalBubble.gameObject.transform.position); } } } }
void Awake() { Instance = this; text = GameObject.Find("BubbleText").GetComponent<Text>(); }
// Start is called before the first frame update void Start() { speachBubble = this; }
void ChainBomb(BubbleScript bubble) { MapTile t = null; MapTile rt = null; MapTile rb = null; MapTile b = null; MapTile lb = null; MapTile lt = null; if (bubble.GetChainBombCount(eTileDir.Top) >= MatchBubbleCount) { t = bubble.TargetMapTile.GetNearbMapTile(eTileDir.Top); } if (bubble.GetChainBombCount(eTileDir.RightTop) >= MatchBubbleCount) { rt = bubble.TargetMapTile.GetNearbMapTile(eTileDir.RightTop); } if (bubble.GetChainBombCount(eTileDir.RightBottom) >= MatchBubbleCount) { rb = bubble.TargetMapTile.GetNearbMapTile(eTileDir.RightBottom); } if (bubble.GetChainBombCount(eTileDir.Bottom) >= MatchBubbleCount) { b = bubble.TargetMapTile.GetNearbMapTile(eTileDir.Bottom); } if (bubble.GetChainBombCount(eTileDir.LeftBottom) >= MatchBubbleCount) { lb = bubble.TargetMapTile.GetNearbMapTile(eTileDir.LeftBottom); } if (bubble.GetChainBombCount(eTileDir.LeftTop) >= MatchBubbleCount) { lt = bubble.TargetMapTile.GetNearbMapTile(eTileDir.LeftTop); } if (t == null && rt == null && rb == null && b == null && lb == null && lt == null) { return; } bubble.ClearBubble(); bubble.transform.localPosition = new Vector3(10000f, 0f, 0f); _liveBubbleList.Remove(bubble); _uselessBubbles.Enqueue(bubble); if (t != null && t.TargetBubble != null) { ChainBomb(t.TargetBubble); } if (rt != null && rt.TargetBubble != null) { ChainBomb(rt.TargetBubble); } if (rb != null && rb.TargetBubble != null) { ChainBomb(rb.TargetBubble); } if (b != null && b.TargetBubble != null) { ChainBomb(b.TargetBubble); } if (lb != null && lb.TargetBubble != null) { ChainBomb(lb.TargetBubble); } if (lt != null && lt.TargetBubble != null) { ChainBomb(lt.TargetBubble); } }