コード例 #1
0
ファイル: Level.cs プロジェクト: VABG/SpaceGame
    public void Win()
    {
        if (player.dead)
        {
            return;
        }
        player.Win();
        levelState         = LevelState.Won;
        UIInformation.text = "You did it!";
        UIScoreScreen.SetActive(true);
        UITotalScore.text = (score + (int)time).ToString();
        //Calculate score (time + score)
        countdown = 5;
        GameMgr.AddScore(score, time);

        HUDInGameObject.SetActive(false);
    }
コード例 #2
0
    protected override void OnUpdate()
    {
        // 在System中涉及到StructChange,需要用ECB等到主线程处理
        var commandBuffer = m_BufferSystem.CreateCommandBuffer();

        Entities.WithAll <DeleteTag>().WithoutBurst().ForEach((Entity entity) =>
        {
            GameMgr.AddScore();
            commandBuffer.DestroyEntity(entity);
        }).Schedule();
        m_BufferSystem.AddJobHandleForProducer(Dependency);

        // 官方写法
        // using (var commandBuffer = new EntityCommandBuffer(Allocator.TempJob))
        // {
        //     Entities.WithAll<DeleteTag>().WithoutBurst().ForEach((Entity entity) =>
        //     {
        //         GameMgr.AddScore();
        //         commandBuffer.DestroyEntity(entity);
        //     }).Run();

        //     commandBuffer.Playback(EntityManager);
        // }
    }