Exemplo n.º 1
0
        /// <summary>Raised before the game begins writes data to the save file (except the initial save creation).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void onSaving(object sender, SavingEventArgs e)
        {
            if (!Sleep.SaveLocation)
            {
                return;
            }

            Log.debug("Saving tent sleep data");

            if (Game1.player.currentLocation.Name == festivalLocation())
            {
                Log.trace("There'll be a festival here tomorrow, canceling");
                Game1.addHUDMessage(new HUDMessage("You camped out where the festival was, so you have returned home."));

                var house = Game1.getLocationFromName("FarmHouse") as FarmHouse;
                Game1.player.currentLocation = Game1.currentLocation = house;
                Game1.player.Position        = new Vector2(house.getBedSpot().X *Game1.tileSize, house.getBedSpot().Y *Game1.tileSize);
                Sleep.SaveLocation           = false;
                return;
            }

            var data = new Sleep.Data();

            data.Location = Game1.currentLocation.Name;
            if (data.X != -1 && data.Y != -1)
            {
                data.X = Game1.player.position.X;
                data.Y = Game1.player.position.Y;
            }

            data.Year   = Game1.year;
            data.Season = Game1.currentSeason;
            data.Day    = Game1.dayOfMonth;

            if (Game1.currentLocation is MineShaft)
            {
                data.MineLevel = (Game1.currentLocation as MineShaft).mineLevel;
            }

            Helper.Data.WriteSaveData("sleepy-eye", data);
            Sleep.SaveLocation = false;
        }
Exemplo n.º 2
0
        private void onSave(object sender, EventArgs args)
        {
            if (!Sleep.SaveLocation)
            {
                return;
            }

            Log.debug("Saving tent sleep data");

            if (Game1.player.currentLocation.name == festivalLocation())
            {
                Log.trace("There'll be a festival here tomorrow, canceling");
                Game1.addHUDMessage(new HUDMessage("You camped out where the festival was, so you have returned home."));

                var house = Game1.getLocationFromName("FarmHouse") as FarmHouse;
                Game1.player.currentLocation = Game1.currentLocation = house;
                Game1.player.position.X      = house.getBedSpot().X *Game1.tileSize;
                Game1.player.position.Y      = house.getBedSpot().Y *Game1.tileSize;
                Sleep.SaveLocation           = false;
                return;
            }

            var data = new Sleep.Data();

            data.Location = Game1.currentLocation.Name;
            data.X        = Game1.player.position.X;
            data.Y        = Game1.player.position.Y;

            data.Year   = Game1.year;
            data.Season = Game1.currentSeason;
            data.Day    = Game1.dayOfMonth;

            if (Game1.currentLocation is MineShaft)
            {
                data.MineLevel = (Game1.currentLocation as MineShaft).mineLevel;
            }

            Helper.WriteJsonFile <Sleep.Data>(Path.Combine(Constants.CurrentSavePath, "sleepy-eye.json"), data);
            Sleep.SaveLocation = false;
        }