Beispiel #1
0
        public Renderer()
        {
            // 2D
            _viewport = new xTile.Dimensions.Rectangle(new Size(Defs.ScreenWidth, Defs.ScreenHeight));

            // 3D
            _CameraPosition = new Vector3(0f, 0f, 100f);
        }
Beispiel #2
0
        public TileSelection(TileSelection tileSelection)
        {
            m_tileSelections = new Dictionary<Location, TileSelectionBorder>();
            foreach (KeyValuePair<Location, TileSelectionBorder> pair in tileSelection.m_tileSelections)
                m_tileSelections[pair.Key] = pair.Value;

            m_bounds = tileSelection.m_bounds;
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            mapDisplayDevice = new XnaDisplayDevice(this.Content, this.GraphicsDevice);
            map.LoadTileSheets(mapDisplayDevice);
            viewport = new xTile.Dimensions.Rectangle(new Size(800, 480));
        }
 /// <summary>
 /// Constructor. 
 /// </summary>
 /// <param name="viewport">The graphics viewport</param>
 public Camera(Viewport viewport)
 {
     this._viewport = viewport;
     this.xTILE_viewport = new xTile.Dimensions.Rectangle(
                         0,
                         0,
                         viewport.Width,
                         viewport.Height);
 }
Beispiel #5
0
 /// <summary>
 /// Constructor. 
 /// </summary>
 /// <param name="viewport">The graphics viewport</param>
 public Camera(Viewport viewport)
 {
     _zoom = 1;
     _stopTime = 0.0f;
     _currentSpeed = 200.0f;
     _maxSpeed = 800.0f;
     _currentDeceleration = _DECELERATION;
     _center = new Vector2(3400, 2300);
     this._viewport = viewport;
     this.xTILE_viewport = new xTile.Dimensions.Rectangle(
                         0,
                         0,
                         viewport.Width,
                         viewport.Height);
 }
        public override void Do()
        {
            Rectangle selectionContext
                = new Rectangle(Location.Origin, m_layer.LayerSize);

            switch (m_changeSelectionType)
            {
                case ChangeSelectionType.SelectAll:
                    m_currentTileSelection.SelectAll(selectionContext);
                    break;
                case ChangeSelectionType.Clear:
                    m_currentTileSelection.Clear();
                    break;
                case ChangeSelectionType.Invert:
                    m_currentTileSelection.Invert(selectionContext);
                    break;
            }
        }
Beispiel #7
0
 public override void MovePosition(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation)
 {
     if (Game1.eventUp && Game1.CurrentEvent != null && Game1.CurrentEvent.isFestival)
     {
         base.MovePosition(time, viewport, currentLocation);
         return;
     }
     if (!Game1.IsMasterGame)
     {
         moveLeft  = (IsRemoteMoving() && FacingDirection == 3);
         moveRight = (IsRemoteMoving() && FacingDirection == 1);
         moveUp    = (IsRemoteMoving() && FacingDirection == 0);
         moveDown  = (IsRemoteMoving() && FacingDirection == 2);
     }
     if (moveUp)
     {
         if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(0), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
         {
             if (Game1.IsMasterGame)
             {
                 position.Y -= base.speed + base.addedSpeed;
             }
             if (base.Age == 3)
             {
                 Sprite.AnimateUp(time);
                 FacingDirection = 0;
             }
         }
         else if (!currentLocation.isTilePassable(nextPosition(0), viewport) || !base.willDestroyObjectsUnderfoot)
         {
             moveUp = false;
             Sprite.currentFrame     = ((Sprite.CurrentAnimation != null) ? Sprite.CurrentAnimation[0].frame : Sprite.currentFrame);
             Sprite.CurrentAnimation = null;
             if (Game1.IsMasterGame && base.Age == 2 && Game1.timeOfDay < 1800)
             {
                 setCrawlerInNewDirection();
             }
         }
     }
     else if (moveRight)
     {
         if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(1), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
         {
             if (Game1.IsMasterGame)
             {
                 position.X += base.speed + base.addedSpeed;
             }
             if (base.Age == 3)
             {
                 Sprite.AnimateRight(time);
                 FacingDirection = 1;
             }
         }
         else if (!currentLocation.isTilePassable(nextPosition(1), viewport) || !base.willDestroyObjectsUnderfoot)
         {
             moveRight               = false;
             Sprite.currentFrame     = ((Sprite.CurrentAnimation != null) ? Sprite.CurrentAnimation[0].frame : Sprite.currentFrame);
             Sprite.CurrentAnimation = null;
             if (Game1.IsMasterGame && base.Age == 2 && Game1.timeOfDay < 1800)
             {
                 setCrawlerInNewDirection();
             }
         }
     }
     else if (moveDown)
     {
         if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(2), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
         {
             if (Game1.IsMasterGame)
             {
                 position.Y += base.speed + base.addedSpeed;
             }
             if (base.Age == 3)
             {
                 Sprite.AnimateDown(time);
                 FacingDirection = 2;
             }
         }
         else if (!currentLocation.isTilePassable(nextPosition(2), viewport) || !base.willDestroyObjectsUnderfoot)
         {
             moveDown                = false;
             Sprite.currentFrame     = ((Sprite.CurrentAnimation != null) ? Sprite.CurrentAnimation[0].frame : Sprite.currentFrame);
             Sprite.CurrentAnimation = null;
             if (Game1.IsMasterGame && base.Age == 2 && Game1.timeOfDay < 1800)
             {
                 setCrawlerInNewDirection();
             }
         }
     }
     else if (moveLeft)
     {
         if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(3), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
         {
             if (Game1.IsMasterGame)
             {
                 position.X -= base.speed + base.addedSpeed;
             }
             if (base.Age == 3)
             {
                 Sprite.AnimateLeft(time);
                 FacingDirection = 3;
             }
         }
         else if (!currentLocation.isTilePassable(nextPosition(3), viewport) || !base.willDestroyObjectsUnderfoot)
         {
             moveLeft                = false;
             Sprite.currentFrame     = ((Sprite.CurrentAnimation != null) ? Sprite.CurrentAnimation[0].frame : Sprite.currentFrame);
             Sprite.CurrentAnimation = null;
             if (Game1.IsMasterGame && base.Age == 2 && Game1.timeOfDay < 1800)
             {
                 setCrawlerInNewDirection();
             }
         }
     }
     if (blockedInterval >= 3000 && (float)blockedInterval <= 3750f && !Game1.eventUp)
     {
         doEmote((Game1.random.NextDouble() < 0.5) ? 8 : 40);
         blockedInterval = 3750;
     }
     else if (blockedInterval >= 5000)
     {
         base.speed      = 1;
         isCharging      = true;
         blockedInterval = 0;
     }
 }
Beispiel #8
0
 public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
 {
     if (farmhouseRestored.Value && tileLocation.X >= shippingBinPosition.X && tileLocation.X <= shippingBinPosition.X + 1 && tileLocation.Y >= shippingBinPosition.Y - 1 && tileLocation.Y <= shippingBinPosition.Y)
     {
         ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, reverseGrab: true, showReceivingMenu: false, Utility.highlightShippableObjects, Game1.getFarm().shipItem, "", null, snapToBottom: true, canBeExitedWithKey: true, playRightClickSound: false, allowRightClick: true, showOrganizeButton: false, 0, null, -1, this);
         itemGrabMenu.initializeUpperRightCloseButton();
         itemGrabMenu.setBackgroundTransparency(b: false);
         itemGrabMenu.setDestroyItemOnClick(b: true);
         itemGrabMenu.initializeShippingBin();
         Game1.activeClickableMenu = itemGrabMenu;
         playSound("shwip");
         if (Game1.player.FacingDirection == 1)
         {
             Game1.player.Halt();
         }
         Game1.player.showCarrying();
         return(true);
     }
     if (getTileIndexAt(tileLocation.X, tileLocation.Y, "Buildings") != -1)
     {
         int tileIndexAt = getTileIndexAt(tileLocation.X, tileLocation.Y, "Buildings");
         if (tileIndexAt == 1470)
         {
             int actual_found_walnuts_count = Math.Max(0, Game1.netWorldState.Value.GoldenWalnutsFound.Value - 1);
             if (actual_found_walnuts_count < 100)
             {
                 Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:qiNutDoor", actual_found_walnuts_count));
             }
             else
             {
                 Game1.playSound("doorClose");
                 Game1.warpFarmer("QiNutRoom", 7, 8, 0);
             }
             return(true);
         }
     }
     if (getCharacterFromName("Birdie") != null && !getCharacterFromName("Birdie").IsInvisible&& (getCharacterFromName("Birdie").getTileLocation().Equals(new Vector2(tileLocation.X, tileLocation.Y)) || getCharacterFromName("Birdie").getTileLocation().Equals(new Vector2(tileLocation.X - 1, tileLocation.Y))))
     {
         if (!who.mailReceived.Contains("birdieQuestBegun"))
         {
             who.Halt();
             Game1.globalFadeToBlack(delegate
             {
                 startEvent(new Event(Game1.content.LoadString("Strings\\Locations:IslandSecret_Event_BirdieIntro"), -888999));
             });
             who.mailReceived.Add("birdieQuestBegun");
             return(true);
         }
         if (who.hasQuest(130) && !who.mailReceived.Contains("birdieQuestFinished") && who.ActiveObject != null && Utility.IsNormalObjectAtParentSheetIndex(who.ActiveObject, 870))
         {
             who.Halt();
             Game1.globalFadeToBlack(delegate
             {
                 who.reduceActiveItemByOne();
                 startEvent(new Event(Game1.content.LoadString("Strings\\Locations:IslandSecret_Event_BirdieFinished"), -666777));
             });
             who.mailReceived.Add("birdieQuestFinished");
             return(true);
         }
         if (who.mailReceived.Contains("birdieQuestFinished"))
         {
             if (who.ActiveObject != null)
             {
                 Game1.drawDialogue(getCharacterFromName("Birdie"), Utility.loadStringDataShort("ExtraDialogue", "Birdie_NoGift"));
             }
             else
             {
                 string possible = null;
                 try
                 {
                     possible = Game1.content.LoadStringReturnNullIfNotFound("Data\\ExtraDialogue:Birdie" + Game1.dayOfMonth);
                 }
                 catch (Exception)
                 {
                 }
                 if (possible != null && possible.Length > 0)
                 {
                     Game1.drawDialogue(getCharacterFromName("Birdie"), possible);
                 }
                 else
                 {
                     Game1.drawDialogue(getCharacterFromName("Birdie"), Utility.loadStringDataShort("ExtraDialogue", "Birdie" + Game1.dayOfMonth % 7));
                 }
             }
         }
     }
     return(base.checkAction(tileLocation, viewport, who));
 }
Beispiel #9
0
        public void Initialize(Game game, ContentManager content, ref GraphicsDeviceManager  graphics)
        {
            uno = new Unicorn(game, content);
            // Create a world for physics to act
            world = new World(new Vector2(0f, 9.8f));

            this.graphics = graphics;

            this.uno = uno;
            this.content = content;
            level = 0;

            mapDisplayDevice = new XnaDisplayDevice(content, graphics.GraphicsDevice);

            viewport = new xTile.Dimensions.Rectangle(new Size(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));

            nextLevelCallDelay = false;
        }
Beispiel #10
0
        public Image GenerateImage(Layer layer)
        {
            Bitmap bitmap = new Bitmap(m_map.DisplayWidth, m_map.DisplayHeight);
            Graphics graphics = Graphics.FromImage(bitmap);

            Graphics oldGraphics = m_graphics;
            m_graphics = graphics;

            xTile.Dimensions.Rectangle viewport = new xTile.Dimensions.Rectangle(layer.DisplaySize);
            layer.Draw(this, viewport, xTile.Dimensions.Location.Origin, false);

            m_graphics = oldGraphics;

            return bitmap;
        }
Beispiel #11
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera = new xTile.Dimensions.Rectangle(new Size(charScreenX, 309));

            //System.IO.Stream stream = TitleContainer.OpenStream("Content\\Maps\\Map02.tbin");

            //map = FormatManager.Instance.BinaryFormat.Load(stream);
            //FixTileLocationsBug(map);
            map = Content.Load<Map>("Maps\\Map02");

            //LoadMap("Map01");
            /*map = Content.Load<Map>("Maps\\Map01");
            map.Layers[3].AfterDraw += OnBeforeLayerDraw;
            map.Layers[4].Visible = false;*/

            _character = new Sprite(contentManager.Load<Texture2D>("golfball"));
            _character.X = charScreenX;
            _character.Y = 128;

            physics = new Physics();
            physics.addCharacterSprite(_character);
            TileArray groundTiles = map.GetLayer("HitGround").Tiles;
            TileArray waterTiles = map.GetLayer("HitWater").Tiles;

            for (int y = 0; y < 48; y++)
            {
                for (int x = 0; x < 800; x++)
                {

                    Tile tgroup = groundTiles[x, y];
                    Tile twater = waterTiles[x, y];

                    if (tgroup != null)
                    {
                        physics.addRect(x * 16, y * 16, 16, 16, Physics.TYPE_GROUND);
                    }

                    if (twater != null)
                    {
                        physics.addRect(x * 16, y * 16, 16, 16, Physics.TYPE_WATER);
                    }

                }
            }

            physics.flickCharacter(139, 309);

            //_player = new Character(Content.Load<Texture2D>("Sprite_Sheet"), 1, 32, 48, this.map);

            //_player.Position = new Point(139, 309);//new Vector2(138, 308);

            base.LoadContent();
        }
