Ejemplo n.º 1
0
        protected override void OnUpdate()
        {
            var env          = World.TinyEnvironment();
            var inputSystem  = World.GetExistingSystem <InputSystem>();
            var puzzleConfig = env.GetConfigData <PuzzleConfiguration>();

            if (!puzzleConfig.IsCompleted)
            {
                return;
            }

            var buttonReplayEntity = Entity.Null;

            Entities.WithAll <ButtonReplay>().ForEach((Entity entity) => { buttonReplayEntity = entity; });
            if (!EntityManager.Exists(buttonReplayEntity))
            {
                return;
            }

            var buttonReplayPointerInteraction = EntityManager.GetComponentData <PointerInteraction>(buttonReplayEntity);

            if (buttonReplayPointerInteraction.clicked || inputSystem.GetKeyDown(KeyCode.Return))
            {
                // Reload the scene
                var buttonReplay = EntityManager.GetComponentData <ButtonReplay>(buttonReplayEntity);
                SceneService.UnloadAllSceneInstances(buttonReplay.SceneToLoad);
                SceneService.LoadSceneAsync(buttonReplay.SceneToLoad);

                puzzleConfig.IsCompleted = false;
                env.SetConfigData(puzzleConfig);
            }
        }
        protected override void OnUpdate()
        {
            bool destroyAllShips = false;

            Entities.WithAll <ButtonDestroyShips>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) =>
            {
                if (pointerInteraction.clicked)
                {
                    destroyAllShips = true;
                }
            });

            if (destroyAllShips)
            {
                var env = World.TinyEnvironment();

                var allyShips = env.GetConfigBufferData <AllyShips>().Reinterpret <SceneReference>().ToNativeArray(Unity.Collections.Allocator.Temp);
                for (int i = 0; i < allyShips.Length; i++)
                {
                    SceneService.UnloadAllSceneInstances(allyShips[i]);
                }
                allyShips.Dispose();

                var enemyShips = env.GetConfigBufferData <EnemyShips>().Reinterpret <SceneReference>().ToNativeArray(Unity.Collections.Allocator.Temp);
                for (int i = 0; i < enemyShips.Length; i++)
                {
                    SceneService.UnloadAllSceneInstances(enemyShips[i]);
                }
                enemyShips.Dispose();
            }
        }
Ejemplo n.º 3
0
        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnStartTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                if (pointerInteraction.clicked)
                {
                    Debug.LogAlways("btn ret click");
                    btnOn = true;
                }
            });


            if (btnOn)
            {
                // 盤面生成.
                Entities.ForEach(( ref PuzzleGen gen ) => {
                    gen.IsGenerate = true;
                });

                // ポーズ解除.
                Entities.ForEach(( ref GameMngr mngr ) => {
                    mngr.IsPause = false;
                });

                // タイトルシーンアンロード.
                SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <PanelConfig>().TitleScn;
                SceneService.UnloadAllSceneInstances(panelBase);
            }
        }
Ejemplo n.º 4
0
        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnRetryTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                if (pointerInteraction.clicked)
                {
                    //Debug.LogAlways("btn ret click");
                    btnOn = true;
                }
            });


            if (btnOn)
            {
                var env = World.TinyEnvironment();

                /*SceneService.UnloadAllSceneInstances( env.GetConfigData<GameConfig>().PrefabBlock );
                 * SceneService.UnloadAllSceneInstances( env.GetConfigData<GameConfig>().PrefabBlockStay );
                 * SceneService.UnloadAllSceneInstances( env.GetConfigData<GameConfig>().PrefabStar );*/

                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().ResultScn);


                // 各種パラメータ初期化.
                Entities.ForEach(( ref FirstSetInfo info ) => {
                    info.Initialized = false;
                });

                Entities.ForEach(( ref InitBlockInfo info ) => {
                    info.Initialized = false;
                });

                // ポーズ解除 & 初期化.
                Entities.ForEach(( ref GameMngr mngr ) => {
                    mngr.IsPause   = false;
                    mngr.Mode      = GameMngrSystem.MdGame;
                    mngr.Score     = 0;
                    mngr.GameTimer = 0;
                    mngr.ModeTimer = 0;
                });

                Entities.ForEach(( ref GeneratorInfo info ) => {
                    info.Initialized = false;
                });


                // スコア表示.
                Entities.WithAll <TextScoreTag>().ForEach(( Entity entity ) => {
                    EntityManager.SetBufferFromString <TextString>(entity, "0");
                });
            }
        }
