示例#1
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);


            if (Health <= 0)
            {
                return;
            }

            this.lastGhost  = Math.Max(0f, this.lastGhost - (float)time.ElapsedGameTime.Milliseconds);
            this.lastDebuff = Math.Max(0f, this.lastDebuff - (float)time.ElapsedGameTime.Milliseconds);

            if (withinPlayerThreshold(10))
            {
                if (lastDebuff == 0f)
                {
                    Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);
                    if (ModEntry.IsLessThanHalfHealth(this))
                    {
                        for (int i = 0; i < 12; i++)
                        {
                            Vector2 trajectory = ModEntry.VectorFromDegree(i * 30) * 10f;
                            currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, trajectory.X, trajectory.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));
                        }
                    }
                    else
                    {
                        currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, velocityTowardPlayer.X, velocityTowardPlayer.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));
                    }


                    this.lastDebuff = Game1.random.Next(3000, 6000);
                }
                if (lastGhost == 0f)
                {
                    int ghosts = 0;
                    using (NetCollection <NPC> .Enumerator enumerator = currentLocation.characters.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NPC j = enumerator.Current;
                            if (j is ToughGhost)
                            {
                                ghosts++;
                            }
                        }
                    }
                    if (ghosts < (Health < MaxHealth / 2 ? this.MaxGhosts * 2 : this.MaxGhosts))
                    {
                        GameLocation aLocation = currentLocation;
                        currentLocation.characters.Add(new ToughGhost(Position, difficulty)
                        {
                            focusedOnFarmers = true
                        });
                        this.lastGhost = (float)Game1.random.Next(3000, 80000);
                    }
                }
            }
        }
示例#2
0
        public static NPC Find(this NetCollection <NPC> npcs, string name)
        {
            NPC npc;

            using (NetCollection <NPC> .Enumerator enumarator = npcs.GetEnumerator())
            {
                while (true)
                {
                    if (enumarator.MoveNext())
                    {
                        NPC npc2 = enumarator.Current;
                        if (npc2.Name != name)
                        {
                            continue;
                        }

                        npc = npc2;
                    }
                    else
                    {
                        return(null);
                    }

                    break;
                }
            }

            return(npc);
        }
        public static bool GameLocation_performAction_Prefix(GameLocation __instance, string action, Farmer who, ref bool __result, Location tileLocation)
        {
            try
            {
                if (action != null && who.IsLocalPlayer)
                {
                    string[] actionParams = action.Split(new char[]
                    {
                        ' '
                    });
                    string text    = actionParams[0];
                    Regex  pattern = new Regex(@"Crib[0-9][0-9]*");
                    if (pattern.IsMatch(text))
                    {
                        int crib = int.Parse(text.Substring(4));
                        Monitor.Log($"Acting on crib {crib+1}");

                        Microsoft.Xna.Framework.Rectangle rect = new Microsoft.Xna.Framework.Rectangle((ModEntry.config.ExistingKidsRoomOffsetX + 15) * 64 + (3 * crib * 64), (ModEntry.config.ExistingKidsRoomOffsetY + 2) * 64, 3 * 64, 4 * 64);
                        using (NetCollection <NPC> .Enumerator enumerator = __instance.characters.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                NPC j = enumerator.Current;
                                if (j is Child)
                                {
                                    if (rect.Intersects(j.GetBoundingBox()))
                                    {
                                        if ((j as Child).Age == 1)
                                        {
                                            Monitor.Log($"Tossing {j.Name}");
                                            (j as Child).toss(who);
                                        }
                                        else if ((j as Child).Age == 0)
                                        {
                                            Monitor.Log($"{j.Name} is sleeping");
                                            Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Locations:FarmHouse_Crib_NewbornSleeping", j.displayName)));
                                        }
                                        else if ((j as Child).isInCrib() && (j as Child).Age == 2)
                                        {
                                            Monitor.Log($"acting on {j.Name}");
                                            return(j.checkAction(who, __instance));
                                        }
                                        __result = true;
                                        return(false);
                                    }
                                }
                            }
                        }
                        __result = true;
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(ManorHouse_performAction_Prefix)}:\n{ex}", LogLevel.Error);
            }
            return(true);
        }
示例#4
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);

            if (Health <= 0)
            {
                return;
            }

            this.lastFly    = Math.Max(0f, this.lastFly - (float)time.ElapsedGameTime.Milliseconds);
            this.lastDebuff = Math.Max(0f, this.lastDebuff - (float)time.ElapsedGameTime.Milliseconds);

            if (withinPlayerThreshold(10))
            {
                if (lastDebuff == 0f)
                {
                    Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);

                    base.currentLocation.projectiles.Add(new DebuffingProjectile(14, 2, 4, 4, 0.196349546f, velocityTowardPlayer.X, velocityTowardPlayer.Y, new Vector2((float)this.GetBoundingBox().X, (float)this.GetBoundingBox().Y), base.currentLocation, this));
                    this.lastDebuff = Game1.random.Next(3000, 6000);
                }
                if (lastFly == 0f)
                {
                    int flies = 0;
                    using (NetCollection <NPC> .Enumerator enumerator = currentLocation.characters.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NPC j = enumerator.Current;
                            if (j is ToughFly)
                            {
                                flies++;
                            }
                        }
                    }
                    if (flies < (Health < MaxHealth / 2 ? this.MaxFlies * 2 : this.MaxFlies))
                    {
                        if (Health < MaxHealth / 2)
                        {
                            Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);
                            base.currentLocation.projectiles.Add(new DebuffingProjectile(13, 7, 4, 4, 0.196349546f, velocityTowardPlayer.X, velocityTowardPlayer.Y, new Vector2((float)this.GetBoundingBox().X, (float)this.GetBoundingBox().Y), base.currentLocation, this));
                        }
                        currentLocation.characters.Add(new ToughFly(Position, difficulty)
                        {
                            focusedOnFarmers = true
                        });
                        this.lastFly = (float)Game1.random.Next(4000, 8000);
                    }
                }
            }
        }
示例#5
0
 public static Monster BossHere(GameLocation location)
 {
     using (NetCollection <NPC> .Enumerator enumerator = location.characters.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             NPC j = enumerator.Current;
             if (BossTypes.ContainsKey(j.GetType()))
             {
                 return((Monster)j);
             }
         }
     }
     return(null);
 }
示例#6
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);
        }