コード例 #1
0
ファイル: GreenTree.cs プロジェクト: Andrey1337/XNA-CowFarm
        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);
        }
コード例 #2
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;
        }
コード例 #3
0
ファイル: Grass.cs プロジェクト: Andrey1337/XNA-CowFarm
        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;
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: Chicken.cs プロジェクト: Andrey1337/XNA-CowFarm
 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);
 }
コード例 #6
0
        public BoulderRock(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 140, 115), new StaticAnimatedSprites(cowGameScreen.GameTextures["boulderRockMovement"], 1, 0))
        {
            float x1 = (float)(DestRect.X + 20) / 100;
            float x2 = (float)(DestRect.X + DestRect.Width - 15) / 100;

            float y1 = (float)(DestRect.Y + DestRect.Height - 40) / 100;
            float y2 = (float)(DestRect.Y + DestRect.Height - 45) / 100;

            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y1), new Vector2(x2, y2));
            x1   = (float)(DestRect.X + 19) / 100;
            x2   = (float)(DestRect.X + 60) / 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 - 13) / 100;
            y2   = (float)(DestRect.Y + DestRect.Height - 45) / 100;
            Body = BodyFactory.CreateEdge(world, new Vector2(x1, y1), new Vector2(x2, y2));
            world.AddStaticEntity(this);
        }
コード例 #7
0
ファイル: Inventory.cs プロジェクト: Andrey1337/XNA-CowFarm
        public Inventory(CowGameScreen cowGameScreen)
        {
            _cowGameScreen = cowGameScreen;
            _typesIds      = ItemsTypesHelper.GetItemsTypes();
            _indexOnFocus  = 0;
            StartPosition  = new Vector2(330, 827);
            EndPosition    = new Vector2(StartPosition.X + _cowGameScreen.GameTextures["inventoryPanel"].Width, StartPosition.Y);

            _containersOnFocus     = new HashSet <Container>();
            _prevContainersOnFocus = new HashSet <Container>();

            var pos = new Vector2(StartPosition.X + 25, StartPosition.Y + 9);

            _containers = new StaticConainer[9];
            for (var i = 0; i < _containers.Length; i++)
            {
                var rect = new Rectangle((int)pos.X, (int)pos.Y, 42, 42);
                _containers[i] = new StaticConainer(rect, cowGameScreen.GameTextures["cleanTexture"]);
                pos.X         += 13 + rect.Width;
            }

            SwapContainer = new SwapContainer(Rectangle.Empty);
        }
コード例 #8
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)
            };
        }
コード例 #9
0
 public ChickenLeg(CowGameScreen cowGameScreen, AnimatedSprites itemMovement, Texture2D iconTexture) : base(cowGameScreen, itemMovement, iconTexture)
 {
     ItemId     = 5;
     Satiety    = 20f;
     StackCount = 6;
 }
コード例 #10
0
ファイル: StatusBar.cs プロジェクト: Andrey1337/XNA-CowFarm
 protected StatusBar(CowGameScreen cowGameScreen, Cow cow)
 {
     _cowGameScreen = cowGameScreen;
     _cow           = cow;
 }
コード例 #11
0
 protected Button(CowGameScreen cowGameScreen)
 {
     CowGameScreen = cowGameScreen;
 }
コード例 #12
0
ファイル: Plant.cs プロジェクト: Andrey1337/XNA-CowFarm
 protected Plant(CowGameScreen cowGameScreen, World world, Rectangle destRect, StaticAnimatedSprites plantMovement) : base(cowGameScreen, world)
 {
     Graphics      = cowGameScreen.Graphics;
     DestRect      = destRect;
     PlantMovement = plantMovement;
 }
コード例 #13
0
ファイル: Entity.cs プロジェクト: Andrey1337/XNA-CowFarm
 protected Entity(CowGameScreen cowGameScreen, World world)
 {
     CowGameScreen = cowGameScreen;
     CurrentWorld  = world;
 }
コード例 #14
0
 public WorkBench(CowGameScreen cowGameScreen) : base(cowGameScreen)
 {
 }
