Esempio n. 1
0
        public void Update(GameTime gameTime, SpriteBatch spriteBatch)
        {
            time += gameTime.ElapsedGameTime;
            Camera.CameraInput();
            WorldObjects.Update(gameTime);
            GenerateWorms();

            foreach (var worm in Worms)
            {
                worm.Update(gameTime, Camera.CameraPos);
                worm.WorldObjectCollision(WorldObjects.donkeyRec);
                if (RectangleCollision.PixelIntersect(worm.WormRectangle, worm.textureData, WorldObjects.donkeyRec, WorldObjects.textureData))
                {
                    Console.WriteLine("Touched");
                }
                //Tilemap Collision
                foreach (var tile in Map.CollisionList)
                {
                    //if (worm.BreakingAnimation.IsDead)
                    //    tile.TileActive = false;

                    if (tile.tileActive)
                    {
                        worm.Collision(spriteBatch, gameTime, tile.TileRectangle, tile);
                    }

                    //if (WeldingActive)
                    //{
                    //    tile.WeldTile();
                    //    WeldingActive = false;
                    //}
                }
                //Blocker Collision
                if (worm.state == Worm.wormState.Blocking)
                {
                    foreach (var Blocker in Worms)
                    {
                        if (Blocker.state == Worm.wormState.Walking)
                        {
                            Blocker.BlockerCollision(worm.WormRectangle, worm.DirectionRight);
                        }
                    }
                }

                //Bouncer Collision
                if (worm.state == Worm.wormState.Bouncing)
                {
                    foreach (var Bouncer in Worms)
                    {
                        if (Bouncer.state == Worm.wormState.Walking)
                        {
                            Bouncer.BouncerCollision(worm.WormRectangle, worm.DirectionRight);
                        }
                    }
                }
            }
        }