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 bool Move(Direction dir) { if (Pbattery != null && Pbattery.TakePower(PpowerAmount)) { switch (dir) { case Direction.Down: Prover.UpdatePos(Prover.Location.X, Prover.Location.Y + 1f); break; case Direction.Up: Prover.UpdatePos(Prover.Location.X, Prover.Location.Y - 1f); break; case Direction.Left: Prover.UpdatePos(Prover.Location.X - 1f, Prover.Location.Y); break; case Direction.Right: Prover.UpdatePos(Prover.Location.X + 1f, Prover.Location.Y); break; } return(true); } else { return(false); } }
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; } } }