public override void Start() { //Kick off one message -- it'll get physics going on this screen. Switchboard.Instance.Broadcast(new Message("ScreenStarted")); //Add the ground actor so they'll have something to bounce off. p3 = new PhysicsActor(); p3.Position = new Vector2(0.0f, -11.0f); p3.Size = new Vector2(30.0f, 5.0f); p3.Color = new Color(0.0f, 1.0f, 0.0f); p3.Density = 0.0f; p3.Friction = 0.1f; World.Instance.Add(p3); //Demo housekeeping below this point. #region Demo Housekeeping String outputText = "These actors are responding to Messages\nthat we're sending through our central Switchboard."; outputText += "\n\nYou can have actors respond to and broadcast arbitrary messages,\nwhich makes it easy to handle events in your game."; outputText += "\n\n\n(Those actors have been hanging out up there this whole time,\nwaiting for the message that this screen had started\nbefore they dropped in.)"; t1 = new TextActor("Console", outputText); t1.Position = new Vector2(0.0f, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenMessagePassing.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(p1); _objects.Add(p2); _objects.Add(p3); #endregion }
public override void Start() { //"Goodnight, Gracie." TextActor t1 = new TextActor("Console", "That's all we've got in the demo app."); t1.Position = new Vector2(0, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; TextActor t2 = new TextActor("Console", "Make sure to check out the documentation -- there are lots of other features."); t2.Position = new Vector2(0, 2); t2.TextAlignment = TextActor.Alignment.Center; TextActor t3 = new TextActor("Console", "http://bitbucket.org/fuzzybinary/angelxna/wiki/Home"); t3.Position = new Vector2(0, -1); t3.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); World.Instance.Add(t2); World.Instance.Add(t3); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenByeBye.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); #endregion }
public override void Start() { // DeveloperConsole.Instance.ItemManager.AddFromObject(this); DeveloperConsole.Instance.ItemManager.AddCommand("PrintToFileLog", x => { _fileLog.Log(x[0].ToString()); return null; }); //Just some TextActors explaining what to do. TextActor t1 = new TextActor("Console", "The console also supports a log. Type \"ECHO <your message>\""); t1.Position = new Vector2(0.0f, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; TextActor t2 = new TextActor("Console", "Type 'PrintToFileLog(\"<your message>\")' to print to Logs\\Logfile.log."); t2.Position = new Vector2(0f, 2f); t2.TextAlignment = TextActor.Alignment.Center; TextActor t3 = new TextActor("Console", "(This is particularly useful when trying to debug your config files.)"); t3.Position = new Vector2(0f, -1f); t3.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); World.Instance.Add(t2); World.Instance.Add(t3); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenLogs.cs, LogFile.log"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); #endregion }
public override void Start() { //CreateActor loads up an Actor Definition file and makes the actor from it a = ActorFactory.Instance.CreateActor( "simple_actor", //the file to load from -- must be located in Config\ActorTempates and end with ".adf" "PurpleActor", //the desired name of the actor 0, //the render layer in which to put the actor (optional) CustomFunc //a custom initialization function if you want one (optional, can be NULL) ); World.Instance.Add(a); t1 = new TextActor("Console", "This Actor was placed using an ActorTemplate file."); t1.Position = new Vector2(0, 4.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); t2 = new TextActor("Console", "You can be data-driven if you want to!"); t2.Position = new Vector2(0, 3.5f); t2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t2); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenDefFile.cs, simple_actor.adf"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(a); #endregion }
public override void Start() { //Just some text actors to give instructions. Nothing much to see here. TextActor t = new TextActor("Console", "This demo is designed to be super simple. Maybe too much so."); t.Position = new Vector2(0.0f, 3.5f); t.TextAlignment = TextActor.Alignment.Center; TextActor t2 = new TextActor("Console", "Each example is self-contained within the file shown at the bottom left."); t2.Position = new Vector2(0, 2); t2.TextAlignment = TextActor.Alignment.Center; TextActor t3 = new TextActor("Console", "The files are pretty thoroughly commented, so check them out to see how we do things."); t3.Position = new Vector2(0, 0.5f); t3.TextAlignment = TextActor.Alignment.Center; TextActor t4 = new TextActor("Console", "Press [A] on the 360 Controller to go to the next example, and Back to go back."); t4.Position = new Vector2(0, -3.5f); t4.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t); World.Instance.Add(t2); World.Instance.Add(t3); World.Instance.Add(t4); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenInstructions.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t); _objects.Add(t2); _objects.Add(t3); _objects.Add(t4); #endregion }
public override void Start() { //Some TextActors pointing you to other files that do cool stuff. TextActor t1 = new TextActor("Console", "(While we're looking at config files, check out autoexec.cfg."); t1.Position = new Vector2(0f, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; TextActor t2 = new TextActor("Console", "It shows how to do controller and keyboard binding, and sets some console"); t2.Position = new Vector2(0, 2); t2.TextAlignment = TextActor.Alignment.Center; TextActor t3 = new TextActor("Console", "variables that get used in code.)"); t3.Position = new Vector2(0f, .5f); t3.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); World.Instance.Add(t2); World.Instance.Add(t3); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenBindingInstructions.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); #endregion }
public override void Start() { //Loads the file from Config\Levels\level_demo.lvl ActorFactory.Instance.LoadLevel("level_demo"); //Since the Actors were just added directly to the world, // we don't have handles to them. The level definition // gave them the tag "spawned," so we can get them that way. Actor[] spawnedActors = TagCollection.Instance.GetObjectsTagged("spawned"); foreach(Actor a in spawnedActors) { //Can check Individual actors for tags as well. if (a.IsTagged("left-tilted")) { a.Rotation = 25.0f; } else if (a.IsTagged("right-tilted")) { a.Rotation = -25.0f; } //Applying tags a.Tag("rotated"); //Removing tags a.Untag("spawned"); } //Demo housekeeping below this point. #region Demo housekeeping t1 = new TextActor("Console", "These Actors were placed and tagged (\"left-tilted\""); t1.Position = new Vector2(0f, 5.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); t2 = new TextActor("Console", "and \"right-tilted\") using a Level file."); t2.Position = new Vector2(0.0f, 4.5f); t2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t2); t3 = new TextActor("Console", "Then their rotations were set based on those tags."); t3.Position = new Vector2(0f, -4.5f); t3.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t3); TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenLevelFile.cs, level_demo.lvl"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); foreach(Actor a in spawnedActors) _objects.Add(a); #endregion }
public override void Start() { //Set up our obstacle course ActorFactory.Instance.LoadLevel("maze"); //Create the bounding box that will limit the pathfinding search area BoundingBox2D bounds = new BoundingBox2D(new Vector2(-20, -20), new Vector2(20, 20)); //Create our pathfinding graph. In our 2D worlds, this is a relatively fast // operation -- you shouldn't be doing it every frame, but recalculating every // so often if your world has changed is not inappropriate. SpatialGraphManager.Instance.CreateGraph( 0.75f, //The size of the entity you want to pathfind (so the generator // can know how small a space can be and still have it fit.) ref bounds //The search area ); //Create a MazeFinder (class definition below), and put him in the bottom // left corner of the maze _mf = new MazeFinder(); _mf.Position = new Vector2(-11.5f, -8.0f); World.Instance.Add(_mf, 2); //Send him to the upper right, watch him scurry _mf.GoTo(Vector2.Zero); // Register this object as the mouse listener InputManager.Instance.RegisterMouseListener(this); //Demo housekeeping below this point. #region Demo housekeeping String description = "This little dude is pathfinding through the area."; description += "\n\nClick the mouse to give him a new target."; description += "\n\nPress [B] to see the pathfinding graph."; TextActor t = new TextActor("Console", description); t.TextAlignment = TextActor.Alignment.Center; t.Position = new Vector2(0.0f, -5.0f); World.Instance.Add(t, 2); TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenPathfinding.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc, 2); _objects.Add(fileLoc); _objects.Add(t); _objects.Add(_mf); Actor[] walls = TagCollection.Instance.GetObjectsTagged("maze_wall"); foreach(Actor a in walls) _objects.Add(a); #endregion }
public override void Start() { //Loads the file from Config\Levels\collisionlevel_demo.lvl ActorFactory.Instance.LoadLevel("collisionlevel_demo"); //All the magic happens in the level file! //Demo housekeeping below this point. t1 = new TextActor("Console", "These Actors were also placed using a level file."); t1.Position = new Vector2(0.0f, 4.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1, 10); t2 = new TextActor("Console", "Their physics-related properties came from actor definitions."); t2.Position = new Vector2(0.0f, -3.5f); t2.TextAlignment = TextActor.Alignment.Center;; World.Instance.Add(t2, 10); t3 = new TextActor("Console", "They respond to sound in a data driven way."); t3.Position = new Vector2(0.0f, -4.5f); t3.TextAlignment = TextActor.Alignment.Center;; World.Instance.Add(t3, 10); t4 = new TextActor("Console", "If the only collision response you need is sound, this is easier."); t4.Position = new Vector2(0.0f, -5.5f); t4.TextAlignment = TextActor.Alignment.Center; ; #region Demo Housekeeping World.Instance.Add(t4, 10); TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenCollisionLevelFile.cs, collisionlevel_demo.lvl,"); TextActor fileLoc2 = new TextActor("ConsoleSmall", " ground_actor.adf, physics_event_actor.adf"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 735); fileLoc.Color = new Color(.3f, .3f, .3f); fileLoc2.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc2.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc, 10); World.Instance.Add(fileLoc2, 10); _objects.Add(fileLoc); _objects.Add(fileLoc2); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); _objects.Add(t4); Actor[] spawnedActors = TagCollection.Instance.GetObjectsTagged("spawned"); foreach (Actor a in spawnedActors) _objects.Add(a); #endregion }
public override void Start() { //Place the actor from a definition file a = ActorFactory.Instance.CreateActor("simple_actor"); World.Instance.Add(a); // Definitions for the global namespace in the console are dirty, but // anything else should be nice and clean. DeveloperConsole.Instance.ItemManager.AddCommand("AddTexture", x => { a.SetSprite("Images\\angel"); return null; }); DeveloperConsole.Instance.ItemManager.AddCommand("ChangeSize", x => { DeveloperConsole.VerifyArgs(x, typeof(float)); a.Size = new Vector2((float)x[0], (float)x[0]); return null; }); t1 = new TextActor("Console", "This demo shows off the console."); t1.Position = new Vector2(0, -3.5f); t1.TextAlignment = TextActor.Alignment.Center; t2 = new TextActor("Console", "Press ~ to open it up. Execute \"AddTexture()\", enjoying the tab-completion."); t2.Position = new Vector2(0, -4.5f); t2.TextAlignment = TextActor.Alignment.Center; t3 = new TextActor("Console", "Then try executing \"ChangeSize(3.14)\" or whatever number suits your fancy."); t3.Position = new Vector2(0, -5.5f); t3.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); World.Instance.Add(t2); World.Instance.Add(t3); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenConsole.cs, simple_actor.adf"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); _objects.Add(a); #endregion }
public override void Start() { p1 = new PhysicsActor(); //PhysicsActors have all the same attributes as regular ones... p1.Size = Vector2.One; p1.Color = new Color(1.0f, 0.0f, 1.0f, 1.0f); //...but with a little bit of magic pixie dust p1.Density = 0.8f; //density (0.0f will make it an immovable object) p1.Friction = 0.5f; p1.Restitution = 0.7f; p2 = new PhysicsActor(); p2.Position = new Vector2(0.0f, -11.0f); p2.Size = new Vector2(30.0f, 5.0f); p2.Color = new Color(0.0f, 1.0f, 0.0f, 1.0f); p2.Density = 0.0f; p2.Friction = 0.1f; //NOTE: After you call InitPhysics (or the world calls it automatically), you // can't directly set an Actor's position, or rotation -- you've turned those // over to the physics engine. You can't change the size, either, since that // would mess up the simulation. World.Instance.Add(p1); World.Instance.Add(p2); //Demo housekeeping below this point. #region Demo Housekeeping t1 = new TextActor("Console", "These Actors use physics. Press [B]."); t1.Position = new Vector2(0.0f, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenPhysicsActor.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(p1); _objects.Add(p2); #endregion }
public override void Start() { // Create the particle actor via the Actor Definition system (.adf files) pa = (ParticleActor)ActorFactory.Instance.CreateActor("particle_demo", null, 0, null); pa.Position = Vector2.Zero; World.Instance.Add(pa); _isActive = true; //lets the mouse events know that they should care //Demo housekeeping below this point. t1 = new TextActor("Console", "Here's a ParticleActor. (Try moving and clicking the mouse!)"); t1.Position = new Vector2(0f, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); t2 = new TextActor("Console", "Press [B] to change its properties."); t2.Position = new Vector2(0f, 2.5f); t2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t2); // Set up a list of colors to be cycled through when the player clicks the mouse buttons particleColors = new List<Color>(); particleColors.Add(Color.DarkBlue); particleColors.Add(Color.GreenYellow); particleColors.Add(Color.Green); particleColors.Add(Color.Aqua); particleColors.Add(Color.Coral); particleColors.Add(Color.Yellow); // Register this object as the mouse listener InputManager.Instance.RegisterMouseListener(this); #region Demo Housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenParticleActors.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(pa); #endregion }
public override void Start() { a1 = new Actor(); a1.Size = new Vector2(5.0f, 5.0f); a1.Color = Color.Blue; a1.Position = new Vector2(-1f, -1f); a2 = new Actor(); a2.Size = new Vector2(5.0f, 5.0f); a2.Color = Color.Red; a2.Position = new Vector2(1f, 1f); World.Instance.Add(a1, 0); //Adding this actor to layer 0 World.Instance.Add(a2, 1); //Adding this actor to layer 1 //For your game, you will may want to use an // enum for these values so you don't have to // keep the integers straight. t1 = new TextActor("Console", "These Actors overlap."); t1.Position = new Vector2(0f, 5.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); t2 = new TextActor("Console", "Use the controller's bumper buttons to change their layer ordering."); t2.Position = new Vector2(0f, 4.5f); t2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t2); //Demo housekeeping below this point. #region Demo Housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenRenderLayers.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(t2); _objects.Add(a1); _objects.Add(a2); #endregion }
public override void Start() { //Set up the PhysicsActors to collide p1 = new PhysicsActor(); p1.Size = new Vector2(1.0f, 1.0f); p1.Color = new Color(1.0f, 0.0f, 1.0f, 1.0f); p1.Density = 0.8f; p1.Friction = 0.5f; p1.Restitution = 0.7f; // Unlike in Angel 1.1 (which uses a global OnCollision handler) here, we // register with the pieces we want to know about collisions from p1.Collision += new CollisionHandler(OnCollision); p2 = new PhysicsActor(); p2.Position = new Vector2(0.0f, -11.0f); p2.Size = new Vector2(30.0f, 5.0f); p2.Color = new Color(0.0f, 1.0f, 0.0f); p2.Density = 0.0f; p2.Friction = 0.1f; World.Instance.Add(p1); World.Instance.Add(p2); //Demo housekeeping below this point. #region Demo housekeeping t1 = new TextActor("Console", "This example looks similar, but is responding to collisions with sound."); t1.Position = new Vector2(0.0f, 3.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1); TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenCollisions.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t1); _objects.Add(p1); _objects.Add(p2); #endregion }
public override void Start() { //Loads the file from Config\Levels\layeredcollisionlevel_demo.lvl ActorFactory.Instance.LoadLevel("layeredcollisionlevel_demo"); //All the magic happens in the level file! t1 = new TextActor("Console", "These new Actors were assigned layers in the level file."); t1.Position = new Vector2(0.0f, 5.5f); t1.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t1, 10); t2 = new TextActor("Console", "Layer names are defined in autoexec.cfg (note variables starting with \"layer_\"),"); t2.Position = new Vector2(0.0f, 4.5f); t2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t2, 10); t3 = new TextActor("Console", "and assigned to Actors by ActorFactorySetLayerName <layerName>."); t3.Position = new Vector2(0.0f, 3.5f); t3.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t3, 10); #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenLayeredCollisionLevelFile.cs, layeredcollisionlevel_demo.lvl,"); TextActor fileLoc2 = new TextActor("ConsoleSmall", " autoexec.cfg"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 735); fileLoc.Color = new Color(.3f, .3f, .3f); fileLoc2.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc2.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc, 10); World.Instance.Add(fileLoc2, 10); _objects.Add(fileLoc); _objects.Add(fileLoc2); _objects.Add(t1); _objects.Add(t2); _objects.Add(t3); Actor[] spawnedActors = TagCollection.Instance.GetObjectsTagged("spawned"); foreach (Actor a in spawnedActors) _objects.Add(a); #endregion }
public override void Start() { // Create the particle actor via the Actor Definition system (.adf files) shiftingActor = new Actor(); shiftingActor.Size = new Vector2(4.0f, 4.0f); shiftingActor.Position = new Vector2(-5.0f, 0.0f); shiftingActor.Color = new Color(1.0f, 1.0f, 0.0f, 0.5f); World.Instance.Add(shiftingActor); Switchboard.Instance.Broadcast(new Message("IntervalScreenStarted")); // Register message (delegates) that will handle transitions between what morphs are happening Switchboard.Instance["IntervalScreenStarted"] += MoveRight; Switchboard.Instance["LeftMoveDone"] += MoveRight; Switchboard.Instance["RightMoveDone"] += MoveLeft; text1 = new TextActor("Console", "This Actor is using Intervals to change its properties. "); text1.Position = new Vector2(0.0f, 3.5f); text1.TextAlignment = TextActor.Alignment.Center; String explanation = "Intervals are kind of \"fire and forget\" functions that let you"; explanation += "\ngive a goal state and a duration, then the Actor itself"; explanation += "\ndoes the interpolation for you."; text2 = new TextActor("Console", explanation); text2.Position = new Vector2(0.0f, -4.0f); text2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(text1); World.Instance.Add(text2); #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenIntervals.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(shiftingActor); _objects.Add(fileLoc); _objects.Add(text1); _objects.Add(text2); #endregion }
public override void Start() { TextActor t = new TextActor("Console", "Welcome to Angel. This is a quick demo of what we can do."); t.Position = new Vector2(0, 3.5f); t.TextAlignment = TextActor.Alignment.Center; TextActor t2 = new TextActor("Console", "(press [A] on the 360 controller or space bar to continue)"); t2.Position = new Vector2(0, 2); t2.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t); World.Instance.Add(t2); //Demo housekeeping below this point. #region Demo housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenStart.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t); _objects.Add(t2); #endregion }
public override void Start() { //Adding an actor to the world is very simple a = new Actor(); a.Size = new Vector2(5.0f, 5.0f); a.Color = Color.Black; World.Instance.Add(a); t = new TextActor("Console", "Here's a simple Actor. (Press [B] to change it.)"); t.Position = new Vector2(0.0f, 3.5f); t.TextAlignment = TextActor.Alignment.Center; World.Instance.Add(t); //Demo housekeeping below this point. #region Demo Housekeeping TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenSimpleActor.cs"); fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755); fileLoc.Color = new Color(.3f, .3f, .3f); World.Instance.Add(fileLoc); _objects.Add(fileLoc); _objects.Add(t); _objects.Add(a); #endregion }
protected void InitializeMap() { // Tim, this is for you! (plz delete this line) // campus map panel Actor campus = new Actor(); campus.Size = new Vector2(512.0f, 768.0f); campus.Position = new Vector2(-256.0f, 0.0f); campus.DrawShape = Actor.ActorDrawShape.Square; campus.SetSprite("map"); World.Instance.Add(campus); // tech web/tree panel Actor tech = new Actor(); tech.Size = new Vector2(512.0f, 768.0f); tech.Position = new Vector2(256.0f, 0.0f); //tech.Color = new Color(0.0f, 0.0f, 1.0f, 0.5f); tech.DrawShape = Actor.ActorDrawShape.Square; tech.SetSprite("tech_tree"); World.Instance.Add(tech); // Player 1 Actor player1 = new Actor(); player1.Size = new Vector2(14.0f, 35.0f); player1.Position = new Vector2(-450.0f, 350.0f); player1.Color = new Color(1.0f, 1.0f, 1.0f); player1.DrawShape = Actor.ActorDrawShape.Square; player1.SetSprite("avatar1"); World.Instance.Add(player1); player1.Name = "Player 1"; // player 1 input DeveloperConsole.Instance.ItemManager.AddCommand("UpPressed", new ConsoleCommandHandler(MoveUp2)); DeveloperConsole.Instance.ItemManager.AddCommand("DownPressed", new ConsoleCommandHandler(MoveDown2)); DeveloperConsole.Instance.ItemManager.AddCommand("LeftPressed", new ConsoleCommandHandler(MoveLeft2)); DeveloperConsole.Instance.ItemManager.AddCommand("RightPressed", new ConsoleCommandHandler(MoveRight2)); Switchboard.Instance["UpPressed"] += new MessageHandler(x => MoveUp2(null)); Switchboard.Instance["DownPressed"] += new MessageHandler(x => MoveDown2(null)); Switchboard.Instance["LeftPressed"] += new MessageHandler(x => MoveLeft2(null)); Switchboard.Instance["RightPressed"] += new MessageHandler(x => MoveRight2(null)); // Player 2 Actor player2 = new Actor(); player2.Size = new Vector2(14.0f, 35.0f); player2.Position = new Vector2(-60.0f, -350.0f); player2.Color = new Color(0.0f, 0.0f, 0.0f); player2.DrawShape = Actor.ActorDrawShape.Square; player2.SetSprite("avatar2"); World.Instance.Add(player2); player2.Name = "Player 2"; // Player 2 input DeveloperConsole.Instance.ItemManager.AddCommand("WPressed", new ConsoleCommandHandler(MoveUp)); DeveloperConsole.Instance.ItemManager.AddCommand("SPressed", new ConsoleCommandHandler(MoveDown)); DeveloperConsole.Instance.ItemManager.AddCommand("APressed", new ConsoleCommandHandler(MoveLeft)); DeveloperConsole.Instance.ItemManager.AddCommand("DPressed", new ConsoleCommandHandler(MoveRight)); Switchboard.Instance["WPressed"] += new MessageHandler(x => MoveUp(null)); Switchboard.Instance["SPressed"] += new MessageHandler(x => MoveDown(null)); Switchboard.Instance["APressed"] += new MessageHandler(x => MoveLeft(null)); Switchboard.Instance["DPressed"] += new MessageHandler(x => MoveRight(null)); // Quick Keyboard Hack DeveloperConsole.Instance.ItemManager.AddCommand("Pause", new ConsoleCommandHandler(Pause)); DeveloperConsole.Instance.ItemManager.AddCommand("UnPause", new ConsoleCommandHandler(UnPause)); DeveloperConsole.Instance.ItemManager.AddCommand("Quit", new ConsoleCommandHandler(QuitFromConsole)); DeveloperConsole.Instance.ItemManager.AddCommand("Start", new ConsoleCommandHandler(Start)); DeveloperConsole.Instance.ItemManager.AddCommand("Victory", new ConsoleCommandHandler(Victory)); DeveloperConsole.Instance.ItemManager.AddCommand("Lose", new ConsoleCommandHandler(Lose)); Switchboard.Instance["Pause"] += new MessageHandler(x => Pause(null)); Switchboard.Instance["UnPause"] += new MessageHandler(x => UnPause(null)); Switchboard.Instance["Quit"] += new MessageHandler(x => QuitFromConsole(null)); Switchboard.Instance["Start"] += new MessageHandler(x => Start(null)); Switchboard.Instance["Victory"] += new MessageHandler(x => Victory(null)); Switchboard.Instance["Lose"] += new MessageHandler(x => Lose(null)); // P1 Status statusTextP1 = new TextActor("Small", ""); statusTextP1.Position = new Vector2(-480.0f, -350.0f); statusTextP1.Name = "P1_Status"; World.Instance.Add(statusTextP1); Switchboard.Instance["Collision"] += new MessageHandler(x => TreeListener(x.Sender)); // P2 Status statusTextP2 = new TextActor("Small", ""); statusTextP2.Position = new Vector2(-200.0f, -350.0f); statusTextP2.Name = "P2_Status"; World.Instance.Add(statusTextP2); Switchboard.Instance["Collision"] += new MessageHandler(x => TreeListener(x.Sender)); Switchboard.Instance["SkillUpdate"] += new MessageHandler(x => UpdateListener(x.Sender)); SoundState.Instance.SoundOff(); // Add (invisible) map squares ActorFactory.Instance.LoadLevel("map_spots"); }
/// <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 iterate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { World.Instance.Initialize(this); // Add the default grid so we can see where our Actors are in the world World.Instance.Add(new GridActor()); pTextP1 = new TextActor("Small", "PAUSED"); World.Instance.Add(pTextP1, 3); startSheetText = new TextActor("Small", ""); World.Instance.Add(startSheetText, 3); endSheetText = new TextActor("Small", "Define Yourself IS OVER"); World.Instance.Add(endSheetText, 3); endSheetScoreP1 = new TextActor("Small", "SCORE 1"); endSheetScoreP1.Position = new Vector2(-300, 200); World.Instance.Add(endSheetScoreP1, 3); endSheetScoreP2 = new TextActor("Small", "SCORE 2"); endSheetScoreP2.Position = new Vector2(300, 200); World.Instance.Add(endSheetScoreP2, 3); pauseSheet = new Actor(); pauseSheet.Size = new Vector2(1024.0f, 768.0f); pauseSheet.Position = new Vector2(0.0f, 0.0f); pauseSheet.DrawShape = Actor.ActorDrawShape.Square; World.Instance.Add(pauseSheet, 2); startSheet = new Actor(); startSheet.Size = new Vector2(1024.0f, 768.0f); startSheet.Position = new Vector2(0.0f, 0.0f); startSheet.DrawShape = Actor.ActorDrawShape.Square; World.Instance.Add(startSheet, 2); endSheet = new Actor(); endSheet.Size = new Vector2(1024.0f, 768.0f); endSheet.Position = new Vector2(0.0f, 0.0f); endSheet.DrawShape = Actor.ActorDrawShape.Square; World.Instance.Add(endSheet, 2); InitializeMap(); InitializeSkillWeb(); clock = new TextActor("Tiny", "Time Left: "); clock.Color = Color.Black; clock.Position = new Vector2(-120, 370); World.Instance.Add(clock); // Set the camera up somewhere "above" the grid World.Instance.Camera.Position = new Vector3(0.0f, 0.0f, 400.0f); // Add the AngelComponent once your setup is done, and Angel will // take care of updating and drawing everything for you. Components.Add(new AngelComponent(this)); // TODO: Add your initialization logic here MusicState.Instance.Play(); MusicState.Instance.Stop(); base.Initialize(); }