Beispiel #12
0
        protected override void Initialize()
        {
            base.Initialize();

            RandomSeed = new Random();

            //Sony's localization decisions be damned...
            InputManager.JapaneseButtonSwap = true;

            // What exactly does distinationRect represent?
            /*
             * The destinationRect defines the area of the screen
             * that the rendertarget gets rendered to.
             * In the Draw() loop, the rendertarget is drawn with destinationRect as its
             * rectangle. This means that the "game window" can be any size within the
             * "program window."
             *
             * The below code centers it and sets it to fill the height of the screen
             * while scaling width to match the intended aspect ratio.
            */
            ScaleFactorX = (((int)ScreenResolution.Y / (int)AspectRatio.Y) * (int)AspectRatio.X);
            destinationRect.X = ((int)ScreenResolution.X / 2);
            destinationRect.Y = ((int)ScreenResolution.Y / 2);
            destinationRect.Height = (int)ScreenResolution.Y;
            destinationRect.Width = (ScaleFactorX);

            Camera.X = 0;
            Camera.Y = 0;
            mapDisplayDevice = new XnaDisplayDevice(
                this.Content, this.GraphicsDevice);

            viewport = new xTile.Dimensions.Rectangle(new Size ( (int)TempResolution.X, (int) TempResolution.Y) );
            ///For one-axis map wrapping
            viewportNorth = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) );
            viewportSouth = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) );
            viewportEast = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) );
            viewportWest = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) );

            renderTarget = new RenderTarget2D(GraphicsDevice, (int)TempResolution.X, (int)TempResolution.Y, false, SurfaceFormat.Color, 0);

            ///Initialize Objects
            //Characters
            mapCharacter = new MapCharacter[255];
            for (int i = 0; i < 255; i++)
                mapCharacter[i] = new MapCharacter(Content.Load<Texture2D>("Texture//Character//00"), 9, 8, 6, RandomSeed.Next());
            mapCharacter[0].Visible = true;
            mapCharacter[1].Visible = true;
            mapCharacter[1].IsWandering = true;

            for (int i = 2; i < 14; i++)
            {
                mapCharacter[i].Visible = true;
                mapCharacter[i].IsWandering = true;
            }

            //Maps
            GameMap.LoadTileSheets(mapDisplayDevice);

            GlobalVariables.TileMapWidth = (GameMap.Layers[0].LayerWidth);
            GlobalVariables.TileMapHeight = (GameMap.Layers[0].LayerHeight);
            GlobalVariables.TileMapResolutionX = (GlobalVariables.TileMapWidth * GlobalVariables.TileSize);
            GlobalVariables.TileMapResolutionY = (GlobalVariables.TileMapHeight * GlobalVariables.TileSize);
        }
Beispiel #13
0
        /// <summary>
        /// Computes and returns a rectangle representing a tile's bounadaries
        /// given the map viewport and location in tile coordinates, taking into
        /// account parallax effects. The rectangle coordinates are computed
        /// relative to the viewport origin
        /// </summary>
        /// <param name="mapViewport">Map viewport in pixels</param>
        /// <param name="tileLocation">Location in tile coordinates</param>
        /// <returns>Rectangle representing the bounadries of the tile</returns>
        public Rectangle GetTileDisplayRectangle(Rectangle mapViewport, Location tileLocation)
        {
            Location layerViewportLocation = ConvertMapToLayerLocation(mapViewport.Location, mapViewport.Size);

            Location tileDisplayLocation = new Location(
                tileLocation.X * m_tileSize.Width, tileLocation.Y * m_tileSize.Height);

            Location tileDisplayOffset = tileDisplayLocation - layerViewportLocation;

            return new Rectangle(tileDisplayOffset, m_tileSize);
        }
Beispiel #14
0
        public virtual void MovePosition(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation)
        {
            if (this is FarmAnimal)
            {
                willDestroyObjectsUnderfoot = false;
            }
            bool should_destroy_underfoot_objects = willDestroyObjectsUnderfoot;

            if (controller != null && controller.nonDestructivePathing)
            {
                should_destroy_underfoot_objects = false;
            }
            if (xVelocity != 0f || yVelocity != 0f)
            {
                applyVelocity(currentLocation);
            }
            else if (moveUp)
            {
                if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(0), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
                {
                    position.Y -= speed + addedSpeed;
                    if (!ignoreMovementAnimation)
                    {
                        Sprite.AnimateUp(time, (speed - 2 + addedSpeed) * -25, Utility.isOnScreen(getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : "");
                        faceDirection(0);
                    }
                }
                else if (!currentLocation.isTilePassable(nextPosition(0), viewport) || !should_destroy_underfoot_objects)
                {
                    Halt();
                }
                else if (should_destroy_underfoot_objects)
                {
                    new Vector2(getStandingX() / 64, getStandingY() / 64 - 1);
                    if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(0), showDestroyedObject: true))
                    {
                        doEmote(12);
                        position.Y -= speed + addedSpeed;
                    }
                    else
                    {
                        blockedInterval += time.ElapsedGameTime.Milliseconds;
                    }
                }
            }
            else if (moveRight)
            {
                if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(1), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
                {
                    position.X += speed + addedSpeed;
                    if (!ignoreMovementAnimation)
                    {
                        Sprite.AnimateRight(time, (speed - 2 + addedSpeed) * -25, Utility.isOnScreen(getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : "");
                        faceDirection(1);
                    }
                }
                else if (!currentLocation.isTilePassable(nextPosition(1), viewport) || !should_destroy_underfoot_objects)
                {
                    Halt();
                }
                else if (should_destroy_underfoot_objects)
                {
                    new Vector2(getStandingX() / 64 + 1, getStandingY() / 64);
                    if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(1), showDestroyedObject: true))
                    {
                        doEmote(12);
                        position.X += speed + addedSpeed;
                    }
                    else
                    {
                        blockedInterval += time.ElapsedGameTime.Milliseconds;
                    }
                }
            }
            else if (moveDown)
            {
                if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(2), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
                {
                    position.Y += speed + addedSpeed;
                    if (!ignoreMovementAnimation)
                    {
                        Sprite.AnimateDown(time, (speed - 2 + addedSpeed) * -25, Utility.isOnScreen(getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : "");
                        faceDirection(2);
                    }
                }
                else if (!currentLocation.isTilePassable(nextPosition(2), viewport) || !should_destroy_underfoot_objects)
                {
                    Halt();
                }
                else if (should_destroy_underfoot_objects)
                {
                    new Vector2(getStandingX() / 64, getStandingY() / 64 + 1);
                    if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(2), showDestroyedObject: true))
                    {
                        doEmote(12);
                        position.Y += speed + addedSpeed;
                    }
                    else
                    {
                        blockedInterval += time.ElapsedGameTime.Milliseconds;
                    }
                }
            }
            else if (moveLeft)
            {
                if (currentLocation == null || !currentLocation.isCollidingPosition(nextPosition(3), viewport, isFarmer: false, 0, glider: false, this) || isCharging)
                {
                    position.X -= speed + addedSpeed;
                    if (!ignoreMovementAnimation)
                    {
                        Sprite.AnimateLeft(time, (speed - 2 + addedSpeed) * -25, Utility.isOnScreen(getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : "");
                        faceDirection(3);
                    }
                }
                else if (!currentLocation.isTilePassable(nextPosition(3), viewport) || !should_destroy_underfoot_objects)
                {
                    Halt();
                }
                else if (should_destroy_underfoot_objects)
                {
                    new Vector2(getStandingX() / 64 - 1, getStandingY() / 64);
                    if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(3), showDestroyedObject: true))
                    {
                        doEmote(12);
                        position.X -= speed + addedSpeed;
                    }
                    else
                    {
                        blockedInterval += time.ElapsedGameTime.Milliseconds;
                    }
                }
            }
            else
            {
                Sprite.animateOnce(time);
            }
            if (should_destroy_underfoot_objects && currentLocation != null && isMoving())
            {
                Point   standing = getStandingXY();
                Vector2 point    = new Vector2(standing.X / 64, standing.Y / 64);
                currentLocation.characterTrampleTile(point);
            }
            if (blockedInterval >= 3000 && (float)blockedInterval <= 3750f && !Game1.eventUp)
            {
                doEmote((Game1.random.NextDouble() < 0.5) ? 8 : 40);
                blockedInterval = 3750;
            }
            else if (blockedInterval >= 5000)
            {
                speed           = 4;
                isCharging      = true;
                blockedInterval = 0;
            }
        }
Beispiel #15
0
        public Vector2 getLocalPosition(xTile.Dimensions.Rectangle viewport)
        {
            Vector2 position = Position;

            return(new Vector2(position.X - (float)viewport.X, position.Y - (float)viewport.Y + (float)yJumpOffset) + drawOffset);
        }
Beispiel #16
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     if (_exitsBlocked && position.Intersects(turtle1Spot))
     {
         return(true);
     }
     if (!westernTurtleMoved && position.Intersects(turtle2Spot))
     {
         return(true);
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
Beispiel #17
0
        private static void checkAction_Postfix(GameLocation __instance, ref bool __result, Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            if (!Config.EnableMod || __result)
            {
                return;
            }

            SMonitor.Log($"Checking for seat");

            foreach (Object obj in __instance.objects.Values)
            {
                if (obj.TileLocation == new Vector2(tileLocation.X, tileLocation.Y) && Config.SeatTypes.Contains(obj.name))
                {
                    SMonitor.Log($"Got object seat");
                    MapSeat ms = new MapSeat();
                    ms.tilePosition.Value = new Vector2(tileLocation.X, tileLocation.Y);
                    ms.seatType.Value     = "stool expert sitting mod";
                    ms.size.Value         = new Vector2(1, 1);
                    __instance.mapSeats.Add(ms);
                    who.BeginSitting(ms);
                    __result = true;
                    break;
                }
            }
            if (__result)
            {
                return;
            }

            foreach (ResourceClump rc in __instance.resourceClumps)
            {
                if (rc.occupiesTile(tileLocation.X, tileLocation.Y - 1))
                {
                    SMonitor.Log($"Got clump seat");
                    MapSeat ms = new MapSeat();
                    ms.tilePosition.Value = new Vector2(tileLocation.X, tileLocation.Y);
                    ms.seatType.Value     = "clump";
                    switch (who.FacingDirection)
                    {
                    case 0:
                    case 2:
                        ms.direction.Value = 2;
                        break;

                    default:
                        if (rc.occupiesTile(tileLocation.X - 1, tileLocation.Y - 1))
                        {
                            ms.direction.Value = 1;
                        }
                        else
                        {
                            ms.direction.Value = 3;
                        }
                        break;
                    }
                    ms.size.Value = new Vector2(1, 1);
                    __instance.mapSeats.Add(ms);
                    who.BeginSitting(ms);
                    __result = true;
                    break;
                }
            }

            if (__result)
            {
                return;
            }

            if (Config.AllowMapSit && __instance.map.GetLayer("Buildings")?.PickTile(tileLocation * Game1.tileSize, Game1.viewport.Size) != null && __instance.map.GetLayer("Building")?.PickTile(new Location(tileLocation.X, tileLocation.Y + 1) * Game1.tileSize, Game1.viewport.Size) == null)
            {
                SMonitor.Log($"Got map seat");
                MapSeat ms = new MapSeat();
                ms.tilePosition.Value = new Vector2(tileLocation.X, tileLocation.Y);
                ms.size.Value         = new Vector2(1, 1);
                ms.seatType.Value     = "map";
                __instance.mapSeats.Add(ms);
                ms.direction.Value = 2;
                who.BeginSitting(ms);
                __result = true;
            }
        }
Beispiel #18
0
 /*********
 ** Private methods
 *********/
 /// <summary>The method to call before <see cref="Layer.Draw"/>.</summary>
 private static void Before_Draw(Layer __instance, IDisplayDevice displayDevice, xTile.Dimensions.Rectangle mapViewport, Location displayOffset, bool wrapAround, int pixelZoom)
 {
     if (__instance.Id == "Back" && xTileLayerPatcher.Rendering == 0 && Game1.currentLocation.Map.Properties.TryGetValue("RenderBehind", out PropertyValue renderBehind))
     {
         xTileLayerPatcher.Rendering++;
         try
         {
             string[] fields = renderBehind.ToString().Split(' ');
             string   locName = fields[0];
             int      offsetX = 0, offsetY = 0;
             if (fields.Length >= 3)
             {
                 offsetX = int.Parse(fields[1]);
                 offsetY = int.Parse(fields[2]);
             }
             float scale = 1f;
             if (fields.Length >= 4)
             {
                 scale = float.Parse(fields[3]);
             }
             xTileLayerPatcher.DoRendering(locName, offsetX, offsetY, scale);
         }
         catch (Exception e)
         {
             Log.Error("Exception while rendering: " + e);
         }
         xTileLayerPatcher.Rendering--;
     }
 }
Beispiel #19
0
 public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
 {
     if (this.map.GetLayer("Buildings").Tiles[tileLocation] != null)
     {
         PropertyValue propertyValue = "";
         this.map.GetLayer("Buildings").Tiles[tileLocation].Properties.TryGetValue("Action", out propertyValue);
         if (propertyValue != null)
         {
             string a = propertyValue.ToString();
             if (!(a == "JojaShop") && a == "JoinJoja")
             {
                 JojaMart.Morris.CurrentDialogue.Clear();
                 if (Game1.player.mailForTomorrow.Contains("JojaMember%&NL&%"))
                 {
                     JojaMart.Morris.setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Morris_ComeBackLater", new object[0]), false, false);
                     Game1.drawDialogue(JojaMart.Morris);
                 }
                 else if (!Game1.player.mailReceived.Contains("JojaMember"))
                 {
                     if (!Game1.player.mailReceived.Contains("JojaGreeting"))
                     {
                         JojaMart.Morris.setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Morris_Greeting", new object[0]), false, false);
                         Game1.player.mailReceived.Add("JojaGreeting");
                         Game1.drawDialogue(JojaMart.Morris);
                     }
                     else if (Game1.stats.DaysPlayed < 0u)
                     {
                         string path = (Game1.dayOfMonth % 7 == 0 || Game1.dayOfMonth % 7 == 6) ? "Data\\ExtraDialogue:Morris_WeekendGreeting" : "Data\\ExtraDialogue:Morris_FirstGreeting";
                         JojaMart.Morris.setNewDialogue(Game1.content.LoadString(path, new object[0]), false, false);
                         Game1.drawDialogue(JojaMart.Morris);
                     }
                     else
                     {
                         string str = (Game1.dayOfMonth % 7 == 0 || Game1.dayOfMonth % 7 == 6) ? "Data\\ExtraDialogue:Morris_WeekendGreeting" : "Data\\ExtraDialogue:Morris_FirstGreeting";
                         if (!Game1.IsMultiplayer || Game1.IsServer)
                         {
                             JojaMart.Morris.setNewDialogue(Game1.content.LoadString(str + "_MembershipAvailable", new object[]
                             {
                                 5000
                             }), false, false);
                             JojaMart.Morris.CurrentDialogue.Peek().answerQuestionBehavior = new Dialogue.onAnswerQuestion(this.signUpForJoja);
                         }
                         else
                         {
                             JojaMart.Morris.setNewDialogue(str + "_SecondPlayer", false, false);
                         }
                         Game1.drawDialogue(JojaMart.Morris);
                     }
                 }
                 else
                 {
                     if (Game1.player.mailForTomorrow.Contains("jojaFishTank%&NL&%") || Game1.player.mailForTomorrow.Contains("jojaPantry%&NL&%") || Game1.player.mailForTomorrow.Contains("jojaCraftsRoom%&NL&%") || Game1.player.mailForTomorrow.Contains("jojaBoilerRoom%&NL&%") || Game1.player.mailForTomorrow.Contains("jojaVault%&NL&%"))
                     {
                         JojaMart.Morris.setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Morris_StillProcessingOrder", new object[0]), false, false);
                     }
                     else
                     {
                         if (Game1.player.isMale)
                         {
                             JojaMart.Morris.setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Morris_CommunityDevelopmentForm_PlayerMale", new object[0]), false, false);
                         }
                         else
                         {
                             JojaMart.Morris.setNewDialogue(Game1.content.LoadString("Data\\ExtraDialogue:Morris_CommunityDevelopmentForm_PlayerFemale", new object[0]), false, false);
                         }
                         JojaMart.Morris.CurrentDialogue.Peek().answerQuestionBehavior = new Dialogue.onAnswerQuestion(this.viewJojaNote);
                     }
                     Game1.drawDialogue(JojaMart.Morris);
                 }
             }
         }
     }
     return(base.checkAction(tileLocation, viewport, who));
 }
Beispiel #20
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character, bool pathfinding, bool projectile = false, bool ignoreCharacterRequirement = false)
 {
     foreach (Furniture furniture in this.furniture)
     {
         if (furniture.furniture_type != 12 && furniture.getBoundingBox(furniture.tileLocation).Intersects(position))
         {
             return(true);
         }
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character, pathfinding, false, false));
 }
