Exemple #1
0
        public virtual void update(GameTime time, GameLocation location, long id, bool move)
        {
            position.UpdateExtrapolation(speed + addedSpeed);
            currentLocation = location;
            faceTowardFarmerEvent.Poll();
            if (yJumpOffset != 0)
            {
                yJumpVelocity += yJumpGravity;
                yJumpOffset   -= (int)yJumpVelocity;
                if (yJumpOffset >= 0)
                {
                    yJumpOffset   = 0;
                    yJumpVelocity = 0f;
                    if (!IsMonster && (location == null || location.Equals(Game1.currentLocation)) && wasJumpWithSound)
                    {
                        checkForFootstep();
                    }
                }
            }
            if (forceUpdateTimer > 0)
            {
                forceUpdateTimer -= time.ElapsedGameTime.Milliseconds;
            }
            updateGlow();
            updateEmote(time);
            updateFaceTowardsFarmer(time, location);
            bool is_event_controlled_character = false;

            if (location.currentEvent != null)
            {
                if (location.isTemp())
                {
                    is_event_controlled_character = true;
                }
                else if (location.currentEvent.actors.Contains(this))
                {
                    is_event_controlled_character = true;
                }
            }
            if (Game1.IsMasterGame | is_event_controlled_character)
            {
                if (controller == null && move && !freezeMotion)
                {
                    updateMovement(location, time);
                }
                if (controller != null && !freezeMotion && controller.update(time))
                {
                    controller = null;
                }
            }
            else
            {
                updateSlaveAnimation(time);
            }
            hasJustStartedFacingPlayer = false;
        }
Exemple #2
0
 public virtual void update(GameTime time, GameLocation location, long id, bool move)
 {
     position.UpdateExtrapolation(speed + addedSpeed);
     currentLocation = location;
     faceTowardFarmerEvent.Poll();
     if (yJumpOffset != 0)
     {
         yJumpVelocity -= 0.5f;
         yJumpOffset   -= (int)yJumpVelocity;
         if (yJumpOffset >= 0)
         {
             yJumpOffset   = 0;
             yJumpVelocity = 0f;
             if (!IsMonster && (location == null || location.Equals(Game1.currentLocation)))
             {
                 checkForFootstep();
             }
         }
     }
     if (faceTowardFarmerTimer > 0)
     {
         faceTowardFarmerTimer -= time.ElapsedGameTime.Milliseconds;
         if (whoToFace.Value != null)
         {
             if (!faceTowardFarmer && faceTowardFarmerTimer > 0 && Utility.tileWithinRadiusOfPlayer((int)getTileLocation().X, (int)getTileLocation().Y, faceTowardFarmerRadius, whoToFace))
             {
                 faceTowardFarmer = true;
             }
             else if (!Utility.tileWithinRadiusOfPlayer((int)getTileLocation().X, (int)getTileLocation().Y, faceTowardFarmerRadius, whoToFace) || faceTowardFarmerTimer <= 0)
             {
                 faceDirection(facingDirectionBeforeSpeakingToPlayer.Value);
                 if (faceTowardFarmerTimer <= 0)
                 {
                     facingDirectionBeforeSpeakingToPlayer.Value = -1;
                     faceTowardFarmer         = false;
                     faceAwayFromFarmer.Value = false;
                     faceTowardFarmerTimer    = 0;
                 }
             }
         }
     }
     if (forceUpdateTimer > 0)
     {
         forceUpdateTimer -= time.ElapsedGameTime.Milliseconds;
     }
     updateGlow();
     updateEmote(time);
     if (Game1.IsMasterGame || location.currentEvent != null)
     {
         if (faceTowardFarmer && whoToFace.Value != null)
         {
             faceGeneralDirection(whoToFace.Value.getStandingPosition());
             if ((bool)faceAwayFromFarmer)
             {
                 faceDirection((FacingDirection + 2) % 4);
             }
         }
         if (controller == null && move && !freezeMotion)
         {
             updateMovement(location, time);
         }
         if (controller != null && !freezeMotion && controller.update(time))
         {
             controller = null;
         }
     }
     else
     {
         updateSlaveAnimation(time);
     }
 }