Exemplo n.º 1
0
    void CheckAddFenShuToPlayer(GameObject obj)
    {
        if (obj == null)
        {
            return;
        }

        SSBall ball = obj.GetComponent <SSBall>();

        if (ball != null)
        {
            SSGlobalData.PlayerEnum indexPlayer = ball.GetBallPlayerIndex();
            if (indexPlayer != SSGlobalData.PlayerEnum.Null && m_DaoJuData != null)
            {
                SSGlobalData.GetInstance().AddPlayerFenShu(indexPlayer, m_DaoJuData.FenShu);
                if (SSGameMange.GetInstance() != null && SSGameMange.GetInstance().m_SSGameScene != null)
                {
                    SSGameMange.GetInstance().m_SSGameScene.RemoveDaoJu(gameObject);
                }

                if (SSGameMange.GetInstance() != null && SSGameMange.GetInstance().m_SSGameUI != null)
                {
                    SSGameMange.GetInstance().m_SSGameUI.CreateDaoJuJiaFenUI(indexPlayer, m_DaoJuData.FenShu);
                }
                CreateTeXiao();
                RemoveSelf();
            }
        }
    }
    void RemoveSelf()
    {
        if (SSGameMange.GetInstance() == null ||
            SSGameMange.GetInstance().m_SSGameUI == null ||
            SSGameMange.GetInstance().m_SSGameScene == null)
        {
            return;
        }

        if (IsRemoveSelf == false)
        {
            IsRemoveSelf = true;
            Destroy(gameObject);
            SSGameMange.GetInstance().m_SSGameUI.ResetInfo();
            SSGameMange.GetInstance().m_SSGameUI.RemoveGameDaoJiShi();
            //游戏结束
            SSGameMange.GetInstance().m_SSGameScene.OnGameOver();

            //展示玩家获胜/失败/平局UI界面
            SSGameMange.GetInstance().m_SSGameUI.ShowPlayerGameRaceResult();

            //关闭镜头跟踪
            SSGameMange.GetInstance().m_SSGameScene.SetIsMoveCamera(false);
        }
    }
    /// <summary>
    /// 发射曲棍球
    /// </summary>
    void FireBall()
    {
        if (SSGameMange.GetInstance() == null ||
            SSGameMange.GetInstance().m_SSGameUI == null ||
            SSGameMange.GetInstance().m_SSGameScene == null)
        {
            return;
        }

        if (SSGameMange.GetInstance().m_SSGameUI.m_GameUIData.IsGameStart == false)
        {
            //有玩家还没拍开始游戏按键
            return;
        }

        if (m_SSBall == null)
        {
            return;
        }

        SSGameMange.GetInstance().m_SSGameScene.ResetBallSpeed();
        SSGameMange.GetInstance().m_SSGameScene.UpdateBallSpeed();

        m_SSBall.Fire(transform.forward);
        m_SSBall = null;

        //开启镜头跟踪
        SSGameMange.GetInstance().m_SSGameScene.SetIsMoveCamera(true);
        //创建游戏倒计时界面
        SSGameMange.GetInstance().m_SSGameUI.CreateGameDaoJiShi();
        //触发玩家发球事件
        SSGameMange.GetInstance().m_SSGameScene.PlayerFireBallEvent();
    }
