Пример #1
0
 public override bool tickUpdate(GameTime time, Vector2 tileLocation)
 {
     if (this.destroy)
     {
         return(true);
     }
     this.alpha = Math.Min(1f, this.alpha + 0.05f);
     if (this.shakeTimer > 0f)
     {
         this.shakeTimer -= (float)time.ElapsedGameTime.Milliseconds;
     }
     if (this.growthStage >= 4 && !this.falling && !this.stump && Game1.player.GetBoundingBox().Intersects(new Rectangle(Game1.tileSize * ((int)tileLocation.X - 1), Game1.tileSize * ((int)tileLocation.Y - 4), 3 * Game1.tileSize, 3 * Game1.tileSize + Game1.tileSize / 2)))
     {
         this.alpha = Math.Max(0.4f, this.alpha - 0.09f);
     }
     if (!this.falling)
     {
         if ((double)Math.Abs(this.shakeRotation) > 1.5707963267948966 && this.leaves.Count <= 0 && this.health <= 0f)
         {
             return(true);
         }
         if (this.maxShake > 0f)
         {
             if (this.shakeLeft)
             {
                 this.shakeRotation -= ((this.growthStage >= 4) ? 0.005235988f : 0.0157079641f);
                 if (this.shakeRotation <= -this.maxShake)
                 {
                     this.shakeLeft = false;
                 }
             }
             else
             {
                 this.shakeRotation += ((this.growthStage >= 4) ? 0.005235988f : 0.0157079641f);
                 if (this.shakeRotation >= this.maxShake)
                 {
                     this.shakeLeft = true;
                 }
             }
         }
         if (this.maxShake > 0f)
         {
             this.maxShake = Math.Max(0f, this.maxShake - ((this.growthStage >= 4) ? 0.00102265389f : 0.00306796166f));
         }
         if (this.struckByLightningCountdown > 0 && Game1.random.NextDouble() < 0.01)
         {
             Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Rectangle(372, 1956, 10, 10), new Vector2(tileLocation.X * (float)Game1.tileSize + (float)Game1.random.Next(-Game1.tileSize, Game1.tileSize * 3 / 2), tileLocation.Y * (float)Game1.tileSize - (float)(Game1.tileSize * 3) + (float)Game1.random.Next(-Game1.tileSize, Game1.tileSize * 2)), false, 0.002f, Color.Gray)
             {
                 alpha       = 0.75f,
                 motion      = new Vector2(0f, -0.5f),
                 interval    = 99999f,
                 layerDepth  = 1f,
                 scale       = (float)(Game1.pixelZoom / 2),
                 scaleChange = 0.01f
             });
         }
     }
     else
     {
         this.shakeRotation += (this.shakeLeft ? (-(this.maxShake * this.maxShake)) : (this.maxShake * this.maxShake));
         this.maxShake      += 0.00153398083f;
         if (Game1.random.NextDouble() < 0.01 && !Game1.currentSeason.Equals("winter"))
         {
             Game1.playSound("leafrustle");
         }
         if ((double)Math.Abs(this.shakeRotation) > 1.5707963267948966)
         {
             this.falling  = false;
             this.maxShake = 0f;
             Game1.playSound("treethud");
             int num = Game1.random.Next(90, 120);
             for (int i = 0; i < num; i++)
             {
                 this.leaves.Add(new Leaf(new Vector2((float)(Game1.random.Next((int)(tileLocation.X * (float)Game1.tileSize), (int)(tileLocation.X * (float)Game1.tileSize + (float)(Game1.tileSize * 3))) + (this.shakeLeft ? (-Game1.tileSize * 5) : (Game1.tileSize * 4))), tileLocation.Y * (float)Game1.tileSize - (float)Game1.tileSize), (float)Game1.random.Next(-10, 10) / 100f, Game1.random.Next(4), (float)Game1.random.Next(10, 40) / 10f));
             }
             Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 12, true, -1, false, -1);
             Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 12, false, -1, false, -1);
             if (Game1.IsMultiplayer)
             {
                 Game1.recentMultiplayerRandom = new Random((int)tileLocation.X * 1000 + (int)tileLocation.Y);
                 Random arg_4D4_0 = Game1.recentMultiplayerRandom;
             }
             else
             {
                 new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + (int)tileLocation.X * 7 + (int)tileLocation.Y * 11);
             }
             if (Game1.IsMultiplayer)
             {
                 Game1.createMultipleObjectDebris(92, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 10, this.lastPlayerToHit);
             }
             else
             {
                 Game1.createMultipleObjectDebris(92, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 10);
             }
             if (this.health <= 0f)
             {
                 this.health = -100f;
             }
         }
     }
     for (int j = this.leaves.Count - 1; j >= 0; j--)
     {
         Leaf expr_59F_cp_0_cp_0 = this.leaves.ElementAt(j);
         expr_59F_cp_0_cp_0.position.Y      = expr_59F_cp_0_cp_0.position.Y - (this.leaves.ElementAt(j).yVelocity - 3f);
         this.leaves.ElementAt(j).yVelocity = Math.Max(0f, this.leaves.ElementAt(j).yVelocity - 0.01f);
         this.leaves.ElementAt(j).rotation += this.leaves.ElementAt(j).rotationRate;
         if (this.leaves.ElementAt(j).position.Y >= tileLocation.Y * (float)Game1.tileSize + (float)Game1.tileSize)
         {
             this.leaves.RemoveAt(j);
         }
     }
     return(false);
 }
