Example #1
0
        /// <summary>
        /// 游戏流程
        /// </summary>
        /// <returns></returns>
        private IEnumerator _Coro_MainProcess()
        {
            var gdata = App.GetGameData <FishGameData>();
            var evtMainProcessFirstEnterScene = gdata.EvtMainProcessFirstEnterScene;

            if (evtMainProcessFirstEnterScene != null)
            {
                evtMainProcessFirstEnterScene();
            }
            var evtMainProcessPrepareChangeScene = gdata.EvtMainProcessPrepareChangeScene;
            var evtMainProcessFinishChangeScene  = gdata.EvtMainProcessFinishChangeScene;
            var evtMainProcessFinishPrelude      = gdata.EvtMainProcessFinishPrelude;
            var musicMgr = Facade.Instance <MusicManager>();

            while (true)
            {
                //普通鱼模式 --------------------------------------------------------------
                State_ = State.Normal;
                gdata.ResetDepth();
                musicMgr.ChangeNextBackSound();
                FishGenerator.StartFishGenerate();
                var tmpTime = Time.time;
                while (IsMainProcessPause || Time.time - tmpTime < TimeNormalScene)
                {
                    // YxDebug.Log("==========倒计时:" + (Time.time - tmpTime) +"("+ TimeNormalScene+")");
                    yield return(1);
                }

                //准备过场 --------------------------------------------------------------
                State_ = State.BeforeSweepingWaitBulletClear;
                gdata.ResetDepth();
                if (evtMainProcessPrepareChangeScene != null)
                {
                    evtMainProcessPrepareChangeScene();
                }

                //停止玩家攻击 --------------------------------------------------------------
                foreach (var p in PlayersBatterys)
                {
                    if (p.IsHide())
                    {
                        continue;
                    }
                    p.GunInst.Fireable = false;
                    p.CanChangeScore   = false;
                    Operation.Reset();
                }

                //等待场景所有子弹消失 --------------------------------------------------------------

                while (true)
                {
                    float numPlayerHaventBullet = 0;
                    foreach (var p in PlayersBatterys)
                    {
                        numPlayerHaventBullet += (p != null && p.GunInst) ? p.GunInst.NumBulletInWorld : 0;
                    }
                    if (numPlayerHaventBullet < 1)
                    {
                        break;
                    }
                    yield return(1);
                }
                State_ = State.Sweeping;

                //停止出鱼 --------------------------------------------------------------
                FishGenerator.StopFishGenerate();
                //                SoundMgr.StopBgm();
                //切换音乐
                musicMgr.ChangeRandomBackSound();

                //开始播放过场,清鱼 --------------------------------------------------------------
                SceneBGMgr.Sweep();
                while (SceneBGMgr.IsSweep)
                {
                    yield return(1);
                }

                State_ = State.Preluding;

                musicMgr.ChangeNextBackSound();

                if (evtMainProcessFinishChangeScene != null)
                {
                    evtMainProcessFinishChangeScene();
                }

                //恢复玩家攻击 --------------------------------------------------------------
                foreach (var p in PlayersBatterys)
                {
                    var gun = p.GunInst;
                    if (gun == null)
                    {
                        continue;
                    }
                    gun.Fireable     = true;
                    p.CanChangeScore = true;
                }

                //开场鱼阵 --------------------------------------------------------------
                var pl = ScenePreludeMgr.DoPrelude();
                if (pl != null)
                {
                    //string preludeName = pl.gameObject.name;
                    //YxDebug.Log("sceneprelude start = " + preludeName+ "   fish num = "+NumFishAlive);
                    bool waitPrelude = true;
                    pl.Evt_PreludeEnd += () => { waitPrelude = false; };
                    while (waitPrelude)
                    {
                        yield return(new WaitForSeconds(0.1F));
                    }
                    //YxDebug.Log("sceneprelude end = " + preludeName + "   fish num = " + NumFishAlive);
                }

                //下一次正常出鱼 --------------------------------------------------------------
                if (evtMainProcessFinishPrelude != null)
                {
                    evtMainProcessFinishPrelude();
                }
            }
        }
Example #2
0
    IEnumerator _Coro_MainProcess()
    {
        if (EvtMainProcess_FirstEnterScene != null)
        {
            EvtMainProcess_FirstEnterScene();
        }

        float tmpTime = 0F;

        while (true)
        {
            State_ = State.Normal;
            SoundMgr.PlayNewBgm();

            FishGenerator.StartFishGenerate();
            //yield return new WaitForSeconds(TimeNormalScene);

            tmpTime = Time.time;
            while (IsMainProcessPause || Time.time - tmpTime < TimeNormalScene)
            {
                yield return(0);
            }

            State_ = State.BeforeSweeping_WaitBulletClear;
            //*准备过场
            if (EvtMainProcess_PrepareChangeScene != null)
            {
                EvtMainProcess_PrepareChangeScene();
            }

            //停止玩家攻击
            foreach (Player p in Players)
            {
                p.GunInst.Fireable = false;
                p.CanChangeScore   = false;
            }
            //等待场景所有子弹消失
            Player[] tmpPlayers = new Player[Players.Length];
            for (int i = 0; i != Players.Length; ++i)
            {
                tmpPlayers[i] = Players[i];
            }
            while (true)
            {
                float numPlayerHaventBullet = 0;
                for (int i = 0; i != tmpPlayers.Length; ++i)
                {
                    if (tmpPlayers[i] != null && tmpPlayers[i].GunInst.NumBulletInWorld == 0)
                    {
                        tmpPlayers[i] = null;
                    }
                    if (tmpPlayers[i] == null)
                    {
                        ++numPlayerHaventBullet;
                    }
                }
                if (numPlayerHaventBullet == tmpPlayers.Length)
                {
                    break;
                }
                yield return(0);
            }
            State_ = State.Sweeping;
            //停止出鱼
            FishGenerator.StopFishGenerate();
            SoundMgr.StopBgm();

            //开始播放过场,清鱼
            SceneBGMgr.Sweep();
            yield return(new WaitForSeconds(SceneBGMgr.UseTime + 0.3F));

            State_ = State.Preluding;

            SoundMgr.PlayNewBgm();

            if (EvtMainProcess_FinishChangeScene != null)
            {
                EvtMainProcess_FinishChangeScene();
            }
            //恢复玩家攻击
            foreach (Player p in Players)
            {
                p.GunInst.Fireable = true;
                p.CanChangeScore   = true;
            }


            //开场鱼阵

            ScenePrelude pl = ScenePreludeMgr.DoPrelude();
            //string preludeName = pl.gameObject.name;
            //Debug.Log("sceneprelude start = " + preludeName+ "   fish num = "+NumFishAlive);
            bool waitPrelude = true;
            pl.Evt_PreludeEnd += () => { waitPrelude = false; };
            while (waitPrelude)
            {
                yield return(new WaitForSeconds(0.1F));
            }
            //Debug.Log("sceneprelude end = " + preludeName + "   fish num = " + NumFishAlive);

            //loop:下一次正常出鱼
            if (EvtMainProcess_FinishPrelude != null)
            {
                EvtMainProcess_FinishPrelude();
            }
        }
    }