public ActorEd CreateActor( int id )
        {
            if( IsTextActor )
                return CreateTextActor( id );

            ActorEd actor = new ActorEd( this );
            actor.ID = id;
            actor.Scale = this._scale;
            actor.Rotation = this._rotation;
            actor.Origin = new Vector2( this.SpriteAsset.Sprite.Width * 0.5f, this.SpriteAsset.Sprite.Height * 0.5f );
            actor.Tags = new string[] { this._name };

            return actor;
        }
        public ActorEd CreateTextActor( int id )
        {
            ActorEd actor = new ActorEd( this );
            actor.ID = id;
            actor.Scale = this._scale;
            actor.Rotation = this._rotation;
            actor.Origin = Vector2.Zero;
            actor.Text = _text;
            actor.TextColor = _textColor;
            actor.UpdateBounds( );
            actor.Tags = new string[] { this._name };

            return actor;
        }
 public void RemoveActor( ActorEd actor )
 {
     _actors.Remove( actor );
     actor.Container = null;
 }
        public ActorEd Clone( )
        {
            ActorEd actor = new ActorEd( _parent );
            actor._origin = this._origin;
            actor._pos = this._pos;
            actor._scale = this._scale;
            actor._rotation = this._rotation;
            actor._sprite = this._sprite;
            actor._visible = this._visible;
            actor._text = this._text;
            actor._textColor = this._textColor;
            actor._name = this._name;
            actor._id = this._id;

            actor.UpdateBounds( );

            return actor;
        }
 public void AddActor( ActorEd actor )
 {
     actor.Container = this;
     _actors.Add( actor );
 }
        public void NewActor( ActorEd actor )
        {
            //Vector2 pos = Helper.ScreenToWorldPosition( Global.SelectedLevelDoc.Viewport.Camera, x, y );
            //if( Global.Tools.IsDragSnapToGrid )
            //    Helper.DragSnap( ref pos );

            //actor.Position = pos;

            SelectedLayer.AddActor( actor );
            actor.AddedToLevel = true;

            Global.MainWindow.OnLevelChanged( this.Parent );
        }
 public void DeleteActor( ActorEd actor )
 {
     SelectedLayer.RemoveActor( actor );
 }
        private static void GameLevelActorWriteData( ActorEd actor, BinaryWriter file )
        {
            file.Write( actor.ID );
            if( actor.Sprite.Name != null )
                file.Write( actor.Sprite.Name );
            else
                file.Write( NO_SPRITE );

            if( actor.Parent.Script == null )
                file.Write( NO_SCRIPT );
            else
                file.Write( actor.Parent.Script.Name );
            file.Write( actor.Name );
            file.Write( actor.Position.X );
            file.Write( actor.Position.Y );
            file.Write( actor.Origin.X );
            file.Write( actor.Origin.Y );
            file.Write( actor.Scale );
            file.Write( actor.Rotation );
            file.Write( actor.Visible );

            file.Write( actor.Tags.Length );
            foreach( string tag in actor.Tags )
            {
                file.Write( tag );
            }

            file.Write( actor.IsTextActor );
            if( actor.IsTextActor )
            {
                file.Write( actor.FontAsset.Font.Name );
                file.Write( actor.Text );
                file.Write( actor.TextColor.R );
                file.Write( actor.TextColor.G );
                file.Write( actor.TextColor.B );
                file.Write( actor.TextColor.A );
            }
        }
        private static void LevelActorWriteData( ActorEd actor, BinaryWriter writer )
        {
            writer.Write( actor.ID );
            writer.Write( actor.Parent.Name );
            writer.Write( actor.Name );
            writer.Write( actor.Position.X );
            writer.Write( actor.Position.Y );
            writer.Write( actor.Origin.X );
            writer.Write( actor.Origin.Y );
            writer.Write( actor.Scale );
            writer.Write( actor.Rotation );
            writer.Write( actor.Visible );

            if( actor.Tags == null )
                actor.Tags = new string[1] { actor.Parent.Name };
            writer.Write( actor.Tags.Length );
            foreach( string tag in actor.Tags )
            {
                writer.Write( tag );
            }

            writer.Write( actor.IsTextActor );
            if( actor.IsTextActor )
            {
                writer.Write( actor.Text );
                writer.Write( actor.TextColor.R );
                writer.Write( actor.TextColor.G );
                writer.Write( actor.TextColor.B );
                writer.Write( actor.TextColor.A );
            }
        }