Beispiel #21
0
 /// <summary>
 /// Converts the viewport given in map pixel coordinates to layer
 /// coordinates taking into account parallax effects
 /// </summary>
 /// <param name="mapViewport">Viewport in map pixel coordinates</param>
 /// <returns>Viewport in layer pixel coordinates</returns>
 public Rectangle ConvertMapToLayerViewport(Rectangle mapViewport)
 {
     return new Rectangle(
         ConvertMapToLayerLocation(
             mapViewport.Location, mapViewport.Size),
             mapViewport.Size);
 }
Beispiel #22
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     if (character == null || character.willDestroyObjectsUnderfoot)
     {
         foreach (Furniture furniture in this.furniture)
         {
             if (furniture.furniture_type != 12 && furniture.getBoundingBox(furniture.tileLocation).Intersects(position))
             {
                 return(true);
             }
         }
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
Beispiel #23
0
 /// <summary>
 /// Visually renders this Map using the given display device and
 /// viewport into the map. The viewport is rendered at the display
 /// device's origin
 /// </summary>
 /// <param name="displayDevice">Display device on which to render the Map</param>
 /// <param name="mapViewport">Viewport into the Map to be rendered</param>
 public void Draw(IDisplayDevice displayDevice, Rectangle mapViewport)
 {
     Draw(displayDevice, mapViewport, Location.Origin, false);
 }
Beispiel #24
0
 public static bool Beach_checkAction_Prefix(Beach __instance, Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who, ref bool __result, NPC ___oldMariner)
 {
     try
     {
         if (___oldMariner != null && ___oldMariner.getTileX() == tileLocation.X && ___oldMariner.getTileY() == tileLocation.Y)
         {
             string playerTerm = Game1.content.LoadString("Strings\\Locations:Beach_Mariner_Player_" + (who.IsMale ? "Male" : "Female"));
             if (who.hasAFriendWithHeartLevel(10, true) && who.houseUpgradeLevel == 0)
             {
                 Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Locations:Beach_Mariner_PlayerNotUpgradedHouse", playerTerm)));
             }
             else if (who.hasAFriendWithHeartLevel(10, true))
             {
                 Response[] answers = new Response[]
                 {
                     new Response("Buy", Game1.content.LoadString("Strings\\Locations:Beach_Mariner_PlayerBuyItem_AnswerYes")),
                     new Response("Not", Game1.content.LoadString("Strings\\Locations:Beach_Mariner_PlayerBuyItem_AnswerNo"))
                 };
                 __instance.createQuestionDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Locations:Beach_Mariner_PlayerBuyItem_Question", playerTerm)), answers, "mariner");
             }
             else
             {
                 Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Locations:Beach_Mariner_PlayerNoRelationship", playerTerm)));
             }
             __result = true;
             return(false);
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed in {nameof(Beach_checkAction_Prefix)}:\n{ex}", LogLevel.Error);
     }
     return(true);
 }
        public static void GameLocation_isCollidingPosition_Postfix(GameLocation __instance, ref bool __result, Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character, bool pathfinding, bool projectile = false, bool ignoreCharacterRequirement = false)
        {
            try
            {
                if (__result == false || !isFarmer || !character.Equals(Game1.player) || !Game1.player.swimming || ModEntry.isUnderwater)
                {
                    return;
                }

                Vector2 next = SwimUtils.GetNextTile();
                //Monitor.Log($"Checking collide {SwimUtils.doesTileHaveProperty(__instance.map, (int)next.X, (int)next.Y, "Water", "Back") != null}");
                if ((int)next.X <= 0 || (int)next.Y <= 0 || __instance.Map.Layers[0].LayerWidth <= (int)next.X || __instance.Map.Layers[0].LayerHeight <= (int)next.Y || SwimUtils.doesTileHaveProperty(__instance.map, (int)next.X, (int)next.Y, "Water", "Back") != null)
                {
                    __result = false;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(GameLocation_isCollidingPosition_Postfix)}:\n{ex}", LogLevel.Error);
            }
        }
Beispiel #26
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character, bool pathfinding, bool projectile = false, bool ignoreCharacterRequirement = false)
 {
     foreach (KeyValuePair <long, FarmAnimal> kvp in animals.Pairs)
     {
         if (character != null && !character.Equals(kvp.Value) && position.Intersects(kvp.Value.GetBoundingBox()) && (!isFarmer || !Game1.player.GetBoundingBox().Intersects(kvp.Value.GetBoundingBox())))
         {
             if (isFarmer && (character as Farmer).TemporaryPassableTiles.Intersects(position))
             {
                 break;
             }
             kvp.Value.farmerPushing();
             return(true);
         }
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character, pathfinding));
 }
Beispiel #27
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Set the sharing mode of the graphics device to turn on XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);

            golfball = new Sprite(contentManager.Load<Texture2D>("golfball"));
            golfball.X = ballScreenX;
            golfball.Y = 128;

            int w = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width;
            int h = SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height;

            // Create xTile mandatory objects

            camera = new xTile.Dimensions.Rectangle(new xTile.Dimensions.Size(w, h));
            mapDisplayDevice = new XnaDisplayDevice(contentManager, SharedGraphicsDeviceManager.Current.GraphicsDevice);

            // Load xTile tilemap from content, some hacking required to load file without processor+importer from contentlib

            // Map file must have; build action set to "none", and copy to output dir
            // set to "always" to be able open this way. Also "Rebuild solution" must
            // be invoked in Visual Studio when resource is initially added.

            System.IO.Stream stream = TitleContainer.OpenStream("Content\\Map02.tbin");

            // Seems that only tbin type of maps are supported by libs

            map = FormatManager.Instance.BinaryFormat.Load(stream);
            fixTileLocationsBug(map);
            map.LoadTileSheets(mapDisplayDevice);

            // Setup Box2D physics

            physics = new Physics();

            // Add golf ball to Box2D world

            physics.addBallSprite(golfball);

            // Add the ground and water hit area rectables to Box2D world
            // Each tile is 16x16 pixels

            TileArray groundTiles = map.GetLayer("HitGround").Tiles;
            TileArray waterTiles = map.GetLayer("HitWater").Tiles;

            for (int y = 0; y < 48; y++)
            {
                for (int x = 0; x < 800; x++)
                {

                    Tile tgroup = groundTiles[x, y];
                    Tile twater = waterTiles[x, y];

                    if (tgroup != null)
                    {
                        physics.addRect(x * 16, y * 16, 16, 16, Physics.TYPE_GROUND);
                    }

                    if (twater != null)
                    {
                        physics.addRect(x * 16, y * 16, 16, 16, Physics.TYPE_WATER);
                    }

                }
            }

            // Start the timer

            timer.Start();

            base.OnNavigatedTo(e);
        }
Beispiel #28
0
        public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            Tile tile = map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size);

            if (tile != null && Game1.year == 1 && Game1.dayOfMonth == 0 && who.IsMainPlayer)
            {
                switch (tile.TileIndex)
                {
                case 265:
                    Game1.drawObjectDialogue((Game1.player.IsMale || talkedToKid) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7127") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7128"));
                    talkedToKid = true;
                    break;

                case 266:
                    if (Game1.player.IsMale)
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7129")));
                    }
                    break;

                case 221:
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7130"));
                    break;

                case 270:
                    if (!talkedToWoman)
                    {
                        Game1.multipleDialogues(new string[2]
                        {
                            Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7131")),
                            Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7132"))
                        });
                    }
                    else
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7133")));
                    }
                    talkedToWoman = true;
                    break;

                case 229:
                    if (!talkedToMan)
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7134")));
                    }
                    break;

                case 232:
                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7135")));
                    break;

                case 233:
                    if (!talkedToOldLady)
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7136")));
                    }
                    else
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7137")));
                    }
                    talkedToOldLady = true;
                    break;

                case 274:
                    if (!foundChange)
                    {
                        Game1.player.Money += 20;
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7138")));
                    }
                    else
                    {
                        foundChange = true;
                    }
                    break;

                case 278:
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7139"));
                    break;

                case 236:
                    switch (timesBagAttempt)
                    {
                    case 0:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7140")));
                        break;

                    case 1:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7141")));
                        break;

                    case 2:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7142")));
                        break;

                    case 3:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7143")));
                        break;

                    case 4:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7144")));
                        break;

                    case 5:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7145")));
                        break;

                    case 10:
                        Game1.multipleDialogues(new string[2]
                        {
                            Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7146")),
                            Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7147"))
                        });
                        Game1.player.Money++;
                        break;

                    default:
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7148")));
                        break;
                    }
                    timesBagAttempt++;
                    break;

                case 459:
                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7149")));
                    break;

                case 238:
                    if (talkedToHaley)
                    {
                        busEvent();
                    }
                    else
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7150")));
                    }
                    break;

                case 225:
                    if (!talkedToHaley)
                    {
                        Game1.drawDialogue(Game1.getCharacterFromName("Haley"), Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7152")));
                    }
                    else
                    {
                        Game1.drawDialogue(Game1.getCharacterFromName("Haley"), Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7154")));
                    }
                    talkedToHaley = true;
                    break;
                }
                return(true);
            }
            return(base.checkAction(tileLocation, viewport, who));
        }
Beispiel #29
0
        /// <summary>
        /// Tests if a Rectangle intersects this Rectangle
        /// </summary>
        /// <param name="rectangle">Rectangle to test</param>
        /// <returns>True in case of intersection, False otherwise</returns>
        public bool Intersects(Rectangle rectangle)
        {
            if (Location.X + Size.Width <= rectangle.Location.X)
                return false;

            if (Location.Y + Size.Height <= rectangle.Location.Y)
                return false;

            if (Location.X >= rectangle.Location.X + rectangle.Size.Width)
                return false;

            if (Location.Y >= rectangle.Location.Y + rectangle.Size.Height)
                return false;

            return true;
        }