Ejemplo n.º 5
0
        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnRetryTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                if (pointerInteraction.clicked)
                {
                    //Debug.LogAlways("btn ret click");
                    btnOn = true;
                }
            });


            if (btnOn)
            {
                var env = World.TinyEnvironment();
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().ResultScn);

                // ゲームマネージャ.
                Entities.ForEach(( ref GameMngr mngr ) => {
                    mngr.IsPause   = false;
                    mngr.Mode      = GameMngrSystem.MdGame;
                    mngr.ModeTimer = 0;
                    mngr.GameTimer = 0;
                    mngr.Score     = 0;
                });

                // スコア表示.
                Entities.WithAll <TextScoreTag>().ForEach(( Entity entity ) => {
                    EntityManager.SetBufferFromString <TextString>(entity, "0");
                });

                // プレイヤー.
                Entities.ForEach(( ref PlayerInfo player ) => {
                    player.Initialized = false;
                });

                // 隕石ジェネレータ.
                Entities.ForEach(( ref MeteoGenInfo info ) => {
                    info.Initialized = false;
                });

                // 隕石初期化システム.
                Entities.ForEach(( ref InitMeteoInfo info ) => {
                    info.InitSplit = false;
                });

                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().PrefabMeteo);
            }
        }
Ejemplo n.º 6
0
//		bool isLoaded;


        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnRetryTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                if (pointerInteraction.clicked)
                {
                    Debug.LogAlways("btn ret click");
                    btnOn = true;
                }
            });


            if (btnOn)
            {
                // 盤面リフレッシュ.
                var env = World.TinyEnvironment();
                SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelRed);
                SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelWhite);

                Entities.ForEach(( ref PuzzleGen gen ) => {
                    gen.IsGenerate = true;
                });
                SceneReference panelBase = new SceneReference();
                panelBase = env.GetConfigData <PanelConfig>().ResultScn;
                SceneService.UnloadAllSceneInstances(panelBase);

                // ポーズ解除 & 初期化.
                Entities.ForEach(( ref GameMngr mngr ) => {
                    mngr.IsPause      = false;
                    mngr.Score        = 0;
                    mngr.GameTimer    = 0;
                    mngr.InputCnt     = 0;
                    mngr.InputCntGoal = 0;
                    mngr.ComboCnt     = 0;
                });

                // ジェネレート回数リセット.
                Entities.ForEach(( ref PuzzleGen gen ) => {
                    gen.GeneratedCnt = 0;
                });

                // スコア表示.
                Entities.WithAll <TextScoreTag>().ForEach(( Entity entity ) => {
                    EntityManager.SetBufferFromString <TextString>(entity, "0");
                });
            }
        }
Ejemplo n.º 7
0
        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnRetryTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                if (pointerInteraction.clicked)
                {
                    btnOn = true;
                }
            });

            if (btnOn)
            {
                var env = World.TinyEnvironment();
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().ResultScn);
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().BallScn);

                // 初期化.
                Entities.ForEach(( ref GameMngr mngr ) => {
                    mngr.Initialized = false;
                });

                Entities.ForEach((Entity entity, ref BallGenerateInfo gen) => {
                    gen.Initialized = false;
                });

                Entities.ForEach((Entity entity, ref BoxInfo box) => {
                    box.Initialized = false;
                });

#if false
                // 初期化.
                Entities.ForEach(( ref BallInfo ball ) => {
                    ball.Count       = 0;
                    ball.Initialized = false;
                });

                Entities.ForEach(( ref BatInfo bat ) => {
                    bat.Initialized = false;
                });

                Entities.ForEach(( ref TargetGenInfo gen ) => {
                    gen.Initialized = false;
                });
#endif
            }
        }
Ejemplo n.º 8
0
    protected override void OnUpdate()
    {
        bool destoryAll = false;

        Entities.ForEach((Entity EntityManager, ref SnakeHead snake, ref Translation translation) =>
        {
            if (!snake.RemoveTail)
            {
                return;
            }
            destoryAll        = true;
            snake.Direction   = float3.zero;
            translation.Value = float3.zero;
            snake.RemoveTail  = false;
        });
        if (destoryAll)
        {
            SceneService.UnloadAllSceneInstances(World.TinyEnvironment().GetConfigData <GameConfig>().SnakeTailSceneReference);
        }
    }
Ejemplo n.º 9
0
        protected override void OnUpdate()
        {
            bool playerDestroy = false;

            Entities.ForEach((Entity entity, ref Player player) =>
            {
                if (!player.Collide)
                {
                    return;
                }
                playerDestroy = true;
            });
            if (playerDestroy)
            {
                SceneService.LoadSceneAsync(World.TinyEnvironment().GetConfigData <GameConfig>().Effect);
                SceneService.UnloadAllSceneInstances(World.TinyEnvironment().GetConfigData <GameConfig>().PlayerScene);
                SceneService.LoadSceneAsync(World.TinyEnvironment().GetConfigData <GameConfig>().RetryScene);
                //SceneService.UnloadAllSceneInstances(World.TinyEnvironment().GetConfigData<GameConfig>().ControllerScene);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Unloads all instances of a certain scenereference INCLUDING INDESTUCTIBLE ONES
        /// </summary>
        /// <warning>This will unload indestructable scenes! Use with care</warning>
        /// <param name="sceneReference">A reference to the scenes to unload</param>
        /// <param name="entityManager">A reference to the entitymanager instance</param>
        /// <returns>A bool to mark the correct unloading of the scenes</returns>
        public static bool UnloadAllScenesOfType(SceneReference sceneReference, EntityManager entityManager)
        {
            try
            {
                var sceneEntities = GetSceneEntities(entityManager);
                for (int i = 0; i < sceneEntities.Length; i++)
                {
                    if (entityManager.GetSharedComponentData <SceneGuid>(sceneEntities[i]).Guid.GetHashCode().Equals(sceneReference.SceneGuid.GetHashCode()))
                    {
                        GetScenesLoadedBuffer(entityManager).RemoveAt(i);
                    }
                }

                SceneService.UnloadAllSceneInstances(sceneReference);
                return(true);
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
                return(false);
            }
        }
Ejemplo n.º 11
0
        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnTestTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                if (pointerInteraction.clicked)
                {
                    //Debug.LogAlways("btn click");
                    btnOn = true;
                }
            });


            if (btnOn)
            {
#if false
                var env = World.TinyEnvironment();
                SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelRed);
                SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelWhite);

                Entities.ForEach(( ref PuzzleGen gen ) => {
                    gen.IsGenerate = true;
                });
#endif
                SceneReference panelBase = new SceneReference();
                var            env       = World.TinyEnvironment();
                panelBase = env.GetConfigData <PanelConfig>().ResultScn;
                if (!isLoaded)
                {
                    SceneService.LoadSceneAsync(panelBase);
                    isLoaded = true;
                }
                else
                {
                    SceneService.UnloadAllSceneInstances(panelBase);
                    isLoaded = false;
                }
            }
        }
Ejemplo n.º 12
0
        protected override void OnUpdate()
        {
            bool reqResult = false;

            Entities.ForEach(( ref TimeOverInfo info ) => {
                info.Timer += World.TinyEnvironment().frameDeltaTime;
                if (info.Timer > 1.5f)
                {
                    reqResult  = true;
                    info.Timer = 0;
                }
            });

            if (reqResult)
            {
                var env = World.TinyEnvironment();
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().TimeOverScn);

                // リザルト表示.
                SceneReference resultScn = World.TinyEnvironment().GetConfigData <GameConfig>().ResultScn;
                SceneService.LoadSceneAsync(resultScn);
            }
        }
