Exemplo n.º 1
0
        void Update()
        {
            player_.rigidbody_.transform_.position_ = camera_.transform.position;
            player_.rigidbody_.transform_.rotation_ = camera_.transform.rotation;
            foreach (var t in list_)
            {
                t.update(1f / 60f, Time.time, 0f /* flow_speed */);
            }
            LockTarget.checkAll(player_, Time.time);

            var inv_mat = player_.rigidbody_.transform_.getInverseR();

            foreach (var t in list_)
            {
                if (t.lock_target_.isEntering(ref inv_mat,
                                              ref player_.rigidbody_.transform_.position_,
                                              1f /* ratio */,
                                              1f /* dist_min */,
                                              500f /* dist_max */))
                {
                    t.owner_.GetComponent <MeshRenderer>().material.color = Color.red;
                }
                else
                {
                    t.owner_.GetComponent <MeshRenderer>().material.color = Color.white;
                }
            }
        }
Exemplo n.º 2
0
        void Update()
        {
            my_camera_.rigidbody_.transform_.position_ = camera_.transform.position;
            my_camera_.rigidbody_.transform_.rotation_ = camera_.transform.rotation;
            foreach (var t in list_)
            {
                t.update(1f / 60f, Time.time);
                // t.renderUpdate(0 /* front */, my_camera_, ref dummy_draw_buffer_);
            }
            LockTarget.checkAll(my_camera_);

            var inv_mat = my_camera_.rigidbody_.transform_.getInverseR();

            foreach (var t in list_)
            {
                if (t.lock_target_.isEntering(ref inv_mat,
                                              ref my_camera_.rigidbody_.transform_.position_,
                                              1f /* ratio */,
                                              1f /* dist_min */,
                                              500f /* dist_max */))
                {
                    t.owner_.GetComponent <MeshRenderer>().material.color = Color.red;
                }
                else
                {
                    t.owner_.GetComponent <MeshRenderer>().material.color = Color.white;
                }
            }
        }