Beispiel #30
0
        public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            int tileIndexOfCheckLocation = (map.GetLayer("Buildings").Tiles[tileLocation] != null) ? map.GetLayer("Buildings").Tiles[tileLocation].TileIndex : (-1);

            if (tileIndexOfCheckLocation == 901 && !isWizardHouseUnlocked())
            {
                Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:Forest_WizardTower_Locked"));
                return(false);
            }
            if (base.checkAction(tileLocation, viewport, who))
            {
                return(true);
            }
            switch (tileIndexOfCheckLocation)
            {
            case 1394:
                if (who.hasRustyKey && !who.mailReceived.Contains("OpenedSewer"))
                {
                    playSound("openBox");
                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Locations:Forest_OpenedSewer")));
                    who.mailReceived.Add("OpenedSewer");
                }
                else if (who.mailReceived.Contains("OpenedSewer"))
                {
                    Game1.warpFarmer("Sewer", 3, 48, 0);
                    playSound("openChest");
                }
                else
                {
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:LockedDoor"));
                }
                break;

            case 1972:
                if (who.achievements.Count > 0)
                {
                    Game1.activeClickableMenu = new ShopMenu(Utility.getHatStock(), 0, "HatMouse");
                }
                else
                {
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:Forest_HatMouseStore_Abandoned"));
                }
                break;
            }
            if (travelingMerchantDay && Game1.timeOfDay < 2000)
            {
                if (tileLocation.X == 27 && tileLocation.Y == 11)
                {
                    Game1.activeClickableMenu = new ShopMenu(Utility.getTravelingMerchantStock((int)(Game1.uniqueIDForThisGame + Game1.stats.DaysPlayed)), 0, "Traveler", Utility.onTravelingMerchantShopPurchase);
                    return(true);
                }
                if (tileLocation.X == 23 && tileLocation.Y == 11)
                {
                    playSound("pig");
                    return(true);
                }
            }
            Microsoft.Xna.Framework.Rectangle boundingBox = new Microsoft.Xna.Framework.Rectangle(tileLocation.X * 64, tileLocation.Y * 64, 64, 64);
            if (log != null && log.getBoundingBox(log.tile).Intersects(boundingBox))
            {
                log.performUseAction(new Vector2(tileLocation.X, tileLocation.Y), this);
                return(true);
            }
            return(false);
        }
Beispiel #31
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // get keyboard and gamepad states
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
            GamePadButtons gamePadButtons = gamePadState.Buttons;
            Vector2 leftThumbStick = gamePadState.ThumbSticks.Left;
            KeyboardState keyboardState = Keyboard.GetState(PlayerIndex.One);

            // check for exit
            if (gamePadButtons.Back == ButtonState.Pressed
                || keyboardState.IsKeyDown(Keys.Escape))
                this.Exit();

            // toggle wraparound on/off
            if (gamePadButtons.X == ButtonState.Pressed || keyboardState.IsKeyDown(Keys.W))
            {
                if (!m_wrapAroundPressed)
                    m_wrapAround = !m_wrapAround;
                m_wrapAroundPressed = true;
            }
            else
            {
                m_wrapAroundPressed = false;
            }

            #if WINDOWS
            // toggle window / fullscreen mode
            if (gamePadButtons.Y == ButtonState.Pressed
                || keyboardState.IsKeyDown(Keys.Space))
            {
                m_graphicsDeviceManager.ToggleFullScreen();

                m_viewPort = new xTile.Dimensions.Rectangle(
                    new xTile.Dimensions.Location(
                        GraphicsDevice.Viewport.TitleSafeArea.Left,
                        GraphicsDevice.Viewport.TitleSafeArea.Top),
                    new xTile.Dimensions.Size(
                        GraphicsDevice.Viewport.TitleSafeArea.Width,
                        GraphicsDevice.Viewport.TitleSafeArea.Height));
            }
            #endif

            // leaf animations
            Random random = new Random();
            for (int index = 0; index < m_vecLeafPositions.Length; index++)
            {
                m_vecLeafPositions[index] += m_vecLeafVelocities[index];
                if (m_vecLeafPositions[index].X > m_viewPort.Width)
                {
                    m_vecLeafPositions[index].X = -m_textureLeaf.Width;
                    m_vecLeafVelocities[index].X = 1 + random.Next(4);
                    m_vecLeafVelocities[index].Y = 1 + random.Next(3);
                }
                if (m_vecLeafPositions[index].Y > m_viewPort.Height)
                {
                    m_vecLeafPositions[index].Y = -m_textureLeaf.Height;
                    m_vecLeafVelocities[index].X = 1 + random.Next(4);
                    m_vecLeafVelocities[index].Y = 1 + random.Next(3);
                }
            }

            // movement via keyboard
            if (keyboardState.IsKeyDown(Keys.Left))
                m_viewPort.Location.X -= 2;

            if (keyboardState.IsKeyDown(Keys.Right))
                m_viewPort.Location.X += 2;

            if (keyboardState.IsKeyDown(Keys.Up))
                m_viewPort.Location.Y -= 2;

            if (keyboardState.IsKeyDown(Keys.Down))
                m_viewPort.Location.Y += 2;

            // stick movement
            m_viewPort.Location.X += (int)(leftThumbStick.X * 4.0f);
            m_viewPort.Location.Y -= (int)(leftThumbStick.Y * 4.0f);

            // touch movement (WP7 and touch-enabled displays)
            foreach (TouchLocation touchLocation in TouchPanel.GetState())
            {
                TouchLocation previousTouchLocation;
                if (touchLocation.State == TouchLocationState.Moved
                    && touchLocation.TryGetPreviousLocation(out previousTouchLocation))
                {
                    m_viewPort.Location.X += (int)(previousTouchLocation.Position.X - touchLocation.Position.X);
                    m_viewPort.Location.Y += (int)(previousTouchLocation.Position.Y - touchLocation.Position.Y);
                }
            }

            // limit viewport to map if wraparound disabled
            if (!m_wrapAround)
            {
                m_viewPort.Location.X = Math.Max(0, m_viewPort.X);
                m_viewPort.Location.Y = Math.Max(0, m_viewPort.Y);
                m_viewPort.Location.X = Math.Min(
                    m_map.DisplayWidth - m_viewPort.Width, m_viewPort.X);
                m_viewPort.Location.Y = Math.Min(
                    m_map.DisplayHeight - m_viewPort.Height, m_viewPort.Y);
            }

            // update map for animations etc.
            m_map.Update(gameTime.ElapsedGameTime.Milliseconds);

            base.Update(gameTime);
        }
Beispiel #32
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character, bool pathfinding, bool projectile = false, bool ignoreCharacterRequirement = false)
 {
     if (log != null && log.getBoundingBox(log.tile).Intersects(position))
     {
         return(true);
     }
     if (travelingMerchantBounds != null)
     {
         foreach (Microsoft.Xna.Framework.Rectangle r in travelingMerchantBounds)
         {
             if (position.Intersects(r))
             {
                 return(true);
             }
         }
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character, pathfinding, projectile, ignoreCharacterRequirement));
 }
Beispiel #33
0
        private static void drawImageLayer(Layer layer, xTile.Display.IDisplayDevice device, xTile.Dimensions.Rectangle viewport, int pixelZoom, Location offset, bool wrap = false)
        {
            Vector2 pos = Game1.GlobalToLocal(new Vector2(offset.X, offset.Y));

            if (layer.Properties.ContainsKey("ParallaxX") || layer.Properties.ContainsKey("ParallaxY"))
            {
                Vector2 end = pos;
                if (layer.Properties.ContainsKey("OffestXReset"))
                {
                    end.X = layer.Properties["OffestXReset"];
                    end.Y = layer.Properties["OffestYReset"];
                }
                end = Game1.GlobalToLocal(end);

                Vector2 start = new Vector2(layer.Properties["StartX"], layer.Properties["StartY"]);

                Vector2 dif = start - end;

                if (layer.Properties.ContainsKey("ParallaxX"))
                {
                    pos.X += ((float.Parse(layer.Properties["ParallaxX"]) * dif.X) / 100f) - dif.X;
                }

                if (layer.Properties.ContainsKey("ParallaxY"))
                {
                    pos.Y += ((float.Parse(layer.Properties["ParallaxY"]) * dif.Y) / 100f) - dif.Y;
                }
            }


            if (!wrap)
            {
                layer.Draw(device, viewport, offset, wrap, pixelZoom);
                return;
            }

            if (layer.GetTileSheetForImageLayer() is TileSheet ts &&
                device is PyDisplayDevice sDevice &&
                sDevice.GetTexture(ts) is Texture2D texture &&
                layer.GetOpacity() is float opacity)
            {
                Color color = Color.White;

                if (layer.GetColor() is TMXColor c)
                {
                    color = new Color(c.R, c.G, c.B, c.A);
                }

                var vp = new Microsoft.Xna.Framework.Rectangle(Game1.viewport.X, Game1.viewport.Y, Game1.viewport.Width, Game1.viewport.Height);
                Microsoft.Xna.Framework.Rectangle dest = new Microsoft.Xna.Framework.Rectangle((int)pos.X, (int)pos.Y, texture.Width * Game1.pixelZoom, texture.Height * Game1.pixelZoom);

                Vector2 s = pos;

                while (s.X > (vp.X - (dest.Width * 2)) || s.Y > (vp.Y - (dest.Height * 2)))
                {
                    s.X -= dest.Width;
                    s.Y -= dest.Height;
                }

                Vector2 e = new Vector2(vp.X + vp.Width + (dest.Width * 2), vp.Height + vp.Y + (dest.Height * 2));

                for (float x = s.X; x <= e.X; x += dest.Width)
                {
                    for (Microsoft.Xna.Framework.Rectangle n = new Microsoft.Xna.Framework.Rectangle((int)x, (int)s.Y, dest.Width, dest.Height); n.Y <= e.Y; n.Y += dest.Height)
                    {
                        if ((layer.Properties["WrapAround"] != "Y" || n.X == dest.X) && (layer.Properties["WrapAround"] != "X" || n.Y == dest.Y))
                        {
                            Game1.spriteBatch.Draw(texture, n, color * opacity);
                        }
                    }
                }
            }
        }
Beispiel #34
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     if ((bool)landslide && position.Intersects(landSlideRect))
     {
         return(true);
     }
     if ((bool)railroadAreaBlocked && position.Intersects(railroadBlockRect))
     {
         return(true);
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
        internal static bool MineShaft_checkAction_prefix(MineShaft __instance, Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            Tile tile = __instance.map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size);

            if (tile != null && who.IsLocalPlayer)
            {
                tile.Properties.TryGetValue("Action", out PropertyValue property);
                if (property != null)
                {
                    string action = property.ToString();

                    if (action.StartsWith("offerPuzzleSteal"))
                    {
                        OfferingPuzzles.StealAttempt(__instance, action, tileLocation, who);
                    }
                    else if (who.ActiveObject != null && action.StartsWith("offerPuzzle_"))
                    {
                        OfferingPuzzles.OfferObject(__instance, action, tileLocation, who);
                    }
                    else if (action.StartsWith("undergroundAltar_"))
                    {
                        Altars.OfferObject(__instance, action, tileLocation, who);
                    }
                    else if (action == "undergroundRiddles")
                    {
                        RiddlePuzzles.Interact(__instance, tileLocation, who);
                    }
                }
            }
            return(true);
        }
