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; }
// Constructor public PetrolBot(Ship botsShip, Graphics botsCanvas, int xPos, Random rGen) { this.botsShip = botsShip; this.botsCanvas = botsCanvas; shipLocation = botsShip.ShipLocation; botState = EPetrolBotState.docked; xPos = xPos * 30; botStartingLocation = new Point(xPos, 520); botCurrentLocation = botStartingLocation; int r = rGen.Next(255); int g = rGen.Next(255); int b = rGen.Next(255); botColor = Color.FromArgb(r, g, b); Ship.OutOfFuelEventHandler outOfFuelHandler = new Ship.OutOfFuelEventHandler(OutOfFuelEventHandler); this.botsShip.OutOfFuelEvent += outOfFuelHandler; EventHandler fullOfFuelHandler = new EventHandler(FullOfFuelEventHandler); this.botsShip.FullOfFuelEvent += fullOfFuelHandler; }