Ejemplo n.º 13
0
        protected override void OnUpdate()
        {
            bool btnOn = false;

            Entities.WithAll <BtnStartTag>().ForEach((Entity entity, ref PointerInteraction pointerInteraction) => {
                //Debug.LogAlways( "start btn" );
                if (pointerInteraction.clicked)
                {
                    btnOn = true;
                }
            });


            if (btnOn)
            {
                // タイトルシーンアンロード.
                SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <GameConfig>().TitleScn;
                SceneService.UnloadAllSceneInstances(panelBase);

                SceneReference mainScn = World.TinyEnvironment().GetConfigData <GameConfig>().MainScn;
                SceneService.LoadSceneAsync(mainScn);
            }
        }
Ejemplo n.º 14
0
        protected override void OnUpdate()
        {
            Entity delEntity   = Entity.Null;
            var    inputSystem = World.GetExistingSystem <InputSystem>();

            bool mouseOn = false;

            if (!isPause())
            {
                mouseOn = inputSystem.GetMouseButtonDown(0);
            }

            // 盤面情報用配列.
            NativeArray <int> InfoAry = new NativeArray <int>(16, Allocator.Temp);
            bool isPanelHit           = false;      // パネルタップしたか?
            bool isReadyToMove        = true;       // パネル動けるか?
            int2 HitCell   = new int2(-1, -1);
            int2 BlankCell = new int2(-1, -1);

            // 盤面情報収集.
            Entities.ForEach((ref PanelInfo panel, ref Translation trans) => {
                // 状態チェック.
                if (!panel.Initialized || panel.Status != PnlStNormal)
                {
                    isReadyToMove = false;
                    return;
                }

                // 情報.
                int idx      = panel.CellPos.x + panel.CellPos.y * 4;
                InfoAry[idx] = panel.Type;

                // マウスとのあたりチェック.
                if (mouseOn)
                {
                    float2 size = new float2(128f, 128f);

                    float3 mypos    = trans.Value;
                    float3 mousePos = inputSystem.GetWorldInputPosition();
                    bool res        = OverlapsObjectCollider(mypos, mousePos, size);
                    if (res)
                    {
                        HitCell    = panel.CellPos;
                        isPanelHit = true;
                    }
                }
            });


            // パネル動ける状態でない場合.
            if (!isReadyToMove)
            {
                isPanelHit = false;
            }

            if (isPanelHit)
            {
                // 入力回数.
                Entities.ForEach(( ref GameMngr mngr ) => {
                    ++mngr.InputCnt;
                });
                // 空きを探す.
                for (int j = 0; j < 4; ++j)
                {
                    for (int i = 0; i < 4; ++i)
                    {
                        int idx = i + j * 4;
                        if (InfoAry[idx] == 0)
                        {
                            BlankCell.x = i;
                            BlankCell.y = j;
                        }
                    }
                }
            }

            // パネル動けるか.
            bool isMovable = false;
            int  moveDir   = -1;                // 0:up 1:down 2:left 3:right.

            if (HitCell.x == BlankCell.x)
            {
                isMovable = true;
                if (HitCell.y < BlankCell.y)
                {
                    moveDir = 1;
                }
                else if (HitCell.y > BlankCell.y)
                {
                    moveDir = 0;
                }
            }
            else if (HitCell.y == BlankCell.y)
            {
                isMovable = true;
                if (HitCell.x < BlankCell.x)
                {
                    moveDir = 3;
                }
                else if (HitCell.x > BlankCell.x)
                {
                    moveDir = 2;
                }
            }

            Entities.ForEach((Entity entity, ref PanelInfo panel, ref Translation trans, ref NonUniformScale scale, ref Sprite2DRenderer sprite) => {
                if (!panel.Initialized)
                {
                    return;
                }

                switch (panel.Status)
                {
                case PnlStAppear:
                    panelAppear(ref panel, ref sprite);
                    break;

                case PnlStNormal:
                    if (isMovable)
                    {
                        panelNormNew(ref panel, ref InfoAry, ref HitCell, ref BlankCell, moveDir);
                    }
                    //if( mouseOn ) {
                    //	panelNorm( ref panel, ref trans, ref InfoAry );
                    //}
                    break;

                case PnlStMove:
                    panelMove(ref panel, ref trans);
                    break;

                case PnlStDisappear:
                    if (panelDisapper(ref panel, ref scale, ref sprite))
                    {
                        delEntity = entity;
                    }
                    break;
                }
            });

            InfoAry.Dispose();

            if (delEntity != Entity.Null)
            {
                // パネル全消しするかチェック.
                bool reqReflesh = false;
                Entities.ForEach(( ref GameMngr mngr ) => {
                    if (mngr.ReqReflesh)
                    {
                        mngr.ReqReflesh = false;
                        reqReflesh      = true;
                    }
                });

                if (reqReflesh)
                {
                    // パネル全消し.
                    var env = World.TinyEnvironment();
                    SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelRed);
                    SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelWhite);
                    // 盤面生成.
                    Entities.ForEach(( ref PuzzleGen gen ) => {
                        gen.IsGenerate = true;
                    });
                    setPause(false);
                }
                else
                {
                    // エンティティ削除.
                    SceneService.UnloadSceneInstance(delEntity);
                    // パネル追加.
                    Entities.ForEach(( ref PuzzleGen gen ) => {
                        gen.IsGenAdditive = true;
                    });
                    setPause(false);
                }
            }
        }
