public void Initialize(asgCameraMode mode, asgPlayerActor player, float cameraForce, Vector2 targetOffset) { cameraMode = mode; this.cameraForce = cameraForce; if (gxtDisplayManager.SingletonIsInitialized) { gxtDisplayManager.Singleton.resolutionChanged += OnResolutionChanged; } gxtOBB tmp = Camera.GetViewOBB(); cameraSafeZone = new gxtOBB(tmp.Position, tmp.Extents * 0.8f, tmp.Rotation); if (gxtDisplayManager.SingletonIsInitialized) { gxtDisplayManager.Singleton.resolutionChanged += OnResolutionChanged; } // cameraSpeed is in screen space cameraSpeed = 3.0f; cameraBody = new gxtRigidBody(); cameraBody.MotionType = gxtRigidyBodyMotion.DYNAMIC; cameraBody.AngularDamping = 1.0f; cameraBody.Damping = 1.0f; cameraBody.IgnoreGravity = true; cameraBody.Mass = 2.0f; cameraBody.CanSleep = false; cameraBody.Awake = true; player.World.AddRigidBody(cameraBody); this.player = player; this.offset = targetOffset; }
public override void Initialize(bool setupDebugDrawing = true) { base.Initialize(); world = new gxtWorld(); world.Initialize(true, "ASG Prototype"); gxtDisplayManager.Singleton.WindowTitle = "ASG Prototype"; if (setupDebugDrawing) { if (gxtDebugDrawer.SingletonIsInitialized) { debugDrawId = gxtDebugDrawer.Singleton.GetNewId(); gxtDebugDrawer.Singleton.AddSceneGraph(debugDrawId, world.SceneGraph); gxtDebugDrawer.Singleton.DebugFont = gxtResourceManager.Singleton.Load<Microsoft.Xna.Framework.Graphics.SpriteFont>("Fonts\\debug_font"); } else { gxtLog.WriteLineV(gxtVerbosityLevel.WARNING, "Cannot Set Up Debug Drawing For The Gameplay Screen Because the Debug Drawer Has Not Been Initialized"); } } gxtLog.WriteLineV(gxtVerbosityLevel.SUCCESS, "Initialized GXT World \"{0}\"", world.Name); gxtLog.WriteLineV(gxtVerbosityLevel.INFORMATIONAL, "Populating world..."); world.PhysicsWorld.AddCollisionGroupName("player", gxtCollisionGroup.GROUP1); world.PhysicsWorld.AddCollisionGroupName("traversable_world_geometry", gxtCollisionGroup.GROUP2); // setup player asgPlayerActor player = new asgPlayerActor(world); player.Initialize(Vector2.Zero, 6.5f); world.AddActor(player); // player controller asgPlayerController playerController = new asgPlayerController(); playerController.Initialize(player); world.AddController(playerController); // camera controller asgCameraController cameraController = new asgCameraController(world.Camera); cameraController.Initialize(asgCameraMode.AUTONOMOUS, player, 1.0f, new Vector2(0.0f, -3.5f)); world.AddController(cameraController); // geoms (platforms and walls) gxtPolygon platformPolygon = gxtGeometry.CreateRectanglePolygon(15.0f, 2.0f); CreatePlatformGeom(platformPolygon, new Vector2(0.0f, 8.5f)); // dynamic box gxtRigidBody boxBody = new gxtRigidBody(); boxBody.Mass = 1.0f; boxBody.CanSleep = false; boxBody.Awake = true; gxtPolygon box = gxtGeometry.CreateRectanglePolygon(1.5f, 1.5f); gxtGeom boxGeom = new gxtGeom(box, true); boxGeom.RigidBody = boxBody; boxBody.Inertia = gxtRigidBody.GetInertiaForRectangle(1.5f, 1.5f, boxBody.Mass); boxBody.Position = new Vector2(-3.5f, -3.5f); world.AddGeom(boxGeom); world.AddRigidBody(boxBody); gxtLog.WriteLineV(gxtVerbosityLevel.INFORMATIONAL, "Done populating world..."); }
public void Initialize(asgPlayerActor player, bool initEnabled = true) { this.playerActor = player; this.enabled = initEnabled; }