public override void Operate() { while (true) { SwinGame.ProcessEvents(); PGC.MasterTextBox.Clear(); if (Pbattery != null) { if (Pbattery.PowerRemaining >= 4) { PGC.MasterTextBox.AddLine("Press D to Drill!"); if (SwinGame.KeyReleased(KeyCode.DKey) && Pbattery.TakePower(PpowerAmount)) { SwinGame.ProcessEvents(); DrillDown(); } } else { PGC.MasterTextBox.AddLine("Not enough power provided"); } } else { PGC.MasterTextBox.AddLine("No battery provided"); } base.Operate(); PGC.DrawEverything(); if (SwinGame.WindowCloseRequested() || SwinGame.KeyReleased(KeyCode.EscapeKey) || SwinGame.MouseClicked(MouseButton.LeftButton)) { SwinGame.ProcessEvents(); break; } } }
public override void Operate() { while (true) { SwinGame.ProcessEvents(); PGC.MasterTextBox.Clear(); if (Pbattery != null) { PGC.MasterTextBox.AddLine("Use Arrow keys to move"); PGC.MasterTextBox.AddLine("Movement costs " + PowerAmount + " out of " + Pbattery.PowerRemaining + " remaining energy"); } else { PGC.MasterTextBox.AddLine("Device is not powered to move"); } base.Operate(); PGC.DrawEverything(); if (SwinGame.KeyReleased(KeyCode.UpKey)) { Move(Direction.Up); } else if (SwinGame.KeyReleased(KeyCode.DownKey)) { Move(Direction.Down); } else if (SwinGame.KeyReleased(KeyCode.LeftKey)) { Move(Direction.Left); } else if (SwinGame.KeyReleased(KeyCode.RightKey)) { Move(Direction.Right); } if (SwinGame.WindowCloseRequested() || SwinGame.KeyReleased(KeyCode.EscapeKey) || SwinGame.MouseClicked(MouseButton.LeftButton)) { SwinGame.ProcessEvents(); break; } } }
public override void Operate() { while (true) { SwinGame.ProcessEvents(); PGC.MasterTextBox.Clear(); if (Pbattery != null) { if (Pbattery.PowerRemaining != Pbattery.MaximumPower) { PGC.MasterTextBox.AddLine("Press S to recharge " + PowerAmount); if (SwinGame.KeyReleased(KeyCode.SKey)) { Pbattery.GivePower(PpowerAmount); if (Pbattery.MaximumPower == Pbattery.PowerRemaining) { base.DeConnectBattery(); PGC.MasterTextBox.Clear(); } } } if (Pbattery != null) { PGC.MasterTextBox.AddLine("Battery has " + Pbattery.PowerRemaining + "/" + Pbattery.MaximumPower + " remaining"); } } else { PGC.MasterTextBox.AddLine("Device is not powered to move"); } base.Operate(); PGC.DrawEverything(); if (SwinGame.WindowCloseRequested() || SwinGame.KeyReleased(KeyCode.EscapeKey) || SwinGame.MouseClicked(MouseButton.LeftButton)) { SwinGame.ProcessEvents(); break; } } }