Ejemplo n.º 15
0
        protected override void OnUpdate()
        {
#if false
            bool isTitleFinished = false;
            Entities.ForEach(( ref GameMngr mngr ) => {
                isTitleFinished = mngr.IsTitleFinished;
                if (!isTitleFinished)
                {
                    mngr.IsTitleFinished = true;
                    mngr.IsPause         = true;
                }
            });

            if (!isTitleFinished)
            {
                SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <PanelConfig>().TitleScn;
                SceneService.LoadSceneAsync(panelBase);
                return;
            }
#endif

            //float timer = 0;
            int score = 0;
            //bool isEnd = false;
            //bool isPause = false;
            bool reqGameOver = false;
            bool reqResult   = false;

            Entities.ForEach(( ref GameMngr mngr ) => {
                float dt = World.TinyEnvironment().frameDeltaTime;

                switch (mngr.Mode)
                {
                case MdTitle:
                    mngr.Mode = MdGame;
                    break;

                case MdGame:
                    if (mngr.ReqGameOver)
                    {
                        mngr.ReqGameOver = false;
                        reqGameOver      = true;
                        mngr.Mode        = MdGameOver;
                        mngr.ModeTimer   = 0;
                    }
                    break;

                case MdGameOver:
                    mngr.ModeTimer += dt;
                    if (mngr.ModeTimer > 1.5f)
                    {
                        mngr.Mode = MdResult;
                        reqResult = true;
                    }
                    break;
                }


                if (mngr.IsPause)
                {
                    //isPause = true;
                    return;
                }


                score = mngr.Score;

                // タイマー.
                mngr.GameTimer += dt;
#if false
                timer = mngr.GameTimer;
                if (timer >= GameTimeLimit)
                {
                    mngr.IsPause = true;
                }
#endif
            });


#if false
            // タイマー表示.
            if (!isPause)
            {
                Entities.WithAll <TextTimerTag>().ForEach(( Entity entity ) => {
                    int t = (int)(GameTimeLimit - timer);
                    EntityManager.SetBufferFromString <TextString>(entity, t.ToString());
                });
            }
#endif

            if (reqResult)
            {
                // ゲームオーバーシーンアンロード.
                SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <GameConfig>().GameOverScn;
                SceneService.UnloadAllSceneInstances(panelBase);
                // リザルト表示.
                //SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <GameConfig>().ResultScn;
                SceneService.LoadSceneAsync(panelBase);
            }
            else if (reqGameOver)
            {
                // ゲームオーバー表示.
                SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <GameConfig>().GameOverScn;
                SceneService.LoadSceneAsync(panelBase);

                // ブロック削除.
                var env = World.TinyEnvironment();
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().PrefabBlock);
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().PrefabBlockStay);
                SceneService.UnloadAllSceneInstances(env.GetConfigData <GameConfig>().PrefabStar);
            }
        }
