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(); }
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; }
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(); }