Example #1
0
 public static void GameLoop_DayStarted(object sender, DayStartedEventArgs e)
 {
     foreach (KeyValuePair <string, DiveMap> kvp in ModEntry.diveMaps)
     {
         GameLocation location = Game1.getLocationFromName(kvp.Key);
         if (location == null)
         {
             Monitor.Log($"GameLocation {kvp.Key} not found in day started loop");
             continue;
         }
         if (kvp.Value.Features.Contains("OceanTreasure") || kvp.Value.Features.Contains("OceanResources") || kvp.Value.Features.Contains("Minerals"))
         {
             Monitor.Log($"Clearing overlay objects from GameLocation {location.Name} ");
             location.overlayObjects.Clear();
         }
         if (kvp.Value.Features.Contains("OceanTreasure"))
         {
             Monitor.Log($"Adding ocean treasure to GameLocation {location.Name} ");
             SwimMaps.AddOceanTreasure(location);
         }
         if (kvp.Value.Features.Contains("OceanResources"))
         {
             Monitor.Log($"Adding ocean forage to GameLocation {location.Name} ");
             SwimMaps.AddOceanForage(location);
         }
         if (kvp.Value.Features.Contains("Minerals"))
         {
             Monitor.Log($"Adding minerals to GameLocation {location.Name} ");
             SwimMaps.AddMinerals(location);
         }
         if (kvp.Value.Features.Contains("SmolFishies") || kvp.Value.Features.Contains("BigFishies") || kvp.Value.Features.Contains("Crabs"))
         {
             Monitor.Log($"Clearing characters from GameLocation {location.Name} ");
             location.characters.Clear();
         }
         if (kvp.Value.Features.Contains("SmolFishies"))
         {
             Monitor.Log($"Adding smol fishies to GameLocation {location.Name} ");
             SwimMaps.AddFishies(location);
         }
         if (kvp.Value.Features.Contains("BigFishies"))
         {
             Monitor.Log($"Adding big fishies to GameLocation {location.Name} ");
             SwimMaps.AddFishies(location, false);
         }
         if (kvp.Value.Features.Contains("Crabs"))
         {
             Monitor.Log($"Adding crabs to GameLocation {location.Name} ");
             SwimMaps.AddCrabs(location);
         }
         if (kvp.Value.Features.Contains("WaterTiles"))
         {
             Monitor.Log($"Adding water tiles to GameLocation {location.Name} ");
             SwimMaps.AddWaterTiles(location);
         }
         if (kvp.Value.Features.Contains("Underwater"))
         {
             Monitor.Log($"Removing water tiles from GameLocation {location.Name} ");
             SwimMaps.RemoveWaterTiles(location);
         }
     }
     if (Game1.getLocationFromName("ScubaCave") != null && !Game1.player.mailReceived.Contains("ScubaMask"))
     {
         SwimMaps.AddScubaChest(Game1.getLocationFromName("ScubaCave"), new Vector2(10, 14), "ScubaMask");
     }
     ModEntry.marinerQuestionsWrongToday = false;
     ModEntry.oxygen = SwimUtils.MaxOxygen();
 }