Ejemplo n.º 16
0
        protected override void OnUpdate()
        {
            var tinyEnv     = World.TinyEnvironment();
            var config      = World.TinyEnvironment().GetConfigData <GameConfig>();
            var retryButton = false;

            Entities.WithAll <RetryButton>().ForEach((Entity entity, ref PointerInteraction pointerInteraction, ref Sprite2DRenderer sprite2D) =>
            {
                retryButton = pointerInteraction.clicked;

                if (!config.GameOver)
                {
                    sprite2D.color.a = 0;
                }

                if (config.GameOver)
                {
                    sprite2D.color.a = 1;
                }

                Entities.ForEach((Entity _entity, ref GameOver gameover, ref Sprite2DRenderer _sprite2D) =>
                {
                    if (!config.GameOver)
                    {
                        _sprite2D.color.a = 0;
                    }

                    if (config.GameOver)
                    {
                        _sprite2D.color.a = 1;
                    }
                });
            });



            if (retryButton)
            {
                config.Retry    = true;
                config.GameOver = false;

                SceneService.UnloadAllSceneInstances(config.BlackScene);
                SceneService.UnloadAllSceneInstances(config.BlackSceneB);
                SceneService.UnloadAllSceneInstances(config.BlackSceneC);

                Entities.ForEach((DynamicBuffer <blackSegments> blacksegments) =>
                {
                    var blacks = blacksegments.Reinterpret <Entity>().ToNativeArray((Unity.Collections.Allocator.Temp));
                    for (int i = 0; i < blacksegments.Length; i++)
                    {
                        blacksegments.Clear();
                        blacks.Dispose();
                    }
                });

                Entities.ForEach((DynamicBuffer <blackSegmentsB> blacksegments) =>
                {
                    var blacks = blacksegments.Reinterpret <Entity>().ToNativeArray((Unity.Collections.Allocator.Temp));
                    for (int i = 0; i < blacksegments.Length; i++)
                    {
                        blacksegments.Clear();
                        blacks.Dispose();
                    }
                });


                Entities.ForEach((DynamicBuffer <blackSegmentsC> blacksegments) =>
                {
                    var blacks = blacksegments.Reinterpret <Entity>().ToNativeArray((Unity.Collections.Allocator.Temp));
                    for (int i = 0; i < blacksegments.Length; i++)
                    {
                        blacksegments.Clear();
                        blacks.Dispose();
                    }
                });



                tinyEnv.SetConfigData(config);
            }
        }