コード例 #15
0
 public Rope(CowGameScreen cowGameScreen)
     : base(cowGameScreen, new StaticAnimatedSprites(cowGameScreen.GameTextures["ropeMovement"], 1, 0), cowGameScreen.GameTextures["ropeIcon"])
 {
     ItemId     = 3;
     StackCount = 3;
 }
コード例 #16
0
 public CutGrass(CowGameScreen cowGameScreen) : base(cowGameScreen, new StaticAnimatedSprites(cowGameScreen.GameTextures["cutGrassMovement"], 1, 0), cowGameScreen.GameTextures["cutGrassIcon"])
 {
     ItemId     = 2;
     StackCount = 9;
     Satiety    = 5f;
 }
コード例 #17
0
ファイル: AlertWindow.cs プロジェクト: Andrey1337/XNA-CowFarm
 protected AlertWindow(CowGameScreen cowGameScreen)
 {
     CowGameScreen = cowGameScreen;
     Buttons       = new List <Button>();
 }
コード例 #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;
 }
コード例 #19
0
 public MainMenuButton(CowGameScreen cowGameScreen, Vector2 position) : base(cowGameScreen)
 {
     Position      = new Rectangle((int)position.X, (int)position.Y, 205, 35);
     ButtonTexture = CowGameScreen.GameTextures["mainMenuButton"];
 }
コード例 #20
0
ファイル: Log.cs プロジェクト: Andrey1337/XNA-CowFarm
 public Log(CowGameScreen cowGameScreen) : base(cowGameScreen, new StaticAnimatedSprites(cowGameScreen.GameTextures["logMovement"], 1, 0), cowGameScreen.GameTextures["logIcon"])
 {
     ItemId     = 4;
     StackCount = 6;
 }
コード例 #21
0
 public SprintBar(CowGameScreen cowGameScreen, Cow cow) : base(cowGameScreen, cow)
 {
     _drawRect    = new Rectangle((int)cow.Inventory.EndPosition.X, (int)cow.Inventory.EndPosition.Y - 19, 18, 18);
     _drawRect.X -= _drawRect.Width + 1;
 }
コード例 #22
0
ファイル: FoodBar.cs プロジェクト: Andrey1337/XNA-CowFarm
 public FoodBar(CowGameScreen cowGameScreen, Cow cow) : base(cowGameScreen, cow)
 {
     _drawRect = new Rectangle((int)cow.Inventory.EndPosition.X - 19, (int)cow.Inventory.EndPosition.Y - 19, 18, 18);
 }
コード例 #23
0
 public Twigs(CowGameScreen cowGameScreen, World world, Vector2 position) : base(world, new Rectangle((int)position.X, (int)position.Y, 30, 23), new AnimatedSprites(cowGameScreen.GameTextures["rocksMovement"], 1, 0), cowGameScreen.GameTextures["rocksIcon"])
 {
 }
コード例 #24
0
ファイル: Rocks.cs プロジェクト: Andrey1337/XNA-CowFarm
 public Rocks(CowGameScreen cowGameScreen) : base(cowGameScreen, new StaticAnimatedSprites(cowGameScreen.GameTextures["rocksMovement"], 1, 0), cowGameScreen.GameTextures["rocksIcon"])
 {
     ItemId     = 1;
     StackCount = 2;
 }
コード例 #25
0
ファイル: Item.cs プロジェクト: Andrey1337/XNA-CowFarm
 protected Item(CowGameScreen cowGameScreen, AnimatedSprites itemMovement, Texture2D iconTexture) : base(cowGameScreen, null)
 {
     IconTexture      = iconTexture;
     ItemMovement     = itemMovement;
     ObjectMovingType = ObjectMovingType.Static;
 }
コード例 #26
0
ファイル: HealthBar.cs プロジェクト: Andrey1337/XNA-CowFarm
 public HealthBar(CowGameScreen cowGameScreen, Cow cow) : base(cowGameScreen, cow)
 {
     _drawRect = new Rectangle((int)cow.Inventory.StartPosition.X, (int)cow.Inventory.StartPosition.Y - 19, 18, 18);
 }