public bool Initialize()
        {
            // インスタンスを代入
            getInstance = this;

            // 接続されているセンサを捜索
            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    this.sensor = potentialSensor;
                    break;
                }
            }

            if (null != this.sensor)
            {
                // SkeletonStreamを有効にする
                this.sensor.SkeletonStream.Enable();

                // SkeletonStreamにイベントを追加
                this.sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady);

                // Turn on the depth stream to receive depth frames
                this.sensor.DepthStream.Enable(DepthFormat);

                this.depthWidth = this.sensor.DepthStream.FrameWidth;

                this.depthHeight = this.sensor.DepthStream.FrameHeight;

                this.sensor.ColorStream.Enable(ColorFormat);

                int colorWidth = this.sensor.ColorStream.FrameWidth;
                int colorHeight = this.sensor.ColorStream.FrameHeight;

                this.colorToDepthDivisor = colorWidth / this.depthWidth;

                // Turn on to get player masks
                this.sensor.SkeletonStream.Enable();

                // Allocate space to put the depth pixels we'll receive
                this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];

                // Allocate space to put the color pixels we'll create
                this.colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength];

                this.playerPixelData = new int[this.sensor.DepthStream.FramePixelDataLength];

                this.colorCoordinates = new ColorImagePoint[this.sensor.DepthStream.FramePixelDataLength];

                // This is the bitmap we'll display on-screen
                this.colorBitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgr32, null);

                // Set the image we display to point to the bitmap where we'll put the image data
                // Image に設定する
                //this.MaskedImage.Source = this.colorBitmap;

                // Add an event handler to be called whenever there is new depth frame data
                this.sensor.AllFramesReady += this.SensorAllFramesReady;

                // センサを起動
                try
                {
                    this.sensor.Start();
                }
                catch (IOException)
                {
                    this.sensor = null;
                }
            }
            else {
                //CompositionTarget.Rendering += UpdateImage;
            }

            // インスタンス化
            this.skeleton = new Skeleton();

            // スレッドでの呼び出し優先度指定
            this.dispatcherTimer = new DispatcherTimer();

            // 1秒ごとに処理()
            this.dispatcherTimer.Interval = new TimeSpan(100000);

            // イベント追加
            this.dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);

            // タイマー動作開始
            //this.dispatcherTimer.Start();

            this.poseSet    = new Vector4[20];
            this.poseCharge = new Vector4[20];
            this.poseAim    = new Vector4[20];
            this.poseShoot  = new Vector4[20];

            try
            {
                this.poseSet    = MotionIO.LoadJoint("poseSet");
                this.poseCharge = MotionIO.LoadJoint("poseCharge");
                this.poseAim    = MotionIO.LoadJoint("poseAim");
                this.poseShoot  = MotionIO.LoadJoint("poseShoot");
            }
            catch (Exception ex)
            {
                Console.WriteLine("読み込み失敗");
            }

            playerColor = Brushes.ForestGreen;
            alphaColor = new SolidColorBrush(Color.FromArgb((byte)0, (byte)255, (byte)255, (byte)255));

            this.bones = new Line[20];
            for (int i = 0; i < this.bones.Length; i++)
            {
                this.bones[i] = new Line();

                // 描画設定
                this.bones[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                this.bones[i].VerticalAlignment = System.Windows.VerticalAlignment.Top;
                this.bones[i].StrokeThickness = 4;
                this.bones[i].Stroke = playerColor;

                // Canvasに追加
                MainWindow.mainCanvas.Children.Add(this.bones[i]);
            }

            nowState = KinectState.None;

            fromShoot = new Point();
            toShoot = new Point();

            return true;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            getInstance = this;

            rand = new Random();

            mainCanvas = MainCanvas;

            background = new Image();
            background.Source = null;
            background.Width = 960;
            background.Height = 540;
            background.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            background.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            background.Margin = new Thickness(0, 0, 0, 0);
            mainCanvas.Children.Add(background);

            stateSetInit();

            titleTex = new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Back/ArrowSimulaterTitle.png", System.UriKind.Relative));

            tutorialTex = new BitmapImage[4];
            for (int i = 0; i < 4; i++) {
                tutorialTex[i] = new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Back/ArrowSimulaterTutorial0" + i.ToString() + ".png", System.UriKind.Relative));
            }
            BackgroundTex =  new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Back/ArrowSimulaterBackground01.png", System.UriKind.Relative));
            ResultBackTex = new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Back/ArrowSimulaterBackground00.png", System.UriKind.Relative));
            resultTex = new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Score/ArrowSimulaterResult.png", System.UriKind.Relative));
            rankingTex = new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Score/ArrowSimulaterRanking.png", System.UriKind.Relative));
            SoremadeTex = new BitmapImage(new Uri("/ArrowSimulater;component/Resource/Back/soremade.png", System.UriKind.Relative));

            KinectManager kinectManager = new KinectManager();
            kinectManager.Initialize();

            Bow bow = new Bow();
            bow.Initialize();

            SpriteManager spriteManager = new SpriteManager();
            spriteManager.Initialize();

            ShootLine shootLine = new ShootLine();
            shootLine.Initialize();

            dispatcherTimer = new DispatcherTimer();

            dispatcherTimer.Interval = new TimeSpan(166666L);

            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);

            dispatcherTimer.Start();

            shoot = new Shoot();

            ScoreManager scoreManager = new ScoreManager();
            scoreManager.Initialize();

            //int[] sL = { 100, 300, 500, 1000, 2000, 4000, 8000 };
            //ScoreManager.getInstance.scoreRoot.Add(sL);

            TMax = 40;
            target = new TargetBase[TMax];

            for (int i = 0; i < TMax - 15; i++) {
                target[i] = new TargetSimple();
                //target[i].setPosition((float)rand.NextDouble() * 250 + 50, (float)rand.NextDouble() * 400 + 100);
            }
            for (int i = TMax - 15; i < TMax - 3; i++) {
                target[i] = new TargetSmall();
            }
            for (int i = TMax - 3; i < TMax; i++) {
                target[i] = new TargetFire();
            }
            target[0].setPosition(100, 400);

            targetIndex = 0;

            //imageSet.Source = SpriteManager.images[0];
        }