Ejemplo n.º 17
0
        protected override void OnUpdate()
        {
            bool isScored  = false;
            bool isRefresh = false;
            int  redCnt    = 0;

            // 赤パネルの数.
            Entities.ForEach((Entity entity, ref PanelInfo panel) => {
                if (!panel.Initialized)
                {
                    return;
                }
                if (panel.Type == PanelSystem.PnlTypeRed)
                {
                    ++redCnt;
                }
            });

            // ゴール判定(仮).
            Entities.ForEach((Entity entity, ref PanelInfo panel) => {
                if (!panel.Initialized)
                {
                    return;
                }

                // red.
                if (panel.Type == PanelSystem.PnlTypeRed)
                {
                    if (panel.NextPos.x == 3 && panel.NextPos.y == 3)
                    {
                        if (panel.Status == PanelSystem.PnlStNormal)
                        {
                            if (redCnt > 1)
                            {
                                // パネル消す.
                                panel.Status = PanelSystem.PnlStDisappear;
                                setPause();
                            }
                            else
                            {
                                // 盤面更新.
                                isRefresh    = true;
                                panel.Status = PanelSystem.PnlStDisappear;
                                setPause();
                            }
                            isScored = true;
                        }
                    }
                }
            });


            //Entity gameMngrEntity = Entity.Null;
            if (isScored)
            {
                int score = 0;
                Entities.ForEach((Entity entity, ref GameMngr gamemngr) => {
                    int preCnt            = gamemngr.InputCntGoal;
                    gamemngr.InputCntGoal = gamemngr.InputCnt;

                    if (gamemngr.InputCntGoal - preCnt == 1)
                    {
                        ++gamemngr.ComboCnt;
                    }
                    else
                    {
                        gamemngr.ComboCnt = 0;
                    }

                    gamemngr.Score += 100;
                    if (gamemngr.ComboCnt > 0)
                    {
                        gamemngr.Score += (int)math.pow(2, gamemngr.ComboCnt) * 10;
                    }

                    score = gamemngr.Score;

                    Debug.LogFormatAlways("input {0} {1} : {2}", preCnt, gamemngr.InputCntGoal, gamemngr.ComboCnt);
                });

                // スコア表示.
                Entities.WithAll <TextScoreTag>().ForEach(( Entity entity ) =>
                {
                    EntityManager.SetBufferFromString <TextString>(entity, score.ToString());
                });


                if (isRefresh)
                {
#if false
                    // パネル全消し.
                    var env = World.TinyEnvironment();
                    SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelRed);
                    SceneService.UnloadAllSceneInstances(env.GetConfigData <PanelConfig>().PanelWhite);
                    // 盤面生成.
                    Entities.ForEach(( ref PuzzleGen gen ) => {
                        gen.IsGenerate = true;
                    });
#else
                    // ここで全消しせずにリクエストしておく.
                    Entities.ForEach(( ref GameMngr mngr ) => {
                        mngr.ReqReflesh = true;
                    });
#endif
                }
            }

            /*
             * if( gameMngrEntity != Entity.Null ) {
             *      GameMngr mngr = EntityManager.GetComponentData<GameMngr>( gameMngrEntity );
             *      int score = mngr.Score;
             *      Debug.LogFormatAlways( "sc {0}", score );
             * }*/
        }
Ejemplo n.º 18
0
        protected override void OnUpdate()
        {
            int  score       = 0;
            bool reqGameOver = false;
            bool reqResult   = false;

            Entities.ForEach(( ref GameMngr mngr ) => {
                float dt = World.TinyEnvironment().frameDeltaTime;

                switch (mngr.Mode)
                {
                case MdGame:
                    if (mngr.ReqGameOver)
                    {
                        mngr.ReqGameOver = false;
                        reqGameOver      = true;
                        mngr.Mode        = MdGameOver;
                        mngr.ModeTimer   = 0;
                    }
                    break;

                case MdGameOver:
                    mngr.ModeTimer += dt;
                    if (mngr.ModeTimer > 1.5f)
                    {
                        mngr.Mode = MdResult;
                        reqResult = true;
                    }
                    break;
                }


                if (mngr.IsPause)
                {
                    //isPause = true;
                    return;
                }

                // タイマー.
                mngr.GameTimer += dt;
#if false
                timer = mngr.GameTimer;
                if (timer >= GameTimeLimit)
                {
                    mngr.IsPause = true;
                }
#endif
            });


#if false
            // タイマー表示.
            if (!isPause)
            {
                Entities.WithAll <TextTimerTag>().ForEach(( Entity entity ) => {
                    int t = (int)(GameTimeLimit - timer);
                    EntityManager.SetBufferFromString <TextString>(entity, t.ToString());
                });
            }
#endif
            if (reqResult)
            {
#if true
                // ゲームオーバーシーンアンロード.
                SceneReference gameoverScn = World.TinyEnvironment().GetConfigData <GameConfig>().GameOverScn;
                SceneService.UnloadAllSceneInstances(gameoverScn);
                // リザルト表示.
                SceneReference resultScn = World.TinyEnvironment().GetConfigData <GameConfig>().ResultScn;
                SceneService.LoadSceneAsync(resultScn);
#endif
            }
            else if (reqGameOver)
            {
                // ゲームオーバー表示.
                SceneReference panelBase = new SceneReference();
                panelBase = World.TinyEnvironment().GetConfigData <GameConfig>().GameOverScn;
                SceneService.LoadSceneAsync(panelBase);
            }
        }