Ejemplo n.º 1
0
        public static AnimatedSprite Adventurer(Vector2 position)
        {
            AnimatedSprite adventurer = new AnimatedSprite("adventurer", Contents.adventurer, position, PlayerIndex.One, fps: 6, keyboardInput: KeyboardInput.Default(),
                                                           gamePadInput: GamePadInput.Default(), isInteractable: true);

            adventurer.AddAnimation(EAnimation.Idle, 4, 50, 37, 0, 0, Vector2.Zero, 4,
                                    () => Console.WriteLine("Idle start"), () => Console.WriteLine("Idle end"));
            adventurer.AddAnimation(EAnimation.IdleLeft, 4, 50, 37, 0, 0, Vector2.Zero, 4,
                                    () => Console.WriteLine("IdleLeft start"), () => Console.WriteLine("IdleLeft end"));
            adventurer.AddAnimation(EAnimation.IdleUp, 4, 50, 37, 0, 0, Vector2.Zero, 4,
                                    () => Console.WriteLine("IdleUp start"), () => Console.WriteLine("IdleUp end"));
            adventurer.AddAnimation(EAnimation.IdleRight, 4, 50, 37, 0, 0, Vector2.Zero, 4,
                                    () => Console.WriteLine("IdleRight start"), () => Console.WriteLine("IdleRight end"));
            adventurer.AddAnimation(EAnimation.IdleDown, 4, 50, 37, 0, 0, Vector2.Zero, 4,
                                    () => Console.WriteLine("IdleDown start"), () => Console.WriteLine("IdleDown end"));

            adventurer.AddAnimation(EAnimation.Left, 5, 50, 37, 37, 1, Vector2.Zero, 5);
            adventurer.AddAnimation(EAnimation.Up, 5, 50, 37, 37, 1, Vector2.Zero, 5);
            adventurer.AddAnimation(EAnimation.Right, 5, 50, 37, 37, 1, Vector2.Zero, 5);
            adventurer.AddAnimation(EAnimation.Down, 5, 50, 37, 37, 1, Vector2.Zero, 5);

            adventurer.AddAnimation(EAnimation.MeleeLeft, 7, 50, 37, 222, 0, Vector2.Zero, 7,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.IdleLeft));
            adventurer.AddAnimation(EAnimation.MeleeUp, 7, 50, 37, 222, 0, Vector2.Zero, 7,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.IdleUp));
            adventurer.AddAnimation(EAnimation.MeleeRight, 7, 50, 37, 222, 0, Vector2.Zero, 7,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.IdleRight));
            adventurer.AddAnimation(EAnimation.MeleeDown, 7, 50, 37, 222, 0, Vector2.Zero, 7,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.IdleDown));

            adventurer.AddAnimation(EAnimation.Melee1, 7, 50, 37, 222, 0, Vector2.Zero, 8,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.Idle));
            adventurer.AddAnimation(EAnimation.Melee2, 4, 50, 37, 259, 0, Vector2.Zero, 8,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.Idle));
            adventurer.AddAnimation(EAnimation.Melee3, 3, 50, 37, 259, 4, Vector2.Zero, 4,
                                    onAnimationEnd: () => adventurer.SetAnimation(EAnimation.Idle));

            return(adventurer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Contents.LoadAll(Content, graphics.GraphicsDevice);

            paddleOne = new Paddle(Contents.paddle, ESide.Left, screenWidth, screenHeight,
                                   KeyboardInput.Default());

            paddleTwo = new Paddle(Contents.paddle, ESide.Right, screenWidth, screenHeight,
                                   gamePadInput: GamePadInput.Default());

            ball = new Ball(Contents.ball,
                            new Vector2(screenWidth / 2, screenHeight / 2),
                            screenWidth, screenHeight);

            ball.Sprite.CollisionHandler = partner => { ball.Forward = !ball.Forward; };

            collisionManager = new CollisionManager(paddleOne.Sprite,
                                                    paddleTwo.Sprite, ball.Sprite);
        }