Beispiel #36
0
        private void export(RenderQueueEntry render)
        {
            GameLocation loc = render.loc;

            //int oldZoom = Game1.pixelZoom;
            //Game1.pixelZoom = 4;
            SpriteBatch    b          = Game1.spriteBatch; // new SpriteBatch(Game1.graphics.GraphicsDevice);
            GraphicsDevice dev        = Game1.graphics.GraphicsDevice;
            var            display    = Game1.mapDisplayDevice;
            RenderTarget2D output     = null;
            RenderTarget2D oldOutput  = null;
            RenderTarget2D myLighting = null;
            Stream         stream     = null;
            bool           begun      = false;
            Rectangle      oldView    = new Rectangle();
            float          oldZoomL   = Game1.options.zoomLevel;

            Game1.options.desiredBaseZoomLevel = 0.25f;
            try
            {
                Log.info("Rendering " + loc.Name + "...");
                output = new RenderTarget2D(dev, loc.map.DisplayWidth / 4, loc.map.DisplayHeight / 4);
                RectangleX viewportX = new RectangleX(0, 0, output.Width, output.Height);
                Rectangle  viewport  = new Rectangle(0, 0, output.Width * 4, output.Height * 4);
                oldView        = Game1.viewport;
                Game1.viewport = viewport;

                Matrix transform = Matrix.CreateScale(0.25f);

                if (loc is DecoratableLocation)
                {
                    foreach (Furniture f in (loc as DecoratableLocation).furniture)
                    {
                        f.updateDrawPosition();
                    }
                }

                if (render.Lighting)
                {
                    int   num1 = 32;
                    float num2 = 1f;
                    if (Game1.options != null)
                    {
                        num1 = Game1.options.lightingQuality;
                        num2 = Game1.options.zoomLevel;
                    }

                    int width  = (int)(output.Width * (1.0 / num2) + Game1.tileSize) / (num1 / 2);
                    int height = (int)(output.Height * (1.0 / num2) + Game1.tileSize) / (num1 / 2);
                    myLighting = new RenderTarget2D(dev, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0,
                                                    RenderTargetUsage.PreserveContents);
                    if (Game1.drawLighting)
                    {
                        dev.SetRenderTarget(myLighting);
                        dev.Clear(Color.White * 0f);
                        b.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null,
                                null, null, transform);
                        b.Draw(Game1.staminaRect, myLighting.Bounds,
                               loc.Name.Equals("UndergroundMine")
                                ? Game1.mine.getLightingColor(null /*gameTime*/)
                                : ((!Game1.ambientLight.Equals(Color.White) && (!Game1.isRaining || !loc.IsOutdoors))
                                    ? Game1.ambientLight
                                    : Game1.outdoorLight));
                        for (int i = 0; i < Game1.currentLightSources.Count; i++)
                        {
                            //if (Utility.isOnScreen(Game1.currentLightSources.ElementAt(i).position, (int)(Game1.currentLightSources.ElementAt(i).radius * (float)Game1.tileSize * 4f)))
                            {
                                b.Draw(Game1.currentLightSources.ElementAt(i).lightTexture,
                                       Game1.currentLightSources.ElementAt(i).position.Value /
                                       (Game1.options.lightingQuality / 2),
                                       Game1.currentLightSources.ElementAt(i).lightTexture.Bounds,
                                       Game1.currentLightSources.ElementAt(i).color.Value, 0f,
                                       new Vector2(Game1.currentLightSources.ElementAt(i).lightTexture.Bounds.Center.X,
                                                   Game1.currentLightSources.ElementAt(i).lightTexture.Bounds.Center.Y),
                                       Game1.currentLightSources.ElementAt(i).radius.Value /
                                       (Game1.options.lightingQuality / 2), SpriteEffects.None, 0.9f);
                            }
                        }

                        b.End();
                        //dev.SetRenderTarget((Game1.options.zoomLevel == 1f) ? null : this.screen);
                    }

                    if (Game1.bloomDay && Game1.bloom != null)
                    {
                        Game1.bloom.BeginDraw();
                    }
                }

                dev.SetRenderTarget(output);
                dev.Clear(Color.Black);
                {
                    if (!loc.Equals(Game1.currentLocation))
                    {
                        loc.map.LoadTileSheets(display);
                    }

                    b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null,
                            transform);
                    begun = true;
                    if (render.Tiles)
                    {
                        display.BeginScene(b);
                        loc.map.GetLayer("Back")
                        .Draw(Game1.mapDisplayDevice, new Rectangle(0, 0, output.Width * 4, output.Height * 4),
                              Location.Origin, false, 4);
                        loc.drawWater(b);
                    }

                    if (render.Characters)
                    {
                        var chars = loc.characters.ToList();
                        if (render.Event && Game1.CurrentEvent != null && loc.Equals(Game1.currentLocation))
                        {
                            chars = Game1.CurrentEvent.actors;
                        }

                        foreach (NPC npc in chars)
                        {
                            if (!npc.swimming.Value && !npc.HideShadow && !npc.IsInvisible &&
                                !loc.shouldShadowBeDrawnAboveBuildingsLayer(npc.getTileLocation()))
                            {
                                b.Draw(Game1.shadowTexture,
                                       Game1.GlobalToLocal(viewport,
                                                           npc.position + new Vector2(npc.Sprite.SpriteWidth * Game1.pixelZoom / 2f,
                                                                                      npc.GetBoundingBox().Height + (npc.IsMonster ? 0 : (Game1.pixelZoom * 3)))),
                                       Game1.shadowTexture.Bounds, Color.White, 0f,
                                       new Vector2(Game1.shadowTexture.Bounds.Center.X,
                                                   Game1.shadowTexture.Bounds.Center.Y),
                                       (Game1.pixelZoom + npc.yJumpOffset / 40f) * npc.Scale, SpriteEffects.None,
                                       Math.Max(0f, npc.getStandingY() / 10000f) - 1E-06f);
                            }
                        }
                    }

                    if (render.Player && Game1.currentLocation.Equals(loc))
                    {
                        if (Game1.displayFarmer && !Game1.player.swimming.Value && !Game1.player.isRidingHorse() &&
                            !Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(
                                Game1.player.getTileLocation()))
                        {
                            b.Draw(Game1.shadowTexture,
                                   Game1.GlobalToLocal(Game1.player.position + new Vector2(32f, 24f)),
                                   Game1.shadowTexture.Bounds, Color.White, 0f,
                                   new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y),
                                   4f - (((Game1.player.running || Game1.player.UsingTool) &&
                                          Game1.player.FarmerSprite.currentAnimationIndex > 1)
                                    ? (Math.Abs(
                                           FarmerRenderer.featureYOffsetPerFrame
                                           [Game1.player.FarmerSprite.CurrentFrame]) *
                                       0.5f)
                                    : 0f), SpriteEffects.None, 0f);
                        }
                    }

                    if (render.Tiles)
                    {
                        loc.map.GetLayer("Buildings")
                        .Draw(Game1.mapDisplayDevice, new Rectangle(0, 0, output.Width * 4, output.Height * 4),
                              Location.Origin, false, 4);
                        display.EndScene();
                    }

                    b.End();
                    begun = false;

                    b.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null,
                            null, transform);
                    begun = true;
                    if (render.Characters)
                    {
                        var chars = loc.characters.ToList();
                        if (render.Event && Game1.CurrentEvent != null && loc.Equals(Game1.currentLocation))
                        {
                            chars = Game1.CurrentEvent.actors;
                        }

                        foreach (NPC npc in chars)
                        {
                            if (!npc.swimming.Value && !npc.HideShadow && !npc.IsInvisible &&
                                !loc.shouldShadowBeDrawnAboveBuildingsLayer(npc.getTileLocation()))
                            {
                                b.Draw(Game1.shadowTexture,
                                       Game1.GlobalToLocal(viewport,
                                                           npc.position + new Vector2(npc.Sprite.SpriteWidth * Game1.pixelZoom / 2f,
                                                                                      npc.GetBoundingBox().Height + (npc.IsMonster ? 0 : (Game1.pixelZoom * 3)))),
                                       Game1.shadowTexture.Bounds, Color.White, 0f,
                                       new Vector2(Game1.shadowTexture.Bounds.Center.X,
                                                   Game1.shadowTexture.Bounds.Center.Y),
                                       (Game1.pixelZoom + npc.yJumpOffset / 40f) * npc.Scale, SpriteEffects.None,
                                       Math.Max(0f, npc.getStandingY() / 10000f) - 1E-06f);
                            }
                        }
                    }

                    if (render.Player && Game1.currentLocation.Equals(loc))
                    {
                        if (Game1.displayFarmer && !Game1.player.swimming.Value && !Game1.player.isRidingHorse() &&
                            Game1.currentLocation
                            .shouldShadowBeDrawnAboveBuildingsLayer(Game1.player.getTileLocation()))
                        {
                            b.Draw(Game1.shadowTexture,
                                   Game1.GlobalToLocal(Game1.player.position + new Vector2(32f, 24f)),
                                   Game1.shadowTexture.Bounds, Color.White, 0f,
                                   new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y),
                                   4f - (((Game1.player.running || Game1.player.UsingTool) &&
                                          Game1.player.FarmerSprite.currentAnimationIndex > 1)
                                    ? (Math.Abs(
                                           FarmerRenderer.featureYOffsetPerFrame
                                           [Game1.player.FarmerSprite.CurrentFrame]) *
                                       0.5f)
                                    : 0f), SpriteEffects.None,
                                   Math.Max(0.0001f, Game1.player.getStandingY() / 10000f + 0.00011f) - 0.0001f);
                        }

                        if (Game1.displayFarmer)
                        {
                            Game1.player.draw(b);
                        }
                    }

                    if (render.Event && loc.Equals(Game1.currentLocation))
                    {
                        if ((Game1.eventUp || Game1.killScreen) && !Game1.killScreen &&
                            Game1.currentLocation.currentEvent != null)
                        {
                            loc.currentEvent.draw(b);
                        }
                    }

                    if (render.Location)
                    {
                        if (Game1.player.currentUpgrade != null &&
                            Game1.player.currentUpgrade.daysLeftTillUpgradeDone <= 3 && loc.Name.Equals("Farm"))
                        {
                            b.Draw(Game1.player.currentUpgrade.workerTexture,
                                   Game1.GlobalToLocal(viewport, Game1.player.currentUpgrade.positionOfCarpenter),
                                   Game1.player.currentUpgrade.getSourceRectangle(), Color.White, 0f, Vector2.Zero, 1f,
                                   SpriteEffects.None,
                                   (Game1.player.currentUpgrade.positionOfCarpenter.Y + Game1.tileSize * 3 / 4) / 10000f);
                        }

                        var charsField   = Helper.Reflection.GetField <NetCollection <NPC> >(loc, "characters");
                        var farmersField = Helper.Reflection.GetField <FarmerCollection>(loc, "farmers");
                        var chars        = loc.characters;
                        var farmers      = loc.farmers;
                        try
                        {
                            if (!render.Player)
                            {
                                var type = typeof(Game1).Assembly.GetType("StardewValley.Network.FarmerCollection");
                                var val  = (FarmerCollection)type.GetConstructor(new[] { typeof(GameLocation) })
                                           .Invoke(new object[] { loc });
                                farmersField.SetValue(val);
                            }

                            if (!render.Characters)
                            {
                                charsField.SetValue(new NetCollection <NPC>());
                            }

                            loc.draw(b);
                        }
                        finally
                        {
                            farmersField.SetValue(farmers);
                            charsField.SetValue(chars);
                        }
                    }

                    if (render.Player && Game1.currentLocation.Equals(loc))
                    {
                        if (Game1.player.ActiveObject == null && (Game1.player.UsingTool || Game1.pickingTool) &&
                            Game1.player.CurrentTool != null &&
                            (!Game1.player.CurrentTool.Name.Equals("Seeds") || Game1.pickingTool))
                        {
                            Game1.drawTool(Game1.player);
                        }
                    }

                    if (render.Location)
                    {
                        if (loc.Name.Equals("Farm"))
                        {
                            Helper.Reflection.GetMethod(Game1.game1, "drawFarmBuildings").Invoke();
                        }
                    }

                    if (render.Location)
                    {
                        if (Game1.tvStation >= 0)
                        {
                            b.Draw(Game1.tvStationTexture,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(6 * Game1.tileSize + Game1.tileSize / 4,
                                                                   2 * Game1.tileSize + Game1.tileSize / 2)),
                                   new RectangleX(Game1.tvStation * 24, 0, 24, 15), Color.White, 0f, Vector2.Zero, 4f,
                                   SpriteEffects.None, 1E-08f);
                        }
                    }

                    if (render.Tiles)
                    {
                        display.BeginScene(b);
                        loc.map.GetLayer("Front")
                        .Draw(Game1.mapDisplayDevice, new Rectangle(0, 0, output.Width * 4, output.Height * 4),
                              Location.Origin, false, 4);
                        display.EndScene();
                    }

                    if (render.Location)
                    {
                        loc.drawAboveFrontLayer(b);
                    }

                    b.End();
                    begun = false;

                    b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null,
                            transform);
                    begun = true;
                    if (render.Location)
                    {
                        if (loc.Name.Equals("Farm") && Game1.stats.SeedsSown >= 200u)
                        {
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(3 * Game1.tileSize + Game1.tileSize / 4,
                                                                   Game1.tileSize + Game1.tileSize / 3)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(4 * Game1.tileSize + Game1.tileSize,
                                                                   2 * Game1.tileSize + Game1.tileSize)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport, new Vector2(5 * Game1.tileSize, 2 * Game1.tileSize)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(3 * Game1.tileSize + Game1.tileSize / 2, 3 * Game1.tileSize)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(5 * Game1.tileSize - Game1.tileSize / 4, Game1.tileSize)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(4 * Game1.tileSize, 3 * Game1.tileSize + Game1.tileSize / 6)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                            b.Draw(Game1.debrisSpriteSheet,
                                   Game1.GlobalToLocal(viewport,
                                                       new Vector2(4 * Game1.tileSize + Game1.tileSize / 5,
                                                                   2 * Game1.tileSize + Game1.tileSize / 3)),
                                   Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 16), Color.White);
                        }
                    }

                    if (render.Player && Game1.currentLocation.Equals(loc))
                    {
                        var meth = typeof(Game1).GetMethod("checkBigCraftableBoundariesForFrontLayer",
                                                           BindingFlags.NonPublic | BindingFlags.Instance);
                        if (Game1.displayFarmer && Game1.player.ActiveObject != null &&
                            Game1.player.ActiveObject.bigCraftable.Value &&
                            (bool)meth.Invoke(Game1.game1, new object[] { }) && Game1.currentLocation.Map
                            .GetLayer("Front")
                            .PickTile(new Location(Game1.player.getStandingX(), Game1.player.getStandingY()),
                                      viewport.Size) == null)
                        {
                            Game1.drawPlayerHeldObject(Game1.player);
                        }
                        else if (Game1.displayFarmer && Game1.player.ActiveObject != null &&
                                 ((Game1.currentLocation.Map.GetLayer("Front")
                                   .PickTile(
                                       new Location((int)Game1.player.position.X,
                                                    (int)Game1.player.position.Y - Game1.tileSize * 3 / 5),
                                       viewport.Size) !=
                                   null &&
                                   !Game1.currentLocation.Map.GetLayer("Front")
                                   .PickTile(
                                       new Location((int)Game1.player.position.X,
                                                    (int)Game1.player.position.Y - Game1.tileSize * 3 / 5), viewport.Size)
                                   .TileIndexProperties.ContainsKey("FrontAlways")) ||
                                  (Game1.currentLocation.Map.GetLayer("Front")
                                   .PickTile(
                                       new Location(Game1.player.GetBoundingBox().Right,
                                                    (int)Game1.player.position.Y - Game1.tileSize * 3 / 5),
                                       viewport.Size) !=
                                   null && !Game1.currentLocation.Map.GetLayer("Front")
                                   .PickTile(
                                       new Location(Game1.player.GetBoundingBox().Right,
                                                    (int)Game1.player.position.Y - Game1.tileSize * 3 / 5),
                                       viewport.Size)
                                   .TileIndexProperties.ContainsKey("FrontAlways"))))
                        {
                            Game1.drawPlayerHeldObject(Game1.player);
                        }

                        if ((Game1.player.UsingTool || Game1.pickingTool) && Game1.player.CurrentTool != null &&
                            (!Game1.player.CurrentTool.Name.Equals("Seeds") || Game1.pickingTool) &&
                            Game1.currentLocation.Map.GetLayer("Front")
                            .PickTile(
                                new Location(Game1.player.getStandingX(),
                                             (int)Game1.player.position.Y - Game1.tileSize * 3 / 5), viewport.Size) !=
                            null && Game1.currentLocation.Map.GetLayer("Front")
                            .PickTile(new Location(Game1.player.getStandingX(), Game1.player.getStandingY()),
                                      viewport.Size) == null)
                        {
                            Game1.drawTool(Game1.player);
                        }
                    }

                    if (render.Tiles)
                    {
                        if (loc.map.GetLayer("AlwaysFront") != null)
                        {
                            display.BeginScene(b);
                            loc.map.GetLayer("AlwaysFront")
                            .Draw(Game1.mapDisplayDevice, new Rectangle(0, 0, output.Width * 4, output.Height * 4),
                                  Location.Origin, false, 4);
                            display.EndScene();
                        }
                    }

                    if (render.Player && Game1.currentLocation.Equals(loc))
                    {
                        if (Game1.toolHold > 400f && Game1.player.CurrentTool.UpgradeLevel >= 1 &&
                            Game1.player.canReleaseTool)
                        {
                            Color color = Color.White;
                            switch ((int)(Game1.toolHold / 600f) + 2)
                            {
                            case 1:
                                color = Tool.copperColor;
                                break;

                            case 2:
                                color = Tool.steelColor;
                                break;

                            case 3:
                                color = Tool.goldColor;
                                break;

                            case 4:
                                color = Tool.iridiumColor;
                                break;
                            }

                            b.Draw(Game1.littleEffect,
                                   new RectangleX((int)Game1.player.getLocalPosition(viewport).X - 2,
                                                  (int)Game1.player.getLocalPosition(viewport).Y -
                                                  (Game1.player.CurrentTool.Name.Equals("Watering Can") ? 0 : Game1.tileSize) - 2,
                                                  (int)(Game1.toolHold % 600f * 0.08f) + 4, Game1.tileSize / 8 + 4), Color.Black);
                            b.Draw(Game1.littleEffect,
                                   new RectangleX((int)Game1.player.getLocalPosition(viewport).X,
                                                  (int)Game1.player.getLocalPosition(viewport).Y -
                                                  (Game1.player.CurrentTool.Name.Equals("Watering Can") ? 0 : Game1.tileSize),
                                                  (int)(Game1.toolHold % 600f * 0.08f), Game1.tileSize / 8), color);
                        }
                    }

                    if (render.Weather)
                    {
                        if (Game1.isDebrisWeather && loc.IsOutdoors && !loc.ignoreDebrisWeather.Value &&
                            !loc.Name.Equals("Desert") && viewport.X > -10)
                        {
                            using (List <WeatherDebris> .Enumerator enumerator4 = Game1.debrisWeather.GetEnumerator())
                            {
                                while (enumerator4.MoveNext())
                                {
                                    enumerator4.Current.draw(b);
                                }
                            }
                        }
                    }

                    if (render.Event)
                    {
                        if (Game1.farmEvent != null)
                        {
                            Game1.farmEvent.draw(b);
                        }
                    }

                    if (render.Lighting)
                    {
                        if (loc.LightLevel > 0f && Game1.timeOfDay < 2000)
                        {
                            b.Draw(Game1.fadeToBlackRect, output.Bounds, Color.Black * loc.LightLevel);
                        }

                        if (Game1.screenGlow)
                        {
                            b.Draw(Game1.fadeToBlackRect, output.Bounds, Game1.screenGlowColor * Game1.screenGlowAlpha);
                        }
                    }

                    if (render.Location)
                    {
                        loc.drawAboveAlwaysFrontLayer(b);
                    }

                    if (render.Player && Game1.currentLocation.Equals(loc))
                    {
                        if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod &&
                            ((Game1.player.CurrentTool as FishingRod).isTimingCast ||
                             (Game1.player.CurrentTool as FishingRod).castingChosenCountdown > 0f ||
                             (Game1.player.CurrentTool as FishingRod).fishCaught ||
                             (Game1.player.CurrentTool as FishingRod).showingTreasure))
                        {
                            Game1.player.CurrentTool.draw(b);
                        }
                    }

                    if (render.Weather)
                    {
                        if (Game1.isRaining && loc.IsOutdoors && !loc.Name.Equals("Desert") && !(loc is Summit) &&
                            (!Game1.eventUp || loc.isTileOnMap(new Vector2(viewport.X / Game1.tileSize,
                                                                           viewport.Y / Game1.tileSize))))
                        {
                            for (int ix = 0; ix < output.Bounds.Width / oldView.Width * 4; ++ix)
                            {
                                for (int iy = 0; iy < output.Bounds.Height / oldView.Height * 4; ++iy)
                                {
                                    var offset = new Vector2(ix * oldView.Width, iy * oldView.Height);
                                    for (int j = 0; j < Game1.rainDrops.Length; j++)
                                    {
                                        b.Draw(Game1.rainTexture, offset + Game1.rainDrops[j].position,
                                               Game1.getSourceRectForStandardTileSheet(Game1.rainTexture,
                                                                                       Game1.rainDrops[j].frame), Color.White);
                                    }
                                }
                            }
                        }
                    }

                    b.End();
                    begun = false;

                    if (render.Event && Game1.currentLocation.Equals(loc))
                    {
                        b.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null,
                                null, transform);
                        begun = true;
                        if (Game1.eventUp && Game1.currentLocation.currentEvent != null)
                        {
                            foreach (NPC current7 in Game1.currentLocation.currentEvent.actors)
                            {
                                if (current7.isEmoting)
                                {
                                    Vector2 localPosition = current7.getLocalPosition(viewport);
                                    localPosition.Y -= Game1.tileSize * 2 + Game1.pixelZoom * 3;
                                    if (current7.Age == 2)
                                    {
                                        localPosition.Y += Game1.tileSize / 2;
                                    }
                                    else if (current7.Gender == 1)
                                    {
                                        localPosition.Y += Game1.tileSize / 6;
                                    }

                                    b.Draw(Game1.emoteSpriteSheet, localPosition,
                                           new RectangleX(
                                               current7.CurrentEmoteIndex * (Game1.tileSize / 4) %
                                               Game1.emoteSpriteSheet.Width,
                                               current7.CurrentEmoteIndex * (Game1.tileSize / 4) /
                                               Game1.emoteSpriteSheet.Width * (Game1.tileSize / 4), Game1.tileSize / 4,
                                               Game1.tileSize / 4), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None,
                                           current7.getStandingY() / 10000f);
                                }
                            }
                        }

                        b.End();
                        begun = false;
                    }

                    if (render.Lighting)
                    {
                        if (Game1.drawLighting)
                        {
                            b.Begin(SpriteSortMode.Deferred,
                                    Helper.Reflection.GetField <BlendState>(Game1.game1, "lightingBlend").GetValue(),
                                    SamplerState.LinearClamp, null, null, null, transform);
                            begun = true;
                            b.Draw(myLighting, Vector2.Zero, myLighting.Bounds, Color.White, 0f, Vector2.Zero,
                                   (float)(Game1.options.lightingQuality / 2) * 4, SpriteEffects.None, 1f);
                            if (render.Weather && Game1.isRaining && loc.IsOutdoors && !(loc is Desert))
                            {
                                b.Draw(Game1.staminaRect, output.Bounds, Color.OrangeRed * 0.45f);
                            }

                            b.End();
                            begun = false;
                        }
                    }
                }

                // This fixes the saved texture being transparent when there is lighting
                // Not a very CLEAN fix... But it works
                oldOutput = output;
                output    = new RenderTarget2D(dev, oldOutput.Width, oldOutput.Height);
                dev.SetRenderTarget(output);
                dev.Clear(Color.Black);
                b.Begin();
                begun = true;
                b.Draw(oldOutput, new Vector2(0, 0), Color.White);
                b.End();
                begun = false;
                dev.SetRenderTarget(null);

                string name = loc.Name;
                if (loc.uniqueName.Value != null)
                {
                    name = loc.uniqueName.Value;
                }

                string dirPath   = Path.Combine(Constants.ExecutionPath, "MapExport");
                string imagePath = Path.Combine(dirPath, $"{name}.png");
                Log.info($"Saving {name} to {Path.GetFullPath(imagePath)}...");

                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                stream = File.Create(imagePath);
                output.SaveAsPng(stream, output.Width, output.Height);
                stream.Dispose();
            }
            catch (Exception e)
            {
                Log.error("Exception: " + e);
            }
            finally
            {
                display.EndScene();
                if (begun)
                {
                    b.End();
                }
                dev.SetRenderTarget(null);
                stream?.Dispose();
                oldOutput?.Dispose();
                output?.Dispose();
                myLighting?.Dispose();
                //Game1.pixelZoom = oldZoom;
                Game1.viewport = oldView;
                Game1.options.desiredBaseZoomLevel = oldZoomL;
            }

            if (loc is DecoratableLocation location)
            {
                foreach (Furniture f in location.furniture)
                {
                    f.updateDrawPosition();
                }
            }
        }
