Пример #1
0
        public LinkStateMachine(Game1 game, LinkSprite linkSprite, Vector2 centerPosition)
        {
            this.centerPosition = centerPosition;
            mode          = LinkMode.Still;
            linkInventory = new LinkInventory(game, this);

            currDirection = new Vector2(LinkConstants.defaultXDirection, LinkConstants.defaultYDirection);
            speed         = LinkConstants.defaultSpeed;

            this.linkSprite = linkSprite;

            totalHealth = HeartConstants.DefaultHeartCount;
            health      = totalHealth;

            remainingDamageDelay = DamageConstants.DamageDisableDelay;
            lowHealthSoundDelay  = LinkConstants.defaultSoundDelay;

            shoveDistance = LinkConstants.defaultShoveDistance;
            PauseMovement = false;
            isGrabbed     = false;
        }
Пример #2
0
        public Link(Game1 game)
        {
            this.game = game;
            // TODO Add this into sprite factory
            Texture2D          linkTexture = game.Content.Load <Texture2D>("Link");
            Texture2D          linkDamageSequenceTexture = game.Content.Load <Texture2D>("LinkDamageSequence");
            Texture2D          linkDeathTexture          = game.Content.Load <Texture2D>("LinkDeath");
            Texture2D          rectangleTexture          = new Texture2D(game.GraphicsDevice, 1, 1);
            GenericTextureMask linkDamageMaskHandler     = new GenericTextureMask(linkTexture, linkDamageSequenceTexture, LinkConstants.DamageMaskRows, LinkConstants.DamageMaskCols, 0);
            SingleMaskHandler  linkDeathMaskHandler      = new SingleMaskHandler(linkTexture, linkDeathTexture);

            Vector2 centerPosition = new Vector2(0, 0);

            linkSprite       = new LinkSprite(game.SpriteBatch, linkTexture, rectangleTexture, LinkConstants.LinkTextureRows, LinkConstants.LinkTextureCols, linkDamageMaskHandler, linkDeathMaskHandler, centerPosition);
            linkStateMachine = new LinkStateMachine(game, linkSprite, centerPosition);
            linkInventory    = linkStateMachine.Inventory;
            linkInventory.ChangeItem(InventoryManager.ItemType.None);

            //Link's body does no damage itself
            this.collidable      = new PlayerCollidable(this, 0, game);
            isGrabbed            = false;
            remainingDamageDelay = DamageConstants.DamageDisableDelay;
        }