コード例 #1
0
ファイル: UIFightBall.cs プロジェクト: tuyiherizon/XiaoChu2
    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();
    }
コード例 #2
0
ファイル: UIFightBox.cs プロジェクト: tuyiherizon/XiaoChu2
    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();
    }