Beispiel #37
0
 /// <summary>
 /// Constructs a new Layer arguments structure
 /// </summary>
 /// <param name="layer">Layer associated with the event</param>
 /// <param name="viewport">Viewport associated with the event</param>
 public LayerEventArgs(Layer layer, Rectangle viewport)
 {
     m_layer = layer;
     m_viewport = viewport;
 }
Beispiel #38
0
 // Token: 0x0600119D RID: 4509 RVA: 0x00169030 File Offset: 0x00167230
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     return((this.train != null && this.train.getBoundingBox().Intersects(position)) || base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
Beispiel #39
0
 /// <summary>
 /// Visually renders the layer using the given display device,
 /// pixel offset from the map origin and display viewport. If
 /// wrapAround is set to True, the layer wraps around at the
 /// edges across and / or down.
 /// </summary>
 /// <param name="displayDevice">Display device on which to render layer</param>
 /// <param name="mapViewport">viewport on the dipslay device</param>
 /// <param name="displayOffset">offset in pixel coordinates into the map from the top left</param>
 /// <param name="wrapAround">Flag indicating if layer wrap-around is performed</param>
 public void Draw(IDisplayDevice displayDevice, Rectangle mapViewport, Location displayOffset, bool wrapAround)
 {
     if (wrapAround)
         DrawWrapped(displayDevice, mapViewport, displayOffset);
     else
         DrawNormal(displayDevice, mapViewport, displayOffset);
 }
Beispiel #40
0
        private static Object CheckForNearbySeedMakers(GameLocation currentLocation, Location location, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            Vector2 key = new Vector2((float)location.X, (float)location.Y);

            if (currentLocation.objects.ContainsKey(key) && currentLocation.objects[key].Name.Equals("Seed Maker"))
            {
                return(currentLocation.objects[key]);
            }
            return(null);
        }
Beispiel #41
0
        private void DrawWrapped(IDisplayDevice displayDevice, Rectangle mapViewport, Location displayOffset)
        {
            if (BeforeDraw != null)
                BeforeDraw(this, new LayerEventArgs(this, mapViewport));

            // store local values for performance
            int tileWidth = m_tileSize.Width;
            int tileHeight = m_tileSize.Height;
            int layerWidth = m_layerSize.Width;
            int layerHeight = m_layerSize.Height;

            // determine internal tile offset
            Location tileInternalOffset = new Location(
                Wrap(mapViewport.X, tileWidth),
                Wrap(mapViewport.Y, tileHeight));

            // determine tile-level viewport location
            int tileXMin = mapViewport.X >= 0 ? mapViewport.X / tileWidth : (mapViewport.X - tileWidth + 1) / tileWidth;
            int tileYMin = mapViewport.Y >= 0 ? mapViewport.Y / tileHeight : (mapViewport.Y - tileHeight + 1) / tileHeight;

            // determine tile-level viewport size
            int tileColumns = 1 + (mapViewport.Size.Width - 1) / tileWidth;
            int tileRows = 1 + (mapViewport.Size.Height - 1) / tileHeight;

            // increment tile-level viewport size if display not tile-aligned
            if (tileInternalOffset.X != 0)
                ++tileColumns;
            if (tileInternalOffset.Y != 0)
                ++tileRows;

            // determine tile-level viewport size limits
            int tileXMax = tileXMin + tileColumns;
            int tileYMax = tileYMin + tileRows;

            Location tileLocation = displayOffset - tileInternalOffset;

            for (int tileY = tileYMin; tileY < tileYMax; tileY++)
            {
                tileLocation.X = displayOffset.X - tileInternalOffset.X;
                for (int tileX = tileXMin; tileX < tileXMax; tileX++)
                {
                    Tile tile = m_tiles[Wrap(tileX, layerWidth), Wrap(tileY, layerHeight)];

                    if (tile != null)
                        displayDevice.DrawTile(tile, tileLocation);

                    tileLocation.X += tileWidth;
                }
                tileLocation.Y += tileHeight;
            }

            if (AfterDraw != null)
                AfterDraw(this, new LayerEventArgs(this, mapViewport));
        }
Beispiel #42
0
        public override void init()
        {
            //Shader stuff
            mDevice = mManager.mGraphicsDevice;
            tempBinding = mDevice.GetRenderTargets();
            tempRenderTarget = new RenderTarget2D(mDevice, 1280, 720);

            blurShader = new BlurFocusShader(mDevice, tempRenderTarget, mManager.blur);
            //rippleShader = new RippleShader(mDevice, tempRenderTarget, mManager.ripple);
            //Shader stuff ends

            //Map stuff
            map = mManager.mGame.Content.Load<Map>("maps\\" + mManager.mLevelName);
            mapDisplayDevice = new XnaDisplayDevice(mManager.mGame.Content, mDevice);
            map.LoadTileSheets(mapDisplayDevice);
            viewport = new xTile.Dimensions.Rectangle(new Size(1280, 720));
            //Map stuff done

            scoreCounter = new ScoreCounter();
            camera = new Camera();
            runEffect = new ParticleEffect(mManager.particleEffect, ParticleEffect.ParticleType.Dust, BlendState.AlphaBlend, camera);
            explosion = new ParticleEffect(mManager.particleEffect, ParticleEffect.ParticleType.Explosion, BlendState.Additive, camera);
            input = new GetInput(PlayerIndex.One);
            player = new Hero(mManager.heroSprites);
            shotList = new List<Shot>();
            puncheeList = new List<Punchee>();
            scoreAreaList = new List<ScoreArea>();
            chargingSoundEffect = mManager.chargingSound.CreateInstance();
            chargingSoundEffect.Pitch = 0.2f;

            attachEventListener();

            for (int i = 0; i < map.Layers[0].LayerWidth; i++)
            {
                for (int j = 0; j < map.Layers[0].LayerHeight; j++)
                {
                    Layer collision = map.Layers[0];
                    Location tileLocation = new Location(i, j);
                    Tile tile = collision.Tiles[tileLocation];

                    if (tile.TileIndex == 90)
                    {
                        ParticleEffect trail = new ParticleEffect(mManager.particleEffect, ParticleEffect.ParticleType.Knockback, BlendState.AlphaBlend, camera);
                        Punchee punched = new Punchee(mManager.startScreen, trail);
                        FollowAI followAI = new FollowAI(punched, player);
                        punched.addAI(followAI);
                        punched.mPosition.X = 32 * i;
                        punched.mPosition.Y = 32 * j;
                        puncheeList.Add(punched);
                    }

                    if (tile.TileIndex == 77)
                    {
                        int posX = i * 32;
                        int posY = j * 32;

                        ScoreArea scoreArea = new ScoreArea(posX, posY);
                        scoreAreaList.Add(scoreArea);
                    }
                }
            }
        }
Beispiel #43
0
        /// <summary>
        /// Visually renders this Map using the given display device and
        /// viewport into the map. The viewport is rendered at the given
        /// display offset. If wrapAround is set to True, the map wraps
        /// around at the edges across and / or down.
        /// </summary>
        /// <param name="displayDevice">Display device on which to render the Map</param>
        /// <param name="mapViewport">Viewport into the Map to be rendered</param>
        /// <param name="displayOffset">Pixel offset on the device where to render the map</param>
        /// <param name="wrapAround">Flag indicating if map wrap-around is performed</param>
        public void Draw(IDisplayDevice displayDevice, Rectangle mapViewport, Location displayOffset, bool wrapAround)
        {
            displayDevice.BeginScene();

            Rectangle deviceViewport = new Rectangle(displayOffset, mapViewport.Size);
            displayDevice.SetViewport(deviceViewport);

            foreach (Layer layer in m_layers)
            {
                if (!layer.Visible)
                    continue;

                Rectangle layerViewport = layer.ConvertMapToLayerViewport(mapViewport);
                layer.Draw(displayDevice, layerViewport, displayOffset, wrapAround);
            }

            displayDevice.EndScene();
        }
Beispiel #44
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     if (!Game1.eventUp && train.Value != null && train.Value.getBoundingBox().Intersects(position))
     {
         return(true);
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
Beispiel #45
0
        protected override void Update(GameTime gameTime)
        {
            InputManager.Update();

            //Update Characters
            foreach (MapCharacter i in mapCharacter)
                if (i.Visible == true) { i.Update(); }

            if (InputManager.Select)
                this.Exit();
            if ((InputManager.Right) && ((!mapCharacter[0].isMoving) && (!InputManager.Up) && (!InputManager.Down)))
                mapCharacter[0].Move(2);
            if ((InputManager.Left) && ((!mapCharacter[0].isMoving) && (!InputManager.Up) && (!InputManager.Down)))
                mapCharacter[0].Move(3);
            if ((InputManager.Up) && (!mapCharacter[0].isMoving))
                mapCharacter[0].Move(0);
            if ((InputManager.Down) && (!mapCharacter[0].isMoving))
                mapCharacter[0].Move(1);
            if (InputManager.Cancel)
                mapCharacter[0].Running = true;
            if (!InputManager.Cancel)
            {
                mapCharacter[0].Running = false;
            }
            if (InputManager.Confirm)
            {
            }
            if (InputManager.Y)
            {
            }

            if ((InputManager.X))
            {
                mapCharacter[1].MoveFor(2, 1);
            }

            Camera.FollowCharacter(mapCharacter[0], ScreenCenter);

            GameMap.Update(gameTime.ElapsedGameTime.Milliseconds);

            //Update the viewport to current zoomed size
            viewport = new xTile.Dimensions.Rectangle(
                new Location(Camera.X, Camera.Y),
                new Size( (int)TempResolution.X, (int)TempResolution.Y));
            //Wrapping Viewports
            viewportNorth = new xTile.Dimensions.Rectangle(
                new Location(Camera.X, ( Camera.Y - GlobalVariables.TileMapResolutionY) ),
                new Size((int)TempResolution.X, (int)TempResolution.Y));
            viewportSouth = new xTile.Dimensions.Rectangle(
                new Location(Camera.X, (Camera.Y + GlobalVariables.TileMapResolutionY)),
                new Size((int)TempResolution.X, (int)TempResolution.Y));
            viewportEast = new xTile.Dimensions.Rectangle(
                new Location( (Camera.X + GlobalVariables.TileMapResolutionX), Camera.Y),
                new Size((int)TempResolution.X, (int)TempResolution.Y));
            viewportWest = new xTile.Dimensions.Rectangle(
                new Location((Camera.X - GlobalVariables.TileMapResolutionX), Camera.Y),
                new Size((int)TempResolution.X, (int)TempResolution.Y));

            //Update the RenderTarget2D
            renderTarget = new RenderTarget2D(GraphicsDevice, (int)TempResolution.X, (int)TempResolution.Y, false, SurfaceFormat.Color, 0);

            //Used for rotation origin, also screen positioning
            ScreenCenter.X = (TempResolution.X / 2);
            ScreenCenter.Y = (TempResolution.Y / 2);

            //Used for drawing sprites, to keep them in sync with the scrolled map
            viewportOffset.X = viewport.Location.X;
            viewportOffset.Y = viewport.Location.Y;

            base.Update(gameTime);

            Console.WriteLine(viewport.Location);
        }
Beispiel #46
0
        public static bool IsTilePassable(GameLocation location, Location tileLocation, xTile.Dimensions.Rectangle viewport)
        {
            PropertyValue passable = null;

            Microsoft.Xna.Framework.Rectangle tileLocationRect = new Microsoft.Xna.Framework.Rectangle((int)tileLocation.X * 64, (int)tileLocation.Y * 64, 64, 64);
            Tile tmp = location.map.GetLayer("Back").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size);

            if (tmp != null)
            {
                tmp.TileIndexProperties.TryGetValue("Passable", out passable);
            }
            Tile tile = location.map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size);

            if (location.largeTerrainFeatures != null)
            {
                using (NetCollection <LargeTerrainFeature> .Enumerator enumerator = location.largeTerrainFeatures.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Current.getBoundingBox().Intersects(tileLocationRect))
                        {
                            return(false);
                        }
                    }
                }
            }
            Vector2 vLocation = new Vector2(tileLocation.X, tileLocation.Y);

            if (location.terrainFeatures.ContainsKey(vLocation) && tileLocationRect.Intersects(location.terrainFeatures[vLocation].getBoundingBox(vLocation)) && (!location.terrainFeatures[vLocation].isPassable(null) || (location.terrainFeatures[vLocation] is HoeDirt && ((HoeDirt)location.terrainFeatures[vLocation]).crop != null)))
            {
                return(false);
            }
            bool result = passable == null && tile == null && tmp != null;

            return(result);
        }
