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 }
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"); }