Пример #2
0
 // Token: 0x060009FC RID: 2556 RVA: 0x000D2820 File Offset: 0x000D0A20
 public override bool tickUpdate(GameTime time, Vector2 tileLocation)
 {
     if (this.shakeTimer > 0f)
     {
         this.shakeTimer -= (float)time.ElapsedGameTime.Milliseconds;
     }
     if (this.destroy)
     {
         return(true);
     }
     this.alpha = Math.Min(1f, this.alpha + 0.05f);
     if (this.growthStage >= 5 && !this.falling && !this.stump && Game1.player.GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(Game1.tileSize * ((int)tileLocation.X - 1), Game1.tileSize * ((int)tileLocation.Y - 5), 3 * Game1.tileSize, 4 * Game1.tileSize + Game1.tileSize / 2)))
     {
         this.alpha = Math.Max(0.4f, this.alpha - 0.09f);
     }
     if (!this.falling)
     {
         if ((double)Math.Abs(this.shakeRotation) > 1.5707963267948966 && this.leaves.Count <= 0 && this.health <= 0f)
         {
             return(true);
         }
         if (this.maxShake > 0f)
         {
             if (this.shakeLeft)
             {
                 this.shakeRotation -= ((this.growthStage >= 5) ? 0.005235988f : 0.0157079641f);
                 if (this.shakeRotation <= -this.maxShake)
                 {
                     this.shakeLeft = false;
                 }
             }
             else
             {
                 this.shakeRotation += ((this.growthStage >= 5) ? 0.005235988f : 0.0157079641f);
                 if (this.shakeRotation >= this.maxShake)
                 {
                     this.shakeLeft = true;
                 }
             }
         }
         if (this.maxShake > 0f)
         {
             this.maxShake = Math.Max(0f, this.maxShake - ((this.growthStage >= 5) ? 0.00102265389f : 0.00306796166f));
         }
     }
     else
     {
         this.shakeRotation += (this.shakeLeft ? (-(this.maxShake * this.maxShake)) : (this.maxShake * this.maxShake));
         this.maxShake      += 0.00153398083f;
         if (Game1.random.NextDouble() < 0.01 && this.treeType != 7)
         {
             Game1.playSound("leafrustle");
         }
         if ((double)Math.Abs(this.shakeRotation) > 1.5707963267948966)
         {
             this.falling  = false;
             this.maxShake = 0f;
             Game1.playSound("treethud");
             int leavesToAdd = Game1.random.Next(90, 120);
             if (Game1.currentLocation.Objects.ContainsKey(tileLocation))
             {
                 Game1.currentLocation.Objects.Remove(tileLocation);
             }
             for (int i = 0; i < leavesToAdd; i++)
             {
                 this.leaves.Add(new Leaf(new Vector2((float)(Game1.random.Next((int)(tileLocation.X * (float)Game1.tileSize), (int)(tileLocation.X * (float)Game1.tileSize + (float)(Game1.tileSize * 3))) + (this.shakeLeft ? (-Game1.tileSize * 5) : (Game1.tileSize * 4))), tileLocation.Y * (float)Game1.tileSize - (float)Game1.tileSize), (float)Game1.random.Next(-10, 10) / 100f, Game1.random.Next(4), (float)Game1.random.Next(10, 40) / 10f));
             }
             if (this.treeType != 7)
             {
                 Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 12 + this.extraWoodCalculator(tileLocation), true, -1, false, -1);
                 Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 12 + this.extraWoodCalculator(tileLocation), false, -1, false, -1);
                 Random r;
                 if (Game1.IsMultiplayer)
                 {
                     Game1.recentMultiplayerRandom = new Random((int)tileLocation.X * 1000 + (int)tileLocation.Y);
                     r = Game1.recentMultiplayerRandom;
                 }
                 else
                 {
                     r = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + (int)tileLocation.X * 7 + (int)tileLocation.Y * 11);
                 }
                 if (Game1.IsMultiplayer)
                 {
                     Game1.createMultipleObjectDebris(92, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 5, this.lastPlayerToHit);
                     int numHardwood = 0;
                     if (Game1.getFarmer(this.lastPlayerToHit) != null)
                     {
                         while (Game1.getFarmer(this.lastPlayerToHit).professions.Contains(14) && r.NextDouble() < 0.4)
                         {
                             numHardwood++;
                         }
                     }
                     if (numHardwood > 0)
                     {
                         Game1.createMultipleObjectDebris(709, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, numHardwood, this.lastPlayerToHit);
                     }
                     if (Game1.getFarmer(this.lastPlayerToHit).getEffectiveSkillLevel(2) >= 1 && r.NextDouble() < 0.75)
                     {
                         Game1.createMultipleObjectDebris(308 + this.treeType, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, r.Next(1, 3), this.lastPlayerToHit);
                     }
                 }
                 else
                 {
                     Game1.createMultipleObjectDebris(92, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 5);
                     int numHardwood2 = 0;
                     if (Game1.getFarmer(this.lastPlayerToHit) != null)
                     {
                         while (Game1.getFarmer(this.lastPlayerToHit).professions.Contains(14) && r.NextDouble() < 0.4)
                         {
                             numHardwood2++;
                         }
                     }
                     if (numHardwood2 > 0)
                     {
                         Game1.createMultipleObjectDebris(709, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, numHardwood2);
                     }
                     if (this.lastPlayerToHit != 0L && Game1.getFarmer(this.lastPlayerToHit).getEffectiveSkillLevel(2) >= 1 && r.NextDouble() < 0.75 && this.treeType < 4)
                     {
                         Game1.createMultipleObjectDebris(308 + this.treeType, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, r.Next(1, 3));
                     }
                 }
             }
             else if (!Game1.IsMultiplayer)
             {
                 Game1.createMultipleObjectDebris(420, (int)tileLocation.X + (this.shakeLeft ? -4 : 4), (int)tileLocation.Y, 5);
             }
             if (this.health == -100f)
             {
                 return(true);
             }
             if (this.health <= 0f)
             {
                 this.health = -100f;
             }
         }
     }
     for (int j = this.leaves.Count - 1; j >= 0; j--)
     {
         Leaf expr_6D9_cp_0_cp_0 = this.leaves.ElementAt(j);
         expr_6D9_cp_0_cp_0.position.Y      = expr_6D9_cp_0_cp_0.position.Y - (this.leaves.ElementAt(j).yVelocity - 3f);
         this.leaves.ElementAt(j).yVelocity = Math.Max(0f, this.leaves.ElementAt(j).yVelocity - 0.01f);
         this.leaves.ElementAt(j).rotation += this.leaves.ElementAt(j).rotationRate;
         if (this.leaves.ElementAt(j).position.Y >= tileLocation.Y * (float)Game1.tileSize + (float)Game1.tileSize)
         {
             this.leaves.RemoveAt(j);
         }
     }
     return(false);
 }