示例#1
0
        public void updateRigidbody(SpritesheetManager spritesheetManager = null)
        {
            rigidBody.applyGravity();
            rigidBody.collisionRectangle.Y += (int)rigidBody.yMovementPossible();

            float netXMovement = rigidBody.xMovementPossible();

            if (spritesheetManager != null)
            {
                spritesheetManager.updateSpritesheetPos(netXMovement / Game1.currentMap.tileSize);
            }
            rigidBody.collisionRectangle.X += (int)netXMovement;
        }
示例#2
0
        public Player(Texture2D standTexture, Texture2D[] walkTexture, Texture2D jumpTexture, float walkFrameDist, int screenWidth, int screenHeight, Inventory inventory, StatManager statManager, Vector2 startingRelativeOffset = new Vector2(), SpriteEffects currentEffect = SpriteEffects.None)
        {
            this.screenWidth  = screenWidth;
            this.screenHeight = screenHeight;
            this.inventory    = inventory;
            playerGUI         = new GUI(this);
            rigidBody         = new RigidBody(1);
            OnTileBreak       = new EventHandler((sender, e) => { });
            this.statManager  = statManager;

            spritesheetManager = new SpritesheetManager(this, walkFrameDist, new Texture2D[3, 2] {
                { standTexture, null }, { walkTexture[0], walkTexture[1] }, { jumpTexture, null }
            });
            float heightToWidthRatio = (float)spritesheetManager.spritesheet[0, 0].Height / spritesheetManager.spritesheet[0, 0].Width;

            drawRectangle = new Rectangle((screenWidth - Game1.currentMap.tileSize) / 2, (int)(screenHeight - (heightToWidthRatio * Game1.currentMap.tileSize)) / 2, Game1.currentMap.tileSize, (int)(heightToWidthRatio * Game1.currentMap.tileSize));
            rigidBody.collisionRectangle = new Rectangle((screenWidth - ((Game1.currentMap.tileSize / 3) * 2)) / 2, (int)(screenHeight - (heightToWidthRatio * Game1.currentMap.tileSize)) / 2, ((Game1.currentMap.tileSize / 3) * 2), (int)(heightToWidthRatio * Game1.currentMap.tileSize));
        }
示例#3
0
        public Enemy(Texture2D standTexture, Texture2D[] walkTexture, Texture2D jumpTexture, int[] drawDimensions, float walkFrameDist, RigidBody rigidBody, MovementAI movementAI, StatManager statManager, int attackTime, Attack attackAction)
        {
            this.attackAction = attackAction;
            this.attackTime   = attackTime;
            movementAI.OnDestinationReached += attack;
            this.movementAI      = movementAI;
            this.rigidBody       = rigidBody;
            movementAI.rigidBody = rigidBody;
            this.statManager     = statManager;
            this.drawDimensions  = drawDimensions;

            Texture2D[,] spritesheet = new Texture2D[3, walkTexture.Length];
            spritesheet[0, 0]        = standTexture;
            for (int i = 0; i < walkTexture.Length; i++)
            {
                spritesheet[1, i] = walkTexture[i];
            }
            spritesheet[2, 0]  = jumpTexture;
            spritesheetManager = new SpritesheetManager(this, walkFrameDist, spritesheet);
        }