Exemplo n.º 3
0
        private void main_loop()
        {
            long begin_time = stopwatch_.ElapsedTicks;

            // flip
            int updating_front = 1 - rendering_front_;

            // begin
            Sight.Instance.begin();
            MySprite.Instance.begin();
            MyFont.Instance.begin();
            Beam.Instance.begin(updating_front);
            Trail.Instance.begin(updating_front);
            Spark.Instance.begin();
            Explosion.Instance.begin();
            Hahen.Instance.begin();

            // update
            bool locked = false;

            if (!pause_)
            {
                GameManager.Instance.update(dt_, update_time_);
                TaskManager.Instance.update(dt_, update_time_);
                // lockon
                locked = LockTarget.checkAll(player_);
                Sight.Instance.updateAll(dt_);
                // HUD
                HUD.Instance.update(dt_, update_time_);
                // collision
                MyCollider.calculate();

                if (InputManager.Instance.getButton(InputManager.Button.Pause) > 0)
                {
                    pause_ = true;
                }
                ++update_frame_;
                update_time_ += dt_;
            }
            else
            {
                if (InputManager.Instance.getButton(InputManager.Button.Pause) > 0)
                {
                    pause_ = false;
                }
            }
            if (locked)
            {
                registSound(DrawBuffer.SE.Lockon);
            }
            update_tick_ = stopwatch_.ElapsedTicks - begin_time;
            begin_time   = stopwatch_.ElapsedTicks;

            // renderUpdate
            draw_buffer_[updating_front].beginRender();
            TaskManager.Instance.renderUpdate(updating_front, ref draw_buffer_[updating_front]);

            // HUD
            HUD.Instance.renderUpdate(updating_front);

            render_update_tick_ = stopwatch_.ElapsedTicks - begin_time;
            // debug info
            if (Options.Instance.PerformanceMeter)
            {
                {
                    MyFont.Instance.putNumber(updating_front, (int)update_frame_, 8 /* keta */, 0.5f /* scale */,
                                              -440f, 270f, MyFont.Type.Green);
                }
                {
                    int gc_count = System.GC.CollectionCount(0 /* generation */) - gc_start_count_;
                    MyFont.Instance.putNumber(updating_front, gc_count, 8 /* keta */, 0.5f /* scale */,
                                              -440f, 254f, MyFont.Type.Red);
                }
                if (used_heap_size_ != 0)
                {
                    int bytes = (int)used_heap_size_;
                    MyFont.Instance.putNumber(updating_front, bytes, 9 /* keta */, 0.5f /* scale */,
                                              -340f, 254f, MyFont.Type.Red);
                }
                if (mono_heap_size_ != 0)
                {
                    int bytes = (int)mono_heap_size_;
                    MyFont.Instance.putNumber(updating_front, bytes, 9 /* keta */, 0.5f /* scale */,
                                              -240f, 254f, MyFont.Type.Red);
                }
                if (mono_used_size_ != 0)
                {
                    int bytes = (int)mono_used_size_;
                    MyFont.Instance.putNumber(updating_front, bytes, 9 /* keta */, 0.5f /* scale */,
                                              -140f, 254f, MyFont.Type.Red);
                }
                {
                    int task_count = TaskManager.Instance.getCount();
                    MyFont.Instance.putNumber(updating_front, task_count, 8 /* keta */, 0.5f /* scale */,
                                              -440f, 238f, MyFont.Type.Blue);
                }

                var height   = 5f;
                var length   = 440f;
                var badget   = 16.666f;
                var update_y = 262f;
                var render_y = 254f;
                {
                    var rect0b = new Rect(-length * 0.5f, update_y, length, height);
                    MySprite.Instance.put(updating_front, ref rect0b, MySprite.Kind.Square, MySprite.Type.Black);

                    var update_ratio = (float)update_tick_ * 1000f / ((float)System.Diagnostics.Stopwatch.Frequency * badget);
                    var rect1b       = new Rect(length * (update_ratio * 0.5f - 1f), update_y,
                                                length * update_ratio, height);
                    MySprite.Instance.put(updating_front, ref rect1b, MySprite.Kind.Square, MySprite.Type.Blue);

                    var render_update_ratio = (float)render_update_tick_ * 1000f / ((float)System.Diagnostics.Stopwatch.Frequency * badget);
                    var rect2b = new Rect(length * (update_ratio - 1f + render_update_ratio * 0.5f), update_y,
                                          length * update_ratio, height);
                    MySprite.Instance.put(updating_front, ref rect2b, MySprite.Kind.Square, MySprite.Type.Green);
                }
#if UNITY_PSP2 || UNITY_PS4
                {
                    var render_ratio = (float)render_tick_ * 1000f / ((float)System.Diagnostics.Stopwatch.Frequency * badget);
                    var rect0b       = new Rect(-length * 0.5f, render_y, length, height);
                    MySprite.Instance.put(updating_front, ref rect0b, MySprite.Kind.Square, MySprite.Type.Black);
                    var rect1b = new Rect(length * (render_ratio * 0.5f - 1f), render_y, length * render_ratio, height);
                    MySprite.Instance.put(updating_front, ref rect1b, MySprite.Kind.Square, MySprite.Type.Red);

                    var render_ratio_begin = (float)render_tick3_ * 1000f / ((float)System.Diagnostics.Stopwatch.Frequency * badget);
                    var render_ratio_end   = (float)render_tick4_ * 1000f / ((float)System.Diagnostics.Stopwatch.Frequency * badget);
                    var render_ratio_len   = render_ratio_end - render_ratio_begin;
                    var rect2b             = new Rect(length * (render_ratio_len * 0.5f - 1f + render_ratio_begin * 0.5f), render_y,
                                                      length * (render_ratio_len), height);
                    MySprite.Instance.put(updating_front, ref rect2b, MySprite.Kind.Square, MySprite.Type.Magenta);
                }
#else
                {
                    var render_ratio = (float)render_tick2_ * 1000f / ((float)System.Diagnostics.Stopwatch.Frequency * badget);
                    var rect0b       = new Rect(-length * 0.5f, render_y, length, height);
                    MySprite.Instance.put(updating_front, ref rect0b, MySprite.Kind.Square, MySprite.Type.Black);
                    var rect1b = new Rect(length * (render_ratio * 0.5f - 1f), render_y, length * render_ratio, height);
                    MySprite.Instance.put(updating_front, ref rect1b, MySprite.Kind.Square, MySprite.Type.Red);
                }
#endif
            }

            // end
            Hahen.Instance.end(updating_front);
            Explosion.Instance.end(updating_front);
            Spark.Instance.end(updating_front);
            Trail.Instance.end();
            Beam.Instance.end();
            MyFont.Instance.end(updating_front);
            MySprite.Instance.end(updating_front);
            Sight.Instance.end(updating_front);
        }
