Example #1
0
        public AlphaBunny(uint UUID, ContentManager content) : base(UUID)
        {
            this.AddComponent(new CmpCollider(this, content.Load <Texture2D>("etc/pixel"))
            {
                GetsPushed           = true,
                GetsPushedBySameType = true,
                Type       = "alphabunny",
                TypeFilter = new string[] { "betabunny" }
            });

            this.AddComponent(new CmpStats(this, 10, 0, true));

            var sprites = new Rectangle[][]
            {
                new Rectangle[] { new Rectangle(0, 0, 32, 32), new Rectangle(32, 0, 32, 32) },
                new Rectangle[] { new Rectangle(0, 32, 32, 32), new Rectangle(32, 32, 32, 32) },
                new Rectangle[] { new Rectangle(0, 64, 32, 32), new Rectangle(32, 64, 32, 32) },
                new Rectangle[] { new Rectangle(0, 96, 32, 32), new Rectangle(32, 96, 32, 32) },
            };

            var anim = new CmpAnim(this, content.Load <Texture2D>("spritesheets/bunny"), sprites)
            {
                renderColor = Color.Pink
            };

            AddComponent(anim);
        }
Example #2
0
        public BetaBunny(uint UUID, ContentManager content) : base(UUID)
        {
            this.AddComponent(new CmpCollider(this, content.Load <Texture2D>("etc/pixel"))
            {
                GetsPushed           = true,
                GetsPushedBySameType = false,
                Type = "betabunny"
            });

            this.AddComponent(new CmpStats(this, 10, 3, true));

            var sprites = new Rectangle[][]
            {
                new Rectangle[] { new Rectangle(0, 0, 32, 32), new Rectangle(32, 0, 32, 32) },
                new Rectangle[] { new Rectangle(0, 32, 32, 32), new Rectangle(32, 32, 32, 32) },
                new Rectangle[] { new Rectangle(0, 64, 32, 32), new Rectangle(32, 64, 32, 32) },
                new Rectangle[] { new Rectangle(0, 96, 32, 32), new Rectangle(32, 96, 32, 32) },
            };

            this.anim        = new CmpAnim(this, content.Load <Texture2D>("spritesheets/bunny"), sprites);
            anim.renderColor = Color.Gray;

            this.ai = new CmpAI_Follower(this, Vector2.One * 2)
            {
                distance_whenToFollow = 30f
            };

            AddComponent(anim);
            AddComponent(ai);
        }
Example #3
0
        public Car(uint UUID, ContentManager content) : base(UUID)
        {
            var collider = new CmpCollider(this, content.Load <Texture2D>("etc/pixel"))
            {
                GetsPushed           = true,
                GetsPushedBySameType = true,
                Type       = "car",
                TypeFilter = new string[] { "betabunny" }
            };

            // This so that the collider rotates according to front wheels of the car
            collider.offset.Y      = 8;
            collider.offset.Height = -16;

            this.AddComponent(collider);

            var sprites = new Rectangle[][]
            {
                new Rectangle[] { new Rectangle(0, 0, 24, 43) },
            };

            var anim = new CmpAnim(this, content.Load <Texture2D>("spritesheets/car"),
                                   sprites // The sprite(s) we created above
                                   )
            {
                renderColor = Color.White
            };

            AddComponent(anim);
        }
Example #4
0
 /// <summary>
 /// Some magic that only works for bunnies
 /// </summary>
 static public void SetAnimBasedOfDirection(CmpAnim anim, Vector2 direction)
 {
     // We check which absolute value that is bigger to determine which axis to prioritize
     if (Math.Abs(direction.Y) < Math.Abs(direction.X))
     {
         if (direction.X > 0) // Right
         {
             anim.currentSpriteCollection = 1;
         }
         else if (direction.X < 0) // Left
         {
             anim.currentSpriteCollection = 3;
         }
     }
     else
     {
         if (direction.Y < 0) // Up
         {
             anim.currentSpriteCollection = 0;
         }
         else if (direction.Y > 0) // Down
         {
             anim.currentSpriteCollection = 2;
         }
     }
     // There is probably a smarter way to do this...
     //else if (direction.X == 1 && direction.Y == -1)
     //{
     //    anim.currentSpriteCollection = 0;
     //    anim.rotation = 0.45f;
     //}
     //else if (direction.X == -1 && direction.Y == -1)
     //{
     //    anim.currentSpriteCollection = 0;
     //    anim.rotation = -0.45f;
     //}
     //else if (direction.X == 1 && direction.Y == 1)
     //{
     //    anim.currentSpriteCollection = 1;
     //    anim.rotation = 0.90f;
     //}
     //else if (direction.X == -1 && direction.Y == 1)
     //{
     //    anim.currentSpriteCollection = 3;
     //    anim.rotation = -0.90f;
     //}
     //else anim.rotation = 0f;
 }