示例#1
0
 public override void dayUpdate(int dayOfMonth)
 {
     isSleepingOnFarmerBed.Value = false;
     UpdateSleepingOnBed();
     base.DefaultPosition = new Vector2(54f, 8f) * 64f;
     Sprite.loop          = false;
     base.Breather        = false;
     if (Game1.isRaining)
     {
         CurrentBehavior = 2;
         warpToFarmHouse(Game1.player);
     }
     else if (base.currentLocation is FarmHouse)
     {
         setAtFarmPosition();
     }
     if (base.currentLocation is Farm && Game1.IsMasterGame)
     {
         if ((base.currentLocation as Farm).petBowlWatered.Value)
         {
             friendshipTowardFarmer.Set(Math.Min(1000, friendshipTowardFarmer.Value + 6));
         }
         (base.currentLocation as Farm).petBowlWatered.Set(newValue: false);
     }
     Halt();
     CurrentBehavior = 1;
     grantedFriendshipForPet.Set(newValue: false);
     _OnNewBehavior();
     Sprite.UpdateSourceRect();
 }
示例#2
0
 public int recolorSkin(int which, bool force = false)
 {
     if (force)
     {
         skin.Value = -1;
     }
     skin.Set(which);
     return(which);
 }
示例#3
0
        public void load(int which)
        {
            Dictionary <int, string> dictionary = Game1.content.Load <Dictionary <int, string> >("Data\\hats");

            if (!dictionary.ContainsKey(which))
            {
                which = 0;
            }
            string[] split = dictionary[which].Split('/');
            Name = split[0];
            if (split[2] == "hide")
            {
                hairDrawType.Set(2);
            }
            else if (Convert.ToBoolean(split[2]))
            {
                hairDrawType.Set(0);
            }
            else
            {
                hairDrawType.Set(1);
            }
            if (skipHairDraw)
            {
                skipHairDraw = false;
                hairDrawType.Set(0);
            }
            if (split.Length > 4)
            {
                string[] specialTags = split[4].Split(' ');
                foreach (string a in specialTags)
                {
                    if (a == "Prismatic")
                    {
                        isPrismatic.Value = true;
                    }
                }
            }
            ignoreHairstyleOffset.Value = Convert.ToBoolean(split[3]);
            base.Category = -95;
        }
 /// <summary>
 ///     A method called via Harmony after the constructor for <see cref="Farmer" />.
 /// </summary>
 /// <param name="___currentToolIndex">The private field currentToolIndex of the <see cref="Farmer" /> instance.</param>
 private static void AfterConstructor(NetInt ___currentToolIndex)
 {
     ___currentToolIndex.Set(-1);
 }