Exemplo n.º 4
0
 internal void Init()
 {
     if (SSGameMange.GetInstance() != null &&
         SSGameMange.GetInstance().m_SSGameScene != null)
     {
         SSGameMange.GetInstance().m_SSGameScene.OnFireBallEvent += OnFireBallEvent;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 设置游戏难度
 /// </summary>
 internal void SetGameNanDu()
 {
     if (SSGameMange.GetInstance() != null &&
         SSGameMange.GetInstance().m_SSGameScene != null)
     {
         SSGameMange.GetInstance().m_SSGameScene.SetGameNanDu(BallSpeed, QiuPaiSpeed);
     }
 }
Exemplo n.º 6
0
 internal void CreateTeXiao()
 {
     if (m_DaoJuData != null && m_DaoJuData.TeXiaoPrefab != null)
     {
         Transform  trParent = SSGameMange.GetInstance().m_CleanupData.DaoJuParent;
         GameObject obj      = (GameObject)Instantiate(m_DaoJuData.TeXiaoPrefab, trParent, transform);
         CheckDestroyThisTimed(obj);
     }
 }
Exemplo n.º 7
0
        internal void SetIsClickStartBt(SSGlobalData.PlayerEnum indexPlayer, bool isClick)
        {
            if (_IsGameStart == true)
            {
                return;
            }

            int index = (int)indexPlayer;

            if (index < 0 || index >= IsClickStartBtArray.Length)
            {
                return;
            }
            IsClickStartBtArray[index] = isClick;

            bool isAllClickStart = true;

            for (int i = 0; i < IsClickStartBtArray.Length; i++)
            {
                if (IsClickStartBtArray[i] == false)
                {
                    isAllClickStart = false;
                    break;
                }
            }

            if (isAllClickStart == true)
            {
                _IsGameStart = true;
                if (m_SSDengDaiDuiFang != null)
                {
                    //删除等待对方UI
                    m_SSDengDaiDuiFang.RemoveDengDaiDuiFang();
                }

                if (m_SSGameUI != null)
                {
                    //创建玩家发球倒计时
                    m_SSGameUI.CreateStartGameGo();
                }

                if (SSGameMange.GetInstance() != null && SSGameMange.GetInstance().m_SSGameScene != null)
                {
                    //游戏开始
                    SSGameMange.GetInstance().m_SSGameScene.OnGameStart();
                }
            }
            else
            {
                if (m_SSDengDaiDuiFang != null)
                {
                    m_SSDengDaiDuiFang.CreateDengDaiDuiFangUI(indexPlayer, PanelCenterTr);
                }
            }
        }
 internal void Init()
 {
     if (SSGameMange.GetInstance() != null && SSGameMange.GetInstance().m_SSGameScene != null)
     {
         //开始创建道具
         SSGameMange.GetInstance().m_SSGameScene.StartCreateDaoJu();
         //开始游戏难度控制
         SSGameMange.GetInstance().m_SSGameScene.StartCheckGameNanDu();
     }
     StartCoroutine(LoopDownDaoJiShi());
 }
Exemplo n.º 9
0
    void ballOut(Collider col)
    {
        if (IndexPlayer == SSGlobalData.PlayerEnum.Null)
        {
            return;
        }

        if (SSGameMange.GetInstance() == null ||
            SSGameMange.GetInstance().m_SSGameScene == null ||
            SSGameMange.GetInstance().m_SSGameUI == null)
        {
            return;
        }
        //创建开始发球界面
        SSGameMange.GetInstance().m_SSGameUI.CreateStartFireBall(IndexPlayer);

        //玩家没有接上曲棍球
        //把曲棍球初始化到玩家的球拍处
        SSBall ball = col.gameObject.GetComponent <SSBall>();

        if (ball)
        {
            ball.SetBallPosition(IndexPlayer);
        }

        SSGlobalData.PlayerEnum indexJiaFenPlayer = SSGlobalData.PlayerEnum.Null;
        switch (IndexPlayer)
        {
        case SSGlobalData.PlayerEnum.PlayerOne:
        {
            indexJiaFenPlayer = SSGlobalData.PlayerEnum.PlayerTwo;
            break;
        }

        case SSGlobalData.PlayerEnum.PlayerTwo:
        {
            indexJiaFenPlayer = SSGlobalData.PlayerEnum.PlayerOne;
            break;
        }
        }

        if (indexJiaFenPlayer != SSGlobalData.PlayerEnum.Null)
        {
            //创建加分UI界面
            SSGameMange.GetInstance().m_SSGameUI.CreateJiaFenUI(indexJiaFenPlayer);
        }

        //播放出界音效
        PlayAudio();

        //关闭镜头跟踪
        SSGameMange.GetInstance().m_SSGameScene.SetIsMoveCamera(false);
    }
Exemplo n.º 10
0
    IEnumerator DelayRemoveGameResult()
    {
        yield return(new WaitForSeconds(6f));

        //删除游戏比赛结果界面
        ClearGameResult();

        //删除玩家分数界面
        SSGameMange.GetInstance().m_SSGameUI.RemovePlayerFenShu();
        //重置数据信息
        SSGlobalData.GetInstance().ResetInfo();
        Resources.UnloadUnusedAssets();

        //创建游戏说明UI界面
        CreateGameShuoMing();
    }
Exemplo n.º 11
0
    internal void SetBallPosition(SSGlobalData.PlayerEnum indexPlayer)
    {
        if (SSGameMange.GetInstance() == null || SSGameMange.GetInstance().m_SSGameScene == null)
        {
            return;
        }

        SSPlayerPaddle paddle = SSGameMange.GetInstance().m_SSGameScene.GetPlayerPaddle(indexPlayer);

        if (paddle != null)
        {
            m_BallData.isMove     = false;
            rigidbody.isKinematic = true;
            paddle.FillBall(m_BallData.posOffsetZ, this);
        }
        SetBallPlayerIndex(indexPlayer);
    }
Exemplo n.º 12
0
    IEnumerator LoopCheckNextGameNanDu()
    {
        int   loopCount = 0;
        float time      = 1f;

        do
        {
            if (SSGameMange.GetInstance().m_SSGameUI.GetIsCreateStartFireBall() == true)
            {
                //创建了开始发球界面
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            //SSDebug.Log("LoopCheckNextGameNanDu -> loopCount ========== " + loopCount);
            if (loopCount == 0)
            {
                if (SSGameMange.GetInstance() != null &&
                    SSGameMange.GetInstance().m_SSGameScene != null)
                {
                    SSGameMange.GetInstance().m_SSGameScene.SetWeiDangMesh(m_IndexNanDu);
                }

                SetGameNanDu(m_IndexNanDu);
                if (m_IndexNanDu == m_NanDuDtArray.Length - 1)
                {
                    //游戏已经到达最后一个阶段
                    ResetInfo();
                    yield break;
                }
            }

            yield return(new WaitForSeconds(time));

            loopCount++;
            bool isGoToNext = GetIsGoToNextNanDu(m_NanDuDtArray[m_IndexNanDu], loopCount * time);
            if (isGoToNext == true)
            {
                //进入下一阶段
                m_IndexNanDu++;
                loopCount = 0;
            }
        }while (IsLoopCheck == true);
    }
    GameObject CreateDaoJu(int index, Transform tr)
    {
        GameObject obj          = null;
        Transform  parent       = SSGameMange.GetInstance().m_CleanupData.DaoJuParent;
        string     prefabPath   = "DaoJu/DeFenDaoJu/DaoJu_" + index;
        GameObject gmDataPrefab = (GameObject)Resources.Load(prefabPath);

        if (gmDataPrefab != null)
        {
            //SSDebug.Log("CreateDaoJu.............. index == " + index);
            obj = (GameObject)Instantiate(gmDataPrefab, parent, tr);
        }
        else
        {
            SSDebug.LogWarning("CreateDaoJu -> gmDataPrefab was null! prefabPath == " + prefabPath);
        }
        return(obj);
    }
Exemplo n.º 14
0
    private void OnFireBallEvent()
    {
        if (SSGameMange.GetInstance() == null)
        {
            return;
        }

        if (SSGameMange.GetInstance().m_SSGameScene != null)
        {
            SSGameMange.GetInstance().m_SSGameScene.OnFireBallEvent -= OnFireBallEvent;
        }

        if (SSGameMange.GetInstance().m_SSGameUI != null)
        {
            SSGameMange.GetInstance().m_SSGameUI.RemoveStartGameGo();
            SSGameMange.GetInstance().m_SSGameUI.RemoveStartFireBall();
        }
        RemoveSelf();
    }
        internal void DownTime()
        {
            if (DaoJiShi <= 0)
            {
                IsEndDaoJiShi = true;
                //倒计时结束
                StopAudio();

                //重置曲棍球位置
                if (SSGameMange.GetInstance() != null &&
                    SSGameMange.GetInstance().m_SSGameScene != null &&
                    SSGameMange.GetInstance().m_SSGameScene.m_SSBall != null)
                {
                    SSGameMange.GetInstance().m_SSGameScene.m_SSBall.ResetInfo();
                }
                return;
            }

            DaoJiShi--;
            ShowDaoJiShi();
        }
Exemplo n.º 16
0
        internal void UpdateBallSpeed()
        {
            if (speedBallCur == 0f)
            {
                speedBallCur = ballSpeed;
            }
            else
            {
                if (speedBallCur < maxBallSpeed)
                {
                    speedBallCur += addBallSpeed;
                    if (speedBallCur > maxBallSpeed)
                    {
                        speedBallCur = maxBallSpeed;
                    }
                }
            }

            if (speedQiuPaiCur == 0f)
            {
                speedQiuPaiCur = qiuPaiSpeed;
            }
            else
            {
                if (speedQiuPaiCur < maxQiuPaiSpeed)
                {
                    speedQiuPaiCur += addQiuPaiSpeed;
                    if (speedQiuPaiCur > maxQiuPaiSpeed)
                    {
                        speedQiuPaiCur = maxQiuPaiSpeed;
                    }
                }
            }

            if (SSGameMange.GetInstance() != null &&
                SSGameMange.GetInstance().m_SSGameScene != null)
            {
                SSGameMange.GetInstance().m_SSGameScene.SetGameNanDu(speedBallCur, speedQiuPaiCur);
            }
        }
Exemplo n.º 17
0
    void OnCollisionExit(Collision col)
    {
        //SSDebug.Log("col == " + col.gameObject.layer);
        if (col.gameObject.layer == m_BallData.badBounceLayer)
        {
            //曲棍球碰上围挡
            SSWeiDangMesh weiDangMesh = col.gameObject.GetComponent <SSWeiDangMesh>();
            if (weiDangMesh != null)
            {
                weiDangMesh.PlayWeiDangAni();
            }

            //m_BallData.m_badBounceCount++;
            //if (m_BallData.m_badBounceCount > m_BallData.BadBounceMax)
            //{
            //    //SSDebug.Log("handle bad bounce!");
            //    handleBadBounce();
            //}
            m_BallData.PlayAudio();
        }
        else
        {
            m_BallData.m_badBounceCount = 0;
        }

        SSPlayerPaddle paddle = col.gameObject.GetComponent <SSPlayerPaddle>();

        if (paddle != null)
        {
            m_BallData.PlayAudio();
            SetBallPlayerIndex(paddle.IndexPlayer);
            if (SSGameMange.GetInstance() != null && SSGameMange.GetInstance().m_SSGameScene != null)
            {
                SSGameMange.GetInstance().m_SSGameScene.UpdateBallSpeed();
            }
            //handleHitPaddle();
        }
    }
    IEnumerator LoopDownDaoJiShi()
    {
        if (m_DaoJiShiData == null)
        {
            yield break;
        }

        if (SSGameMange.GetInstance() == null)
        {
            yield break;
        }

        if (SSGameMange.GetInstance().m_SSGameUI == null)
        {
            yield break;
        }

        m_DaoJiShiData.Init();
        yield return(new WaitForSeconds(1f));

        do
        {
            if (SSGameMange.GetInstance().m_SSGameUI.GetIsCreateStartFireBall() == true)
            {
                //创建了开始发球界面,倒计时停止
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            SetDaoJiShi();
            if (m_DaoJiShiData.IsEndDaoJiShi == false)
            {
                yield return(new WaitForSeconds(1f));
            }
        }while (m_DaoJiShiData.IsEndDaoJiShi == false);
    }
    IEnumerator DelayStartCreateDaoJu()
    {
        if (m_ManageData == null)
        {
            yield break;
        }

        do
        {
            if (IsDelayStartCreateDaoJu == false)
            {
                yield break;
            }

            if (SSGameMange.GetInstance().m_SSGameUI.GetIsCreateStartFireBall() == true)
            {
                //创建了开始发球界面
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            float time = m_ManageData.TimeCreateDaoJu.GetRandom();
            yield return(new WaitForSeconds(time));

            if (IsDelayStartCreateDaoJu == false)
            {
                yield break;
            }

            if (SSGameMange.GetInstance().m_SSGameUI.GetIsCreateStartFireBall() == true)
            {
                //创建了开始发球界面
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            //产生道具
            RandomCreateDaoJu();

            time = m_ManageData.LifeTime;
            bool isEmpty = false;
            for (int i = 0; i < time; i++)
            {
                if (IsDelayStartCreateDaoJu == false)
                {
                    yield break;
                }

                yield return(new WaitForSeconds(1));

                isEmpty = m_ListDaoJuData.GetIsEmpty();
                if (isEmpty == true)
                {
                    //开始下一轮的道具产生
                    break;
                }

                if (SSGameMange.GetInstance().m_SSGameUI.GetIsCreateStartFireBall() == true)
                {
                    //创建了开始发球界面
                    break;
                }
            }

            if (isEmpty == false)
            {
                CleanAllDaoJu();
            }
        }while (IsDelayStartCreateDaoJu == true);
        //SSDebug.LogWarning("End DelayStartCreateDaoJu....................");
    }