예제 #1
0
        public void AfterDayStarted(object sender, EventArgs e)
        {
            prefix = "";

            if (Game1.currentSeason.ToLower().Equals("spring") || Game1.currentSeason.ToLower().Equals("summer"))
            {
                prefix = "spring";
            }
            else if (Game1.currentSeason.ToLower().Equals("fall"))
            {
                prefix = "fall";
            }
            else
            {
                prefix = "winter";
            }

            // Determine spawn map
            // If player is married to Alex, make Dusty spawn on the farm or in the farm house
            if (Game1.getCharacterFromName("Alex", true).isMarried())
            {
                // If it's raining or snowing
                if (Game1.isRaining || Game1.isSnowing)
                {
                    spawnMap = Game1.getLocationFromName("FarmHouse");
                }
                else
                {
                    spawnMap = Game1.getLocationFromName("Farm");
                }
            }
            else if (!Game1.isRaining && !Game1.isSnowing)
            {
                spawnMap = Game1.getLocationFromName("Town");
            }

            // Find spawn point and spawn Dusty
            if (Game1.player.IsMainPlayer && spawnMap != null)
            {
                doggie = new Dusty(new AnimatedSprite("Dusty.xnb", 0, 29, 25), this.GetDustySpawn(), 0, "Dusty");
                spawnMap.addCharacter(doggie);
                Helper.Content.AssetEditors.Add(new BoxEditor(this.Helper, prefix, false));

                //this.Monitor.Log("Added Dusty to the spawn map.");
            }
            // If no spawn map could be determined, Dusty should be in his box
            else if (spawnMap == null)
            {
                Helper.Content.AssetEditors.Add(new BoxEditor(this.Helper, prefix, true));
            }

            if (spawnMap == null)
            {
                //this.Monitor.Log("Did not spawn Dusty today... or did I?");

                foreach (NPC n in Game1.getLocationFromName("Farm").getCharacters())
                {
                    //this.Monitor.Log(n.getName());

                    // If for some arcane reason Dusty ends up spawning EVEN THOUGH THERE IS NO WAY HE SHOULD, remove him again
                    if (n.getName().Equals("Dusty"))
                    {
                        Game1.getLocationFromName("Farm").characters.Remove(n);
                        //this.Monitor.Log("Found a stray Dusty and removed him.");
                        break;
                    }
                }
            }
            else
            {
                //this.Monitor.Log("Spawned Dusty at " + spawnMap.Name + " (" + doggie.Position.X / 64 + "/" + doggie.Position.Y / 64 + ")");
                //this.Monitor.Log("Is Dusty at " + spawnMap + "? -> " + spawnMap.characters.Contains(doggie));
            }



            /* // TODO: Figure this out
             *  /*
             * if(spawnMap.Name.Equals("Town")) {
             * for(int i=51; i<=54; i++)
             *   {
             *       for(int j=68; j<=70; j++)
             *       {
             *           spawnMap.setTileProperty(i, j, "Buildings", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "Back", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "Front", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "AlwaysFront", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "Paths", "Passable", "true");
             *
             *           //this.Monitor.Log("Made tile " + i + "/" + j + " walkable");
             *       }
             *   }
             *   }
             */

            Helper.Content.InvalidateCache(prefix + "_town");
            Helper.Content.InvalidateCache(@"/Maps/" + prefix + "_town");
        }
예제 #2
0
        private void AfterDayStarted(object sender, EventArgs e)
        {
            _prefix = "";
            switch (Game1.currentSeason.ToLower())
            {
            case "spring":
            case "summer":
                _prefix = "spring";
                break;

            case "fall":
                _prefix = "fall";
                break;

            default:
                _prefix = "winter";
                break;
            }

            // Determine spawn map
            // If player is married to Alex, make Dusty spawn on the farm or in the farm house
            if (Game1.getCharacterFromName("Alex").isMarried())
            {
                // If it's raining or snowing
                if (Game1.isRaining || Game1.isSnowing)
                {
                    _spawnMap = Game1.getLocationFromName("FarmHouse");
                }
                else
                {
                    _spawnMap = Game1.getLocationFromName("Farm");
                }
            }
            else if (!Game1.isRaining && !Game1.isSnowing)
            {
                _spawnMap = Game1.getLocationFromName("Town");
            }

            // Find spawn point and spawn Dusty
            if (Game1.player.IsMainPlayer && _spawnMap != null)
            {
                _doggie = new Dusty(new AnimatedSprite("Dusty.xnb", 0, 29, 25), GetDustySpawn(), 0, "Dusty");
                _spawnMap.addCharacter(_doggie);
                Helper.Content.AssetEditors.Add(new BoxEditor(Helper, _prefix));

                //this.Monitor.Log("Added Dusty to the spawn map.");
            }
            // If no spawn map could be determined, Dusty should be in his box
            else if (_spawnMap == null)
            {
                Helper.Content.AssetEditors.Add(new BoxEditor(Helper, _prefix, true));
            }

            if (_spawnMap == null)
            {
                //this.Monitor.Log("Did not spawn Dusty today... or did I?");
                foreach (var n in Game1.getLocationFromName("Farm").getCharacters()
                         .Where(n => n.getName().Equals("Dusty")))
                {
                    Game1.getLocationFromName("Farm").characters.Remove(n);
                    //this.Monitor.Log("Found a stray Dusty and removed him.");
                    break;
                }
            }

            /* // TODO: Figure this out
             *  /*
             * if(spawnMap.Name.Equals("Town")) {
             * for(int i=51; i<=54; i++)
             *   {
             *       for(int j=68; j<=70; j++)
             *       {
             *           spawnMap.setTileProperty(i, j, "Buildings", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "Back", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "Front", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "AlwaysFront", "Passable", "true");
             *           spawnMap.setTileProperty(i, j, "Paths", "Passable", "true");
             *
             *           //this.Monitor.Log("Made tile " + i + "/" + j + " walkable");
             *       }
             *   }
             *   }
             */
            Helper.Content.InvalidateCache(_prefix + "_town");
            Helper.Content.InvalidateCache(@"/Maps/" + _prefix + "_town");
        }