//Event handler for every time the rain timer ticks private void rain_Tick(object sender, EventArgs e) { for (int i = 0; i < rainAmount; i++) { int nextInt = Rand.Next(0, rainDokiesSelected); int nextSizeInt = Rand.Next(0, rainSizeCount); if (!justMonika) { if (nextInt == 0 && !rainSayori) { nextInt++; } if (nextInt == 1 && !rainNatsuki) { nextInt++; } if (nextInt == 2 && !rainYuri) { nextInt++; } } else { nextInt = (int)Who.wMonika; } if (nextSizeInt == 0 && !rainLarge) { nextSizeInt++; } if (nextSizeInt == 1 && !rainMedium) { nextSizeInt++; } Who next = (Who)nextInt; DokiSize nextSize = (DokiSize)nextSizeInt; Doki doki = null; switch (next) { case Who.wSayori: doki = GetSayori((int)nextSize, true); break; case Who.wNatsuki: doki = GetNatsuki((int)nextSize, true); break; case Who.wYuri: doki = GetYuri((int)nextSize, true); break; case Who.wMonika: doki = GetMonika((int)nextSize, true); break; } doki.Location = new Point(Rand.Next(0, doki.rWall), -doki.Height - 5); doki.Show(); } rain.Interval = Rand.Next(lowerRainInterval, higherRainInterval + 1); }
//Size ranges from 0(Large) to 2(small) public Doki(Bitmap S, Bitmap H, Bitmap D, DokiSize size, Who dokiWho, bool isRain = false) { InitializeComponent(); happy = (Bitmap)H.Clone(); happy_Flip = (Bitmap)H.Clone(); standing = (Bitmap)S.Clone(); standing_Flip = (Bitmap)S.Clone(); dead = (Bitmap)D.Clone(); who = dokiWho; Screen myScreen = Screen.FromControl(this); Rectangle area = myScreen.WorkingArea; setHappy(); floor = area.Height - this.image.Height + area.Y; rainFloor = area.Height + this.image.Height * 2 + 5; rWall = area.Width - this.image.Width + area.X; lWall = area.X; happy_Flip.RotateFlip(RotateFlipType.RotateNoneFlipX); standing_Flip.RotateFlip(RotateFlipType.RotateNoneFlipX); this.Disposed += (ss, ee) => { Fall.Dispose(); Jump.Dispose(); Move.Dispose(); Walk.Dispose(); Die.Dispose(); Rain.Dispose(); happy.Dispose(); standing.Dispose(); happy_Flip.Dispose(); standing_Flip.Dispose(); dead.Dispose(); }; Die.Tick += new EventHandler(Die_Elapsed); Die.Interval = 10; if (!isRain) { walkHopMax += 2 * (int)size + 1; jumpSpeedMax += 2 * (int)size + 1; //jumpReduction walkHop = walkHopMax; jumpSpeed = jumpSpeedMax; falling = true; this.image.MouseDown += image_MouseDown; this.image.MouseMove += image_MouseMove; this.image.MouseUp += image_MouseUp; Fall.Tick += new EventHandler(Fall_Elapsed); Fall.Interval = 15; Jump.Tick += new EventHandler(Jump_Elapsed); Jump.Interval = 10; Walk.Tick += new EventHandler(Walk_Elapsed); Walk.Interval = 10; Move.Tick += new EventHandler(Move_Elapsed); Move.Interval = rand.Next(750, 2751); Fall.Start(); } else { acc /= 8; if (rand.Next(0, 2) == 0) { Flip(); } setHappy(); this.Update(); Rain.Tick += new EventHandler(Rain_Elapsed); Rain.Interval = 15; Rain.Start(); } }