Exemple #1
0
        private float tagAlpha = 0; //Alpha color value for nametags

        #endregion Fields

        #region Constructors

        public Player(Map map, Vector2 position, string name, long RUI, int ID)
        {
            this.Map = map;
            Smiley = SmileyType.Default;
            Mode = PlayerMode.Normal;
            Tint = Color.White;

            SimulationState = new EntityState();
            DisplayState = new EntityState();
            PreviousState = new EntityState();

            SimulationState.Position = PreviousState.Position = DisplayState.Position = position;

            this.RUI = RUI;
            this.ID = (byte)ID;
            this.Username = name;
            Index = map.Players.Count;
        }
Exemple #2
0
        /// <summary>
        /// Updates the player physics, states, etc
        /// </summary>
        public void Update(GameTime gameTime)
        {
            //Clear Input
            if (IsMine)
                IsJumping = false;
            //Make sure PreviousDisplay is one frame behind DisplayState
            PreviousState = SimulationState;
            SimulationState.Bounds = Bounds;
            //Handle Movement and Collision
            if (IsMine && Map.Game.IsActive)
            {
                if (HandleInput())
                {
                    Game.NetManager.Send(new PlayerStateMessage(this));
                }
            }
            ApplyPhysics(gameTime);
            // Set DisplayState
            if (IsMine)
                DisplayState = SimulationState;
            else
                Interpolate(gameTime);

            DisplayState.Position.X = Math.Max(0, DisplayState.Position.X);
            DisplayState.Position.Y = Math.Max(0, DisplayState.Position.Y);
        }