Beispiel #47
0
        private void OnViewViewportSetSize(object sender, EventArgs eventArgs)
        {
            ToolStripMenuItem toolStripMenuItemSelected = (ToolStripMenuItem)sender;
            string sizeTag = toolStripMenuItemSelected.Tag.ToString();
            Size viewPortSize = xTile.Dimensions.Size.FromString(sizeTag);

            Rectangle viewport = new Rectangle(
                xTile.Dimensions.Location.Origin, viewPortSize);

            m_mapPanel.AutoScaleViewport = false;
            m_mapPanel.Viewport = viewport;

            foreach (ToolStripMenuItem toolStripMenuItem in m_viewViewportMenuItem.DropDownItems)
                toolStripMenuItem.Checked
                    = toolStripMenuItem == toolStripMenuItemSelected;
        }
Beispiel #48
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ScaleFactorX = (((int)ScreenResolution.Y / (int)AspectRatio.Y) * (int)AspectRatio.X);
            //destinationRect.X = ((int)ScreenResolution.X / 2);
            //destinationRect.Y = ((int)ScreenResolution.Y / 2);
            //destinationRect.Height = (int)ScreenResolution.Y;
            //destinationRect.Width = (ScaleFactorX);

            Camera.X = 0;
            Camera.Y = 0;
            mapDisplayDevice = new XnaDisplayDevice(
                this.Content, this.GraphicsDevice);

            viewport = new xTile.Dimensions.Rectangle(new Size((int)TempResolution.X, (int)TempResolution.Y));
            //viewportL = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) );
            //viewportR = new xTile.Dimensions.Rectangle(new Size( (int)TempResolution.X, (int)TempResolution.Y) );
            renderTarget = new RenderTarget2D(GraphicsDevice, (int)TempResolution.X, (int)TempResolution.Y, false, SurfaceFormat.Color, 0);

            ///Initialize Objects
            //Characters
            mapCharacter = new MapCharacter[255];
            for (int i = 0; i < 255; i++)
                mapCharacter[i] = new MapCharacter(Content.Load<Texture2D>("Texture//Character//00"), 9, 0, 0);
            mapCharacter[0].Visible = true;
            mapCharacter[1].Visible = true;
            //Maps
            GameMap.LoadTileSheets(mapDisplayDevice);
        }
Beispiel #49
0
        protected override void Initialize()
        {
            base.Initialize();

            m_xnaDisplayDevice = new XnaDisplayDevice(this.Content, graphics.GraphicsDevice);
            map.LoadTileSheets(m_xnaDisplayDevice);
            viewport = new xTile.Dimensions.Rectangle(new Size(800,600));

            viewport.X = 0;
            viewport.Y = 280;
        }
Beispiel #50
0
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character, bool pathfinding, bool projectile = false, bool ignoreCharacterRequirement = false)
 {
     foreach (KeyValuePair <long, FarmAnimal> animal in (Dictionary <long, FarmAnimal>) this.animals)
     {
         if (character != null && !character.Equals((object)animal.Value) && position.Intersects(animal.Value.GetBoundingBox()))
         {
             animal.Value.farmerPushing();
             return(true);
         }
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character, pathfinding, false, false));
 }
Beispiel #51
0
        public MapPanel()
        {
            InitializeComponent();

            m_commandHistory = CommandHistory.Instance;

            m_singleTileCursor = new Cursor(new MemoryStream(Properties.Resources.ToolsSingleTileCursor));
            m_tileBlockCursor = new Cursor(new MemoryStream(Properties.Resources.ToolsTileBlockCursor));
            m_eraserCursor = new Cursor(new MemoryStream(Properties.Resources.ToolsEraserCursor));
            m_dropperCursor = new Cursor(new MemoryStream(Properties.Resources.ToolsDropperCursor));

            m_viewport = new xTile.Dimensions.Rectangle(
                xTile.Dimensions.Location.Origin, xTile.Dimensions.Size.Zero);
            m_autoScaleViewport = true;

            m_zoomIndex = 5;
            m_zoom = 1.0f;

            m_layerCompositing = LayerCompositing.DimUnselected;

            m_editTool = EditTool.SingleTile;
            m_innerPanel.Cursor = m_singleTileCursor;
            m_mouseInside = false;
            m_mouseLocation = new Location();
            m_tileLayerLocation = xTile.Dimensions.Location.Origin;
            m_dragTileStart = xTile.Dimensions.Location.Origin;

            m_tileSelection = new TileSelection();
            m_ctrlKeyPressed = false;

            m_random = new Random();
            m_textureDistribution = new List<Tile>();

            m_tileGuides = false;

            m_veilBrush = new SolidBrush(Color.FromArgb(192, SystemColors.InactiveCaption));
            m_imageAttributes = new ImageAttributes();
            m_colorMatrix = new ColorMatrix();
            m_tileSelectionPen = new Pen(SystemColors.ActiveCaption);
            m_tileSelectionBrush = new SolidBrush(
                Color.FromArgb(128, SystemColors.ActiveCaption));

            m_dashPattern = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
            m_tileGuidePen = new Pen(Color.Black);
            m_tileGuidePen.DashPattern = m_dashPattern;

            m_animationTimer.Enabled = !this.DesignMode;

            m_dtStart = DateTime.Now;

            this.MouseWheel += new MouseEventHandler(OnMouseWheel);
        }
 // Token: 0x060011B4 RID: 4532 RVA: 0x0016B070 File Offset: 0x00169270
 public override bool isCollidingPosition(Microsoft.Xna.Framework.Rectangle position, xTile.Dimensions.Rectangle viewport, bool isFarmer, int damagesFarmer, bool glider, Character character)
 {
     foreach (ResourceClump expr_15 in this.stumps)
     {
         if (expr_15.getBoundingBox(expr_15.tile).Intersects(position))
         {
             return(true);
         }
     }
     return(base.isCollidingPosition(position, viewport, isFarmer, damagesFarmer, glider, character));
 }
