diff options
| author | MichaelTheShifter <[email protected]> | 2016-06-25 21:22:46 -0400 |
|---|---|---|
| committer | MichaelTheShifter <[email protected]> | 2016-06-25 21:22:46 -0400 |
| commit | 309f9fe361af7b0a508770951af7c548dfca78ad (patch) | |
| tree | e4303c0d47e0daff6d61a6f934b1aa957e67f93d /source/WindowsFormsApplication1/Apps | |
| parent | 84f689b91a73e512b035df40bbcf556b008a3b81 (diff) | |
| download | shiftos-c--309f9fe361af7b0a508770951af7c548dfca78ad.tar.gz shiftos-c--309f9fe361af7b0a508770951af7c548dfca78ad.tar.bz2 shiftos-c--309f9fe361af7b0a508770951af7c548dfca78ad.zip | |
Added online Hacker Battles with matchmaking system
It's untested, but in theory it'll all work perfectly.
Diffstat (limited to 'source/WindowsFormsApplication1/Apps')
3 files changed, 248 insertions, 71 deletions
diff --git a/source/WindowsFormsApplication1/Apps/NetworkBrowser.Designer.cs b/source/WindowsFormsApplication1/Apps/NetworkBrowser.Designer.cs index cf9468d..2b79b6d 100644 --- a/source/WindowsFormsApplication1/Apps/NetworkBrowser.Designer.cs +++ b/source/WindowsFormsApplication1/Apps/NetworkBrowser.Designer.cs @@ -29,10 +29,12 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NetworkBrowser)); this.panel1 = new System.Windows.Forms.Panel(); this.label3 = new System.Windows.Forms.Label(); this.btnscreen = new System.Windows.Forms.Button(); this.pnlmynet = new System.Windows.Forms.Panel(); + this.pgtotalhealth = new ShiftOS.ProgressBarEX(); this.flmodules = new System.Windows.Forms.FlowLayoutPanel(); this.label5 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -44,15 +46,23 @@ this.panel2 = new System.Windows.Forms.Panel(); this.lbnetdesc = new System.Windows.Forms.Label(); this.lbtitle = new System.Windows.Forms.Label(); - this.pgtotalhealth = new ShiftOS.ProgressBarEX(); this.tmrcalctotal = new System.Windows.Forms.Timer(this.components); + this.button1 = new System.Windows.Forms.Button(); + this.pnlonline = new System.Windows.Forms.Panel(); + this.lbonlinedesc = new System.Windows.Forms.Label(); + this.lbonlineheader = new System.Windows.Forms.Label(); + this.lbonlineservers = new System.Windows.Forms.ListBox(); + this.btnjoinlobby = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.pnlmynet.SuspendLayout(); this.panel2.SuspendLayout(); + this.pnlonline.SuspendLayout(); this.SuspendLayout(); // // panel1 // + this.panel1.Controls.Add(this.pnlonline); + this.panel1.Controls.Add(this.button1); this.panel1.Controls.Add(this.label3); this.panel1.Controls.Add(this.btnscreen); this.panel1.Controls.Add(this.pnlmynet); @@ -104,6 +114,28 @@ this.pnlmynet.Size = new System.Drawing.Size(404, 447); this.pnlmynet.TabIndex = 6; // + // pgtotalhealth + // + this.pgtotalhealth.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pgtotalhealth.BackColor = System.Drawing.Color.Black; + this.pgtotalhealth.BlockSeparation = 3; + this.pgtotalhealth.BlockWidth = 5; + this.pgtotalhealth.Color = System.Drawing.Color.Gray; + this.pgtotalhealth.Label = "Progress:"; + this.pgtotalhealth.Location = new System.Drawing.Point(7, 98); + this.pgtotalhealth.MaxValue = 100; + this.pgtotalhealth.MinValue = 0; + this.pgtotalhealth.Name = "pgtotalhealth"; + this.pgtotalhealth.Orientation = ShiftOS.ProgressBarEX.ProgressBarOrientation.Horizontal; + this.pgtotalhealth.ShowLabel = false; + this.pgtotalhealth.ShowValue = true; + this.pgtotalhealth.Size = new System.Drawing.Size(394, 32); + this.pgtotalhealth.Step = 10; + this.pgtotalhealth.Style = ShiftOS.ProgressBarEX.ProgressBarExStyle.Continuous; + this.pgtotalhealth.TabIndex = 4; + this.pgtotalhealth.Value = 0; + // // flmodules // this.flmodules.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -209,7 +241,7 @@ this.lbnetdesc.Name = "lbnetdesc"; this.lbnetdesc.Size = new System.Drawing.Size(283, 290); this.lbnetdesc.TabIndex = 1; - this.lbnetdesc.Text = "No network selected."; + this.lbnetdesc.Text = resources.GetString("lbnetdesc.Text"); // // lbtitle // @@ -221,31 +253,80 @@ this.lbtitle.TabIndex = 0; this.lbtitle.Text = "Network Browser"; // - // pgtotalhealth - // - this.pgtotalhealth.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgtotalhealth.BackColor = System.Drawing.Color.Black; - this.pgtotalhealth.BlockSeparation = 3; - this.pgtotalhealth.BlockWidth = 5; - this.pgtotalhealth.Color = System.Drawing.Color.Gray; - this.pgtotalhealth.Location = new System.Drawing.Point(7, 98); - this.pgtotalhealth.MaxValue = 100; - this.pgtotalhealth.MinValue = 0; - this.pgtotalhealth.Name = "pgtotalhealth"; - this.pgtotalhealth.Orientation = ShiftOS.ProgressBarEX.ProgressBarOrientation.Horizontal; - this.pgtotalhealth.ShowValue = true; - this.pgtotalhealth.Size = new System.Drawing.Size(394, 32); - this.pgtotalhealth.Step = 10; - this.pgtotalhealth.Style = ShiftOS.ProgressBarEX.ProgressBarExStyle.Continuous; - this.pgtotalhealth.TabIndex = 4; - this.pgtotalhealth.Value = 0; - // // tmrcalctotal // this.tmrcalctotal.Enabled = true; this.tmrcalctotal.Tick += new System.EventHandler(this.tmrcalctotal_Tick); // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button1.Location = new System.Drawing.Point(549, 465); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(83, 23); + this.button1.TabIndex = 9; + this.button1.Text = "Battle online!"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // pnlonline + // + this.pnlonline.Controls.Add(this.btnjoinlobby); + this.pnlonline.Controls.Add(this.lbonlineservers); + this.pnlonline.Controls.Add(this.lbonlinedesc); + this.pnlonline.Controls.Add(this.lbonlineheader); + this.pnlonline.Location = new System.Drawing.Point(12, 12); + this.pnlonline.Name = "pnlonline"; + this.pnlonline.Size = new System.Drawing.Size(404, 447); + this.pnlonline.TabIndex = 10; + // + // lbonlinedesc + // + this.lbonlinedesc.Location = new System.Drawing.Point(4, 37); + this.lbonlinedesc.Name = "lbonlinedesc"; + this.lbonlinedesc.Size = new System.Drawing.Size(386, 364); + this.lbonlinedesc.TabIndex = 3; + this.lbonlinedesc.Text = "You can battle other Shifters over the Internet by joining a lobby and waiting fo" + + "r a match to be made. Please select a server from the list below."; + // + // lbonlineheader + // + this.lbonlineheader.AutoSize = true; + this.lbonlineheader.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.lbonlineheader.Location = new System.Drawing.Point(3, 5); + this.lbonlineheader.Name = "lbonlineheader"; + this.lbonlineheader.Size = new System.Drawing.Size(106, 20); + this.lbonlineheader.TabIndex = 2; + this.lbonlineheader.Text = "Online battles"; + // + // lbonlineservers + // + this.lbonlineservers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbonlineservers.BackColor = System.Drawing.Color.Black; + this.lbonlineservers.ForeColor = System.Drawing.Color.White; + this.lbonlineservers.FormattingEnabled = true; + this.lbonlineservers.Location = new System.Drawing.Point(1, 72); + this.lbonlineservers.Name = "lbonlineservers"; + this.lbonlineservers.Size = new System.Drawing.Size(389, 329); + this.lbonlineservers.TabIndex = 4; + this.lbonlineservers.SelectedIndexChanged += new System.EventHandler(this.lbonlineservers_SelectedIndexChanged); + // + // btnjoinlobby + // + this.btnjoinlobby.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnjoinlobby.Enabled = false; + this.btnjoinlobby.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnjoinlobby.Location = new System.Drawing.Point(306, 415); + this.btnjoinlobby.Name = "btnjoinlobby"; + this.btnjoinlobby.Size = new System.Drawing.Size(84, 23); + this.btnjoinlobby.TabIndex = 8; + this.btnjoinlobby.Text = "Join Lobby"; + this.btnjoinlobby.UseVisualStyleBackColor = true; + this.btnjoinlobby.Click += new System.EventHandler(this.btnjoinlobby_Click); + // // NetworkBrowser // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -263,6 +344,8 @@ this.pnlmynet.PerformLayout(); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); + this.pnlonline.ResumeLayout(false); + this.pnlonline.PerformLayout(); this.ResumeLayout(false); } @@ -286,5 +369,11 @@ private System.Windows.Forms.Label label4; private ProgressBarEX pgtotalhealth; private System.Windows.Forms.Timer tmrcalctotal; + private System.Windows.Forms.Panel pnlonline; + private System.Windows.Forms.Label lbonlinedesc; + private System.Windows.Forms.Label lbonlineheader; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ListBox lbonlineservers; + private System.Windows.Forms.Button btnjoinlobby; } }
\ No newline at end of file diff --git a/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs b/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs index 127140f..e99e9a6 100644 --- a/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs +++ b/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs @@ -23,6 +23,36 @@ namespace ShiftOS private void NetworkBrowser_Load(object sender, EventArgs e) { + Online.Hacking.Matchmaker.Initiated += (o, a) => + { + if (selected_server == null) + { + lbonlineservers.Items.Clear(); + foreach (var s in Online.Hacking.Matchmaker.Servers) + { + lbonlineservers.Items.Add(s.ServerName); + } + } + }; + Online.Hacking.Matchmaker.MorePlayersFound += (o, a) => + { + if(selected_server != null) + { + lbonlineheader.Text = selected_server.ServerName + " - Lobby"; + lbonlinedesc.Text = $@"Network Browser is waiting for the server to pair you with another network... + + +Players in lobby: {Online.Hacking.Matchmaker.Players.Count} + +My Network: + - {Hacking.MyNetwork.Count} available modules + - {API.Codepoints} codepoints + - {API.CurrentSave.MyOnlineNetwork.Wins} wins, {API.CurrentSave.MyOnlineNetwork.Losses} losses. + +You can set your name and description in the Network Status page."; + + } + }; LoadNetworks(); SetupSidePane(); pnlmynet.Hide(); @@ -107,16 +137,29 @@ Those above values only matter if the leader decides to become a friend. If they public void SetupUI(List<string> tier) { - if (tier.Count > 0) + pnlonline.Visible = online_mode; + pnlonline.BringToFront(); + btnjoinlobby.Enabled = (selected_server != null); + if (online_mode) { - foreach (var t in tier) + if(Online.Hacking.Matchmaker.Servers == null) { - lbnets.Items.Add(t); + Online.Hacking.Matchmaker.Initiate(); } } else { - AddLeader(CurrentTier); + if (tier.Count > 0) + { + foreach (var t in tier) + { + lbnets.Items.Add(t); + } + } + else + { + AddLeader(CurrentTier); + } } } @@ -197,61 +240,68 @@ Those above values only matter if the leader decides to become a friend. If they } else { - string tier_upgrade = null; - if (SelectedNet.IsLeader == true) + if (online_mode == false) { - tier_upgrade = "nb_tier_" + CurrentTier; - } - var hui = new HackUI(SelectedNet); - hui.OnWin += (object s, EventArgs a) => - { - if (tier_upgrade != null) + string tier_upgrade = null; + if (SelectedNet.IsLeader == true) + { + tier_upgrade = "nb_tier_" + CurrentTier; + } + var hui = new HackUI(SelectedNet); + hui.OnWin += (object s, EventArgs a) => { - API.Upgrades[tier_upgrade] = true; - if(CurrentTier == "easy") + if (tier_upgrade != null) { - if(API.Upgrades["midgamebridge"] == false) + API.Upgrades[tier_upgrade] = true; + if (CurrentTier == "easy") { - var term = new Terminal(); - API.CreateForm(term, API.LoadedNames.TerminalName, API.GetIcon("Terminal")); - term.StartDanaRossStory(); + if (API.Upgrades["midgamebridge"] == false) + { + var term = new Terminal(); + API.CreateForm(term, API.LoadedNames.TerminalName, API.GetIcon("Terminal")); + term.StartDanaRossStory(); + } } - } - else if(CurrentTier == "medium") - { - var h = new HoloChat(); - var fakeroom = new FakeChatClient(); - fakeroom.Name = "The Hacker Alliance"; - fakeroom.Topic = "The Hacker Alliance - We are the masters. DevX cannot control us."; - fakeroom.OtherCharacters = new List<string>(new [] {"Richard Ladouceur"}); - fakeroom.Messages = JsonConvert.DeserializeObject<Dictionary<string, string>>(Properties.Resources.AustinWalkerCompletionStory); - API.CreateForm(h, "QuickChat", API.GetIcon("QuickChat")); - var t = new Thread(new ThreadStart(new Action(() => + else if (CurrentTier == "medium") { - Thread.Sleep(200); - h.Invoke(new Action(() => + var h = new HoloChat(); + var fakeroom = new FakeChatClient(); + fakeroom.Name = "The Hacker Alliance"; + fakeroom.Topic = "The Hacker Alliance - We are the masters. DevX cannot control us."; + fakeroom.OtherCharacters = new List<string>(new[] { "Richard Ladouceur" }); + fakeroom.Messages = JsonConvert.DeserializeObject<Dictionary<string, string>>(Properties.Resources.AustinWalkerCompletionStory); + API.CreateForm(h, "QuickChat", API.GetIcon("QuickChat")); + var t = new Thread(new ThreadStart(new Action(() => { - h.SetupFakeClient(fakeroom); - })); - }))); - - } - foreach(var mod in SelectedNet.Network) - { - if (mod.Type != SystemType.Core) + Thread.Sleep(200); + h.Invoke(new Action(() => + { + h.SetupFakeClient(fakeroom); + })); + }))); + + } + foreach (var mod in SelectedNet.Network) { - mod.HP = 0; - Hacking.MyNetwork.Add(mod); + if (mod.Type != SystemType.Core) + { + mod.HP = 0; + Hacking.MyNetwork.Add(mod); + } } + SetupMyNet(); } - SetupMyNet(); - } - API.CurrentSave.CompletedNets.Add(SelectedNet.Name); - SelectedNet = null; - LoadNetworks(); - SetupSidePane(); - }; - hui.Show(); + API.CurrentSave.CompletedNets.Add(SelectedNet.Name); + SelectedNet = null; + LoadNetworks(); + SetupSidePane(); + }; + hui.Show(); + } + else + { + //nyi + } } } @@ -297,5 +347,36 @@ Those above values only matter if the leader decides to become a friend. If they pgtotalhealth.MaxValue = total; pgtotalhealth.Value = hp; } + + bool online_mode = false; + + private void button1_Click(object sender, EventArgs e) + { + online_mode = !online_mode; + LoadNetworks(); + } + + Online.Hacking.ServerInfo selected_server = null; + + private void lbonlineservers_SelectedIndexChanged(object sender, EventArgs e) + { + var server_name = lbonlineservers.SelectedItem as string; + var server = new Online.Hacking.ServerInfo(); + foreach(var srv in Online.Hacking.Matchmaker.Servers) + { + if (srv.ServerName == server_name) + server = srv; + } + selected_server = server; + LoadNetworks(); + } + + private void btnjoinlobby_Click(object sender, EventArgs e) + { + lbonlineservers.Hide(); + API.CurrentSave.MyOnlineNetwork.Codepoints = API.Codepoints; + Package_Grabber.SendMessage(selected_server.IPAddress, "join_lobby", API.CurrentSave.MyOnlineNetwork); + Online.Hacking.Matchmaker.Matchmake(selected_server); + } } } diff --git a/source/WindowsFormsApplication1/Apps/NetworkBrowser.resx b/source/WindowsFormsApplication1/Apps/NetworkBrowser.resx index fa83c0a..e5cb9b1 100644 --- a/source/WindowsFormsApplication1/Apps/NetworkBrowser.resx +++ b/source/WindowsFormsApplication1/Apps/NetworkBrowser.resx @@ -117,6 +117,13 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <data name="lbnetdesc.Text" xml:space="preserve"> + <value>Welcome to the Network Browser. Here, you can choose various enemy networks to battle and conquer. On the left is the network selection panel, and it will let you choose what network you'd like to fight. When you beat a network, it's removed from the list. + +Below the network selection panel is a Tier button. You can click it to change the difficulty of networks that you will fight. The higher the tier, the harder the battle. Beside that button, is the Screen button. Clicking it will switch between the Network Selection panel and your Network Status panel which will show you the health of all your modules if they are below max. + +You can start the battle using the "Start Battle" button, and you can join an online session using the "Battle online" button. It is wise to practice offline, as offline networks are more predictable than online ones - and you require more speed to battle against another real player. But, this is ShiftOS. Do what you wish.</value> + </data> <metadata name="tmrcalctotal.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> |
