private static void _Collision(int i) { //Game if (enemy[i].Bounds.IntersectsWith(character.Bounds)) { pause = true; fight = true; e_move[i] = 0; MiniGame.e_count = i; char_move = 0; Save._Upload(); _enemyRemove(0); f.Controls.Clear(); Interface.Scenes("s_minigame"); } for (int j = 0; j < e_count; j++) { if (i != j) { if (enemy[i].Bounds.IntersectsWith(enemy[j].Bounds)) { e_move[j] = 0; e_move[i] = 1; } } } }
public static void InGame() { f.Controls.Clear(); f.BackColor = Color.LightGreen; //f.BackgroundImage = Interface.res[15]; if (!Save.save) { _start(); } Interface.Scenes("s_interface"); if (!Save.save) { character = new PictureBox(); character.Location = new Point(20, _height / 2 - 20); character.Size = new Size(40, 40); character.Image = Interface.res[0]; f.Controls.Add(character); } fruit = new PictureBox(); fruit.Location = new Point(_width + 50, 10); fruit.Size = new Size(10, 10); fruit.Image = Interface.res[1]; f.Controls.Add(fruit); if (Save.save) { Save._Unload(); } if (!Save.save) { _enemySpawn("spawn"); _enemySpawn("spawn"); } else { _enemySpawn("update"); } if (!key) { Interface.sound[0].PlayLooping(); f.KeyDown += new KeyEventHandler(OKP); key = true; } }
public static void _dead() { if (character_hp <= 0) { if (!die) { f.Controls.Clear(); Save.save = false; die = true; DialogResult result = MessageBox.Show("Вы умерли", "Смерть", MessageBoxButtons.RetryCancel); if (result == DialogResult.Retry) { InGame(); } if (result == DialogResult.Cancel) { f.BackColor = Color.LightBlue; Interface.Scenes("s_menu"); } } } }
private static void _CheckBorders() { if (Locations.move_right) { if (character.Location.X < 0) //Right { int y = character.Location.Y; f.Controls.Clear(); _enemyRemove(); Interface.Scenes("s_interface"); Locations.numhow_right++; Locations.numwhere_right = 1; Locations.numwhere_left = 0; Locations.numwhere_up = 0; Locations.numwhere_down = 0; character = new PictureBox(); character.Location = new Point(_width - 58, y); character.Size = new Size(40, 40); character.Image = Interface.res[0]; f.Controls.Add(character); Locations._moveAllow(); } } if (Locations.move_left) { if (character.Location.X > _width - 18) //Left { int y = character.Location.Y; f.Controls.Clear(); _enemyRemove(); Interface.Scenes("s_interface"); Locations.numhow_left++; Locations.numwhere_right = 0; Locations.numwhere_left = 1; Locations.numwhere_up = 0; Locations.numwhere_down = 0; character = new PictureBox(); character.Location = new Point(0, y); character.Size = new Size(40, 40); character.Image = Interface.res[0]; f.Controls.Add(character); Locations._moveAllow(); } } if (Locations.move_up) { if (character.Location.Y < 40) //Up { int x = character.Location.X; f.Controls.Clear(); _enemyRemove(); Interface.Scenes("s_interface"); Locations.numhow_up++; Locations.numwhere_right = 0; Locations.numwhere_left = 0; Locations.numwhere_up = 1; Locations.numwhere_down = 0; character = new PictureBox(); character.Location = new Point(x, _height - 80); character.Size = new Size(40, 40); character.Image = Interface.res[0]; f.Controls.Add(character); Locations._moveAllow(); } } if (Locations.move_down) { if (character.Location.Y > _height - 41) //Down { int x = character.Location.X; f.Controls.Clear(); _enemyRemove(); Interface.Scenes("s_interface"); Locations.numhow_down++; Locations.numwhere_right = 0; Locations.numwhere_left = 0; Locations.numwhere_up = 0; Locations.numwhere_down = 1; character = new PictureBox(); character.Location = new Point(x, 41); character.Size = new Size(40, 40); character.Image = Interface.res[0]; f.Controls.Add(character); Locations._moveAllow(); } } }
public static void OKP(object sender, KeyEventArgs e) { switch (e.KeyCode.ToString()) { case "W": //Up if (!pause && !die && !MiniGame.minigame) { if (char_move != 0) { m_x = 0; m_y = neg_move * (int)spd; _characterMove(); } } break; case "A": //Left if (!pause && !die && !MiniGame.minigame) { if (char_move != 0) { m_x = neg_move * (int)spd; m_y = 0; _characterMove(); } } break; case "S": //Down if (!pause && !die && !MiniGame.minigame) { if (char_move != 0) { m_x = 0; m_y = posi_move * (int)spd; _characterMove(); } } break; case "D": //Right if (!pause && !die && !MiniGame.minigame) { if (char_move != 0) { m_x = posi_move * (int)spd; m_y = 0; _characterMove(); } } break; case "Escape": if (Interface.p_game && !MiniGame.minigame) { pause = true; DialogResult result = MessageBox.Show ("Да - выход из игры, Нет - выход в меню", "Выход", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { Application.Exit(); } if (result == DialogResult.No) { pause = false; Save._Upload(); Interface.Scenes("s_menu"); } if (result == DialogResult.Cancel) { pause = false; } } else { Application.Exit(); } break; case "I": if (!die && !MiniGame.minigame) { if (!Inventory.inv && !pause) { if (!Inventory.key) { f.KeyDown += new KeyEventHandler(Inventory.OKP_inv); Inventory.key = true; } pause = true; Inventory.inv = true; Save._Upload(); _enemyRemove(0); f.Controls.Clear(); Interface.Scenes("s_inventory"); } else { pause = false; Inventory.inv = false; InGame(); } } break; //Debug case "Z": if (debug) { _fruitSpawn(); } break; case "C": if (debug) { character_hp = character_hp - 1; } break; case "X": if (debug) { if (!e_cmove) { e_cmove = true; } else { e_cmove = false; } } break; case "H": if (debug) { immortal = true; } break; case "O": if (debug && !MiniGame.minigame) { exp = exp_n - 1; } break; case "P": if (debug) { if (!pause) { pause = true; } else { pause = false; } } break; } }
private void Form1_Shown(object sender, EventArgs e) { Interface.CreateWindow(); Interface.Scenes("s_menu"); Interface.resload(); }