public PetrolBot(Graphics botCanvas, Ship botShip, Point botStartingLocation, Random rGen) { this.botCanvas = botCanvas; this.botShip = botShip; this.botStartingLocation = botStartingLocation; botColour = Color.FromArgb(rGen.Next(255), rGen.Next(255), rGen.Next(255)); botCurrentLocation = botStartingLocation; Ship.OutOfFuelEventHandler outOfFuelHandler = new Ship.OutOfFuelEventHandler(OutOfFuelEventHandler); botShip.OutOfFuelEvent += outOfFuelHandler; Ship.FullOfFuelEventHandler fullOfFuelHandler = new Ship.FullOfFuelEventHandler(FullOfFuelEventHandler); botShip.FullOfFuelEvent += fullOfFuelHandler; }
//Constructor public PetrolBot(Graphics botCanvas, Color botColor, Point startLoc, Ship botShip) { this.botCanvas = botCanvas; this.botColor = botColor; this.botShip = botShip; botStartingLocation = startLoc; botCurrentLocation = botStartingLocation; Ship.OutOfFuelEventHandler outOfFuelHandler = new Ship.OutOfFuelEventHandler(OutOfFuelEventHandler); botShip.OutOfFuelEvent += outOfFuelHandler; Ship.FullOfFuelEventHandler fullOfFuelHandler = new Ship.FullOfFuelEventHandler(FullOfFuelEventHandler); botShip.FullOfFuelEvent += fullOfFuelHandler; }
public Bot(Point startPosition, Point world_size, int size, Graphics g, Ship subject, Color botColor) : base(startPosition, world_size, size, g) { //Keep reference to subject/color this.subject = subject; this.botColor = botColor; this.startPosition = startPosition; //Create a new handlers Ship.OutOfFuelEventHandler OutOfFuelHandle = new Ship.OutOfFuelEventHandler(OutOfFuelCalled); Ship.FullOfFuelEventHandler FullOfFuelHandle = new Ship.FullOfFuelEventHandler(FullOfFuelCalled); //Register handlers subject.OutOfFuelEvent += OutOfFuelHandle; subject.FullOfFuelEvent += FullOfFuelHandle; }
//ctor public PetrolBot(Graphics parentCanvas, Color colour, Point startLoc, int botSize, Ship tetheredShip) { this.botSize = botSize; this.parentCanvas = parentCanvas; botColour = colour; botShip = tetheredShip; //Set the starting location & the current location as the initially passed in location. botStartingLocation = startLoc; //This will not change botCurrentLocation = botStartingLocation; //This will change a lot. //Bind event handler Ship.OutOfFuelEventHandler outOfFuelHandler = new Ship.OutOfFuelEventHandler(OutOfFuelEventHandler); botShip.OutOfFuelEvent += outOfFuelHandler; Ship.FullOfFuelEventHandler fullOfFuelHandler = new Ship.FullOfFuelEventHandler(FullOfFuelEventHandler); botShip.FullOfFuelEvent += fullOfFuelHandler; }