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 void AddObjectToTagList(Actor aActor, string asTag) { if (!_tagMappings.ContainsKey(asTag)) _tagMappings.Add(asTag, new List<Actor>()); _tagMappings[asTag].Add(aActor); }
public SkillNode(string name) { Actor = new Actor(); Name = name; Actor.Size = new Vector2(40, 40); Actor.Position = new Vector2(-256.0f, 0.0f); Actor.Color = new Color(1.0f, 0.3f, 0.0f); Actor.DrawShape = Actor.ActorDrawShape.Square; SkillPointsModifier = new SkillPointsModifier(); }
public SkillNode() { Actor = new Actor(); Actor.Color = new Color(1.0f, 1.0f, 1.0f, 0.0f); Actor.DrawShape = Actor.ActorDrawShape.Square; Actor.Size = new Vector2(40, 40); Actor.Tag("skill_node"); PointsNeeded = 50; SkillPointsModifier = new SkillPointsModifier(); SkillNode.Nodes.Add(this); SkillWeb.Instance.AddNode(this); }
public void MouseDownEvent(Vector2 screenCoordinates, InputManager.MouseButton button) { Selected = World.Instance.FindAt((int)screenCoordinates.X, (int)screenCoordinates.Y) as Actor; if (Selected != null) { Vector2 worldCoordinates = World.Instance.Camera.ScreenToWorld((int)screenCoordinates.X, (int)screenCoordinates.Y); _HeldOffset = Selected.Position - worldCoordinates; _bObjectHeld = true; } else { _bCameraHeld = true; _screenHeldPosition = screenCoordinates; _cameraHeldPosition = World.Instance.Camera.Position; } }
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() { 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() { // 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() { //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(); }
public void OnKeyDown(Microsoft.Xna.Framework.Input.Keys key) { if (key == Microsoft.Xna.Framework.Input.Keys.Delete) { if (_selectedObject != null) { World.Instance.Remove(_selectedObject); Selected = null; } } }
public void CustomFunc(Actor a) { a.Rotation = 45.0f; a.Position = new Vector2(0, -1); }
public CollisionPair(Actor a1, Actor a2) { this.a1 = a1; this.a2 = a2; }
private bool updatePlayerSkillProgress(Actor player, string skillName) { bool updated = false; bool justFinished = false; if (player.Name == "Player 1") { SkillNode node = FindActiveNodeByNameAndPlayer(skillName, player.Name); if (node != null) { if (node.Completed(player.Name)) { updated = false; _game.StatusTextP1.Color = Color.Green; _game.StatusTextP1.DisplayString = skillName + " already completed"; } else { node.P1_Points += 1; if (node.Completed(player.Name)) { justFinished = true; } updated = true; _game.StatusTextP1.Color = Color.Blue; _game.StatusTextP1.DisplayString = skillName + " updating"; } } else { _game.StatusTextP1.Color = Color.White; _game.StatusTextP1.DisplayString = skillName + ": prereqs not met"; } } else if (player.Name == "Player 2") { SkillNode node = FindActiveNodeByNameAndPlayer(skillName, player.Name); if (node != null) { if (node.Completed(player.Name)) { updated = false; _game.StatusTextP2.Color = Color.Green; _game.StatusTextP2.DisplayString = skillName + " already completed"; } else { node.P2_Points += 1; if (node.Completed(player.Name)) { justFinished = true; } updated = true; _game.StatusTextP2.Color = Color.Blue; _game.StatusTextP2.DisplayString = skillName + " updating"; } } else { _game.StatusTextP2.Color = Color.Black; _game.StatusTextP2.DisplayString = skillName + ": prereqs not met"; } } MessageObject messageObject = new MessageObject(); messageObject.play = player; messageObject.boolie = updated; messageObject.justFinished = justFinished; Switchboard.Instance.Broadcast(new Message("SkillUpdate", messageObject)); return updated; }
private void SerializeActorProperties(TextWriter stream, Actor template, Actor myActor) { // Compare all console properties in the current Actor to those of a created version PropertyInfo[] properties = template.GetType().GetProperties(); foreach (PropertyInfo info in properties) { if (info.GetCustomAttributes(typeof(ConsolePropertyAttribute), true).Length > 0) { if (!info.GetValue(template, null).Equals(info.GetValue(myActor, null))) { object newValue = info.GetValue(myActor, null); stream.Write('\t'); stream.Write(info.Name); stream.Write(" = "); // String is a special case as it needs to be enclosed in quotes if (newValue is string) { stream.Write('"'); stream.Write(newValue.ToString()); stream.Write('"'); } // Check if the console has this type registered, meaning it will have // special syntax to write it out. else { ConsoleType type = DeveloperConsole.Instance.ItemManager.GetConsoleType(newValue.GetType()); if (type != null) { stream.Write(type.Serialize(newValue)); } else stream.Write(newValue.ToString()); } stream.WriteLine(); } } } }
public void SerializeActorDefinition(string definitionName, Actor myActor) { definitionName = definitionName.Trim(); if (definitionName.Length == 0) return; StringBuilder sb = new StringBuilder(@"Config\"); sb.Append(s_ActorTemplateDirectory); sb.Append(definitionName); sb.Append(".adf"); ConstructorInfo constructor = myActor.GetType().GetConstructor(new Type[] {}); if (constructor == null) { Log.Instance.Log("[WARN] Could not serialize actor definition. Actor type '" + myActor.GetType().Name + "' does not have a default constructuor."); return; } Actor template = (Actor)constructor.Invoke(null); using (StreamWriter stream = new StreamWriter(sb.ToString())) { stream.WriteLine("ActorFactory.InitializeActor(" + myActor.GetType().Name + ".Create())"); SerializeActorProperties(stream, template, myActor); } // This actor is now of this definition myActor.ActorDefinition = definitionName; }
public void RemoveObjectFromTagList(Actor aActor, string asTag) { _tagMappings[asTag].Remove(aActor); if (_tagMappings[asTag].Count == 0) _tagMappings.Remove(asTag); }
private void EditorForm_Disposed(object sender, EventArgs e) { Selected = null; InputManager.Instance.UnregisterMouseListener(this); InputManager.Instance.UnregisterKeyListener(this); World.Instance.EndEditing(); }
void EditorForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && _selectedObject != null) { World.Instance.Remove(_selectedObject); _selectedObject = null; } }
protected void InitializeSkillWeb() { SkillWeb.Instance.Game = this; DeveloperConsole.Instance.ItemManager.AddCommand("TestUpdateSkills", new ConsoleCommandHandler(TestUpdateSkills)); DeveloperConsole.Instance.ItemManager.AddCommand("Quit", new ConsoleCommandHandler(QuitFromConsole)); iconTextureOne = Content.Load<Texture2D>("map"); iconTextureOne = Content.Load<Texture2D>("tech_tree"); iconTextureOne = Content.Load<Texture2D>("titlescreen"); iconTextureOne = Content.Load<Texture2D>("avatar1"); iconTextureOne = Content.Load<Texture2D>("avatar2"); iconTextureOne = Content.Load<Texture2D>("eng_icon"); iconTextureOne = Content.Load<Texture2D>("lib_icon"); iconTextureOne = Content.Load<Texture2D>("sci_icon"); iconTextureOne = Content.Load<Texture2D>("soc_icon"); iconTextureOne = Content.Load<Texture2D>("sports_icon"); iconTextureOne = Content.Load<Texture2D>("stu_icon"); //node_first.Location = new Vector2(10, 0); //node_first.Actor.Position = new Vector2(100, 100); //World.Instance.Add(node_first.Actor); ActorFactory.Instance.LoadLevel("first_few"); //Actor[] spawnedActors = TagCollection.Instance.GetObjectsTagged("skill_node"); //if (spawnedActors != null) //{ // foreach (Actor a in spawnedActors) // { // //a.Position = new Vector2(30, 30); // World.Instance.Add(a); // } //} //SkillNode node; //node = SkillNode.Create(); //node.Location = new Vector2(50, 100); //node = SkillNode.Create(); //node.Location = new Vector2(100, 100); //node.Color = new Color(1.0f, 1.0f, 0.0f); //node = SkillNode.Create(); //node.Location = new Vector2(-100, 150); //node.Color = new Color(1.0f, 0.5f, 0.0f); foreach (SkillNode _node in SkillWeb.Instance.Nodes) { World.Instance.Add(_node.Actor); Actor p1_bar = new Actor(); p1_bar.Position = new Vector2(_node.Actor.Position.X - 30, _node.Actor.Position.Y); p1_bar.Size = new Vector2(10, 40); p1_bar.Color = Color.White; p1_bar.DrawShape = Actor.ActorDrawShape.Square; World.Instance.Add(p1_bar); _node.P1_ProgBar = p1_bar; _node.P1_Points = 20; Actor p2_bar = new Actor(); p2_bar.Position = new Vector2(_node.Actor.Position.X + 30, _node.Actor.Position.Y); p2_bar.Size = new Vector2(10, 40); p2_bar.Color = Color.Black; p2_bar.DrawShape = Actor.ActorDrawShape.Square; World.Instance.Add(p2_bar); _node.P2_ProgBar = p2_bar; _node.P2_Points = 10; SpriteFont helveticaTiny; SpriteFont helveticaSmall; helveticaTiny = Content.Load<SpriteFont>("fonts/HelveticaTiny"); helveticaSmall = Content.Load<SpriteFont>("fonts/HelveticaSmall"); FontCache.Instance.RegisterFont("fonts\\HelveticaTiny", "Tiny"); FontCache.Instance.RegisterFont("fonts\\HelveticaSmall", "Small"); //TextActor nameText = new TextActor("Tiny", _node.Name, TextActor.Alignment.Center); //nameText.Position = new Vector2(_node.Actor.Position.X - 20, _node.Actor.Position.Y - 30); //World.Instance.Add(nameText); } Switchboard.Instance["Collision"] += new MessageHandler(x => UpdateSkillProgress(x.Sender)); }
public static void InitializeActor(Actor aTheActor) { DeveloperConsole.Instance.Using(aTheActor); }
public void SerializeActor(TextWriter stream, Actor myActor) { Actor template = null; if(myActor.ActorDefinition != null) { stream.WriteLine("BeginActor(\"" + myActor.ActorDefinition + "\")"); template = CreateActor(myActor.ActorDefinition); } else { ConstructorInfo constructor = myActor.GetType().GetConstructor(new Type[] { }); if (constructor != null) { stream.WriteLine("ActorFactory.InitializeActor(" + myActor.GetType().Name + ".Create())"); template = (Actor)constructor.Invoke(null); } } if(template == null) { Log.Instance.Log("[WARN] Could not serialize actor '" + myActor.Name + "'. Could not create a template for the actor."); return; } SerializeActorProperties(stream, template, myActor); // Write out all tags for the actor foreach (string tag in myActor.GetTags()) stream.WriteLine("\tTag(\"" + tag + "\")"); stream.WriteLine("EndActor()"); stream.WriteLine(); }
private void _btnAddActor_Click(object sender, EventArgs e) { Actor theActor; if (_tcActorDefinitions.SelectedTab == _tpBaseActors) { ConstructorInfo info = _baseActorMap[(string)_lbBaseActors.SelectedItem]; theActor = (Actor)info.Invoke(null); } else { string definition = (string)_lbActorDefinitions.SelectedItem; theActor = ActorFactory.Instance.CreateActor(definition); } // Find the center of the screen Camera cam = World.Instance.Camera; Vector2 centerScreen = cam.ScreenToWorld(cam.WindowWidth / 2, cam.WindowHeight / 2); theActor.Position = centerScreen; World.Instance.Add(theActor); Selected = theActor; }