public static RobotProxy SpawnPlayableRobot(ShooterEngine engine) { var model = new RobotModel(); model.TurretRotation = (float)(random.NextDouble() * Math.PI * 2); var view = new RobotView(engine, model); var body = BodyFactory.CreateCircle(engine.World, 0.5f, 1f); body.BodyType = BodyType.Dynamic; body.LinearDamping = 2f; body.AngularDamping = 2f; body.Rotation = (float)(random.NextDouble() * Math.PI * 2); Texture2D lightTexture; if(RobotFactory.LightTexture == null) { RobotFactory.LightTexture = Krypton.Factories.TextureFactory.CreatePoint(engine.GraphicsDevice, 32); //RobotFactory.LightTexture = engine.Game.Content.Load<Texture2D>("Textures/Lights/RobotHeadlight"); } var light = new PointLight(RobotFactory.LightTexture); light.Intensity = 1; light.Radius = 10f; light.Color = Color.Gray; light.Fov = MathHelper.TwoPi / 3f; light.Rotation = model.TurretRotation; light = null; var controller = new AbsoluteRobotController(engine, model, body, light); var linker = new RobotLinker(body, model, light); var proxy = new RobotProxy(engine, model, view, controller, body, linker, light); proxy.Initialize(); return proxy; }
public RobotProxy(ShooterEngine engine, RobotModel model, RobotView view, AbsoluteRobotController controller, Body body, RobotLinker linker, PointLight light) { if(engine == null) { throw new ArgumentException("Engine cannot be null", "engine"); } this.Engine = engine; this.Model = model; this.View = view; this.Controller = controller; this.Body = body; this.Linker = linker; this.Light = light; }