Ejemplo n.º 1
0
        public Rock(CowGameScreen cowGameScreen, World world, Vector2 position) :
            base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 160, 108), new StaticAnimatedSprites(cowGameScreen.GameTextures["rockMovement"], 1, 0))
        {
            world.AddStaticEntity(this);
            float x1 = (float)(DestRect.X + 22) / 100;
            float x2 = (float)(DestRect.X + DestRect.Width - 23) / 100;

            float y1 = (float)(DestRect.Y + DestRect.Height - 30) / 100;
            float y2 = (float)(DestRect.Y + DestRect.Height - 35) / 100;

            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y1), new Vector2(x2, y2));

            x2 = (float)(DestRect.X + DestRect.Width - 50) / 100;
            y2 = (float)(DestRect.Y + DestRect.Height - 20) / 100;

            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y1), new Vector2(x2, y2));

            x1 = x2;
            y1 = y2;
            x2 = (float)(DestRect.X + DestRect.Width - 22) / 100;
            y2 = (float)(DestRect.Y + DestRect.Height - 35) / 100;

            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y1), new Vector2(x2, y2));
            Body.CollidesWith        = Category.All;
            Body.CollisionCategories = Category.All;
        }
Ejemplo n.º 2
0
 protected Animal(CowGameScreen cowGameScreen, World world, Rectangle destRect, DynamicAnimatedSprites rightWalk,
                  DynamicAnimatedSprites leftWalk, DynamicAnimatedSprites upWalk, DynamicAnimatedSprites downWalk) : base(cowGameScreen, world)
 {
     DestRect  = destRect;
     RightWalk = rightWalk;
     LeftWalk  = leftWalk;
     UpWalk    = upWalk;
     DownWalk  = downWalk;
 }
Ejemplo n.º 3
0
        public BerryBush(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 130, 120), new StaticAnimatedSprites(cowGameScreen.GameTextures["berryBushMovement"], 1, 0))
        {
            float x1 = (float)(DestRect.X + 47) / 100;
            float y  = (float)(DestRect.Y + DestRect.Height - 17) / 100;

            float x2 = (float)(DestRect.Width + DestRect.X - 60) / 100;

            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y), new Vector2(x2, y));
            world.AddStaticEntity(this);
        }
Ejemplo n.º 4
0
 public override void Drop(World world, Vector2 position)
 {
     Body                     = BodyFactory.CreateCircle(world, (float)2 / 100, 1f, new Vector2(position.X, position.Y) / 100);
     Body.BodyType            = BodyType.Dynamic;
     Body.CollisionCategories = Category.All & ~Category.Cat10;
     Body.CollidesWith        = Category.All & ~Category.Cat10;
     Body.BodyTypeName        = "rope";
     CanInteract              = true;
     DestRect                 = new Rectangle((int)position.X, (int)position.Y, 32, 32);
     world.AddDynamicEntity(this);
     CurrentWorld = world;
 }
Ejemplo n.º 5
0
        public OrangeTree(CowGameScreen cowGameScreen, World world, Vector2 position) : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 155, 261), new StaticAnimatedSprites(cowGameScreen.GameTextures["orangeTreeMovement"], 1, 0))
        {
            world.AddStaticEntity(this);
            float width  = (float)14 / 100;
            float height = (float)1 / 100;
            float x      = (float)(DestRect.X + DestRect.Width - 80) / 100;
            float y      = (float)(DestRect.Y + DestRect.Height - 22) / 100;

            Body = BodyFactory.CreateRectangle(world, width, height, 0f, new Vector2(x, y));

            Body.BodyType            = BodyType.Static;
            Body.CollisionCategories = Category.All;
            Body.CollidesWith        = Category.All;
        }
Ejemplo n.º 6
0
        public override void Drop(World world, Vector2 position)
        {
            _origin.X = ItemMovement.SpriteWidth / 2;
            _origin.Y = ItemMovement.SpriteHeight / 2;

            Body = BodyFactory.CreateCircle(world, (float)1 / 100, 0.2f, position / 100);
            Body.BodyTypeName        = "apple";
            CanInteract              = true;
            Body.BodyType            = BodyType.Dynamic;
            Body.CollisionCategories = Category.All & ~Category.Cat10;
            Body.CollidesWith        = Category.All & ~Category.Cat10;
            DestRect = new Rectangle((int)position.X, (int)position.Y, 20, 20);
            world.AddDynamicEntity(this);
            CurrentWorld = world;
        }
Ejemplo n.º 7
0
        public Bush(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 84, 87), new StaticAnimatedSprites(cowGameScreen.GameTextures["bushMovement"], 1, 0))
        {
            CurrentWorld = world;
            CurrentWorld.AddStaticEntity(this);

            float x1 = (float)(DestRect.X + 30) / 100;
            float y  = (float)(DestRect.Y + DestRect.Height - 18) / 100;
            float x2 = x1 + (float)24 / 100;

            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y), new Vector2(x2, y));
            Body.BodyTypeName        = "bush";
            Body.BodyType            = BodyType.Static;
            Body.CollisionCategories = Category.All;
            Body.CollidesWith        = Category.All;
        }
