mirror of
https://github.com/seriocomedy/ShiftOS-C-.git
synced 2025-01-22 17:22:14 +00:00
More client-side fixes.
Still got some moldy bread in there... if ya know what I mean. I meant bugs.
This commit is contained in:
parent
a067684f08
commit
dec9dfac5e
3 changed files with 141 additions and 112 deletions
|
@ -61,7 +61,7 @@ public int Value
|
|||
this.Invalidate();
|
||||
}
|
||||
else {
|
||||
throw new ArgumentOutOfRangeException("The value must be between the minimum and maximum values.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,6 +235,8 @@ public void AddModule(Computer newModule)
|
|||
TotalPlayerHP += newModule.HP;
|
||||
AllPlayerComputers.Add(newModule);
|
||||
newModule.Show();
|
||||
if (!InOnlineBattle)
|
||||
{
|
||||
newModule.StolenModule += (o, a) =>
|
||||
{
|
||||
var t = new Thread(new ThreadStart(() =>
|
||||
|
@ -278,6 +280,7 @@ public void AddModule(Computer newModule)
|
|||
|
||||
}
|
||||
};
|
||||
}
|
||||
newModule.OnDestruction += (object s, EventArgs a) =>
|
||||
{
|
||||
if (this.SelectedPlayerComputer == newModule)
|
||||
|
@ -515,7 +518,7 @@ private void Player_System_Repaired(object s, EventArgs e)
|
|||
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 @@ private void Player_System_Damaged(object s, EventArgs e)
|
|||
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 @@ private void HackUI_Load(object sender, EventArgs e)
|
|||
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 @@ private void LoadEnemyScreen()
|
|||
AllEnemyComputers = new List<Computer>();
|
||||
VisualizeEnemyNetwork();
|
||||
tmrenemyhealthdetect.Start();
|
||||
ThisEnemyPC.Enemy = true;
|
||||
ThisEnemyPC.Enemy = !InOnlineBattle;
|
||||
}
|
||||
|
||||
private void VisualizeEnemyNetwork()
|
||||
|
@ -1136,12 +1140,15 @@ private void VisualizeEnemyNetwork()
|
|||
}
|
||||
|
||||
public void Enemy_System_Attacking(object s, EventArgs a)
|
||||
{
|
||||
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 @@ public void AddEnemyModule(Computer newModule)
|
|||
WormToPlayer();
|
||||
};
|
||||
}
|
||||
newModule.Enemy = !InOnlineBattle;
|
||||
}
|
||||
|
||||
public void Enemy_Firewall_Deflect(Computer fwall)
|
||||
|
@ -1563,6 +1571,16 @@ public void LoadOnlineEnemy()
|
|||
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 @@ private void Receiver_ModuleHealthSet(object sender, Online.Hacking.Events.Healt
|
|||
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
|
||||
|
|
|
@ -29,6 +29,8 @@ public static void Initiate()
|
|||
foreach(var c in Package_Grabber.clients)
|
||||
{
|
||||
c.Value.OnReceived += (o, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var om = (e.Data.Object as ObjectModel);
|
||||
if (om.Command == "server_info")
|
||||
|
@ -41,6 +43,11 @@ public static void Initiate()
|
|||
Initiated?.Invoke(null, new EventArgs());
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
Package_Grabber.SendMessage(c.Value.RemoteHost, "get_info");
|
||||
}
|
||||
|
@ -53,6 +60,8 @@ public static void Matchmake(ServerInfo si)
|
|||
Players = new List<Network>();
|
||||
var server = Package_Grabber.clients[si.IPAddress];
|
||||
server.OnReceived += (o, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var om = e.Data.Object as ObjectModel;
|
||||
if (om.Command == "matchmaking")
|
||||
|
@ -63,6 +72,11 @@ public static void Matchmake(ServerInfo si)
|
|||
MorePlayersFound?.Invoke(null, new EventArgs());
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
Package_Grabber.SendMessage(si.IPAddress, "get_matchmaking");
|
||||
int index = 0;
|
||||
|
@ -74,7 +88,7 @@ public static void Matchmake(ServerInfo si)
|
|||
{
|
||||
SelectedNetwork = Players[index];
|
||||
MakerTimer.Stop();
|
||||
SelectedNetworkListener = new NetListener(si, SelectedNetwork);
|
||||
SelectedNetworkListener = new NetListener(si, API.CurrentSave.MyOnlineNetwork);
|
||||
SelectedNetworkTransmitter = new NetTransmitter(si, SelectedNetwork);
|
||||
Package_Grabber.SendMessage(SelectedServer.IPAddress, $"leave_lobby {JsonConvert.SerializeObject(API.CurrentSave.MyOnlineNetwork)}");
|
||||
}
|
||||
|
@ -118,11 +132,15 @@ private void register_events(ServerInfo si, Network net)
|
|||
var server = Package_Grabber.clients[si.IPAddress];
|
||||
server.OnReceived += (o, e) =>
|
||||
{
|
||||
if(e.Data.Object is string)
|
||||
if (e.Data.Object is ObjectModel)
|
||||
{
|
||||
|
||||
var data = (e.Data.Object as ObjectModel);
|
||||
if (data.Command != null)
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<ObjectModel>(e.Data.Object as string);
|
||||
string[] args = data.Command.Split(' ');
|
||||
if ((data.OptionalObject as Network) == net) {
|
||||
if ((data.OptionalObject as Network)?.Name == net.Name)
|
||||
{
|
||||
switch (args[0].ToLower())
|
||||
{
|
||||
case "set_health":
|
||||
|
@ -173,6 +191,7 @@ private void register_events(ServerInfo si, Network net)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue