Beispiel #1
0
    public override void LoadContent()
    {
      base.LoadContent();

			if (!string.IsNullOrEmpty(AttachedPathingNodeName) && AttachedPathingNode == null)
				AttachedPathingNode = GameScreen.GetPath(AttachedPathingNodeName);

      // Check to see if this was pre-loaded
			if (string.IsNullOrEmpty(SpriteSheetFileName))
			{
				Actor original;

				if (ContentManager != null)
					original = ContentManager.Load<Actor>(AssetName);
				else
					original = GameScreen.Content.Load<Actor>(AssetName);

				if (original == null)
					throw new Exception("Error: Could not load the Actor!");

				Direction = original.Direction;
				DrawOrder = original.DrawOrder;
				UpdateOrder = original.UpdateOrder;
				Name = original.Name;
				PlayerIndex = original.PlayerIndex;
				Role = original.Role;
				Enabled = original.Enabled;
				Visible = original.Visible;
				SpriteSheetFileName = original.SpriteSheetFileName;

				ClipPlayer = new AnimationPlayer2D(Game)
				             	{
				             		AssetName = original.ClipPlayer.AssetName,
				             		Sequences = original.ClipPlayer.Sequences
				             	};
			}

			ClipPlayer.GameScreen = GameScreen;
			ClipPlayer.SetShaderParameters += OnSetShaderParams;
			ClipPlayer.AssetPath = AssetFolder;
    	ClipPlayer.AssetName = SpriteSheetFileName;
			ClipPlayer.Game = Game;
			ClipPlayer.GameScreen = GameScreen;
			ClipPlayer.SpriteBatch = SpriteBatch;
			ClipPlayer.ContentManager = ContentManager;
			ClipPlayer.Initialize();

      if (BoundingBoxRenderer == null)
      {
        BoundingBoxRenderer = new BoundingBoxRenderer(Game);
        BoundingBoxRenderer.GameScreen = GameScreen;
        BoundingBoxRenderer.SpriteBatch = SpriteBatch;
        BoundingBoxRenderer.Initialize();
      }
    }
Beispiel #2
0
		public Actor(Game game, string assetFolder, string assetName, ContentManager contentManager)
			: base(game)
		{
			AssetName = assetName;
			AssetFolder = assetFolder;
			Scale = Vector2.One;
			Direction = Direction.Right;

			// Create a new clip player
			ClipPlayer = new AnimationPlayer2D(Game);

			SpriteEffects = SpriteEffects.None;

			ContentManager = contentManager;
		}