示例#5
0
        public override void behaviorAtGameTick(GameTime time)
        {
            invincibleCountdown = 1000;

            chargingMonster = false;
            if (!(currentLocation is SlimeHutch))
            {
                foreach (NPC npc in currentLocation.characters)
                {
                    if (npc is Familiar)
                    {
                        continue;
                    }

                    if (npc is Monster && FamiliarsUtils.withinMonsterThreshold(this, (Monster)npc, 2))
                    {
                        chargingMonster = true;
                        if (currentTarget == null || Vector2.Distance(npc.position, position) < Vector2.Distance(currentTarget.position, position))
                        {
                            currentTarget = (Monster)npc;
                        }
                    }
                }
            }

            if (attackState.Value == 1)
            {
                IsWalkingTowardPlayer = false;
                Halt();
            }
            else if (withinPlayerThreshold() && followingOwner)
            {
                if (withinPlayerThreshold(1))
                {
                    Halt();
                }
                else
                {
                    IsWalkingTowardPlayer = true;
                }
            }
            else
            {
                IsWalkingTowardPlayer    = false;
                nextChangeDirectionTime -= time.ElapsedGameTime.Milliseconds;
                nextWanderTime          -= time.ElapsedGameTime.Milliseconds;
                if (nextChangeDirectionTime < 0)
                {
                    nextChangeDirectionTime = Game1.random.Next(500, 1000);
                    facingDirection.Value   = (facingDirection.Value + (Game1.random.Next(0, 3) - 1) + 4) % 4;
                }
                if (nextWanderTime < 0)
                {
                    if (wanderState)
                    {
                        nextWanderTime = Game1.random.Next(1000, 2000);
                    }
                    else
                    {
                        nextWanderTime = Game1.random.Next(1000, 3000);
                    }
                    wanderState = !wanderState;
                }
                if (wanderState)
                {
                    moveLeft = (moveUp = (moveRight = (moveDown = false)));
                    tryToMoveInDirection(facingDirection.Value, false, DamageToFarmer, isGlider);
                }
            }
            timeUntilNextAttack -= time.ElapsedGameTime.Milliseconds;
            if (attackState.Value == 0 && chargingMonster)
            {
                firing.Set(false);
                if (timeUntilNextAttack < 0)
                {
                    timeUntilNextAttack = 0;
                    attackState.Set(1);
                    nextFireTime  = 500;
                    totalFireTime = 3000;
                    if (ModEntry.Config.DinoSoundEffects)
                    {
                        currentLocation.playSound("croak", NetAudio.SoundContext.Default);
                    }
                    return;
                }
            }
            else if (totalFireTime > 0)
            {
                if (!firing)
                {
                    if (currentTarget != null)
                    {
                        faceGeneralDirection(currentTarget.Position, 0, false);
                    }
                }
                totalFireTime -= time.ElapsedGameTime.Milliseconds;
                if (nextFireTime > 0)
                {
                    nextFireTime -= time.ElapsedGameTime.Milliseconds;
                    if (nextFireTime <= 0)
                    {
                        if (!firing.Value)
                        {
                            firing.Set(true);
                            currentLocation.playSound("furnace", NetAudio.SoundContext.Default);
                        }
                        float   fire_angle  = 0f;
                        Vector2 shot_origin = new Vector2((float)GetBoundingBox().Center.X - 32f * scale, (float)GetBoundingBox().Center.Y - 32f * scale);
                        switch (facingDirection.Value)
                        {
                        case 0:
                            yVelocity      = -1f;
                            shot_origin.Y -= 74f * scale;
                            fire_angle     = 90f;
                            break;

                        case 1:
                            xVelocity      = -1f;
                            shot_origin.X += 74f * scale;
                            fire_angle     = 0f;
                            break;

                        case 2:
                            yVelocity      = 1f;
                            fire_angle     = 270f;
                            shot_origin.Y += 74 * scale;
                            break;

                        case 3:
                            xVelocity      = 1f;
                            shot_origin.X -= 74f * scale;
                            fire_angle     = 180f;
                            break;
                        }
                        fire_angle += (float)Math.Sin((double)((float)totalFireTime / 1000f * 180f) * 3.1415926535897931 / 180.0) * 25f;
                        Vector2 shot_velocity = new Vector2((float)Math.Cos((double)fire_angle * 3.1415926535897931 / 180.0), -(float)Math.Sin((double)fire_angle * 3.1415926535897931 / 180.0));
                        shot_velocity *= 10f;
                        BasicProjectile projectile = new BasicProjectile(GetDamage(), 10, 0, 1, 0.196349546f, shot_velocity.X, shot_velocity.Y, shot_origin, "", "", false, true, currentLocation, this, false, null);
                        projectile.ignoreTravelGracePeriod.Value = true;
                        projectile.maxTravelDistance.Value       = GetFireDistance();
                        currentLocation.projectiles.Add(projectile);
                        nextFireTime = 50;
                    }
                }
                if (totalFireTime <= 0)
                {
                    AddExp(1);
                    totalFireTime = 0;
                    nextFireTime  = 0;
                    attackState.Set(0);
                    timeUntilNextAttack = Game1.random.Next(1000, 2000);
                }
            }
        }
示例#6
0
 public void changePants(int whichPants)
 {
     pants.Set(whichPants);
 }
示例#7
0
 public void changeShirt(int whichShirt)
 {
     shirt.Set(whichShirt);
 }
示例#8
0
 public void recolorShoes(int which)
 {
     shoes.Set(which);
 }
示例#9
0
 public virtual void setUpgradeLevel(int upgrade_level)
 {
     upgradeLevel.Set(upgrade_level);
     updateMap();
     updateLayout();
 }
