예제 #1
0
 public virtual void update(GameTime time, GameLocation location, long id, bool move)
 {
     if (this.yJumpOffset != 0)
     {
         this.yJumpVelocity -= 0.5f;
         this.yJumpOffset   -= (int)this.yJumpVelocity;
         if (this.yJumpOffset >= 0)
         {
             this.yJumpOffset   = 0;
             this.yJumpVelocity = 0f;
             if (!this.IsMonster && (location == null || location.Equals(Game1.currentLocation)))
             {
                 FarmerSprite.checkForFootstep(this);
             }
         }
     }
     if (this.faceTowardFarmerTimer > 0)
     {
         this.faceTowardFarmerTimer -= time.ElapsedGameTime.Milliseconds;
         if (!this.faceTowardFarmer && this.faceTowardFarmerTimer > 0 && Utility.tileWithinRadiusOfPlayer((int)this.getTileLocation().X, (int)this.getTileLocation().Y, this.faceTowardFarmerRadius, this.whoToFace))
         {
             this.faceTowardFarmer = true;
         }
         else if (!Utility.tileWithinRadiusOfPlayer((int)this.getTileLocation().X, (int)this.getTileLocation().Y, this.faceTowardFarmerRadius, this.whoToFace) || this.faceTowardFarmerTimer <= 0)
         {
             this.faceDirection(this.facingDirectionBeforeSpeakingToPlayer);
             if (this.faceTowardFarmerTimer <= 0)
             {
                 this.facingDirectionBeforeSpeakingToPlayer = -1;
                 this.faceTowardFarmer      = false;
                 this.faceAwayFromFarmer    = false;
                 this.faceTowardFarmerTimer = 0;
             }
         }
     }
     if (this.forceUpdateTimer > 0)
     {
         this.forceUpdateTimer -= time.ElapsedGameTime.Milliseconds;
     }
     this.updateGlow();
     this.updateEmote(time);
     if (!Game1.IsMultiplayer || Game1.IsServer || this.ignoreMultiplayerUpdates)
     {
         if (this.faceTowardFarmer && this.whoToFace != null)
         {
             this.faceGeneralDirection(this.whoToFace.getStandingPosition(), 0);
             if (this.faceAwayFromFarmer)
             {
                 this.faceDirection((this.facingDirection + 2) % 4);
             }
         }
         if ((this.controller == null & move) && !this.freezeMotion)
         {
             this.updateMovement(location, time);
         }
         if (this.controller != null && !this.freezeMotion && this.controller.update(time))
         {
             this.controller = null;
         }
         if (Game1.IsServer && !Game1.isFestival() && Game1.random.NextDouble() < 0.2)
         {
             MultiplayerUtility.broadcastNPCMove((int)this.position.X, (int)this.position.Y, id, location);
             return;
         }
     }
     else if (!Game1.eventUp)
     {
         this.lerpPosition(this.positionToLerpTo);
         if (this.distanceFromLastServerPosition() >= 8f)
         {
             this.animateInFacingDirection(time);
         }
     }
 }