public virtual bool Collision(Shoot shoot) { if (!active) return false; float col = MyMath.Collision(new Point(shoot.px, shoot.py), new Point(px, py), new Point(shoot.vx, shoot.vy), length, new Point(4, 1)); if (col <= 1.0f && col >= 0.0f) { shoot.Hit(point); Break(); return true; } return false; }
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]; }