示例#10
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);

            if (Health <= 0)
            {
                return;
            }

            // fire!

            timeUntilNextAttack -= time.ElapsedGameTime.Milliseconds;

            List <Farmer> farmers = new List <Farmer>();

            FarmerCollection.Enumerator enumerator = currentLocation.farmers.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (enumerator.Current.currentLocation == currentLocation && enumerator.Current.GetBoundingBox().Intersects(GetBoundingBox()))
                {
                    enumerator.Current.takeDamage((int)Math.Round(20 * difficulty), true, null);
                    totalFireTime = 0;
                    nextFireTime  = 10;
                    attackState.Set(0);
                    timeUntilNextAttack = Game1.random.Next(1000, 2000);
                }
            }

            if (attackState.Value == 0 && withinPlayerThreshold(20))
            {
                firing.Set(false);
                if (timeUntilNextAttack < 0)
                {
                    timeUntilNextAttack = 0;
                    attackState.Set(1);
                    nextFireTime  = 50;
                    totalFireTime = 3000;
                    return;
                }
            }
            else if (totalFireTime > 0)
            {
                Farmer player = Player;
                if (!firing.Value)
                {
                    if (player != null)
                    {
                        faceGeneralDirection(player.Position, 0, false);
                    }
                }
                totalFireTime -= time.ElapsedGameTime.Milliseconds;
                if (nextFireTime > 0)
                {
                    nextFireTime -= time.ElapsedGameTime.Milliseconds;
                    if (nextFireTime <= 0)
                    {
                        if (!firing.Value)
                        {
                            firing.Set(true);
                        }
                        float   fire_angle  = 0f;
                        Vector2 shot_origin = new Vector2((float)GetBoundingBox().Center.X, (float)GetBoundingBox().Center.Y);
                        faceGeneralDirection(player.Position, 0, false);
                        switch (facingDirection.Value)
                        {
                        case 0:
                            fire_angle = 90f;
                            break;

                        case 1:
                            fire_angle = 0f;
                            break;

                        case 2:
                            fire_angle = 270f;
                            break;

                        case 3:
                            fire_angle = 180f;
                            break;
                        }
                        fire_angle += (float)Math.Sin((double)((float)totalFireTime / 1000f * 180f) * 3.1415926535897931 / 180.0) * 25f;
                        Vector2 shot_velocity = new Vector2((float)Math.Cos((double)fire_angle * 3.1415926535897931 / 180.0), -(float)Math.Sin((double)fire_angle * 3.1415926535897931 / 180.0));
                        shot_velocity *= 5f;

                        for (int i = 0; i < 8; i++)
                        {
                            bool one   = i < 4;
                            bool two   = i % 4 < 2;
                            bool three = i % 2 == 0;

                            Vector2 v = new Vector2((three ? shot_velocity.X : shot_velocity.Y) * (one ? -1 : 1), (three ? shot_velocity.Y : shot_velocity.X) * (two ? -1 : 1));
                            //v = ModEntry.RotateVector(v, j);
                            BasicProjectile projectile = new BossProjectile((int)(5 * difficulty), 766, 0, 1, 0.196349546f, v.X, v.Y, shot_origin, "", "", false, false, currentLocation, this, true, null, 13, true);
                            projectile.IgnoreLocationCollision       = true;
                            projectile.ignoreTravelGracePeriod.Value = true;
                            projectile.maxTravelDistance.Value       = 512;
                            currentLocation.projectiles.Add(projectile);

                            if (!ModEntry.IsLessThanHalfHealth(this))
                            {
                                i++;
                            }
                        }
                        if (ModEntry.IsLessThanHalfHealth(this))
                        {
                            j += 1;
                        }
                        j %= 360;


                        nextFireTime = 20;
                    }
                }
                if (totalFireTime <= 0)
                {
                    totalFireTime = 0;
                    nextFireTime  = 20;
                    attackState.Set(0);

                    timeUntilNextAttack = 0;
                }
            }
        }
