public GameController(int width, int height, Canvas GameBoard, ProgressBar CPUProgressBar, Window window) { //setup player player = new Player(); CPUprogressBar = CPUProgressBar; Point robotStartPosition = new Point(1, 1); runningProgramm = new Programm(this); gameWorld = new GameWorld(width, height, robotStartPosition); commandTimer = new DispatcherTimer { Interval = new TimeSpan(1000) }; EventHandler eventHandler = new EventHandler(HandleCommandTime); commandTimer.Tick += eventHandler; commandTimer.Start(); InitialRobotInfo(); robot = new Robot(entityCounter++, robotStartPosition, this, activeEquipment); //Link robot to equipment activeEquipment.ForEach(e => e.robot = robot); robotEquipment.ForEach(e => e.robot = robot); initalEquipment.ForEach(e => e.robot = robot); //Calculate robot values robot.equipment.ForEach(e => e.SettupRobot()); renderer = new Rendering.Renderer(GameBoard, this, gameWorld.map.Cast <GameObject>().ToList()); renderer.AddEntity(robot, Rendering.RenderObjectType.image); SettupRobotInfo(); }
public Robot(int id, Point start, GameController gameController, List <RobotEquipment> parts) : base(id, Colors.Red, start) { equipment = new List <RobotEquipment>(parts); EnterField = e => { Point movement = Programm.GetOffset(e.Angle, e.position, gameController.gameWorld, out MapObject field); if (movement == new Point(0, 0)) { return(true); } if (!field.blocking && field.entities.TrueForAll(E => !E.blocking)) { //Change map tile owner e.link.entities.Remove(e); field.entities.Add(e); e.link = field; //Now move robot on field e.position += movement; return(true); } else { //TODO: Calcuate damage + collision return(false); } }; link = gameController.gameWorld.map[0, 0]; }