public static DebugCamera create()
        {
            var camera = new DebugCamera();

            camera.init();
            return(camera);
        }
Exemple #2
0
        void initialize()
        {
            MyRandom.setSeed(12345L);
            camera_final_         = GameObject.Find("FinalCamera").GetComponent <Camera>();
            camera_final_.enabled = false;
            if ((float)Screen.width / (float)Screen.height < 16f / 9f)
            {
                var size = camera_final_.orthographicSize * ((16f / 9f) * ((float)Screen.height / (float)Screen.width));
                camera_final_.orthographicSize = size;
            }
            meter_draw_ = true;

            Application.targetFrameRate = (int)RENDER_FPS; // necessary for iOS because the default is 30fps.
            // QualitySettings.vSyncCount = 1;

            stopwatch_ = new System.Diagnostics.Stopwatch();
            stopwatch_.Start();
            rendering_front_ = 0;

            setFPS(DefaultFps);
            update_frame_      = 0;
            update_time_       = 100.0; // ゼロクリア状態を過去のものにするため増やしておく
            render_frame_      = 0;
            render_sync_frame_ = 0;
            pause_             = false;
            spectator_mode_    = true;

            camera_          = GameObject.Find("Main Camera").GetComponent <Camera>();
            ProjectionMatrix = camera_.projectionMatrix;

            MissileManager.Instance.initialize(camera_);
            InputManager.Instance.init();
            Controller.Instance.init(false /* auto */);
            TaskManager.Instance.init();
            Fighter.createPool();
            Spark.Instance.init(spark_material_);
            Debris.Instance.init(debris_material_);
            MySprite.Instance.init(sprites_, sprite_material_);
            MySpriteRenderer.Instance.init(camera_);
            MyFont.Instance.init(font_, font_material_);
            MyFontRenderer.Instance.init();

            PerformanceMeter.Instance.init();

            draw_buffer_ = new DrawBuffer[2];
            for (int i = 0; i < 2; ++i)
            {
                draw_buffer_[i].init();
            }

            debug_camera_     = DebugCamera.create();
            spectator_camera_ = SpectatorCamera.create();
            set_camera();

            // audio
            audio_sources_explosion_ = new AudioSource[AUDIOSOURCE_EXPLOSION_MAX];
            for (var i = 0; i < AUDIOSOURCE_EXPLOSION_MAX; ++i)
            {
                audio_sources_explosion_[i]        = gameObject.AddComponent <AudioSource>();
                audio_sources_explosion_[i].clip   = se_explosion_;
                audio_sources_explosion_[i].volume = 0.01f;
                audio_sources_explosion_[i].pitch  = 0.25f;
            }
            audio_source_explosion_index_ = 0;
            audio_sources_laser_          = new AudioSource[AUDIOSOURCE_LASER_MAX];
            for (var i = 0; i < AUDIOSOURCE_LASER_MAX; ++i)
            {
                audio_sources_laser_[i]        = gameObject.AddComponent <AudioSource>();
                audio_sources_laser_[i].clip   = se_laser_;
                audio_sources_laser_[i].volume = 0.025f;
            }
            audio_source_laser_index_ = 0;

            GameManager.Instance.init(debug_mode_);

#if UNITY_PS4 || UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
            int rw = 1920;
            int rh = 1080;
#else
            int rw = 1024;
            int rh = 576;
#endif
            render_texture_ = new RenderTexture(rw, rh, 24 /* depth */, RenderTextureFormat.ARGB32);
            render_texture_.Create();
            camera_.targetTexture       = render_texture_;
            final_material_.mainTexture = render_texture_;
            alpha_matrices_             = new Matrix4x4[ALPHA_MAX];
            frustum_planes_             = new Vector4[6];

            initialized_          = true;
            camera_final_.enabled = true;
        }