Ejemplo n.º 8
0
        public GreenTree(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 155, 261), new StaticAnimatedSprites(cowGameScreen.GameTextures["greenTreeMovement"], 1, 0))
        {
            _world         = world;
            _cowGameScreen = cowGameScreen;
            float width  = (float)14 / 100;
            float height = (float)1 / 100;

            float x = (float)(DestRect.X + DestRect.Width - 80) / 100;
            float y = (float)(DestRect.Y + DestRect.Height - 22) / 100;

            Body              = BodyFactory.CreateRectangle(world, width, height, 0f, new Vector2(x, y));
            Body.BodyType     = BodyType.Static;
            Body.BodyTypeName = "tree";
            world.ContactManager.Contacted += TreeCollides;

            world.AddStaticEntity(this);
        }
Ejemplo n.º 9
0
        public void ChangeWorld(World world, Direction direction)
        {
            switch (direction)
            {
            case Direction.Right:
                Body = BodyFactory.CreateCircle(world, (float)2 / 100, 1f, new Vector2(0.25f, Body.Position.Y));
                break;

            case Direction.Left:
                Body = BodyFactory.CreateCircle(world, (float)2 / 100, 1f, new Vector2((float)(CowGameScreen.Graphics.PreferredBackBufferWidth - 25) / 100, Body.Position.Y));
                break;
            }

            Body.BodyTypeName        = "cutGrass";
            CurrentWorld             = world;
            Body.BodyType            = BodyType.Dynamic;
            Body.CollisionCategories = Category.All & ~Category.Cat10;
            Body.CollidesWith        = Category.All & ~Category.Cat10;
        }
Ejemplo n.º 10
0
        public void ChangeWorld(World world, Direction direction)
        {
            switch (direction)
            {
            case Direction.Right:
                Body = BodyFactory.CreateRectangle(world, 0.54f, 0.15f, 0, new Vector2(0, Body.Position.Y));
                break;

            case Direction.Left:
                Body = BodyFactory.CreateRectangle(world, 0.54f, 0.15f, 0, new Vector2((float)CowGameScreen.Graphics.PreferredBackBufferWidth / 100, Body.Position.Y));
                break;
            }

            Body.BodyTypeName        = "cow";
            Body.BodyType            = BodyType.Dynamic;
            Body.CollisionCategories = Category.All & ~Category.Cat10;
            Body.CollidesWith        = Category.All & ~Category.Cat10;
            CurrentWorld             = world;
        }
Ejemplo n.º 11
0
        public Grass(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 25, 51), new StaticAnimatedSprites(cowGameScreen.GameTextures["grassMovement"], 1, 0))
        {
            _currentAnim        = PlantMovement;
            _eatenGrassMovement = new StaticAnimatedSprites(cowGameScreen.GameTextures["eatenGrassMovement"], 1, 0);

            CurrentWorld = world;

            Body = BodyFactory.CreateRectangle(world, (float)DestRect.Width / 100, (float)DestRect.Height / 200, 0, new Vector2((float)(DestRect.X + DestRect.Width / 2) / 100, (float)(DestRect.Y + 30) / 100));

            Body.BodyTypeName        = "grass";
            Body.BodyType            = BodyType.Static;
            Body.CollisionCategories = Category.Cat10;
            Body.CollidesWith        = Category.Cat10;

            ReapaintTexture = TextureHelper.RepaintRectangle(TextureHelper.CopyTexture(PlantMovement.Animation, Graphics));
            CanInteract     = true;
            world.AddStaticEntity(this);
            _eatedTime = TimeSpan.Zero;
        }
Ejemplo n.º 12
0
        public Apple(CowGameScreen cowGameScreen, World world, GreenTree tree, Rectangle destRect) : base(cowGameScreen, new StaticAnimatedSprites(cowGameScreen.GameTextures["appleMovement"], 1, 0), cowGameScreen.GameTextures["appleIcon"])
        {
            _origin.X           = ItemMovement.SpriteWidth / 2;
            _origin.Y           = ItemMovement.SpriteHeight / 2;
            ItemId              = 0;
            StackCount          = 3;
            _eatenAppleMovement = cowGameScreen.GameTextures["eatenAppleMovement"];

            _tree                    = tree;
            Body                     = BodyFactory.CreateCircle(world, (float)1 / 100, 0.2f, new Vector2((float)destRect.X / 100, (float)destRect.Y / 100));
            DestRect                 = destRect;
            Body.BodyType            = BodyType.Dynamic;
            Body.BodyTypeName        = "apple";
            Body.CollisionCategories = Category.Cat10;
            Body.CollidesWith        = Category.Cat10;

            Satiety      = 10f;
            CurrentWorld = world;
            CurrentWorld.ContactManager.Contacted += AppleFloorContacted;
        }