Beispiel #53
0
 /// <summary>
 /// Extends this Rectangle to contain the given Rectangle
 /// </summary>
 /// <param name="rectangle">Rectangle to contain</param>
 public void ExtendTo(Rectangle rectangle)
 {
     Location corner = rectangle.Location;
     ExtendTo(corner);
     corner.X += rectangle.Size.Width - 1;
     ExtendTo(corner);
     corner.Y += rectangle.Size.Height - 1;
     ExtendTo(corner);
     corner.X -= rectangle.Size.Width - 1;
     ExtendTo(corner);
 }
Beispiel #54
0
 public TileSelection()
 {
     m_tileSelections = new Dictionary<Location, TileSelectionBorder>();
     m_bounds = new Rectangle(Location.Origin, Size.Zero);
 }
Beispiel #55
0
 /// <summary>
 /// Constructs a Rectangle from another one
 /// </summary>
 /// <param name="rectangle">Rectangle to clone</param>
 public Rectangle(Rectangle rectangle)
 {
     Location = rectangle.Location;
     Size = rectangle.Size;
 }
        public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            if (map.GetLayer("Buildings").Tiles[tileLocation] != null)
            {
                switch (map.GetLayer("Buildings").Tiles[tileLocation].TileIndex)
                {
                case 595:
                    if (Game1.timeOfDay < 1700)
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_Closed"));
                    }
                    else
                    {
                        Game1.activeClickableMenu = new ShopMenu(getBlueBoatStock(), 0, "BlueBoat");
                    }
                    break;

                case 69:
                case 877:
                    if (Game1.timeOfDay < 1700)
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_GiftGiverClosed"));
                    }
                    else if (!hasReceivedFreeGift)
                    {
                        createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_GiftGiverQuestion"), createYesNoResponses(), "GiftGiverQuestion");
                    }
                    else
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_GiftGiverEnjoy"));
                    }
                    break;

                case 653:
                    if ((Game1.getLocationFromName("Submarine") as Submarine).submerged.Value || Game1.netWorldState.Value.IsSubmarineLocked)
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_SubmarineInUse"));
                        return(true);
                    }
                    break;

                case 399:
                    if (Game1.timeOfDay < 1700)
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_Closed"));
                    }
                    else
                    {
                        Game1.activeClickableMenu = new ShopMenu(Utility.getTravelingMerchantStock((int)(Game1.uniqueIDForThisGame + Game1.stats.DaysPlayed)), 0, "TravelerNightMarket", Utility.onTravelingMerchantShopPurchase);
                    }
                    break;

                case 70:
                    if (Game1.timeOfDay < 1700)
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_Closed"));
                    }
                    else
                    {
                        Game1.activeClickableMenu = new ShopMenu(geMagicShopStock(), 0, "magicBoatShop");
                    }
                    break;

                case 68:
                    if (Game1.timeOfDay < 1700)
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_PainterClosed"));
                    }
                    else if (Game1.player.mailReceived.Contains(paintingMailKey))
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_PainterSold"));
                    }
                    else
                    {
                        createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_PainterQuestion"), createYesNoResponses(), "PainterQuestion");
                    }
                    break;

                case 1285:
                    createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:BeachNightMarket_WarperQuestion"), createYesNoResponses(), "WarperQuestion");
                    break;
                }
            }
            return(base.checkAction(tileLocation, viewport, who));
        }
Beispiel #57
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // set window title (PC version, windowed mode only)
            #if WINDOWS
            Window.Title = "xTile XNA Demo Application (Windows)";
            #elif XBOX
            Window.Title = "xTile XNA Demo Application (XBOX 360)";
            #elif ZUNE
            Window.Title = "xTile XNA Demo Application (Zune)";
            #elif WINDOWS_PHONE
            Window.Title = "xTile XNA Demo Application (Windows Phone)";
            #endif

            // set map viewport to match window size
            m_viewPort = new xTile.Dimensions.Rectangle(0, 0,
                m_graphicsDeviceManager.PreferredBackBufferWidth,
                m_graphicsDeviceManager.PreferredBackBufferHeight);

            // set help panel size
            #if WINDOWS
            m_panelRectangle = new Microsoft.Xna.Framework.Rectangle(
                0, m_viewPort.Height - 104, m_viewPort.Width, 104);
            #elif XBOX360
            m_panelRectangle = new Microsoft.Xna.Framework.Rectangle(
                0, m_viewPort.Height - 80, m_viewPort.Width, 80);
            #elif WINDOWS_PHONE
            m_panelRectangle = new Microsoft.Xna.Framework.Rectangle(
                0, m_viewPort.Height - 56, m_viewPort.Width, 56);
            #endif

            m_vecLeafPositions = new Vector2[20];
            m_vecLeafVelocities = new Vector2[m_vecLeafPositions.Length];
            Random random = new Random();
            for (int index = 0; index < m_vecLeafPositions.Length; index++)
            {
                m_vecLeafPositions[index] = new Vector2(
                    random.Next(m_viewPort.Width), random.Next(m_viewPort.Height));
                m_vecLeafVelocities[index] = new Vector2(
                    1 + random.Next(4), 1 + random.Next(3));
            }

            base.Initialize();
        }
Beispiel #58
0
        public static void drawLayer(Layer layer, xTile.Display.IDisplayDevice device, xTile.Dimensions.Rectangle viewport, int pixelZoom, Location offset, bool wrap = false)
        {
            if (layer.Properties.ContainsKey("DrawConditions") && !layer.Properties.ContainsKey("DrawConditionsResult") && Game1.currentLocation is GameLocation gl && gl.Map is Map m)
            {
                PyUtils.checkDrawConditions(m);
            }

            if (layer.Properties.ContainsKey("DrawConditions") && (!layer.Properties.ContainsKey("DrawConditionsResult") || layer.Properties["DrawConditionsResult"] != "T"))
            {
                return;
            }


            if (!layer.Properties.ContainsKey("OffestXReset"))
            {
                layer.Properties["OffestXReset"] = offset.X;
                layer.Properties["OffestYReset"] = offset.Y;
            }

            if (!layer.Properties.ContainsKey("StartX"))
            {
                Vector2 local = Game1.GlobalToLocal(new Vector2(offset.X, offset.Y));
                layer.Properties["StartX"] = local.X;
                layer.Properties["StartY"] = local.Y;
            }

            if (layer.Properties.ContainsKey("AutoScrollX"))
            {
                string[] ax = layer.Properties["AutoScrollX"].ToString().Split(',');
                int      cx = int.Parse(ax[0]);
                int      mx = 1;
                if (ax.Length > 1)
                {
                    mx = int.Parse(ax[1]);
                }

                if (cx < 0)
                {
                    mx *= -1;
                }

                if (Game1.currentGameTime.TotalGameTime.Ticks % cx == 0)
                {
                    offset.X += mx;
                }
            }

            if (layer.Properties.ContainsKey("AutoScrollY"))
            {
                string[] ay = layer.Properties["AutoScrollY"].ToString().Split(',');
                int      cy = int.Parse(ay[0]);
                int      my = 1;
                if (ay.Length > 1)
                {
                    my = int.Parse(ay[1]);
                }

                if (cy < 0)
                {
                    my *= -1;
                }

                if (Game1.currentGameTime.TotalGameTime.Ticks % cy == 0)
                {
                    offset.Y += my;
                }
            }

            layer.SetOffset(offset);

            if (layer.Properties.ContainsKey("tempOffsetx") && layer.Properties.ContainsKey("tempOffsety"))
            {
                offset = new Location(int.Parse(layer.Properties["tempOffsetx"]), int.Parse(layer.Properties["tempOffsety"]));
            }

            if (layer.IsImageLayer())
            {
                drawImageLayer(layer, offset, wrap);
            }
            else
            {
                layer.Draw(device, viewport, offset, wrap, pixelZoom);
            }
        }
Beispiel #59
0
        public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            Tile tile = this.map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * Game1.tileSize, tileLocation.Y * Game1.tileSize), viewport.Size);

            if (tile != null && Game1.year == 1 && Game1.dayOfMonth == 0 && who.IsMainPlayer)
            {
                int tileIndex = tile.TileIndex;
                if (tileIndex <= 238)
                {
                    if (tileIndex <= 225)
                    {
                        if (tileIndex != 221)
                        {
                            if (tileIndex == 225)
                            {
                                if (!this.talkedToHaley)
                                {
                                    Game1.drawDialogue(Game1.getCharacterFromName("Haley", false), Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7152", new object[0])));
                                }
                                else
                                {
                                    Game1.drawDialogue(Game1.getCharacterFromName("Haley", false), Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7154", new object[0])));
                                }
                                this.talkedToHaley = true;
                            }
                        }
                        else
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7130", new object[0]));
                        }
                    }
                    else
                    {
                        switch (tileIndex)
                        {
                        case 229:
                            if (!this.talkedToMan)
                            {
                                Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7134", new object[0])));
                            }
                            break;

                        case 230:
                        case 231:
                            break;

                        case 232:
                            Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7135", new object[0])));
                            break;

                        case 233:
                            if (!this.talkedToOldLady)
                            {
                                Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7136", new object[0])));
                            }
                            else
                            {
                                Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7137", new object[0])));
                            }
                            this.talkedToOldLady = true;
                            break;

                        default:
                            if (tileIndex != 236)
                            {
                                if (tileIndex == 238)
                                {
                                    if (this.talkedToHaley)
                                    {
                                        this.busEvent();
                                    }
                                    else
                                    {
                                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7150", new object[0])));
                                    }
                                }
                            }
                            else
                            {
                                switch (this.timesBagAttempt)
                                {
                                case 0:
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7140", new object[0])));
                                    goto IL_4D6;

                                case 1:
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7141", new object[0])));
                                    goto IL_4D6;

                                case 2:
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7142", new object[0])));
                                    goto IL_4D6;

                                case 3:
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7143", new object[0])));
                                    goto IL_4D6;

                                case 4:
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7144", new object[0])));
                                    goto IL_4D6;

                                case 5:
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7145", new object[0])));
                                    goto IL_4D6;

                                case 10:
                                    Game1.multipleDialogues(new string[]
                                    {
                                        Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7146", new object[0])),
                                        Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7147", new object[0]))
                                    });
                                    Game1.player.money++;
                                    goto IL_4D6;
                                }
                                Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7148", new object[0])));
IL_4D6:
                                this.timesBagAttempt++;
                            }
                            break;
                        }
                    }
                }
                else if (tileIndex <= 270)
                {
                    if (tileIndex != 265)
                    {
                        if (tileIndex != 266)
                        {
                            if (tileIndex == 270)
                            {
                                if (!this.talkedToWoman)
                                {
                                    Game1.multipleDialogues(new string[]
                                    {
                                        Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7131", new object[0])),
                                        Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7132", new object[0]))
                                    });
                                }
                                else
                                {
                                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7133", new object[0])));
                                }
                                this.talkedToWoman = true;
                            }
                        }
                        else if (Game1.player.isMale)
                        {
                            Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7129", new object[0])));
                        }
                    }
                    else
                    {
                        Game1.drawObjectDialogue((Game1.player.isMale || this.talkedToKid) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7127", new object[0]) : Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7128", new object[0]));
                        this.talkedToKid = true;
                    }
                }
                else if (tileIndex != 274)
                {
                    if (tileIndex != 278)
                    {
                        if (tileIndex == 459)
                        {
                            Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7149", new object[0])));
                        }
                    }
                    else
                    {
                        Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7139", new object[0]));
                    }
                }
                else if (!this.foundChange)
                {
                    Game1.player.money += 20;
                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Bus.cs.7138", new object[0])));
                }
                else
                {
                    this.foundChange = true;
                }
                return(true);
            }
            return(base.checkAction(tileLocation, viewport, who));
        }
Beispiel #60
0
 public void update(xTile.Dimensions.Rectangle viewport)
 {
     position.X = 0f - (float)(viewport.X + viewport.Width / 2) / ((float)Game1.currentLocation.map.GetLayer("Back").LayerWidth * 64f) * ((float)(chunksWide * chunkWidth) * zoom - (float)viewport.Width);
     position.Y = 0f - (float)(viewport.Y + viewport.Height / 2) / ((float)Game1.currentLocation.map.GetLayer("Back").LayerHeight * 64f) * ((float)(chunksHigh * chunkHeight) * zoom - (float)viewport.Height);
 }