Exemplo n.º 4
0
        private void main_loop()
        {
            long begin_time = stopwatch_.ElapsedTicks;

            // flip
            int updating_front = 1 - rendering_front_;

            // update
            if (!pause_)
            {
                // adaptive frame rate
                setFPS((int)(1f / elapsed_frame_time_));       // call here for stable DT during pause.

                if (Options.Instance.PerformanceMeter &&
                    InputManager.Instance.getButton(InputManager.Button.FFWPlus) > 0)
                {
                    fast_forward_ratio_ += 9;
                }
                if (InputManager.Instance.getButton(InputManager.Button.FFWMinus) > 0)
                {
                    fast_forward_ratio_ -= 9;
                }
                fast_forward_ratio_ = Mathf.Clamp(fast_forward_ratio_, 1, 10);

                for (var i = 0; i < fast_forward_ratio_; ++i)
                {
                    update_flow_speed(dt_);
                    TubeScroller.Instance.update(dt_, flow_speed_);
                    GameManager.Instance.update(dt_, update_time_);
                    Player.Instance.update(dt_, update_time_, flow_speed_);
                    TaskManager.Instance.update(dt_, update_time_, flow_speed_);
                    // lockon
                    bool locked = false;
                    if (player_.isNowLocking())
                    {
                        locked = LockTarget.checkAll(player_, update_time_);
                    }
                    // collision
                    MyCollider.calculate();

                    if (locked)
                    {
                        registSound(DrawBuffer.SE.Lockon);
                    }
                    if (InputManager.Instance.getButton(InputManager.Button.Pause) > 0)
                    {
                        pause_ = true;
                        registBgm(DrawBuffer.BGM.Pause);
                        registMotion(DrawBuffer.Motion.Pause);
                    }
                    ++update_frame_;
                    update_time_ += dt_;
                }
            }
            else
            {
                if (InputManager.Instance.getButton(InputManager.Button.Pause) > 0)
                {
                    pause_ = false;
                    registBgm(DrawBuffer.BGM.Resume);
                    registMotion(DrawBuffer.Motion.Resume);
                }
                else
                {
                    if (InputManager.Instance.getButton(InputManager.Button.Back) > 0)
                    {
                        long  elapsed_tick = stopwatch_.ElapsedTicks - pause_back_time_;
                        float elapsed      = (float)elapsed_tick / ((float)System.Diagnostics.Stopwatch.Frequency);
                        if (elapsed > 1f)
                        {
                            GameManager.Instance.setReplayMode(false);
                            restart();
                            pause_ = false;
                        }
                    }
                    else
                    {
                        pause_back_time_ = stopwatch_.ElapsedTicks;
                    }
                }
            }
            // profile
            update_tick_ = stopwatch_.ElapsedTicks - begin_time;
            begin_time   = stopwatch_.ElapsedTicks;

            // begin
            MyFont.Instance.begin();
            MySprite.Instance.begin();
            VRSprite.Instance.begin();
            Sight.Instance.begin();
            Beam.Instance.begin(updating_front);
            Beam2.Instance.begin(updating_front);
            Trail.Instance.begin(updating_front);
            Spark.Instance.begin();
            Explosion.Instance.begin();
            Hahen.Instance.begin();
            Shockwave.Instance.begin();
            Shield.Instance.begin();

            // renderUpdate
            draw_buffer_[updating_front].beginRender();
            my_camera_.renderUpdate(updating_front, ref draw_buffer_[updating_front]);
            player_.renderUpdate(updating_front, ref draw_buffer_[updating_front]);
            TaskManager.Instance.renderUpdate(updating_front, my_camera_, ref draw_buffer_[updating_front]);

            // debug info
            renderUpdate_debug_info(updating_front);

            // end
            Shield.Instance.end(updating_front);
            Shockwave.Instance.end(updating_front);
            Hahen.Instance.end(updating_front);
            Explosion.Instance.end(updating_front);
            Spark.Instance.end(updating_front);
            Trail.Instance.end();
            Beam2.Instance.end();
            Beam.Instance.end();
            Sight.Instance.end(updating_front);
            VRSprite.Instance.end(updating_front);
            MySprite.Instance.end(updating_front);
            MyFont.Instance.end(updating_front);

            render_update_tick_ = stopwatch_.ElapsedTicks - begin_time;
        }