Game-Design / Sprint2 / Sprint2_actual / Link State Files / LinkStateLeftMoving.cs
LinkStateLeftMoving.cs
Raw
using System;
using System.Collections.Generic;
using System.Text;

namespace Sprint2_actual.StateFiles
{
    class LinkStateLeftMoving : ILinkState
    {
        private Link link;

        public LinkStateLeftMoving(Link link)
        {
            this.link = link;
            link.linkSprite = new LinkSpriteLeftWalking(link);
        }
        public void Update()
        {
            link.linkX -= (int)GlobalVars.gameTime.ElapsedGameTime.TotalMilliseconds / 5;
        }
        public void TakeDamage()
        {
            link.game.Player = new DamagedLink(link);
            //TO-DO: How does game get in here? Is there any alternative to passing game?
        }
        public void MoveLeft()
        {
            //NO-OP
            //Already moving left
        }

        public void MoveRight()
        {
            link.state = new LinkStateRightMoving(link);
        }

        public void MoveUp()
        {
            link.state = new LinkStateUpMoving(link);
        }

        public void MoveDown()
        {
            link.state = new LinkStateDownMoving(link);
        }
        public void Idle()
        {
            link.state = new LinkStateLeftIdle(link);
            //this is how a moving sprite returns to its idle state when all keys are let go
        }
        public void Attack()
        {
            link.state = new LinkStateLeftAttack(link);
        }
        public void UseItem()
        {
            link.state = new LinkStateLeftUseItem(link);
            //should item type be made here? if not, we need to make a Use____() for each item and state for each item link could use.
            //May be more practical to do the latter, but latter would make it so we do not have to change our interfaces later
        }
    }
}