diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index c5ea375..11bed40 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -1,64 +1,13 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications +namespace ShiftOS.WinForms.Applications { partial class Pong { - /// + /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - /// + /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. @@ -71,738 +20,40 @@ namespace ShiftOS.WinForms.Applications base.Dispose(disposing); } + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.gameTimer = new System.Windows.Forms.Timer(this.components); - this.counter = new System.Windows.Forms.Timer(this.components); - this.tmrcountdown = new System.Windows.Forms.Timer(this.components); - this.tmrstoryline = new System.Windows.Forms.Timer(this.components); - this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); - this.pnlmultiplayerhandshake = new System.Windows.Forms.Panel(); - this.lvotherplayers = new System.Windows.Forms.ListView(); - this.lbmpstatus = new System.Windows.Forms.Label(); - this.pnlintro = new System.Windows.Forms.Panel(); - this.btnmatchmake = new System.Windows.Forms.Button(); - this.Label6 = new System.Windows.Forms.Label(); - this.btnstartgame = new System.Windows.Forms.Button(); - this.Label8 = new System.Windows.Forms.Label(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListView(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); - this.label10 = new System.Windows.Forms.Label(); - this.pnlgamestats = new System.Windows.Forms.Panel(); - this.button1 = new System.Windows.Forms.Button(); - this.label12 = new System.Windows.Forms.Label(); - this.lblnextstats = new System.Windows.Forms.Label(); - this.Label7 = new System.Windows.Forms.Label(); - this.lblpreviousstats = new System.Windows.Forms.Label(); - this.Label4 = new System.Windows.Forms.Label(); - this.btnplayon = new System.Windows.Forms.Button(); - this.Label3 = new System.Windows.Forms.Label(); - this.btncashout = new System.Windows.Forms.Button(); - this.Label2 = new System.Windows.Forms.Label(); - this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlfinalstats = new System.Windows.Forms.Panel(); - this.btnplayagain = new System.Windows.Forms.Button(); - this.lblfinalcodepoints = new System.Windows.Forms.Label(); - this.Label11 = new System.Windows.Forms.Label(); - this.lblfinalcomputerreward = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); - this.lblfinallevelreward = new System.Windows.Forms.Label(); - this.lblfinallevelreached = new System.Windows.Forms.Label(); - this.lblfinalcodepointswithtext = new System.Windows.Forms.Label(); - this.pnllose = new System.Windows.Forms.Panel(); - this.lblmissedout = new System.Windows.Forms.Label(); - this.lblbutyougained = new System.Windows.Forms.Label(); - this.btnlosetryagain = new System.Windows.Forms.Button(); - this.Label5 = new System.Windows.Forms.Label(); - this.Label1 = new System.Windows.Forms.Label(); - this.lblbeatai = new System.Windows.Forms.Label(); - this.lblcountdown = new System.Windows.Forms.Label(); - this.ball = new ShiftOS.WinForms.Controls.Canvas(); - this.paddleHuman = new System.Windows.Forms.PictureBox(); - this.paddleComputer = new System.Windows.Forms.Panel(); - this.lbllevelandtime = new System.Windows.Forms.Label(); - this.lblstatscodepoints = new System.Windows.Forms.Label(); - this.lblstatsY = new System.Windows.Forms.Label(); - this.lblstatsX = new System.Windows.Forms.Label(); - this.pgcontents.SuspendLayout(); - this.pnlmultiplayerhandshake.SuspendLayout(); - this.pnlintro.SuspendLayout(); - this.pnlhighscore.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); - this.pnlfinalstats.SuspendLayout(); - this.pnllose.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); + this.pnlcanvas = new System.Windows.Forms.Panel(); this.SuspendLayout(); // - // gameTimer - // - this.gameTimer.Interval = 30; - this.gameTimer.Tick += new System.EventHandler(this.gameTimer_Tick); - // - // counter - // - this.counter.Interval = 1000; - this.counter.Tick += new System.EventHandler(this.counter_Tick); - // - // tmrcountdown - // - this.tmrcountdown.Interval = 1000; - this.tmrcountdown.Tick += new System.EventHandler(this.countdown_Tick); - // - // tmrstoryline - // - this.tmrstoryline.Interval = 1000; - this.tmrstoryline.Tick += new System.EventHandler(this.tmrstoryline_Tick); - // - // pgcontents - // - this.pgcontents.BackColor = System.Drawing.Color.White; - this.pgcontents.Controls.Add(this.pnlmultiplayerhandshake); - this.pgcontents.Controls.Add(this.pnlintro); - this.pgcontents.Controls.Add(this.pnlhighscore); - this.pgcontents.Controls.Add(this.pnlgamestats); - this.pgcontents.Controls.Add(this.pnlfinalstats); - this.pgcontents.Controls.Add(this.pnllose); - this.pgcontents.Controls.Add(this.lblbeatai); - this.pgcontents.Controls.Add(this.lblcountdown); - this.pgcontents.Controls.Add(this.ball); - this.pgcontents.Controls.Add(this.paddleHuman); - this.pgcontents.Controls.Add(this.paddleComputer); - this.pgcontents.Controls.Add(this.lbllevelandtime); - this.pgcontents.Controls.Add(this.lblstatscodepoints); - this.pgcontents.Controls.Add(this.lblstatsY); - this.pgcontents.Controls.Add(this.lblstatsX); - this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.pgcontents.Location = new System.Drawing.Point(0, 0); - this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(912, 504); - this.pgcontents.TabIndex = 20; - this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - // - // pnlmultiplayerhandshake - // - this.pnlmultiplayerhandshake.Controls.Add(this.lvotherplayers); - this.pnlmultiplayerhandshake.Controls.Add(this.lbmpstatus); - this.pnlmultiplayerhandshake.Location = new System.Drawing.Point(446, 88); - this.pnlmultiplayerhandshake.Name = "pnlmultiplayerhandshake"; - this.pnlmultiplayerhandshake.Size = new System.Drawing.Size(396, 231); - this.pnlmultiplayerhandshake.TabIndex = 15; - this.pnlmultiplayerhandshake.Visible = false; - // - // lvotherplayers - // - this.lvotherplayers.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvotherplayers.Location = new System.Drawing.Point(0, 45); - this.lvotherplayers.MultiSelect = false; - this.lvotherplayers.Name = "lvotherplayers"; - this.lvotherplayers.Size = new System.Drawing.Size(396, 186); - this.lvotherplayers.TabIndex = 1; - this.lvotherplayers.UseCompatibleStateImageBehavior = false; - this.lvotherplayers.View = System.Windows.Forms.View.Details; - this.lvotherplayers.DoubleClick += new System.EventHandler(this.lvotherplayers_DoubleClick); - // - // lbmpstatus - // - this.lbmpstatus.Dock = System.Windows.Forms.DockStyle.Top; - this.lbmpstatus.Location = new System.Drawing.Point(0, 0); - this.lbmpstatus.Name = "lbmpstatus"; - this.lbmpstatus.Size = new System.Drawing.Size(396, 45); - this.lbmpstatus.TabIndex = 0; - this.lbmpstatus.Tag = "header2"; - this.lbmpstatus.Text = "Waiting for other players..."; - this.lbmpstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // pnlintro - // - this.pnlintro.Controls.Add(this.btnmatchmake); - this.pnlintro.Controls.Add(this.Label6); - this.pnlintro.Controls.Add(this.btnstartgame); - this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(0, 0); - this.pnlintro.Name = "pnlintro"; - this.pnlintro.Size = new System.Drawing.Size(595, 303); - this.pnlintro.TabIndex = 13; - this.pnlintro.Tag = "header2"; - // - // btnmatchmake - // - this.btnmatchmake.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnmatchmake.Location = new System.Drawing.Point(188, 253); - this.btnmatchmake.Name = "btnmatchmake"; - this.btnmatchmake.Size = new System.Drawing.Size(242, 28); - this.btnmatchmake.TabIndex = 16; - this.btnmatchmake.Text = "Or, play against another Shifter!"; - this.btnmatchmake.UseVisualStyleBackColor = true; - this.btnmatchmake.Click += new System.EventHandler(this.btnmatchmake_Click); - // - // Label6 - // - this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label6.Location = new System.Drawing.Point(3, 39); - this.Label6.Name = "Label6"; - this.Label6.Size = new System.Drawing.Size(589, 159); - this.Label6.TabIndex = 15; - this.Label6.Text = "{PONG_DESC}"; - this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnstartgame - // - this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnstartgame.Location = new System.Drawing.Point(188, 215); - this.btnstartgame.Name = "btnstartgame"; - this.btnstartgame.Size = new System.Drawing.Size(242, 28); - this.btnstartgame.TabIndex = 15; - this.btnstartgame.Text = "{PLAY}"; - this.btnstartgame.UseVisualStyleBackColor = true; - this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click); - // - // Label8 - // - this.Label8.AutoSize = true; - this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label8.ForeColor = System.Drawing.Color.Black; - this.Label8.Location = new System.Drawing.Point(250, 5); - this.Label8.Name = "Label8"; - this.Label8.Size = new System.Drawing.Size(280, 31); - this.Label8.TabIndex = 14; - this.Label8.Text = "{PONG_WELCOME}"; - // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(688, 302); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - this.lbhighscore.UseCompatibleStateImageBehavior = false; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlgamestats - // - this.pnlgamestats.Controls.Add(this.button1); - this.pnlgamestats.Controls.Add(this.label12); - this.pnlgamestats.Controls.Add(this.lblnextstats); - this.pnlgamestats.Controls.Add(this.Label7); - this.pnlgamestats.Controls.Add(this.lblpreviousstats); - this.pnlgamestats.Controls.Add(this.Label4); - this.pnlgamestats.Controls.Add(this.btnplayon); - this.pnlgamestats.Controls.Add(this.Label3); - this.pnlgamestats.Controls.Add(this.btncashout); - this.pnlgamestats.Controls.Add(this.Label2); - this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(104, 375); - this.pnlgamestats.Name = "pnlgamestats"; - this.pnlgamestats.Size = new System.Drawing.Size(466, 284); - this.pnlgamestats.TabIndex = 6; - this.pnlgamestats.Visible = false; - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(32, 223); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(191, 35); - this.button1.TabIndex = 10; - this.button1.Text = "{PONG_VIEW_HIGHSCORES}"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.btnhighscore_Click); - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(8, 187); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(245, 33); - this.label12.TabIndex = 9; - this.label12.Text = "{PONG_HIGHSCORE_EXP}"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblnextstats - // - this.lblnextstats.AutoSize = true; - this.lblnextstats.Location = new System.Drawing.Point(278, 136); - this.lblnextstats.Name = "lblnextstats"; - this.lblnextstats.Size = new System.Drawing.Size(0, 13); - this.lblnextstats.TabIndex = 8; - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label7.Location = new System.Drawing.Point(278, 119); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(124, 16); - this.Label7.TabIndex = 7; - this.Label7.Text = "Next Level Stats:"; - // - // lblpreviousstats - // - this.lblpreviousstats.AutoSize = true; - this.lblpreviousstats.Location = new System.Drawing.Point(278, 54); - this.lblpreviousstats.Name = "lblpreviousstats"; - this.lblpreviousstats.Size = new System.Drawing.Size(0, 13); - this.lblpreviousstats.TabIndex = 6; - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label4.Location = new System.Drawing.Point(278, 37); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(154, 16); - this.Label4.TabIndex = 5; - this.Label4.Text = "Previous Level Stats:"; - // - // btnplayon - // - this.btnplayon.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayon.Location = new System.Drawing.Point(32, 147); - this.btnplayon.Name = "btnplayon"; - this.btnplayon.Size = new System.Drawing.Size(191, 35); - this.btnplayon.TabIndex = 4; - this.btnplayon.Text = "Play on for 3 codepoints!"; - this.btnplayon.UseVisualStyleBackColor = true; - this.btnplayon.Click += new System.EventHandler(this.btnplayon_Click); - // - // Label3 - // - this.Label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label3.Location = new System.Drawing.Point(8, 111); - this.Label3.Name = "Label3"; - this.Label3.Size = new System.Drawing.Size(245, 33); - this.Label3.TabIndex = 3; - this.Label3.Text = "{PONG_PLAYON_DESC}"; - this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btncashout - // - this.btncashout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btncashout.Location = new System.Drawing.Point(32, 73); - this.btncashout.Name = "btncashout"; - this.btncashout.Size = new System.Drawing.Size(191, 35); - this.btncashout.TabIndex = 2; - this.btncashout.Text = "Cash out with 1 codepoint!"; - this.btncashout.UseVisualStyleBackColor = true; - this.btncashout.Click += new System.EventHandler(this.btncashout_Click); - // - // Label2 - // - this.Label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label2.Location = new System.Drawing.Point(8, 37); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(245, 33); - this.Label2.TabIndex = 1; - this.Label2.Text = "{PONG_CASHOUT_DESC}"; - this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbllevelreached - // - this.lbllevelreached.AutoSize = true; - this.lbllevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelreached.Location = new System.Drawing.Point(149, 6); - this.lbllevelreached.Name = "lbllevelreached"; - this.lbllevelreached.Size = new System.Drawing.Size(185, 20); - this.lbllevelreached.TabIndex = 0; - this.lbllevelreached.Text = "You Reached Level 2!"; - // - // pnlfinalstats - // - this.pnlfinalstats.Controls.Add(this.btnplayagain); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepoints); - this.pnlfinalstats.Controls.Add(this.Label11); - this.pnlfinalstats.Controls.Add(this.lblfinalcomputerreward); - this.pnlfinalstats.Controls.Add(this.Label9); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreward); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreached); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepointswithtext); - this.pnlfinalstats.Location = new System.Drawing.Point(172, 74); - this.pnlfinalstats.Name = "pnlfinalstats"; - this.pnlfinalstats.Size = new System.Drawing.Size(362, 226); - this.pnlfinalstats.TabIndex = 9; - this.pnlfinalstats.Visible = false; - // - // btnplayagain - // - this.btnplayagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayagain.Location = new System.Drawing.Point(5, 194); - this.btnplayagain.Name = "btnplayagain"; - this.btnplayagain.Size = new System.Drawing.Size(352, 29); - this.btnplayagain.TabIndex = 16; - this.btnplayagain.Text = "{PLAY}"; - this.btnplayagain.UseVisualStyleBackColor = true; - this.btnplayagain.Click += new System.EventHandler(this.btnplayagain_Click); - // - // lblfinalcodepoints - // - this.lblfinalcodepoints.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepoints.Location = new System.Drawing.Point(3, 124); - this.lblfinalcodepoints.Name = "lblfinalcodepoints"; - this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); - this.lblfinalcodepoints.TabIndex = 15; - this.lblfinalcodepoints.Tag = "header1"; - this.lblfinalcodepoints.Text = "134 CP"; - this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label11 - // - this.Label11.AutoSize = true; - this.Label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label11.Location = new System.Drawing.Point(162, 82); - this.Label11.Name = "Label11"; - this.Label11.Size = new System.Drawing.Size(33, 33); - this.Label11.TabIndex = 14; - this.Label11.Tag = "header2"; - this.Label11.Text = "+"; - this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcomputerreward - // - this.lblfinalcomputerreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcomputerreward.Location = new System.Drawing.Point(193, 72); - this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; - this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); - this.lblfinalcomputerreward.TabIndex = 12; - this.lblfinalcomputerreward.Tag = "header2"; - this.lblfinalcomputerreward.Text = "34"; - this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label9 - // - this.Label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label9.Location = new System.Drawing.Point(179, 31); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(180, 49); - this.Label9.TabIndex = 11; - this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreward - // - this.lblfinallevelreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreward.Location = new System.Drawing.Point(12, 72); - this.lblfinallevelreward.Name = "lblfinallevelreward"; - this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); - this.lblfinallevelreward.TabIndex = 10; - this.lblfinallevelreward.Tag = "header2"; - this.lblfinallevelreward.Text = "100"; - this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreached - // - this.lblfinallevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreached.Location = new System.Drawing.Point(3, 31); - this.lblfinallevelreached.Name = "lblfinallevelreached"; - this.lblfinallevelreached.Size = new System.Drawing.Size(170, 49); - this.lblfinallevelreached.TabIndex = 9; - this.lblfinallevelreached.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcodepointswithtext - // - this.lblfinalcodepointswithtext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepointswithtext.Location = new System.Drawing.Point(3, 2); - this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; - this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); - this.lblfinalcodepointswithtext.TabIndex = 1; - this.lblfinalcodepointswithtext.Tag = "header2"; - this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; - this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // pnllose - // - this.pnllose.Controls.Add(this.lblmissedout); - this.pnllose.Controls.Add(this.lblbutyougained); - this.pnllose.Controls.Add(this.btnlosetryagain); - this.pnllose.Controls.Add(this.Label5); - this.pnllose.Controls.Add(this.Label1); - this.pnllose.Location = new System.Drawing.Point(209, 71); - this.pnllose.Name = "pnllose"; - this.pnllose.Size = new System.Drawing.Size(266, 214); - this.pnllose.TabIndex = 10; - this.pnllose.Visible = false; - // - // lblmissedout - // - this.lblmissedout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblmissedout.Location = new System.Drawing.Point(3, 175); - this.lblmissedout.Name = "lblmissedout"; - this.lblmissedout.Size = new System.Drawing.Size(146, 35); - this.lblmissedout.TabIndex = 3; - this.lblmissedout.Text = "You Missed Out On: 500 Codepoints"; - this.lblmissedout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblbutyougained - // - this.lblbutyougained.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbutyougained.Location = new System.Drawing.Point(3, 125); - this.lblbutyougained.Name = "lblbutyougained"; - this.lblbutyougained.Size = new System.Drawing.Size(146, 35); - this.lblbutyougained.TabIndex = 3; - this.lblbutyougained.Text = "But you gained 5 Codepoints"; - this.lblbutyougained.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnlosetryagain - // - this.btnlosetryagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnlosetryagain.Location = new System.Drawing.Point(155, 176); - this.btnlosetryagain.Name = "btnlosetryagain"; - this.btnlosetryagain.Size = new System.Drawing.Size(106, 35); - this.btnlosetryagain.TabIndex = 2; - this.btnlosetryagain.Text = "Try Again"; - this.btnlosetryagain.UseVisualStyleBackColor = true; - this.btnlosetryagain.Click += new System.EventHandler(this.btnlosetryagain_Click); - // - // Label5 - // - this.Label5.Location = new System.Drawing.Point(7, 26); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(260, 163); - this.Label5.TabIndex = 1; - // - // Label1 - // - this.Label1.Dock = System.Windows.Forms.DockStyle.Top; - this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label1.Location = new System.Drawing.Point(0, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(266, 16); - this.Label1.TabIndex = 0; - this.Label1.Text = "You lose!"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // lblbeatai - // - this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbeatai.Location = new System.Drawing.Point(47, 41); - this.lblbeatai.Name = "lblbeatai"; - this.lblbeatai.Size = new System.Drawing.Size(600, 30); - this.lblbeatai.TabIndex = 8; - this.lblbeatai.Tag = "header2"; - this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; - this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblbeatai.Visible = false; - // - // lblcountdown - // - this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblcountdown.Location = new System.Drawing.Point(182, 152); - this.lblcountdown.Name = "lblcountdown"; - this.lblcountdown.Size = new System.Drawing.Size(315, 49); - this.lblcountdown.TabIndex = 7; - this.lblcountdown.Text = "3"; - this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblcountdown.Visible = false; - // - // ball - // - this.ball.BackColor = System.Drawing.Color.Black; - this.ball.Location = new System.Drawing.Point(300, 152); - this.ball.Name = "ball"; - this.ball.Size = new System.Drawing.Size(20, 20); - this.ball.TabIndex = 2; - this.ball.MouseEnter += new System.EventHandler(this.ball_MouseEnter); - this.ball.MouseLeave += new System.EventHandler(this.ball_MouseLeave); - // - // paddleHuman - // - this.paddleHuman.BackColor = System.Drawing.Color.Black; - this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleHuman.Name = "paddleHuman"; - this.paddleHuman.Size = new System.Drawing.Size(20, 100); - this.paddleHuman.TabIndex = 3; - this.paddleHuman.TabStop = false; - // - // paddleComputer - // - this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(878, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - this.paddleComputer.Name = "paddleComputer"; - this.paddleComputer.Size = new System.Drawing.Size(20, 100); - this.paddleComputer.TabIndex = 1; - // - // lbllevelandtime - // - this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; - this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); - this.lbllevelandtime.Name = "lbllevelandtime"; - this.lbllevelandtime.Size = new System.Drawing.Size(912, 22); - this.lbllevelandtime.TabIndex = 4; - this.lbllevelandtime.Tag = "header1"; - this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; - this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatscodepoints - // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatscodepoints.AutoSize = true; - this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 460); - this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23); - this.lblstatscodepoints.TabIndex = 12; - this.lblstatscodepoints.Tag = "header2"; - this.lblstatscodepoints.Text = "Codepoints: "; - this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsY - // - this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatsY.AutoSize = true; - this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsY.Location = new System.Drawing.Point(440, 460); - this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(76, 23); - this.lblstatsY.TabIndex = 11; - this.lblstatsY.Tag = "header2"; - this.lblstatsY.Text = "Yspeed:"; - this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsX - // - this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lblstatsX.AutoSize = true; - this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsX.Location = new System.Drawing.Point(3, 460); - this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(83, 23); - this.lblstatsX.TabIndex = 5; - this.lblstatsX.Tag = "header2"; - this.lblstatsX.Text = "Xspeed: "; - this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // pnlcanvas + // + this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcanvas.Location = new System.Drawing.Point(0, 0); + this.pnlcanvas.Name = "pnlcanvas"; + this.pnlcanvas.Size = new System.Drawing.Size(620, 469); + this.pnlcanvas.TabIndex = 0; + this.pnlcanvas.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlcanvas_Paint); + this.pnlcanvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlcanvas_MouseMove); // // Pong // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pgcontents); - this.DoubleBuffered = true; + this.Controls.Add(this.pnlcanvas); this.Name = "Pong"; - this.Size = new System.Drawing.Size(912, 504); - this.Load += new System.EventHandler(this.Pong_Load); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - this.pgcontents.ResumeLayout(false); - this.pgcontents.PerformLayout(); - this.pnlmultiplayerhandshake.ResumeLayout(false); - this.pnlintro.ResumeLayout(false); - this.pnlintro.PerformLayout(); - this.pnlhighscore.ResumeLayout(false); - this.pnlhighscore.PerformLayout(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); - this.pnlfinalstats.ResumeLayout(false); - this.pnlfinalstats.PerformLayout(); - this.pnllose.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); + this.Size = new System.Drawing.Size(620, 469); this.ResumeLayout(false); } - internal System.Windows.Forms.Panel paddleComputer; - internal System.Windows.Forms.Timer gameTimer; - internal System.Windows.Forms.PictureBox paddleHuman; - internal System.Windows.Forms.Label lbllevelandtime; - internal System.Windows.Forms.Label lblstatsX; - internal System.Windows.Forms.Timer counter; - internal System.Windows.Forms.Panel pnlgamestats; - internal System.Windows.Forms.Label lblnextstats; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.Label lblpreviousstats; - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.Button btnplayon; - internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.Button btncashout; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label lbllevelreached; - internal System.Windows.Forms.Label lblcountdown; - internal System.Windows.Forms.Timer tmrcountdown; - internal System.Windows.Forms.Label lblbeatai; - internal System.Windows.Forms.Panel pnlfinalstats; - internal System.Windows.Forms.Button btnplayagain; - internal System.Windows.Forms.Label lblfinalcodepoints; - internal System.Windows.Forms.Label Label11; - internal System.Windows.Forms.Label lblfinalcomputerreward; - internal System.Windows.Forms.Label Label9; - internal System.Windows.Forms.Label lblfinallevelreward; - internal System.Windows.Forms.Label lblfinallevelreached; - internal System.Windows.Forms.Label lblfinalcodepointswithtext; - internal System.Windows.Forms.Panel pnllose; - internal System.Windows.Forms.Label lblmissedout; - internal System.Windows.Forms.Label lblbutyougained; - internal System.Windows.Forms.Button btnlosetryagain; - internal System.Windows.Forms.Label Label5; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Label lblstatscodepoints; - internal System.Windows.Forms.Label lblstatsY; - internal System.Windows.Forms.Panel pnlintro; - internal System.Windows.Forms.Label Label6; - internal System.Windows.Forms.Button btnstartgame; - internal System.Windows.Forms.Label Label8; - internal System.Windows.Forms.Timer tmrstoryline; - private System.Windows.Forms.Panel pnlhighscore; - private System.Windows.Forms.ListView lbhighscore; - private System.Windows.Forms.Label label10; - internal Canvas pgcontents; - internal Canvas ball; - internal System.Windows.Forms.Button button1; - internal System.Windows.Forms.Label label12; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.Button button2; - internal System.Windows.Forms.Button btnmatchmake; - private System.Windows.Forms.Panel pnlmultiplayerhandshake; - private System.Windows.Forms.ListView lvotherplayers; - private System.Windows.Forms.Label lbmpstatus; + + #endregion + + private System.Windows.Forms.Panel pnlcanvas; } } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 87f0306..a88d69f 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -1,1011 +1,186 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; +using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; +using System.Data; using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using Newtonsoft.Json; using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { - [MultiplayerOnly] [Launcher("Pong", true, "al_pong", "Games")] [WinOpen("pong")] + [DefaultTitle("Pong")] [DefaultIcon("iconPong")] public partial class Pong : UserControl, IShiftOSWindow { - //I can assure you guaranteed that there is an acorn somewhere, in this place, and the sailors are looking for it - int xVel = 7; - int yVel = 8; - int computerspeed = 8; - int level = 1; - int secondsleft = 60; - int casualposition; - double xveldec = 3.0; - double yveldec = 3.0; - double incrementx = 0.4; - double incrementy = 0.2; - int levelxspeed = 3; - int levelyspeed = 3; - ulong beatairewardtotal; - ulong beataireward = 1; - readonly uint[] levelrewards = { - 0, - 20, - 60, - 140, - 290, - 400, - 600, - 900, - 1200, - 1600, - 2000, - 2500, - 3000, - 4000, - 5000, - 6000, - 8000, - 10000, - 13000, - 16000, - 20000, - 25000, - 32000, - 40000, - 50000, - 60000, - 75000, - 90000, - 110000, - 140000, - 180000, - 220000, - 270000, - 320000, - 400000, - 500000, - 640000, - 800000, - 1000000, - 1500000, - 2000000}; - ulong totalreward; - int countdown = 3; - int rwdmultiplier; - Thread soundThread; - - bool aiShouldIsbeEnabled = true; // who named this variable? and were they having a stroke? - - private void playsound(System.IO.Stream stream) - { - soundThread = new Thread((a) => ShiftOS.Engine.AudioManager.PlayStream((System.IO.Stream)a)); - soundThread.Start(stream); - } - public Pong() { InitializeComponent(); - } - - private void Pong_Load(object sender, EventArgs e) - { - rwdmultiplier = ShiftoriumFrontend.UpgradeInstalled("pong_upgrade") ? 2 : 1; - } - - // Move the paddle according to the mouse position. - private void pongMain_MouseMove(object sender, MouseEventArgs e) - { - var loc = this.PointToClient(MousePosition); - if (IsMultiplayerSession) + paddleWidth = pnlcanvas.Width / 30; + drawTimer = new Timer(); + drawTimer.Interval = 16; + drawTimer.Tick += (o, a) => { - if (IsLeader) - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleHuman.Top.ToString()); - } - else - { - paddleComputer.Location = new Point(paddleComputer.Location.X, (loc.Y) - (paddleComputer.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleComputer.Top.ToString()); - } - } - else + UpdateBall(); + pnlcanvas.Refresh(); + }; + } + + private double ballX = 0.0f; + private double ballY = 0.0f; + + + private double speedFactor = 0.025; + + private double xVel = 1; + private double yVel = 1; + + private int paddleWidth; + + private double playerY = 0.0; + private double opponentY = 0.0; + + public void UpdateBall() + { + double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); + double ballYLocal = linear(ballY, -1.0, 1.0, 0, pnlcanvas.Height); + + ballXLocal -= ((double)paddleWidth / 2); + ballYLocal -= ((double)paddleWidth / 2); + + double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); + double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); + + int paddleHeight = pnlcanvas.Height / 5; + + + Rectangle ballRect = new Rectangle((int)ballXLocal, (int)ballYLocal, paddleWidth, paddleWidth); + + Rectangle playerRect = new Rectangle((int)paddleWidth, (int)(playerYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); + Rectangle opponentRect = new Rectangle((int)(pnlcanvas.Width - (paddleWidth * 2)), (int)(opponentYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); + + //Top and bottom walls: + if (ballRect.Top <= 0 || ballRect.Bottom >= pnlcanvas.Height) + yVel = -yVel; //reverse the Y velocity + + //Left and right walls (NOTE: TEMPORARY) + if (ballRect.Left <= 0 || ballRect.Right >= pnlcanvas.Width) + xVel = -xVel; //reverse the Y velocity + + + + //Enemy paddle: + if (ballRect.IntersectsWith(opponentRect)) { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - } - } - - private void CenterPanels() - { - pnlfinalstats.CenterParent(); - pnlgamestats.CenterParent(); - pnlhighscore.CenterParent(); - pnlintro.CenterParent(); - pnllose.CenterParent(); - lblcountdown.CenterParent(); - lblbeatai.Left = (this.Width - lblbeatai.Width) / 2; - SetupStats(); - } - - public void SetupStats() - { - lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5); - lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5); - lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5; - lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2; - } - - int OpponentY = 0; - - bool IsLeader = true; - - int LeaderX = 0; - int LeaderY = 0; - - // ERROR: Handles clauses are not supported in C# - private void gameTimer_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - ball.BackColor = paddleComputer.BackColor = paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - - //Check if paddle upgrade has been bought and change paddles accordingly - //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) - //{ - // paddleHuman.Height = 150; - // paddleComputer.Height = 150; - //} - //I don't know the point of this but I'm fucking 86ing it. - Michael - - //Set the computer player to move according to the ball's position. - if (IsMultiplayerSession) + //check if the ball x is greater than the player paddle's middle coordinate + if (ballRect.Right <= opponentRect.Right - (opponentRect.Width / 2)) { - //If we're multiplayer, then we want to set the computer Y to the opponent's Y. - //If we're the leader, we set the AI paddle, else we set the player paddle. - if (IsLeader) - paddleComputer.Top = OpponentY; - else - paddleHuman.Top = OpponentY; - } - else - { - if (aiShouldIsbeEnabled) - if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) - { - if (ball.Top > paddleComputer.Top + 50) - paddleComputer.Top += computerspeed; - else - paddleComputer.Top -= computerspeed; - casualposition = rand.Next(-150, 201); - } - else - { - //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael - if (paddleComputer.Top > this.Height / 2 - paddleComputer.Height + casualposition) - paddleComputer.Top -= computerspeed; - else - paddleComputer.Top += computerspeed; - } - } - //Set Xvel and Yvel speeds from decimal - if (xVel > 0) - xVel = (int)Math.Round(xveldec); - else - xVel = (int)-Math.Round(xveldec); - if (yVel > 0) - yVel = (int)Math.Round(yveldec); - else - yVel = (int)-Math.Round(yveldec); - - if (IsMultiplayerSession && !IsLeader) - { - // Move it to the leader's ball position. - ball.Location = new Point(LeaderX, LeaderY); - } - else - { - var newRect = new Rectangle(ball.Location, ball.Size); // copy ball's Bounds - newRect.X += xVel; - newRect.Y += yVel; - - // Check for top wall. - if (newRect.Y < 0) - { - newRect.Y = 0; - yVel = -yVel; - playsound(Properties.Resources.typesound); - } - - // Check for bottom wall. - if (newRect.Y > pgcontents.Height - ball.Height) - { - newRect.Y = pgcontents.Height - ball.Height; - yVel = -yVel; - playsound(Properties.Resources.typesound); - } - - - // Check for player paddle. - if (newRect.IntersectsWith(paddleHuman.Bounds)) - { - newRect.X = paddleHuman.Left + ball.Width + 1; - //randomly increase x or y speed of ball - switch (rand.Next(1, 3)) - { - case 1: - xveldec = xveldec + incrementx; - break; - case 2: - if (yveldec > 0) - yveldec = yveldec + incrementy; - else - yveldec = yveldec - incrementy; - break; - } - xVel = -xVel; - playsound(Properties.Resources.writesound); - - } - - // Check for computer paddle. - if (newRect.IntersectsWith(paddleComputer.Bounds)) - { - newRect.X = paddleComputer.Left - paddleComputer.Width - 1; - xveldec = xveldec + incrementx; - xVel = -xVel; - playsound(Properties.Resources.writesound); - } - ball.Location = newRect.Location; - } - - - - // Check for left wall. - if (ball.Location.X < -100) - { - //If we are in multiplayer, and not the leader, we won. - if (IsMultiplayerSession) - { - if (IsLeader) - { - //We lost. - NotifyLoseToTarget(); - } - else - { - //We won. - NotifyWinToTarget(); - Win(); - } - } - else - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - pnllose.Show(); - gameTimer.Stop(); - counter.Stop(); - lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) - { - totalreward = (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal); - double onePercent = (totalreward / 100); - lblbutyougained.Show(); - lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (ulong)(onePercent)); - } - else - { - lblbutyougained.Hide(); - } - } - } - - // Check for right wall. - if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100) - { - if (IsMultiplayerSession) - { - //If we are the leader we won. - if (IsLeader) - { - NotifyWinToTarget(); - Win(); - } - else - { - NotifyLoseToTarget(); - } - } - else - { - Win(); - } - } - - if (IsMultiplayerSession) - { - if (IsLeader) - { - ServerManager.Forward(OpponentGUID, "pong_mp_setballpos", JsonConvert.SerializeObject(ball.Location)); - } - } - - if (IsLeader) - { - //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy - lblstatsX.Text = "X vel: " + xveldec; - lblstatsY.Text = "Y vel: " + yveldec; - lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); - lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " seconds left"; - - if (xVel > 20 || xVel < -20) - { - paddleHuman.Width = Math.Abs(xVel); - paddleComputer.Width = Math.Abs(xVel); - } - else - { - paddleHuman.Width = paddleComputer.Width = 20; - } - } - if (!IsMultiplayerSession) - { - computerspeed = Math.Abs(yVel); - } - } - } - - public void ServerMessageReceivedHandler(ServerMessage msg) - { - if (IsMultiplayerSession) - { - if (msg.Name == "pong_mp_setballpos") - { - var pt = JsonConvert.DeserializeObject(msg.Contents); - LeaderX = pt.X; - LeaderY = pt.Y; - } - else if (msg.Name == "pong_mp_left") - { - this.Invoke(new Action(() => - { - AppearanceManager.Close(this); - })); - Infobox.Show("Opponent has closed Pong.", "The opponent has closed Pong, therefore the connection between you two has dropped."); - } - else if (msg.Name == "pong_mp_youlose") - { - this.Invoke(new Action(LoseMP)); - } - else if (msg.Name == "pong_mp_setopponenty") - { - int y = Convert.ToInt32(msg.Contents); - OpponentY = y; - } - else if (msg.Name == "pong_handshake_matchmake") - { - if (!PossibleMatchmakes.Contains(msg.Contents)) - PossibleMatchmakes.Add(msg.Contents); - this.Invoke(new Action(ListMatchmakes)); - } - else if (msg.Name == "pong_handshake_resendid") - { - ServerManager.Forward("all", "pong_handshake_matchmake", YouGUID); - } - else if (msg.Name == "pong_handshake_complete") - { - IsLeader = true; - - OpponentGUID = msg.Contents; - LeaveMatchmake(); - this.Invoke(new Action(() => - { - pnlmultiplayerhandshake.Hide(); - StartLevel(); - })); - } - else if (msg.Name == "pong_mp_levelcompleted") - { - level = Convert.ToInt32(msg.Contents) + 1; - this.Invoke(new Action(CompleteLevel)); - } - else if (msg.Name == "pong_handshake_chosen") - { - IsLeader = false; - LeaveMatchmake(); - OpponentGUID = msg.Contents; - YouGUID = ServerManager.thisGuid.ToString(); - //Start the timers. - counter.Start(); - SendFollowerGUID(); - this.Invoke(new Action(() => - { - pnlmultiplayerhandshake.Hide(); - })); - } - else if (msg.Name == "pong_mp_cashedout") - { - this.Invoke(new Action(() => - { - btncashout_Click(this, EventArgs.Empty); - })); - Infobox.Show("Cashed out.", "The other player has cashed out their Codepoints. Therefore, we have automatically cashed yours out."); - } - else if (msg.Name == "pong_mp_startlevel") - { - OpponentAgrees = true; - if (YouAgree == false) - { - Infobox.PromptYesNo("Play another level?", "The opponent wants to play another level. Would you like to as well?", (answer) => - { - YouAgree = answer; - ServerManager.Forward(OpponentGUID, "pong_mp_level_callback", YouAgree.ToString()); - }); - } - } - else if (msg.Name == "pong_mp_level_callback") - { - bool agreed = bool.Parse(msg.Contents); - OpponentAgrees = agreed; - if (OpponentAgrees) - { - if (IsLeader) - { - //this.Invoke(new Action(())) - } - } - } - else if (msg.Name == "pong_handshake_left") - { - if (this.PossibleMatchmakes.Contains(msg.Contents)) - this.PossibleMatchmakes.Remove(msg.Contents); - this.Invoke(new Action(ListMatchmakes)); - } - else if (msg.Name == "pong_mp_clockupdate") - { - secondsleft = Convert.ToInt32(msg.Contents); - } - else if (msg.Name == "pong_mp_youwin") - { - this.Invoke(new Action(Win)); - } - } - } - - bool OpponentAgrees = false; - bool YouAgree = false; - - public void ListMatchmakes() - { - lvotherplayers.Items.Clear(); - var c = new ColumnHeader(); - c.Width = lvotherplayers.Width; - c.Text = "Player"; - lvotherplayers.Columns.Clear(); - lvotherplayers.Columns.Add(c); - - lvotherplayers.FullRowSelect = true; - foreach (var itm in PossibleMatchmakes) - { - if (itm != YouGUID) - { - var l = new ListViewItem(); - l.Text = itm; - lvotherplayers.Items.Add(l); - } - } - - if (PossibleMatchmakes.Count > 0) - { - lbmpstatus.Text = "Select a player."; - } - else - { - lbmpstatus.Text = "Waiting for players..."; - } - } - - public void NotifyLoseToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youwin", null); - } - - public void NotifyWinToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youlose", null); - } - - public void LeaveMatchmake() - { - ServerManager.Forward("all", "pong_handshake_left", YouGUID); - } - - List PossibleMatchmakes = new List(); - - public void SendLeaderGUID(string target) - { - ServerManager.Forward(target, "pong_handshake_chosen", YouGUID); - } - - - public void StartMultiplayer() - { - IsMultiplayerSession = true; - YouGUID = ServerManager.thisGuid.ToString(); - ServerManager.SendMessage("pong_handshake_matchmake", YouGUID); - StartMatchmake(); - } - - public void StartMatchmake() - { - pnlmultiplayerhandshake.Show(); - pnlmultiplayerhandshake.CenterParent(); - pnlmultiplayerhandshake.BringToFront(); - - ServerManager.Forward("all", "pong_handshake_resendid", null); - - } - - - public void SendFollowerGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_complete", YouGUID); - } - - public void LoseMP() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - if (IsLeader) - if (xVel > 0) + //reverse x velocity to send the ball the other way xVel = -xVel; - lblbeatai.Show(); - lblbeatai.Text = "The opponent has beaten you!"; - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - } + //set y velocity based on where the ball hit the paddle + yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); - public void Win() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - beatairewardtotal = beatairewardtotal + beataireward; - lblbeatai.Show(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}"); - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - public void CompleteLevel() - { - if (SaveSystem.CurrentSave.UniteAuthToken != null) - { - try - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongLevel() < level) - unite.SetPongLevel(level); } - catch { } - } - //Only set these stats if the user is the leader. - if (IsLeader) - { - secondsleft = 60; - level = level + 1; - generatenextlevel(); + } - pnlgamestats.Show(); - pnlgamestats.BringToFront(); - pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2)); - counter.Stop(); - gameTimer.Stop(); - } - // ERROR: Handles clauses are not supported in C# - private void counter_Tick(object sender, EventArgs e) - { - if (IsLeader) + //Player paddle: + if (ballRect.IntersectsWith(playerRect)) { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) + //check if the ball x is greater than the player paddle's middle coordinate + if(ballRect.Left >= playerRect.Left + (playerRect.Width / 2)) { - secondsleft = secondsleft - 1; - if (secondsleft == 0) - { - CompleteLevel(); - } + //reverse x velocity to send the ball the other way + xVel = -xVel; + + //set y velocity based on where the ball hit the paddle + yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); - lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); } + } - SetupStats(); + + + + + + ballX += xVel * speedFactor; + ballY += yVel * speedFactor; + } - [Obsolete("This method does nothing. Use UniteClient for highscore queries.")] - public void SendHighscores() + private void pnlcanvas_Paint(object sender, PaintEventArgs e) { + + paddleWidth = pnlcanvas.Width / 30; + double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); + double ballYLocal = linear(ballY, -1.0, 1.0, 0, pnlcanvas.Height); + + ballXLocal -= ((double)paddleWidth / 2); + ballYLocal -= ((double)paddleWidth / 2); + + + e.Graphics.Clear(pnlcanvas.BackColor); + + //draw the ball + e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth)); + + double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); + double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); + + int paddleHeight = pnlcanvas.Height / 5; + + int paddleStart = paddleWidth; + + //draw player paddle + e.Graphics.FillRectangle(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)paddleWidth, (float)(playerYLocal - (float)(paddleHeight / 2)), (float)paddleWidth, (float)paddleHeight)); + + //draw opponent + e.Graphics.FillRectangle(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)(pnlcanvas.Width - (paddleWidth*2)), (float)(opponentYLocal - (float)(paddleHeight / 2)), (float)paddleWidth, (float)paddleHeight)); + } - // ERROR: Handles clauses are not supported in C# - private void btnplayon_Click(object sender, EventArgs e) + static public double linear(double x, double x0, double x1, double y0, double y1) { - xveldec = levelxspeed; - yveldec = levelyspeed; - - secondsleft = 60; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, paddleHuman.Location.Y + paddleHuman.Height / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - //Increase the ball speed stats for the next level - private void generatenextlevel() - { - lbllevelreached.Text = Localization.Parse("{YOU_REACHED_LEVEL} " + level + "!"); - - lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - levelxspeed += rand.Next(1, 3); - - levelyspeed += rand.Next(1, 3); - - int rndinc = rand.Next(1, 6); - if (rndinc == 5) - incrementy += 0.3; - else - incrementy += (((rndinc - 1) % 2) + 1) / 10; - - lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - if (level < 15) + if ((x1 - x0) == 0) { - beataireward = (ulong)(level * 5); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - beataireward *= 2; + return (y0 + y1) / 2; } - else - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - beataireward = levelrewards[level - 1]; - else - beataireward = (ulong)Math.Round((double) levelrewards[level - 1] / 2); - - totalreward = levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal; - - btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); - btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); } - // ERROR: Handles clauses are not supported in C# - private void countdown_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - if (countdown == 0) - { - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - return; - } - if (!lblcountdown.Visible) - lblcountdown.Show(); - lblcountdown.Text = countdown.ToString(); - countdown -= 1; - playsound(Properties.Resources.typesound); - } - } - - // ERROR: Handles clauses are not supported in C# - private void btncashout_Click(object sender, EventArgs e) - { - pnlgamestats.Hide(); - pnlfinalstats.Show(); - lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); - lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = (levelrewards[level - 1] * rwdmultiplier).ToString(); - lblfinalcomputerreward.Text = beatairewardtotal.ToString(); - lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); - SaveSystem.TransferCodepointsFrom("pong", totalreward); - if (!string.IsNullOrWhiteSpace(SaveSystem.CurrentSave.UniteAuthToken)) - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongCP() < totalreward) - { - unite.SetPongCP(totalreward); - } - } - if (IsMultiplayerSession) - { - ServerManager.Forward(OpponentGUID, "pong_mp_cashedout", null); - StopMultiplayerSession(); - } - } - - public void StopMultiplayerSession() - { - IsMultiplayerSession = false; - IsLeader = true; - OpponentGUID = ""; - YouGUID = ""; - } - - private void newgame() - { - pnlfinalstats.Hide(); - pnllose.Hide(); - pnlintro.Hide(); - - level = 1; - totalreward = 0; - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = 10; - } - else - { - beataireward = 5; - } - beatairewardtotal = 0; - secondsleft = 60; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: "); - //reset stats text - lblstatsX.Text = Localization.Parse("{H_VEL}: "); - lblstatsY.Text = Localization.Parse("{V_VEL}: "); - - levelxspeed = 3; - levelyspeed = 3; - - incrementx = 0.4; - incrementy = 0.2; - - xveldec = levelxspeed; - yveldec = levelyspeed; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, (paddleHuman.Location.Y + paddleHuman.Height) / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{{LEVEL}}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - public void btnhighscore_Click(object s, EventArgs a) - { - pnlhighscore.BringToFront(); - SetupHighScores(); - } - - bool IsMultiplayerSession = false; - - string YouGUID = ""; - string OpponentGUID = ""; - - public void SetupHighScores() - { - lbhighscore.Items.Clear(); - lbhighscore.View = View.Details; - lbhighscore.FullRowSelect = true; - lbhighscore.Columns.Clear(); - var n = new ColumnHeader(); - n.Text = "Player"; - n.Width = lbhighscore.Width / 3; - var l = new ColumnHeader(); - l.Text = "Level"; - l.Width = n.Width; - var c = new ColumnHeader(); - c.Text = "Codepoints"; - c.Width = n.Width; - lbhighscore.Columns.Add(n); - lbhighscore.Columns.Add(l); - lbhighscore.Columns.Add(c); - - var t = new Thread(() => - { - try - { - - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - var hs = unite.GetPongHighscores(); - foreach (var score in hs.Highscores) - { - if (this.ParentForm.Visible == false) - { - Thread.CurrentThread.Abort(); - } - string username = unite.GetDisplayNameId(score.UserId); - this.Invoke(new Action(() => - { - var name_item = new ListViewItem(); - name_item.Text = username; - lbhighscore.Items.Add(name_item); - name_item.SubItems.Add(score.Level.ToString()); - name_item.SubItems.Add(score.CodepointsCashout.ToString()); - })); - } - } - catch - { - try - { - if (this.ParentForm.Visible) - { - Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); - this.Invoke(new Action(pnlgamestats.BringToFront)); - } - } - catch { } //JUST. ABORT. THE. FUCKING. THREAD. - return; - } - }); - t.Start(); - pnlhighscore.Show(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayagain_Click(object sender, EventArgs e) - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnlosetryagain_Click(object sender, EventArgs e) - { - newgame(); - } - - public void StartLevel() - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnstartgame_Click(object sender, EventArgs e) - { - newgame(); - } - - Random rand = new Random(); - // ERROR: Handles clauses are not supported in C# - private void tmrstoryline_Tick(object sender, EventArgs e) - { - // Random chance of showing getshiftnet storyline - int i = rand.Next(0, 100); - - if (i >= 25 && i <= 50) - tmrstoryline.Stop(); - - } - - // ERROR: Handles clauses are not supported in C# - private void me_closing(object sender, FormClosingEventArgs e) - { - tmrstoryline.Stop(); - } - - private void ball_MouseEnter(object sender, EventArgs e) - { - aiShouldIsbeEnabled = false; - } - - private void ball_MouseLeave(object sender, EventArgs e) - { - aiShouldIsbeEnabled = true; - } + Timer drawTimer = null; public void OnLoad() { - pnlintro.BringToFront(); - pnlintro.Show(); - pnlhighscore.Hide(); - pnlgamestats.Hide(); - pnlfinalstats.Hide(); - CenterPanels(); - lblbeatai.Hide(); - ServerManager.MessageReceived += this.ServerMessageReceivedHandler; + drawTimer.Start(); } public void OnSkinLoad() { - CenterPanels(); - this.SizeChanged += (o, a) => - { - CenterPanels(); - }; } public bool OnUnload() { - if (IsMultiplayerSession) - { - if (!string.IsNullOrWhiteSpace(OpponentGUID)) - ServerManager.Forward(OpponentGUID, "pong_mp_left", null); - LeaveMatchmake(); - } - ServerManager.MessageReceived -= this.ServerMessageReceivedHandler; - + drawTimer.Stop(); return true; } public void OnUpgrade() { - CenterPanels(); } - private void button2_Click(object sender, EventArgs e) + private void pnlcanvas_MouseMove(object sender, MouseEventArgs e) { - pnlhighscore.Hide(); - } - - private void btnmatchmake_Click(object sender, EventArgs e) - { - this.StartMultiplayer(); - pnlintro.Hide(); - lblbeatai.Text = "Beat the other player to earn Codepoints."; - lblcountdown.Text = "Waiting for another player..."; - lblcountdown.Left = (this.Width - lblcountdown.Width) / 2; - } - - private void lvotherplayers_DoubleClick(object sender, EventArgs e) - { - if (lvotherplayers.SelectedItems.Count > 0) - { - SendLeaderGUID(lvotherplayers.SelectedItems[0].Text); - } + playerY = linear(e.Y, 0, pnlcanvas.Height, -1, 1); } } -} \ No newline at end of file +} diff --git a/ShiftOS.WinForms/Applications/Pong.resx b/ShiftOS.WinForms/Applications/Pong.resx index cc96099..1af7de1 100644 --- a/ShiftOS.WinForms/Applications/Pong.resx +++ b/ShiftOS.WinForms/Applications/Pong.resx @@ -117,19 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 227, 17 - - - 134, 17 - - - 340, 17 - - - 17, 17 - - - 472, 17 - \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 31de44e..9e16b19 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -77,6 +77,12 @@ IconManager.cs + + UserControl + + + Pong.cs + UserControl @@ -197,12 +203,6 @@ Notifications.cs - - UserControl - - - Pong.cs - UserControl @@ -490,6 +490,9 @@ IconManager.cs + + Pong.cs + TriPresent.cs @@ -547,9 +550,6 @@ Notifications.cs - - Pong.cs - Shifter.cs