Example #2
0
        public static void AbigailCaveTick()
        {
            Game1.player.CurrentToolIndex = Game1.player.items.Count;

            List <NPC> list = Game1.player.currentLocation.characters.ToList().FindAll((n) => (n is Monster) && (n as Monster).Health <= 0);

            foreach (NPC n in list)
            {
                Game1.player.currentLocation.characters.Remove(n);
            }

            if (abigailTicks < 0)
            {
                return;
            }
            Game1.exitActiveMenu();

            if (abigailTicks == 0)
            {
                FieldInfo f1 = Game1.player.currentLocation.characters.GetType().GetField("OnValueRemoved", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                f1.SetValue(Game1.player.currentLocation.characters, null);
            }

            Vector2 v   = Vector2.Zero;
            float   yrt = (float)(1 / Math.Sqrt(2));

            if (Helper.Input.IsDown(SButton.Up))
            {
                if (Helper.Input.IsDown(SButton.Right))
                {
                    v = new Vector2(yrt, -yrt);
                }
                else if (Helper.Input.IsDown(SButton.Left))
                {
                    v = new Vector2(-yrt, -yrt);
                }
                else
                {
                    v = new Vector2(0, -1);
                }
            }
            else if (Helper.Input.IsDown(SButton.Down))
            {
                if (Helper.Input.IsDown(SButton.Right))
                {
                    v = new Vector2(yrt, yrt);
                }
                else if (Helper.Input.IsDown(SButton.Left))
                {
                    v = new Vector2(-yrt, yrt);
                }
                else
                {
                    v = new Vector2(0, 1);
                }
            }
            else if (Helper.Input.IsDown(SButton.Right))
            {
                v = new Vector2(1, 0);
            }
            else if (Helper.Input.IsDown(SButton.Left))
            {
                v = new Vector2(-1, 0);
            }
            else if (Helper.Input.IsDown(SButton.MouseLeft))
            {
                float x  = Game1.viewport.X + Game1.getOldMouseX() - Game1.player.position.X;
                float y  = Game1.viewport.Y + Game1.getOldMouseY() - Game1.player.position.Y;
                float dx = Math.Abs(x);
                float dy = Math.Abs(y);
                if (y < 0)
                {
                    if (x > 0)
                    {
                        if (dy > dx)
                        {
                            if (dy - dx > dy / 2)
                            {
                                v = new Vector2(0, -1);
                            }
                            else
                            {
                                v = new Vector2(yrt, -yrt);
                            }
                        }
                        else
                        {
                            if (dx - dy > x / 2)
                            {
                                v = new Vector2(1, 0);
                            }
                            else
                            {
                                v = new Vector2(yrt, -yrt);
                            }
                        }
                    }
                    else
                    {
                        if (dy > dx)
                        {
                            if (dy - dx > dy / 2)
                            {
                                v = new Vector2(0, -1);
                            }
                            else
                            {
                                v = new Vector2(-yrt, -yrt);
                            }
                        }
                        else
                        {
                            if (dx - dy > x / 2)
                            {
                                v = new Vector2(-1, 0);
                            }
                            else
                            {
                                v = new Vector2(-yrt, -yrt);
                            }
                        }
                    }
                }
                else
                {
                    if (x > 0)
                    {
                        if (dy > dx)
                        {
                            if (dy - dx > dy / 2)
                            {
                                v = new Vector2(0, 1);
                            }
                            else
                            {
                                v = new Vector2(yrt, yrt);
                            }
                        }
                        else
                        {
                            if (dx - dy > x / 2)
                            {
                                v = new Vector2(1, 0);
                            }
                            else
                            {
                                v = new Vector2(yrt, yrt);
                            }
                        }
                    }
                    else
                    {
                        if (dy > dx)
                        {
                            if (dy - dx > dy / 2)
                            {
                                v = new Vector2(0, -1);
                            }
                            else
                            {
                                v = new Vector2(-yrt, yrt);
                            }
                        }
                        else
                        {
                            if (dx - dy > x / 2)
                            {
                                v = new Vector2(-1, 0);
                            }
                            else
                            {
                                v = new Vector2(-yrt, yrt);
                            }
                        }
                    }
                }
            }

            if (v != Vector2.Zero && Game1.player.millisecondsPlayed - lastProjectile > 350)
            {
                Game1.player.currentLocation.projectiles.Add(new AbigailProjectile(1, 383, 0, 0, 0, v.X * 6, v.Y * 6, new Vector2(Game1.player.getStandingX() - 24, Game1.player.getStandingY() - 48), "Cowboy_monsterDie", "Cowboy_gunshot", false, true, Game1.player.currentLocation, Game1.player, true));
                lastProjectile = Game1.player.millisecondsPlayed;
            }

            foreach (SButton button in abigailShootButtons)
            {
                if (Helper.Input.IsDown(button))
                {
                    switch (button)
                    {
                    case SButton.Up:
                        break;

                    case SButton.Right:
                        v = new Vector2(1, 0);
                        break;

                    case SButton.Down:
                        v = new Vector2(0, 1);
                        break;

                    default:
                        v = new Vector2(-1, 0);
                        break;
                    }
                }
            }


            abigailTicks++;
            if (abigailTicks > 80000 / 16f)
            {
                if (Game1.player.currentLocation.characters.ToList().FindAll((n) => (n is Monster)).Count > 0)
                {
                    return;
                }

                abigailTicks           = -1;
                Game1.player.hat.Value = null;
                Game1.stopMusicTrack(Game1.MusicContext.Default);

                if (!Game1.player.mailReceived.Contains("ScubaFins"))
                {
                    Game1.playSound("Cowboy_Secret");
                    SwimMaps.AddScubaChest(Game1.player.currentLocation, new Vector2(8, 8), "ScubaFins");
                }

                Game1.player.currentLocation.setMapTile(8, 16, 91, "Buildings", null);
                Game1.player.currentLocation.setMapTile(9, 16, 92, "Buildings", null);
                Game1.player.currentLocation.setTileProperty(9, 16, "Back", "Water", "T");
                Game1.player.currentLocation.setMapTile(10, 16, 93, "Buildings", null);
                Game1.player.currentLocation.setMapTile(8, 17, 107, "Buildings", null);
                Game1.player.currentLocation.setMapTile(9, 17, 108, "Back", null);
                Game1.player.currentLocation.setTileProperty(9, 17, "Back", "Water", "T");
                Game1.player.currentLocation.removeTile(9, 17, "Buildings");
                Game1.player.currentLocation.setMapTile(10, 17, 109, "Buildings", null);
                Game1.player.currentLocation.setMapTile(8, 18, 139, "Buildings", null);
                Game1.player.currentLocation.setMapTile(9, 18, 140, "Buildings", null);
                Game1.player.currentLocation.setMapTile(10, 18, 141, "Buildings", null);
                SwimMaps.AddWaterTiles(Game1.player.currentLocation);
            }
            else
            {
                if (Game1.random.NextDouble() < 0.04)
                {
                    int   which = Game1.random.Next(3);
                    Point p     = new Point();
                    switch (Game1.random.Next(4))
                    {
                    case 0:
                        p = new Point(8 + which, 1);
                        break;

                    case 1:
                        p = new Point(1, 8 + which);
                        break;

                    case 2:
                        p = new Point(8 + which, 16);
                        break;

                    case 3:
                        p = new Point(16, 8 + which);
                        break;
                    }
                    Game1.player.currentLocation.characters.Add(new AbigailMetalHead(new Vector2(p.X * Game1.tileSize, p.Y * Game1.tileSize), 0));
                }
            }
        }