Ejemplo n.º 13
0
        public Cow(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 54, 49),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowRightWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowLeftWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowUpWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowDownWalk"], 3, 16))
        {
            Inventory  = new Inventory.Inventory(cowGameScreen);
            CraftPanel = new CraftPanel(cowGameScreen);
            ListBars   = new List <StatusBar>
            {
                new HealthBar(cowGameScreen, this),
                new FoodBar(cowGameScreen, this),
                new SprintBar(cowGameScreen, this)
            };
            Delay        = 200f;
            HealthPoint  = 100;
            StarvePoint  = 100;
            CurrentWorld = world;
            Boost        = 1;
            SpeedX       = 1.5f;
            SpeedY       = 1f;
            CurrentWorld = world;

            _interactableList = new List <Entity>();
            _attackList       = new List <Entity>();

            _previousFocusInteractables = new HashSet <Entity>();
            _previousFocusAttackables   = new HashSet <Entity>();

            Body                     = BodyFactory.CreateRectangle(world, 0.54f, 0.15f, 0, new Vector2((float)DestRect.X / 100, (float)DestRect.Y / 100));
            Body.BodyType            = BodyType.Dynamic;
            Body.CollisionCategories = Category.All & ~Category.Cat10;
            Body.CollidesWith        = Category.All & ~Category.Cat10;

            CurrentAnim       = LeftWalk;
            Body.BodyTypeName = "cow";

            CowGameScreen.WordlsList.ForEach(worldInList => worldInList.ContactManager.Nearby += NearbyCow);
        }
Ejemplo n.º 14
0
 public Chicken(CowGameScreen cowGameScreen, World world, Vector2 position)
     : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 56, 46),
     new DynamicAnimatedSprites(cowGameScreen.GameTextures["whiteChickenRightWalk"], 3, 0),
     new DynamicAnimatedSprites(cowGameScreen.GameTextures["whiteChickenLeftWalk"], 3, 0),
     new DynamicAnimatedSprites(cowGameScreen.GameTextures["whiteChickenUpWalk"], 3, 0),
     new DynamicAnimatedSprites(cowGameScreen.GameTextures["whiteChickenDownWalk"], 3, 0))
 {
     Body = BodyFactory.CreateRectangle(world, 0.22f, 0.05f, 0, position / 100);
     Body.CollisionCategories = Category.All;
     Body.CollidesWith = Category.All;
     Body.BodyType = BodyType.Dynamic;
     Body.BodyTypeName = "chicken";
     Delay = 400f;
     SpeedX = 0.7f;
     SpeedY = 0.6f;
     HealthPoint = 20;
     Rnd = new Random(2);
     CurrentAnim = RightWalk;
     CurrentWorld = world;
     WayList = new List<Vector2> { new Vector2(100, 500), new Vector2(800, 500) };
     world.AddDynamicEntity(this);
 }
Ejemplo n.º 15
0
        public Cat(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 56, 46),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["catRightWalk"], 3, 0),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["catLeftWalk"], 3, 0),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["catUpWalk"], 3, 0),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["catDownWalk"], 3, 0))
        {
            Rnd          = new Random(100);
            CurrentWorld = world;
            CurrentAnim  = RightWalk;

            Body = BodyFactory.CreateRectangle(CurrentWorld, 0.28f, 0.05f, 0, position / 100);
            Body.CollisionCategories = Category.All;
            Body.CollidesWith        = Category.All;
            Body.BodyType            = BodyType.Dynamic;
            Body.BodyTypeName        = "cat";
            Delay  = 500f;
            SpeedX = 0.8f;
            SpeedY = 0.7f;
            CurrentWorld.AddDynamicEntity(this);
            WayList = new List <Vector2> {
                new Vector2(100, 100), new Vector2(800, 100)
            };
        }
Ejemplo n.º 16
0
 public abstract void Drop(World world, Vector2 position);
Ejemplo n.º 17
0
 protected Entity(CowGameScreen cowGameScreen, World world)
 {
     CowGameScreen = cowGameScreen;
     CurrentWorld  = world;
 }
Ejemplo n.º 18
0
 protected Decoration(CowGameScreen cowGameScreen, World world, Rectangle destRect, StaticAnimatedSprites decorationMovement) : base(cowGameScreen, world)
 {
     this.DestRect           = destRect;
     this.DecorationMovement = decorationMovement;
     this.ObjectMovingType   = ObjectMovingType.Static;
 }
Ejemplo n.º 19
0
 public TreeGenerator(World world, GraphicsDeviceManager graphics, AnimatedSprites textureMovement,
                      int objectsMaxCounter) : base(world, graphics, textureMovement, objectsMaxCounter)
 {
     _obectsMaxCounter = objectsMaxCounter;
 }