public void BombMoveTo(UIFightBall targetBall) { _BombTargetPos = targetBall.transform.position; Vector2 curPos = _FightBallAnchor.transform.position; _BombMoveVec = _BombTargetPos - curPos; }
public void ExChangeBalls(UIFightBall ballA, UIFightBall ballB) { _TestMode = false; _LastMoveTime = Time.time; if (!ballA.BallInfo.IsCanMove() || !ballB.BallInfo.IsCanMove()) { return; } StarAnim(); iTween.MoveTo(ballA._FightBallAnchor.gameObject, ballB.transform.position, _ExchangeBallTime); iTween.MoveTo(ballB._FightBallAnchor.gameObject, ballA.transform.position, _ExchangeBallTime); StartCoroutine(AnimEnd(ballA, ballB)); PlayMoveSound(); UIGuide.HideGuide(); }
public void Exchange(UIFightBall otherBall) { var temp = otherBall._FightBallAnchor; otherBall._FightBallAnchor = _FightBallAnchor; _FightBallAnchor = temp; var tempNormal = otherBall._NormalBallInfo; otherBall._NormalBallInfo = _NormalBallInfo; _NormalBallInfo = tempNormal; var tempSp = otherBall._SPBallInfo; otherBall._SPBallInfo = _SPBallInfo; _SPBallInfo = tempSp; otherBall.ResetRoot(); ResetRoot(); }
public IEnumerator AnimEnd(UIFightBall ballA, UIFightBall ballB) { yield return(new WaitForSeconds(_ExchangeBallTime + 0.1f)); //iTween.Stop(); BallBox.Instance.MoveBall(ballA.BallInfo, ballB.BallInfo); //ballA.Exchange(ballB); ballA.ResetRoot(); ballB.ResetRoot(); ballA.ShowBall(); ballB.ShowBall(); var moveList = new List <BallInfo>() { ballA.BallInfo, ballB.BallInfo }; var elimitBalls = BallBox.Instance.CheckNormalEliminate(moveList); var spElimitMove = BallBox.Instance.CheckSpMove(moveList); var spElimitElimit = BallBox.Instance.CheckSpElimit(elimitBalls); var exploreBalls = BallBox.Instance.CurrentElimitnate(); var afterElimit = BallBox.Instance.AfterElimitnate(); BallBox.AddBallInfos(elimitBalls, spElimitMove); BallBox.AddBallInfos(elimitBalls, spElimitElimit); BallBox.AddBallInfos(elimitBalls, exploreBalls); BallBox.AddBallInfos(elimitBalls, afterElimit); if (elimitBalls.Count == 0) { iTween.MoveTo(ballA._FightBallAnchor.gameObject, ballB.transform.position, _ExchangeBallTime); iTween.MoveTo(ballB._FightBallAnchor.gameObject, ballA.transform.position, _ExchangeBallTime); yield return(new WaitForSeconds(_ExchangeBallTime + 0.1f)); BallBox.Instance.MoveBack(ballA.BallInfo, ballB.BallInfo); //ballA.Exchange(ballB); ballA.ResetRoot(); ballB.ResetRoot(); ballA.ShowBall(); ballB.ShowBall(); EndAnim(); yield break; } else { do { float elimitAnimTime = 0; AudioClip elimitSound = _ElimitAudio; FIGHT_SOUND_TYPE soundLevel = FIGHT_SOUND_TYPE.ELIMIT; foreach (var elimitBall in elimitBalls) { bool isContentBomb = false; if (!elimitBall._IsBoomSP) { foreach (var optBombInfo in BallBox.Instance._CurrentOptExtra) { if (optBombInfo._OptBall == elimitBall) { isContentBomb = true; break; } foreach (var bombElimitBall in optBombInfo._ElimitBalls) { if (bombElimitBall == elimitBall) { isContentBomb = true; break; } } if (isContentBomb) { break; } } } var uiBall = GetBallUI(elimitBall); if (uiBall.IsSPBallBomb()) { elimitSound = _BombAudio; soundLevel = FIGHT_SOUND_TYPE.BOMB; } else if (soundLevel < FIGHT_SOUND_TYPE.LINE && uiBall.IsSPBallLine()) { elimitSound = _LineAudio; soundLevel = FIGHT_SOUND_TYPE.LINE; } else if (soundLevel < FIGHT_SOUND_TYPE.COMBINE && BallBox.Instance._CurrentOptExtra.Count > 0) { elimitSound = _CombineAudio; soundLevel = FIGHT_SOUND_TYPE.COMBINE; } if (isContentBomb) { continue; } var elimitT = uiBall.Elimit(); if (elimitT > elimitAnimTime) { elimitAnimTime = elimitT; } } PlayerUISound(elimitSound, 1); StartCoroutine(BombCreateAnim()); yield return(new WaitForSeconds(elimitAnimTime + _ElimitBallTime)); BallBox.Instance.ClearElimitInfo(); foreach (var elimitBall in elimitBalls) { var uiBall = GetBallUI(elimitBall); uiBall.ShowBall(); } yield return(new WaitForSeconds(_ElimitBallTime)); UIFightBattleField.ShowElimitInfo(); var fillingTime = Filling(); yield return(new WaitForSeconds(fillingTime)); List <BallInfo> checkBalls = new List <BallInfo>(); BallBox.AddBallInfos(checkBalls, _FillingBalls); BallBox.AddBallInfos(checkBalls, exploreBalls); elimitBalls = BallBox.Instance.CheckNormalEliminate(); //elimitBalls = BallBox.Instance.CheckNormalEliminate(); var spSubElimitBalls = BallBox.Instance.CheckSpElimit(elimitBalls); exploreBalls = BallBox.Instance.CurrentElimitnate(); var subafterElimit = BallBox.Instance.AfterElimitnate(); BallBox.AddBallInfos(elimitBalls, spSubElimitBalls); BallBox.AddBallInfos(elimitBalls, exploreBalls); BallBox.AddBallInfos(elimitBalls, subafterElimit); }while (elimitBalls.Count > 0); } var reShowList = BallBox.Instance.RoundEnd(); if (reShowList != null && reShowList.Count > 0) { foreach (var elimitBall in reShowList) { var uiBall = GetBallUI(elimitBall); uiBall.ShowBall(); } } var eliminate = BallBox.Instance.FindPowerEliminate(); if (eliminate == null) { Debug.Log("No eliminate!!!"); yield return(new WaitForSeconds(1)); int refreshTimes = 0; while (eliminate == null) { if (refreshTimes < 2) { RefreshNormal(); } else { BallBox.Instance.RefreshNormalForElimit(false); UpdateBalls(); } ++refreshTimes; eliminate = BallBox.Instance.FindPowerEliminate(); } } //ShowElimit(); EndAnim(); }
public void InitBox(int x, int y) { _BoxWidth = x; _BoxLength = y; _FightBox.constraint = GridLayoutGroup.Constraint.FixedColumnCount; _FightBox.constraintCount = x; _BallInfos = new UIFightBall[x][]; for (int i = 0; i < x; ++i) { _BallInfos[i] = new UIFightBall[y * 2]; for (int j = 0; j < y * 2; ++j) { GameObject ballGO = GameObject.Instantiate(_BallPrefab.gameObject); UIFightBall ballInfo = ballGO.GetComponentInChildren <UIFightBall>(); ballGO.transform.SetParent(_FightBox.transform); ballGO.transform.localScale = Vector3.one; var localPos = GetBallPosByIdx(0, 0, i, j); ballGO.transform.localPosition = localPos; _BallInfos[i][j] = ballInfo; _BallInfos[i][j]._Pos = new Vector2(i, j); _BallInfos[i][j].SetFightBox(this); if (j < y) { ballGO.gameObject.SetActive(true); var bgGO = GameObject.Instantiate(_BallBGPrefab); bgGO.gameObject.SetActive(true); bgGO.transform.SetParent(_BallBGBox.transform); bgGO.transform.position = ballGO.transform.position; bgGO.transform.localScale = Vector3.one; } else { ballGO.gameObject.SetActive(false); } } } _BoxBGBounderBottom.sizeDelta = new Vector2(_BallWidth * x, _BoxBGBounderBottom.sizeDelta.y); _BoxBGBounderBottom.localPosition = _BallInfos[0][0].transform.localPosition - new Vector3(_BallWidth * 0.5f, _BallHeight * 0.5f, 0); _BoxBGBounderLeft.sizeDelta = new Vector2(_BallHeight * y, _BoxBGBounderLeft.sizeDelta.y); _BoxBGBounderLeft.localPosition = _BallInfos[0][(int)_BoxLength - 1].transform.localPosition + new Vector3(-_BallWidth * 0.5f, _BallHeight * 0.5f, 0); _BoxBGBounderRight.sizeDelta = new Vector2(_BallHeight * y, _BoxBGBounderRight.sizeDelta.y); _BoxBGBounderRight.localPosition = _BallInfos[(int)_BoxWidth - 1][0].transform.localPosition + new Vector3(_BallWidth * 0.5f, -_BallHeight * 0.5f, 0); for (int j = 0; j < _BoxLength; ++j) { for (int i = 0; i < _BoxWidth; ++i) { _BallInfos[i][j].SetBallInfo(BallBox.Instance._BallBoxInfo[i][j]); _BallInfos[i][j].ShowBall(); } } }