示例#11
0
        public override void behaviorAtGameTick(GameTime time)
        {
            if (attackState.Value == 1)
            {
                base.IsWalkingTowardPlayer = false;
                Halt();
            }
            else if (withinPlayerThreshold())
            {
                base.IsWalkingTowardPlayer = true;
            }
            else
            {
                base.IsWalkingTowardPlayer = false;
                nextChangeDirectionTime   -= time.ElapsedGameTime.Milliseconds;
                nextWanderTime            -= time.ElapsedGameTime.Milliseconds;
                if (nextChangeDirectionTime < 0)
                {
                    nextChangeDirectionTime = Game1.random.Next(500, 1000);
                    _ = FacingDirection;
                    facingDirection.Value = (facingDirection.Value + (Game1.random.Next(0, 3) - 1) + 4) % 4;
                }
                if (nextWanderTime < 0)
                {
                    if (wanderState)
                    {
                        nextWanderTime = Game1.random.Next(1000, 2000);
                    }
                    else
                    {
                        nextWanderTime = Game1.random.Next(1000, 3000);
                    }
                    wanderState = !wanderState;
                }
                if (wanderState)
                {
                    moveLeft = (moveUp = (moveRight = (moveDown = false)));
                    tryToMoveInDirection(facingDirection.Value, isFarmer: false, base.DamageToFarmer, isGlider);
                }
            }
            timeUntilNextAttack -= time.ElapsedGameTime.Milliseconds;
            if (attackState.Value == 0 && withinPlayerThreshold(2))
            {
                firing.Set(newValue: false);
                if (timeUntilNextAttack < 0)
                {
                    timeUntilNextAttack = 0;
                    attackState.Set(1);
                    nextFireTime  = 500;
                    totalFireTime = 3000;
                    base.currentLocation.playSound("croak");
                }
            }
            else
            {
                if (totalFireTime <= 0)
                {
                    return;
                }
                if (!firing)
                {
                    Farmer player = base.Player;
                    if (player != null)
                    {
                        faceGeneralDirection(player.Position);
                    }
                }
                totalFireTime -= time.ElapsedGameTime.Milliseconds;
                if (nextFireTime > 0)
                {
                    nextFireTime -= time.ElapsedGameTime.Milliseconds;
                    if (nextFireTime <= 0)
                    {
                        if (!firing.Value)
                        {
                            firing.Set(newValue: true);
                            base.currentLocation.playSound("furnace");
                        }
                        float   fire_angle  = 0f;
                        Vector2 shot_origin = new Vector2((float)GetBoundingBox().Center.X - 32f, (float)GetBoundingBox().Center.Y - 32f);
                        switch (facingDirection.Value)
                        {
                        case 0:
                            yVelocity      = -1f;
                            shot_origin.Y -= 64f;
                            fire_angle     = 90f;
                            break;

                        case 1:
                            xVelocity      = -1f;
                            shot_origin.X += 64f;
                            fire_angle     = 0f;
                            break;

                        case 3:
                            xVelocity      = 1f;
                            shot_origin.X -= 64f;
                            fire_angle     = 180f;
                            break;

                        case 2:
                            yVelocity  = 1f;
                            fire_angle = 270f;
                            break;
                        }
                        fire_angle += (float)Math.Sin((double)((float)totalFireTime / 1000f * 180f) * Math.PI / 180.0) * 25f;
                        Vector2 shot_velocity = new Vector2((float)Math.Cos((double)fire_angle * Math.PI / 180.0), 0f - (float)Math.Sin((double)fire_angle * Math.PI / 180.0));
                        shot_velocity *= 10f;
                        BasicProjectile projectile = new BasicProjectile(25, 10, 0, 1, (float)Math.PI / 16f, shot_velocity.X, shot_velocity.Y, shot_origin, "", "", explode: false, damagesMonsters: false, base.currentLocation, this);
                        projectile.ignoreTravelGracePeriod.Value = true;
                        projectile.maxTravelDistance.Value       = 256;
                        base.currentLocation.projectiles.Add(projectile);
                        nextFireTime = 50;
                    }
                }
                if (totalFireTime <= 0)
                {
                    totalFireTime = 0;
                    nextFireTime  = 0;
                    attackState.Set(0);
                    timeUntilNextAttack = Game1.random.Next(1000, 2000);
                }
            }
        }
