Пример #1
0
 public TileEntitySceneObject(MapLoaderSceneObject loadedObject)
 {
     AnimationManager = new AnimationManager();
     Object           = Global.GetSceneObjectBYID(loadedObject.ShortName).Clone();
     Quantity         = loadedObject.Quantity;
     Position         = new Vector2(loadedObject.MapX, loadedObject.MapY);
     AnimationManager.Play(Object.Animation);
     CreateCollisionMask();
 }
Пример #2
0
 public TileSceneObject(Animation animation, Vector2 position, Vector2 velocity)
 {
     Animation        = animation;
     Position         = position;
     Velocity         = velocity;
     DisposalTimer    = 0.5f;
     IsDisposable     = false;
     AnimationManager = new AnimationManager();
     AnimationManager.Play(Animation);
 }
Пример #3
0
        public InventoryItem(SceneObject item, int qty)
        {
            Item     = item;
            Quantity = qty;

            IsSelected = false;

            AnimationManager = new AnimationManager();
            AnimationManager.Play(Item.Animation);
        }
Пример #4
0
        private void UpdateRunWalk()
        {
            float deltaTime = (float)Global.GameTime.ElapsedGameTime.TotalSeconds;

            if (IsGrounded == false)
            {
                // Add Gravity
                FallVector = FallVector + new Vector2(0, Global.GRAVITY_RATE * deltaTime);

                if (FallVector.Y > 4f)
                {
                    FallVector = new Vector2(0, 6f);
                }

                Velocity = Velocity + FallVector;
                AnimationManager.Play(AnimationLibrary["jump"]);
            }

            if (Velocity != new Vector2(0, 0))
            {
                ProposedPosition = Position + Velocity;
                CreateCollisionMask(ProposedPosition, 32, 64);
                OnPlayerMoved();

                if (IsColliding == true)
                {
                    for (int i = Collisions.Count - 1; i >= 0; i--)
                    {
                        HandleCollision(Collisions.ElementAt(i));
                        Collisions.RemoveAt(i);
                    }

                    IsColliding = false;
                }

                int propX = (int)ProposedPosition.X;
                int propY = (int)ProposedPosition.Y;

                ProposedPosition = new Vector2(propX, propY);

                Position = ProposedPosition;
                Velocity = new Vector2(0);
                CreateCollisionMask(Position, 32, 64);
            }
        }
Пример #5
0
        public ActorPlayer(int id, PlayerIndex controller, Vector2 position)
        {
            ID               = id;
            Controller       = controller;
            Position         = position;
            ProposedPosition = position;
            Velocity         = new Vector2(0);
            FallVector       = new Vector2(0);
            Content          = Global.Content;

            WalkSpeed = 32f;
            RunSpeed  = 128f;
            MoveSpeed = WalkSpeed;

            Collisions  = new List <Rectangle>();
            IsColliding = false;
            IsGrounded  = true;

            CreateCollisionMask(Position, 32, 64);

            AnimationManager = new AnimationManager();
            AnimationLibrary = new Dictionary <string, Animation>();
            Facing           = ActorFacing.Right;
            Movement         = MovementType.RunWalk;
            SavedMovement    = MovementType.RunWalk;

            ActiveLadder = null;

            LoadContent();

            AnimationManager.Play(AnimationLibrary["idle"]);

            Inventory = new ActorInventory();

            InputManager.DownPressed     += OnDownPress;
            InputManager.UpPressed       += OnUpPress;
            InputManager.LeftPressed     += OnLeftPress;
            InputManager.RightPressed    += OnRightPress;
            InputManager.JumpPressed     += OnJumpPress;
            InputManager.RunPressed      += OnRunPress;
            InputManager.RunReleased     += OnRunRelease;
            InputManager.InteractPressed += OnInteractPress;
        }