public LocalPlayer(Game game, long sessionID, int id, string imageAssetPath, Vector2 position, float angle, PhysicsSimulator physicsSimulator, float speed, float mass, CollisionCategory collisionCategories, short index, KeyboardControls controls, ProjectileFactory projectileFactory) : base(game, sessionID, id, imageAssetPath, position, angle, physicsSimulator, speed, mass, collisionCategories, index) { Controls = controls; this.projectileFactory = projectileFactory; Projectiles = new List<ProjectileLocal>(); Geometry.OnCollision += OnCollision; Body.LinearDragCoefficient = 100; Body.RotationalDragCoefficient = 6000; }
public PlayerFactory(Game game, PhysicsSimulator physicsSimulator, float zOrder, float mass, float speed, string textureFolder, string[] textureNames, ProjectileFactory projectileFactory) { this.game = game; this.physicsSimulator = physicsSimulator; this.zOrder = zOrder; this.mass = mass; this.speed = speed; this.textureFolder = textureFolder; this.textureNames = textureNames; this.projectileFactory = projectileFactory; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { IsFixedTimeStep = true; TargetElapsedTime = new TimeSpan(0,0,0,0,10); //10ms --> 100 fps for physics update physicsSimulator = new PhysicsSimulator(Vector2.Zero); BackgroundColor = Color.CornflowerBlue; spriteBatch = new SpriteBatch(GraphicsDevice); Services.AddService(typeof(SpriteBatch), spriteBatch); RemoteObjectsList = new RemoteObjectList(); LocalObjectList = new LocalObjectList(); remotePlayers = new Dictionary<long, PlayerRemote>(); projectileFactory = new ProjectileFactory(this, physicsSimulator, playerZOrder, 5, 50, "Players/Projectiles/",SharedLists.ProjectileTextureNames); playerFactory = new PlayerFactory(this, physicsSimulator, 0, playerMass, playerSpeed, "Players/Avatars/",SharedLists.PlayerTextureNames, projectileFactory); healthBarFactory = new HealthBarFactory(this, 70, 20, 100, 100); client.DiscoverKnownPeer(host, port); base.Initialize(); }