Пример #1
0
        public Game(CanvasHelper _cv)
        {
            cv = _cv;
            cv.MouseButtonEvent += Canvas_MouseLeftButtonUp;
            cv.KeyDown          += CanvasKeyDown;
            cv.KeyUp            += CanvasKeyUp;

            GameStates                  = new Dictionary <State, States.StateBase>(4);
            GameStates[State.Menu]      = new States.MenuState(cv, resources, player);
            GameStates[State.Selecting] = new States.SelectingState(cv, resources, player);
            GameStates[State.Playing]   = new States.PlayingState(cv, resources, player);
            GameStates[State.Result]    = new States.ResultState(cv, resources, player);
            foreach (var s in GameStates)
            {
                s.Value.OnPushState += OnPushState;
            }
        }
Пример #2
0
        private void Canvas_Loaded(object sender, EventArgs e)
        {
            canvas.Focus();
            cv   = new CanvasHelper(canvas);
            game = new Game(cv);

            try {
                game.Initialize();
            } catch (Exception ex) {
                MessageBox.Show("在初始化时发生错误!\n\n详细信息: \n" + ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
                return;
            }

            loop    = new Thread(new ThreadStart(Loop));
            looping = true;
            loop.Start();
        }
Пример #3
0
 public bool Draw(CanvasHelper cv, decimal now, double[] segments, Dictionary <string, object> resources, double factor = 0.7)
 {
     if (!OnScreen(now, factor))
     {
         return(false);
     }
     if (type == Type.Tap)
     {
         if (status == Status.Free)
         {
             if (column == 0 || column == 3)
             {
                 cv.Image(GetNoteX(segments), GetNoteY(time, now, factor), GetNoteWidth(segments), GetNoteLength(factor), (Brush)resources["img.note1"]);
             }
             else
             {
                 cv.Image(GetNoteX(segments), GetNoteY(time, now, factor), GetNoteWidth(segments), GetNoteLength(factor), (Brush)resources["img.note2"]);
             }
         }
     }
     else
     {
         Brush b = null;
         if (column == 0 || column == 3)
         {
             b = (Brush)resources["img.note1L"];
         }
         else
         {
             b = (Brush)resources["img.note2L"];
         }
         if (status == Status.Miss || endStatus == Status.Miss)
         {
             b         = b.Clone();
             b.Opacity = 0.6;
         }
         cv.Image(GetNoteX(segments), GetNoteY(endtime, now, factor), GetNoteWidth(segments), GetNoteLength(factor), b);
     }
     return(true);
 }