aboutsummaryrefslogtreecommitdiff
path: root/source/WindowsFormsApplication1/Gameplay
diff options
context:
space:
mode:
authorMichaelTheShifter <[email protected]>2016-06-28 18:30:15 -0400
committerMichaelTheShifter <[email protected]>2016-06-28 18:30:15 -0400
commitdec9dfac5eebfbfd3a21ba5cfd0ca320cd5f1bfb (patch)
tree58271fa2509f724cad4c1b6caa9116fee1588766 /source/WindowsFormsApplication1/Gameplay
parenta067684f084c6fce5e7d7d8140a2d2f56953b579 (diff)
downloadshiftos-c-_theultimatehacker-dec9dfac5eebfbfd3a21ba5cfd0ca320cd5f1bfb.tar.gz
shiftos-c-_theultimatehacker-dec9dfac5eebfbfd3a21ba5cfd0ca320cd5f1bfb.tar.bz2
shiftos-c-_theultimatehacker-dec9dfac5eebfbfd3a21ba5cfd0ca320cd5f1bfb.zip
More client-side fixes.
Still got some moldy bread in there... if ya know what I mean. I meant bugs.
Diffstat (limited to 'source/WindowsFormsApplication1/Gameplay')
-rw-r--r--source/WindowsFormsApplication1/Gameplay/HackUI.cs108
1 files changed, 59 insertions, 49 deletions
diff --git a/source/WindowsFormsApplication1/Gameplay/HackUI.cs b/source/WindowsFormsApplication1/Gameplay/HackUI.cs
index 2d17596..f62ae62 100644
--- a/source/WindowsFormsApplication1/Gameplay/HackUI.cs
+++ b/source/WindowsFormsApplication1/Gameplay/HackUI.cs
@@ -235,49 +235,52 @@ namespace ShiftOS
TotalPlayerHP += newModule.HP;
AllPlayerComputers.Add(newModule);
newModule.Show();
- newModule.StolenModule += (o, a) =>
+ if (!InOnlineBattle)
{
- var t = new Thread(new ThreadStart(() =>
+ newModule.StolenModule += (o, a) =>
{
- var rnd = new Random();
- var lst = new List<Computer>();
- if (newModule.Enslaved)
- lst = AllPlayerComputers;
- else
- lst = AllEnemyComputers;
- WriteLine($"[{newModule.Hostname}] Starting network hack...");
- Thread.Sleep(5000);
-
- var pc = lst[rnd.Next(0, lst.Count)];
- this.Invoke(new Action(() =>
+ var t = new Thread(new ThreadStart(() =>
{
- if (pc.Type != SystemType.Core)
+ var rnd = new Random();
+ var lst = new List<Computer>();
+ if (newModule.Enslaved)
+ lst = AllPlayerComputers;
+ else
+ lst = AllEnemyComputers;
+ WriteLine($"[{newModule.Hostname}] Starting network hack...");
+ Thread.Sleep(5000);
+
+ var pc = lst[rnd.Next(0, lst.Count)];
+ this.Invoke(new Action(() =>
{
- module_to_steal = pc;
+ if (pc.Type != SystemType.Core)
+ {
+ module_to_steal = pc;
- pgpong.Left = (this.Width - pgpong.Width) / 2;
- pgpong.Top = (this.Height - pgpong.Height) / 2;
+ pgpong.Left = (this.Width - pgpong.Width) / 2;
+ pgpong.Top = (this.Height - pgpong.Height) / 2;
- pgpong.Show();
- newgame();
- }
+ pgpong.Show();
+ newgame();
+ }
+ }));
}));
- }));
- t.Start();
- };
- newModule.EnslavedModule += (o, e) =>
- {
- if(!newModule.Enslaved)
+ t.Start();
+ };
+ newModule.EnslavedModule += (o, e) =>
{
- var pc = AllEnemyComputers[rand.Next(0, AllEnemyComputers.Count)];
- if(!pc.Enslaved)
+ if (!newModule.Enslaved)
{
- WriteLine($"[{newModule.Hostname}] Successfully enslaved {pc.Hostname}");
- pc.Enslaved = true;
+ var pc = AllEnemyComputers[rand.Next(0, AllEnemyComputers.Count)];
+ if (!pc.Enslaved)
+ {
+ WriteLine($"[{newModule.Hostname}] Successfully enslaved {pc.Hostname}");
+ pc.Enslaved = true;
+ }
+
}
-
- }
- };
+ };
+ }
newModule.OnDestruction += (object s, EventArgs a) =>
{
if (this.SelectedPlayerComputer == newModule)
@@ -515,7 +518,7 @@ namespace ShiftOS
lbcompromised.Location = new Point(location, y);
lbcompromised.Show();
c.Flash(lbcompromised);
-
+ transmitter?.send_message(Online.Hacking.NetTransmitter.Messages.SetHealth, $"{c.Hostname} {c.HP}");
}
@@ -529,6 +532,8 @@ namespace ShiftOS
lbcompromised.Location = new Point(location, y);
lbcompromised.Show();
c.Flash(lbcompromised);
+ transmitter?.send_message(Online.Hacking.NetTransmitter.Messages.SetHealth, $"{c.Hostname} {c.HP}");
+
}
private void btnaddmodule_Click(object sender, EventArgs e)
@@ -1094,7 +1099,6 @@ namespace ShiftOS
Audio.Play("hackerbattle_ambient");
Hacking.RepairTimer.Stop(); //Don't want the player to be able to repair dead modules during a battle!
- this.TopMost = true;
this.WindowState = FormWindowState.Maximized;
LoadPlayerScreen();
if (InOnlineBattle)
@@ -1114,7 +1118,7 @@ namespace ShiftOS
AllEnemyComputers = new List<Computer>();
VisualizeEnemyNetwork();
tmrenemyhealthdetect.Start();
- ThisEnemyPC.Enemy = true;
+ ThisEnemyPC.Enemy = !InOnlineBattle;
}
private void VisualizeEnemyNetwork()
@@ -1137,10 +1141,13 @@ namespace ShiftOS
public void Enemy_System_Attacking(object s, EventArgs a)
{
- int i = new Random().Next(AllPlayerComputers.Count);
- var pc = AllPlayerComputers[i];
- var se = (Computer)s;
- pc.LaunchAttack(se.GetProperType());
+ if (!InOnlineBattle)
+ {
+ int i = new Random().Next(AllPlayerComputers.Count);
+ var pc = AllPlayerComputers[i];
+ var se = (Computer)s;
+ pc.LaunchAttack(se.GetProperType());
+ }
}
public Computer SelectedEnemyComputer = null;
@@ -1292,6 +1299,7 @@ namespace ShiftOS
WormToPlayer();
};
}
+ newModule.Enemy = !InOnlineBattle;
}
public void Enemy_Firewall_Deflect(Computer fwall)
@@ -1563,6 +1571,16 @@ namespace ShiftOS
receiver.ModulePlaced += Receiver_ModulePlaced;
receiver.ModuleUpgraded += Receiver_ModuleUpgraded;
receiver.ModuleRemoved += Receiver_ModuleRemoved;
+ receiver.ModuleDisabled += (o, e) =>
+ {
+ foreach(var c in AllEnemyComputers)
+ {
+ if(c.Hostname == e.hostName)
+ {
+ c.Disable();
+ }
+ }
+ };
}
private void Receiver_ModuleRemoved(object sender, Online.Hacking.Events.ModuleRemoved e)
@@ -1605,15 +1623,7 @@ namespace ShiftOS
if (m.Hostname == e.host_name)
mod = m;
}
- int health_amount = mod.HP - e.health;
- if(health_amount > 0)
- {
- mod.Repair(health_amount);
- }
- else if(health_amount < 0)
- {
- mod.LaunchAttack(AttackType.Virus, -health_amount);
- }
+ mod.HP = e.health;
}
#endregion