/**
  Space by A.H. Schulak (Shoe) October 1996
  Space by A.H. Schulak (Shoe) March 1998
**/

package Space;

public class KeyController {   
  private Key _left;
  private Key _right;
  private Key _activate;
  private Key _thrust;
  private Key _dethrust;
  private Key _warp;

  private static final String LEFT = "j";
  private static final String RIGHT = "l";
  private static final String ACTIVATE = "Space";
  private static final String THRUST = "i";
  private static final String DETHRUST = "k";
  private static final String WARP = "w";
  
  public KeyController(GP.Graphic graphic, Starfield space,
		       ShipInterface ship) {    
    _left = new Key(graphic,LEFT,new Space.Manipulators.TurnLeft(ship));
    _right = new Key(graphic,RIGHT,new Space.Manipulators.TurnRight(ship));
    _activate = new Key(graphic,ACTIVATE,new Space.Manipulators.Activate(ship));
    _thrust = new Key(graphic,THRUST,new Space.Manipulators.Thrust(ship));
    _dethrust = new Key(graphic,DETHRUST,new Space.Manipulators.Dethrust(ship));
    _warp = new Key(graphic,WARP,new Space.Manipulators.Warp(ship,space));
  }

  /**
    These two methods allow me disable and enable the key interactors so
    that when this is not the current input device they keys will not be
    active.
    **/
  
  public void TurnOff() {
    _left.TurnOffReactor();
    _right.TurnOffReactor();
    _activate.TurnOffReactor();
    _thrust.TurnOffReactor();
    _dethrust.TurnOffReactor();
    _warp.TurnOffReactor();
  }

  public void TurnOn() {
    _left.TurnOnReactor();
    _right.TurnOnReactor();
    _activate.TurnOnReactor();
    _thrust.TurnOnReactor();
    _dethrust.TurnOnReactor();
    _warp.TurnOnReactor();
  } 
  
}