示例#12
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);

            if (Health <= 0)
            {
                return;
            }

            // fire!

            timeUntilNextAttack -= time.ElapsedGameTime.Milliseconds;
            if (attackState.Value == 0 && withinPlayerThreshold(5))
            {
                firing.Set(false);
                if (timeUntilNextAttack < 0)
                {
                    timeUntilNextAttack = 0;
                    attackState.Set(1);
                    nextFireTime  = 50;
                    totalFireTime = 3000;
                    return;
                }
            }
            else if (totalFireTime > 0)
            {
                Farmer player = Player;
                if (!firing.Value)
                {
                    if (player != null)
                    {
                        faceGeneralDirection(player.Position, 0, false);
                    }
                }
                totalFireTime -= time.ElapsedGameTime.Milliseconds;
                if (nextFireTime > 0)
                {
                    nextFireTime -= time.ElapsedGameTime.Milliseconds;
                    if (nextFireTime <= 0)
                    {
                        if (!firing.Value)
                        {
                            firing.Set(true);
                            currentLocation.playSound("furnace", NetAudio.SoundContext.Default);
                        }
                        float   fire_angle  = 0f;
                        Vector2 shot_origin = new Vector2((float)GetBoundingBox().Center.X, (float)GetBoundingBox().Center.Y);
                        faceGeneralDirection(player.Position, 0, false);
                        switch (facingDirection.Value)
                        {
                        case 0:
                            yVelocity      = -1f;
                            shot_origin.Y -= 64f;
                            fire_angle     = 90f;
                            break;

                        case 1:
                            xVelocity      = -1f;
                            shot_origin.X += 64f;
                            fire_angle     = 0f;
                            break;

                        case 2:
                            yVelocity  = 1f;
                            fire_angle = 270f;
                            break;

                        case 3:
                            xVelocity      = 1f;
                            shot_origin.X -= 64f;
                            fire_angle     = 180f;
                            break;
                        }
                        fire_angle += (float)Math.Sin((double)((float)totalFireTime / 1000f * 180f) * 3.1415926535897931 / 180.0) * 25f;
                        Vector2 shot_velocity = new Vector2((float)Math.Cos((double)fire_angle * 3.1415926535897931 / 180.0), -(float)Math.Sin((double)fire_angle * 3.1415926535897931 / 180.0));
                        shot_velocity *= 10f;
                        BasicProjectile projectile = new BasicProjectile((int)Math.Round(10 * difficulty), 10, 0, 1, 0.196349546f, shot_velocity.X, shot_velocity.Y, shot_origin, "", "", false, false, currentLocation, this, false, null);
                        projectile.ignoreTravelGracePeriod.Value = true;
                        projectile.maxTravelDistance.Value       = 512;
                        currentLocation.projectiles.Add(projectile);
                        if (Health < MaxHealth / 2)
                        {
                            currentLocation.projectiles.Add(new BasicProjectile((int)Math.Round(10 * difficulty), 10, 3, 4, 0f, shot_velocity.X, shot_velocity.Y, shot_origin, "", "", true, false, currentLocation, this, false, null));
                        }
                        nextFireTime = 50;
                    }
                }
                if (totalFireTime <= 0)
                {
                    totalFireTime = 0;
                    nextFireTime  = 0;
                    attackState.Set(0);
                    timeUntilNextAttack = Game1.random.Next(2000, 4000);
                }
            }
        }
示例#13
0
        public void LoadData(bool initialize_color = false)
        {
            if (_loadedData)
            {
                return;
            }
            int item_index = base.ParentSheetIndex;

            base.Category = -100;
            if (Game1.clothingInformation.ContainsKey(item_index))
            {
                string[] data2 = Game1.clothingInformation[item_index].Split('/');
                Name        = data2[0];
                price.Value = Convert.ToInt32(data2[5]);
                indexInTileSheetMale.Value   = Convert.ToInt32(data2[3]);
                indexInTileSheetFemale.Value = Convert.ToInt32(data2[4]);
                dyeable.Value = Convert.ToBoolean(data2[7]);
                if (initialize_color)
                {
                    string[] rgb_string = data2[6].Split(' ');
                    clothesColor.Value = new Color(Convert.ToInt32(rgb_string[0]), Convert.ToInt32(rgb_string[1]), Convert.ToInt32(rgb_string[2]));
                }
                displayName = data2[1];
                description = data2[2];
                switch (data2[8].ToLower().Trim())
                {
                case "pants":
                    clothesType.Set(1);
                    break;

                case "shirt":
                    clothesType.Set(0);
                    break;

                case "accessory":
                    clothesType.Set(2);
                    break;
                }
                if (data2.Length >= 10)
                {
                    otherData.Set(data2[9]);
                }
                else
                {
                    otherData.Set("");
                }
                if (GetOtherData().Contains("Prismatic"))
                {
                    isPrismatic.Set(newValue: true);
                }
            }
            else
            {
                base.ParentSheetIndex = item_index;
                string[] data = Game1.clothingInformation[-1].Split('/');
                clothesType.Set(1);
                if (item_index >= 1000)
                {
                    data = Game1.clothingInformation[-2].Split('/');
                    clothesType.Set(0);
                    item_index -= 1000;
                }
                if (initialize_color)
                {
                    clothesColor.Set(new Color(1f, 1f, 1f));
                }
                if (clothesType.Value == 1)
                {
                    dyeable.Set(newValue: true);
                }
                else
                {
                    dyeable.Set(newValue: false);
                }
                displayName = data[1];
                description = data[2];
                indexInTileSheetMale.Set(item_index);
                indexInTileSheetFemale.Set(-1);
            }
            if (dyeable.Value)
            {
                description = description + Environment.NewLine + Environment.NewLine + Game1.content.LoadString("Strings\\UI:Clothes_Dyeable");
            }
            _loadedData = true;
        }