예제 #1
0
파일: myForm.cs 프로젝트: Zamk/WinFormsTest
        private void StartGame()
        {
            wc             = new WaterConteiner();
            c              = new Courier();
            timer          = new Timer();
            timer.Interval = 1000 / FPS;
            timer.Tick    += TimerTick;

            wc.CreateWaterConteiner(sizeOfConteiner);
            Paint += wc.RedrawConteiner;

            c.CreateCourier(new Point(courierStartPositionX, conteinerPositionY));
            Paint += c.Redraw;

            c.CourierTookWaterEvent += new CourierHandler(wc.CourierTookWaterHandler);
            c.CourierFinishedEvent  += new CourierHandler(wc.CourierFinishedHandler);
            c.CourierFinishedEvent  += new CourierHandler(TicksReset);


            wc.WaterConteinerFullEvent += new WaterConteinerHandler(c.WaterConteinerFullHandler);

            c.ConteinerPositionX = conteinerPositionX;
            c.Speed = courierSpeed;

            timer.Start();
        }
예제 #2
0
        public void Start()
        {
            wc = new WaterConteiner(5);
            c  = new Courier(new Point(courierStartPosition.X, courierStartPosition.Y));

            c.CourierTookWaterEvent += new CourierHandler(wc.CourierTookWaterHandler);
            c.CourierFinishedEvent  += new CourierHandler(wc.CourierFinishedHandler);
            c.CourierFinishedEvent  += new CourierHandler(End);

            wc.WaterConteinerFullEvent += new WaterConteinerHandler(c.WaterConteinerFullHandler);

            c.ConteinerPositionX = conteinerPosition.X;
            c.Speed = 10;            //courierSpeed;
        }
예제 #3
0
파일: myForm.cs 프로젝트: Zamk/WinFormsTest
        private void StopGame()
        {
            if (timer != null)
            {
                timer.Stop();
            }

            if (wc != null)
            {
                wc.Clear();
                wc = null;
            }
            if (c != null)
            {
                c.Stop();
                c = null;
            }
            TicksReset();
            this.Refresh();
        }