private void tHelp_Tick(object sender, EventArgs e)//выбор бонус { int r = matilda1.RandomInt(1, 15); int x = matilda1.RandomInt(0, ClientRectangle.Width - 25); int y = menuStrip1.Height; if (r == 1 || r <= 7) { SuperImage h = matilda1.CreateSuperImage("3_fireballs_pack.png", x, y, 25, 25); h.Name = "Перезарядка"; mmm.Add(h); } if (r >= 8 && r <= 12) { SuperImage h = matilda1.CreateSuperImage("3_fireballs_pack3.png", x, y, 25, 25); h.Name = "Тройной"; mmm.Add(h); } if (r > 12) { SuperImage h = matilda1.CreateSuperImage("3_fireballs_pack2.png", x, y, 25, 25); h.Name = "Супер"; mmm.Add(h); } tHelp.Interval = matilda1.RandomInt(5000, 15000); }
public static SuperImage SuperResolution(SuperImage image) { //python superres.py sham.jpg var image_path = Path.Combine(Environment.CurrentDirectory, "Python", "SuperRes", "temp", image.Name); byte[] img_bytes = Convert.FromBase64String(image.Base64); using (Image jpg_image = Image.FromStream(new MemoryStream(img_bytes))) { jpg_image.Save(image_path, ImageFormat.Jpeg); // Or Png } var superres_file = Path.Combine(Environment.CurrentDirectory, "Python", "SuperRes", "superres.py"); Process SolutionExecution = new Process(); SolutionExecution.StartInfo.RedirectStandardOutput = true; SolutionExecution.StartInfo.FileName = "python"; SolutionExecution.StartInfo.Arguments = string.Format("{0} {1}", superres_file, image_path); SolutionExecution.Start(); string ExecutionOutput = SolutionExecution.StandardOutput.ReadToEnd(); ExecutionOutput = ExecutionOutput.Replace(Environment.NewLine, String.Empty); if (File.Exists(ExecutionOutput)) { image.ImagePath = ExecutionOutput; image.Base64 = ConvertTo64(ExecutionOutput); } return(image); }
public void Streaming(Client client) { //MessageBox.Show(service.State.ToString()); while (true) { try { SuperImage si = service.GetScreenShotAsync(client.PcName).Result; using (var ms = new System.IO.MemoryStream(si.Content)) { var image = new BitmapImage(); image.BeginInit(); image.CacheOption = BitmapCacheOption.OnLoad; image.StreamSource = ms; image.EndInit(); new Thread(() => Task.Factory.StartNew(() => ChangeScreen(image))).Start(); } } catch (FaultException ex) { MessageBox.Show(ex.Code.SubCode.Name + "\n" + ex.Code.Name); MessageBox.Show(ex.Reason.ToString()); MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void стартToolStripMenuItem_Click(object sender, EventArgs e) { timer1.Start(); label2.Text = breek.ToString(); label1.Text = ""; //Чтобы убрать надпись Game Over, когда начинаем игру не в первый раз for (int i = 0; i < ball_count; i++) { SuperBall ball; ball = new SuperBall(matilda1, "3_метеорит2.png", ClientRectangle.Width / 2 - 25, ClientRectangle.Height / 2 - 25, 50, 50, "ball"); ball.topstep = matilda1.RandomInt(-30, 30); ball.leftstep = matilda1.RandomInt(-30, 30); balls.Add(ball); } desk = matilda1.CreateSuperImage(null, ClientRectangle.Width / 2 - 50, ClientRectangle.Height - 30 - 30, 100, 30, "desk"); desk.OnPaint += PaintDesk; int brick_top = 33; for (int i = 0; i < 3; i++) { int brick_left = 35; for (int j = 0; j < 16; /*именно столько помещается*/ j++) { brick = matilda1.CreateSuperImage(null, brick_left, brick_top, 100, 45, "rock"); brick.OnPaint += Brick_OnPaint; brick_left += 100 + 20; } brick_top += 45 + 33; } }
public void sTARTToolStripMenuItem_Click(object sender, EventArgs e)// начало игры { tStrike.Enabled = true; tMetior.Enabled = true; tMetiorMove.Enabled = true; tHelp.Enabled = true; tAllTime.Start(); if (rocket == false) { mmm.Clear(); Fireball.Clear(); matilda1.ClearAllImages(); sec = 00; min = 0; ship = matilda1.CreateSuperImage("3_ракета3.png", x_S, y_S, w_S, h_S, "Ракета"); Earth = matilda1.CreateSuperImage("3_Земля.jpg", x_E, y_E, w_E, h_E); Earth.Name = "Земля"; rocket = true; if (arcada == true) { fireballCount = 50; lFBCount.Text = fireballCount.ToString(); } else { fireballCount = 10000; lFBCount.Text = fireballCount.ToString(); } } label1.Visible = false; point = 0; }
void CreateMet(int x, int y, int r) { SuperImage m = matilda1.CreateSuperImage("3_метеорит2.png", x, y, 25 * r, 25 * r); m.Offset = matilda1.RandomInt(-3, 3); m.Name = "M" + r.ToString(); mmm.Add(m); }
// создание самого faire ball^а по клику мышки private void Form1_MouseClick(object sender, MouseEventArgs e) { if (bullet_count > 0) { SuperImage fball = matilda1.CreateSuperImage("3_fireball.png", desk.Left + desk.Width / 2 - 30 / 2, desk.Top - 30, 30, 30, "fire!"); bullets.Add(fball); bullet_count--; } }
public void GetScreenshot(Client Client) { GoAnotherAdditionMode(AdditionType.Image); Active.Content = Client.PcName; string filename = (AppDomain.CurrentDomain.BaseDirectory + "Screenshots\\screenshot_" + Client.PcName + "_" + Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "Screenshots").Length + ".png"); SuperImage ScreenShot = service.GetScreenShotAsync(Client.PcName).Result; File.WriteAllBytes(filename, ScreenShot.Content); Dispatcher.Invoke(() => Screen.Source = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute))); }
int breek = 48; // колво кирпичей void PaintDesk(SuperImage s, SuperImagePainter b) { if (color == true) { b.FillRectangle(0, 0, s.Width, s.Height, Color.Red); } else { b.FillRectangle(0, 0, s.Width, s.Height, Color.LightPink); } }
private void Form1_MouseClick(object sender, MouseEventArgs e) { if (bullet_count > 0) { SuperImage fball = matilda1.CreateSuperImage("3_fireball.png", desk.Left + desk.Width / 2 - 30 / 2, desk.Top - 30, 30, 30, "fire!"); bullets.Add(fball); bullet_count--; } //Тут ты забыл обратно возвращать цвет дощечки после того, как закончатся пули else { color = false; } }
//Создание доски с нуля, по точкам void DeskOnPaint(SuperImage s, SuperImagePainter p) { if (bullet_count > 0) { p.FillPolygon(desk_points, Color.Pink); p.DrawString(bullet_count.ToString(), 6, s.Width / 2 - 4, 2, Color.Black); } else { p.FillPolygon(desk_points, Color.Yellow); } p.DrawPolygon(desk_points, Color.Black, 2); }
public void Form1_Load(object sender, EventArgs e) { x_E = 0; y_E = ClientRectangle.Height - 50; w_E = ClientRectangle.Width; h_E = 50; Earth = matilda1.CreateSuperImage("3_Земля.jpg", x_E, y_E, w_E, h_E); Earth.Name = "Земля"; x_S = ClientRectangle.Width / 2 - 35; y_S = ClientRectangle.Height - 40 - 70; ship = matilda1.CreateSuperImage("3_ракета3.png", x_S, y_S, w_S, h_S, "Ракета"); rocket = true; }
//const int brick_width = 70; //const int brick_heigth = 30; private void Form1_Load(object sender, EventArgs e) { CreateBreacks(); desk = matilda1.CreateSuperImage( null, ClientRectangle.Width / 2 - desk_width - 2, GetDeskTop(), desk_width, desk_heigth, "доска"); desk.OnPaint += DeskOnPaint; labels_bottom_height = ClientRectangle.Height - label1.Top; }
public ChaosRenderingMachine(string pMachineName, int pDisplayWidth, int pDisplayHeight, SuperColor pInfiniteColor, SuperColor pStartColor, SuperColor pEndColor, int pColorCount) { //Set the machine name this._MachineName = pMachineName; //Set the machines viewport size this._PixelWidth = pDisplayWidth; this._PixelHeight = pDisplayHeight; //Define a color to represent "infinite" this._InfiniteColor = pInfiniteColor; //Create a simple Gradient Pallete this._Palette = new SuperImagePalette(pStartColor, pEndColor, pColorCount); //Create a simple image; later this could end up being a "subsuper" image? Only buffers no gtk this._MachineOutputImage = new SuperImage(this._PixelWidth, this._PixelHeight, 2); }
//The simplest Constructor public ChaosRenderingMachine(string pMachineName) { //Set the machine name this._MachineName = pMachineName; //Set the machines viewport size this._PixelWidth = 400; this._PixelHeight = 300; //Define a color to represent "infinite" this._InfiniteColor = new SuperColor(0, 15, 0); //Create a simple 100 color pallette SuperColor tmpStartColor = new SuperColor(0, 0, 0); SuperColor tmpEndColor = new SuperColor(255, 255, 255); this._Palette = new SuperImagePalette(tmpStartColor, tmpEndColor, 100); //Create a simple image; later this could end up being a "subsuper" image? Only buffers no gtk this._MachineOutputImage = new SuperImage(this._PixelWidth, this._PixelHeight); }
// Цветом зарисовываем кирпич, да с рамкой private void SiBrick_OnPaint(SuperImage s, SuperImagePainter p) { SuperBrick brick = (SuperBrick)s; if (brick.include_fireballpack) { p.FillRectangle(0, 0, s.Width, s.Height, Color.Red); } else if (brick.multi_live) { p.FillRectangle(0, 0, s.Width, s.Height, Color.Gray); p.FillRectangle(6, 6, 12, 16, Color.White); p.DrawString(brick.count_live.ToString(), 10, 6, 6, Color.Black); } else { p.FillRectangle(0, 0, s.Width, s.Height, Color.LightBlue); } p.DrawRectangle(0, 0, s.Width, s.Height, Color.Black, 1); }
private void Form1_MouseClick(object sender, MouseEventArgs e) { if (e.Button.ToString() == "Left") { if (ship.IsDisposed == false && fireballCount != 0) { fireballCount--; lFBCount.Text = fireballCount.ToString(); int x = (ship.Left + ship.Width / 2 - 10); int y = (ship.Top - 25); SuperImage d = matilda1.CreateSuperImage("3_fireball.png", x, y, 20 * bonus_F, 20 * bonus_F); d.Name = "fire"; Fireball.Add(d); } } if (e.Button.ToString() == "Right" && triple > 0) { for (int i = -2; i <= 2; i += 2) { int x = (ship.Left + ship.Width / 2 - 10); int y = (ship.Top - 25); SuperImage d = matilda1.CreateSuperImage("3_fireball.png", x, y, 20 * bonus_F, 20 * bonus_F); d.Name = "fire"; d.Offset = i; Fireball.Add(d); } } if (fireballCount == 0) { lFB.ForeColor = Color.Red; lFBCount.ForeColor = Color.Red; } }
void Awake() { image = GetComponent <SuperImage>(); normalColor = image.color; OnAwake(); }
private void matilda1_OnConnection(SuperImage a, SuperImage b) { if (a.Name == "desk" && b.Name == "ball") { //if (b.Top + 60 > a.Top) //{ // ((SuperBall)b).leftstep *= -1; //} //else //{ // ((SuperBall)b).topstep *= -1; //} //Здесь решается задача отталкивания метеорита от доски в правильном направлении //Сам алгоритм оценки координат немного сложноват //Он зашит внутри метода VerticalConnection из matils'ы SuperBall ball; ball = b as SuperBall; bool x = matilda1.IsVerticalConnection(ball, a); if (x == true) //Функция возвращает "правду", если метеорит ударился о верхнюю или нижнюю границы доски { ball.topstep *= -1; //В этом случае "отталкиваем" метеорит вверх/вниз } else //Функция возвращает "ложь", если метеорит ударился о правую или левую границы доски { ball.leftstep *= -1; //В этом случае "отталкиваем" метеорит вправо/влево } } if (b.Name == "desk" && a.Name == "ball") { //if (a.Top + 60 > b.Top) //{ // ((SuperBall)a).leftstep *= -1; //} //else //{ // ((SuperBall)a).topstep *= -1; //} //Смотри зеркальное условие SuperBall ball; ball = a as SuperBall; bool x = matilda1.IsVerticalConnection(ball, b); if (x == true) { ball.topstep *= -1; } else { ball.leftstep *= -1; } } if (a.Name == "rock" && b.Name == "ball") { //((SuperBall)b).topstep *= -1; SuperBall ball; ball = b as SuperBall; breek--; label2.Text = breek.ToString(); //Смотри столкновение метеорита с доской bool x = matilda1.IsVerticalConnection(ball, a); if (x == true) { ball.topstep *= -1; } else { ball.leftstep *= -1; } a.Dispose(); int ver = matilda1.RandomInt(1, 4); if (ver == 1) { SuperImage bonus = matilda1.CreateSuperImage("4_ball.png", b.Left, b.Top, 30, 30, "plus"); plus.Add(bonus); } if (breek <= 0) { label1.Text = "You Win"; timer1.Stop(); matilda1.ClearAllImages(); timer1.Stop(); matilda1.ClearAllImages(); } } if (b.Name == "rock" && a.Name == "ball") { //((SuperBall)a).topstep *= -1; SuperBall ball; ball = a as SuperBall; breek--; label2.Text = breek.ToString(); //Смотри столкновение метеорита с доской bool x = matilda1.IsVerticalConnection(ball, b); if (x == true) { ball.topstep *= -1; } else { ball.leftstep *= -1; } b.Dispose(); int ver = matilda1.RandomInt(1, 4); if (ver == 1) { SuperImage bonus = matilda1.CreateSuperImage("4_ball.png", b.Left, b.Top, 30, 30, "plus"); plus.Add(bonus); } if (breek <= 0) { label1.Text = "You Win"; timer1.Stop(); matilda1.ClearAllImages(); timer1.Stop(); matilda1.ClearAllImages(); } } if (a.Name == "plus" && b.Name == "desk") { a.Dispose(); plus.Remove(a); //Тут ты забыл удалить бонус из массива. Из-за этого он так и остаётся в "мозгах" компьютера. Цикл будет продолжать двигать невидимый шарик вниз. color = true; bullet_count += 5; } if (b.Name == "plus" && a.Name == "desk") { b.Dispose(); plus.Remove(b); //То же самое, что и в предыдущем "зеркальном" условии color = true; bullet_count += 5; } //Кирпичи не сбивались пулями, потому что вообще не было этого куска кода, который за это отвечает if (a.Name == "rock" && b.Name == "fire!") { a.Dispose(); b.Dispose(); bullets.Remove(b); breek--; label2.Text = breek.ToString(); if (drop == ball_count) { label1.Text = "Game Over"; timer1.Stop(); matilda1.ClearAllImages(); timer1.Stop(); matilda1.ClearAllImages(); } } if (b.Name == "rock" && a.Name == "fire!") { b.Dispose(); a.Dispose(); bullets.Remove(a); breek--; label2.Text = breek.ToString(); if (drop == ball_count) { label1.Text = "Game Over"; timer1.Stop(); matilda1.ClearAllImages(); timer1.Stop(); matilda1.ClearAllImages(); } } }
private void Brick_OnPaint(SuperImage s, SuperImagePainter p) { p.FillRectangle(0, 0, s.Width, s.Height, Color.LightGoldenrodYellow); }
private void matilda1_OnConnection(SuperImage a, SuperImage b) //столкновение картинок { if (a.Name == "M1" && b.Name == "fire") { point++; label9.Text = point.ToString(); mmm.Remove(a); a.Dispose(); Fireball.Remove(b); b.Dispose(); } if (a.Name == "fire" && b.Name == "M1") { point++; label9.Text = point.ToString(); mmm.Remove(b); b.Dispose(); Fireball.Remove(a); a.Dispose(); } if (a.Name == "M2" && b.Name == "fire") { point++; label9.Text = point.ToString(); int x = a.Left; int y = a.Top; mmm.Remove(a); a.Dispose(); Fireball.Remove(b); b.Dispose(); CreateMet(x, y, 1); CreateMet(x, y, 1); } if (a.Name == "fire" && b.Name == "M2") { point++; label9.Text = point.ToString(); int x = b.Left; int y = b.Top; mmm.Remove(b); b.Dispose(); Fireball.Remove(a); a.Dispose(); CreateMet(x, y, 1); CreateMet(x, y, 1); } if (a.Name == "M3" && b.Name == "fire") { point++; label9.Text = point.ToString(); int x = a.Left; int y = a.Top; mmm.Remove(a); a.Dispose(); Fireball.Remove(b); b.Dispose(); CreateMet(x, y, 2); CreateMet(x, y, 2); } if (a.Name == "fire" && b.Name == "M3") { point++; label9.Text = point.ToString(); int x = b.Left; int y = b.Top; mmm.Remove(b); b.Dispose(); Fireball.Remove(a); a.Dispose(); CreateMet(x, y, 2); CreateMet(x, y, 2); } if (a.Name == "Ракета" && b.Name.Contains("M")) { if (protect > 0) { point += 3; label9.Text = point.ToString(); } else { a.Dispose(); ship.Dispose(); tStrike.Stop(); tMetior.Stop(); tMetiorMove.Stop(); tHelp.Stop(); tAllTime.Stop(); label1.Visible = true; rocket = false; } mmm.Remove(b); b.Dispose(); } if (a.Name.Contains("M") && b.Name == "Ракета") { if (protect > 0) { point += 3; label9.Text = point.ToString(); } else { b.Dispose(); ship.Dispose(); tStrike.Stop(); tMetior.Stop(); tMetiorMove.Stop(); tHelp.Stop(); tAllTime.Stop(); label1.Visible = true; rocket = false; } mmm.Remove(a); a.Dispose(); } if (a.Name == "Ракета" && b.Name == "Перезарядка") { mmm.Remove(b); b.Dispose(); if (arcada == true) { point += 100; fireballCount += 20; label4.Visible = true; label7.Visible = true; } else { fireballCount += 50; label7.Visible = true; } lFB.ForeColor = Color.Cyan; lFBCount.ForeColor = Color.Cyan; bonTime = 2; tBonTime.Start(); lFBCount.Text = fireballCount.ToString(); } if (a.Name == "Перезарядка" && b.Name == "Ракета") { mmm.Remove(a); a.Dispose(); if (arcada == true) { point += 100; fireballCount += 20; label4.Visible = true; label7.Visible = true; } else { fireballCount += 50; label7.Visible = true; } lFB.ForeColor = Color.Cyan; lFBCount.ForeColor = Color.Cyan; bonTime = 2; tBonTime.Start(); lFBCount.Text = fireballCount.ToString(); } if (a.Name == "Тройной" && b.Name == "Ракета") { a.Dispose(); triple = 10; tTriple.Start(); label5.Visible = true; label6.Visible = true; } if (b.Name == "Тройной" && a.Name == "Ракета") { b.Dispose(); triple = 10; tTriple.Start(); label5.Visible = true; label6.Visible = true; } if (a.Name == "Супер" && b.Name == "Ракета") { if (tProtect.Enabled == false) // чтоб не складывать несколько { protect = 15; // увеличил до 15 сек, так как за 10 ракета толком вырасти не успевает tProtect.Start(); bonus_F = 2; tBig.Start(); label3.Text = "Protect ON:"; label2.Visible = true; } a.Dispose(); } if (b.Name == "Супер" && a.Name == "Ракета") { if (tProtect.Enabled == false) // чтоб не складывать несколько { protect = 15; // увеличил до 15 сек, так как за 10 ракета толком вырасти не успевает tProtect.Start(); bonus_F = 2; tBig.Start(); label3.Text = "Protect ON:"; label2.Visible = true; } b.Dispose(); } }
private void matilda1_OnConnection(SuperImage a, SuperImage b) { //Отбиваемся от шариков доской if (a.Name == "Шарик" && b.Name == "доска") { BallAndDeskContact((SuperBall)a); } if (a.Name == "доска" && b.Name == "Шарик") { BallAndDeskContact((SuperBall)b); } // получаем снаряды if (a.Name == "firepack" && b.Name == "доска") { a.Dispose(); fireballs_pack.Remove(a); bullet_count += 3; } if (a.Name == "доска" && b.Name == "firepack") { b.Dispose(); fireballs_pack.Remove(b); bullet_count += 3; } // попадание снарядами if (a.Name == "Кирпич" && b.Name == "fire!") { b.Dispose(); bullets.Remove(b); BrickContact((SuperBrick)a); CheckVictory(); } if (a.Name == "fire!" && b.Name == "Кирпич") { a.Dispose(); bullets.Remove(a); BrickContact((SuperBrick)b); CheckVictory(); } if (a.Name == "Кирпич" && b.Name == "Шарик") { SuperBall Ball = (SuperBall)b; Ball.top_step *= -1; BrickContact((SuperBrick)a); CheckVictory(); } if (a.Name == "Шарик" && b.Name == "Кирпич") { SuperBall Ball = (SuperBall)a; Ball.top_step *= -1; BrickContact((SuperBrick)b); CheckVictory(); } }