Game-Design / Sprint2 / Sprint2_actual / Items / DisplayItemStateMachine.cs
DisplayItemStateMachine.cs
Raw
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Sprint2_actual.SpriteFactories;
using Sprint2_actual;
using System;
using System.Collections.Generic;
using System.Text;


namespace Sprint2_actual.Items
{

    public class DisplayItemStateMachine
    {
        private enum ItemState
        {
            WoodenSword,
            WhiteSword,
            MagicalSword,
            MagicalShield,
            Boomerang,
            MagicalBoomerang,
            Bomb,
            Bow,
            Arrow,
            SilverArrow,
            BlueCandle,
            RedCandle,
            Recorder,
            Food,
            Letter,
            LifePotion,
            Potion2nd,
            MagicalRod,
            Raft,
            BookOfMagic,
            BlueRing,
            RedRing,
            Stepladder,
            MagicalKey,
            PowerBracelet,
            Compass,
            DungeonMap,
            SmallKey,
            TriforceFragment,
            RecoveryHeart,
            HeartContainer,
            Clock,
            OrangeRupee,
            BlueRupee,
            Fairy

        }

        Game1 game;
        ItemState currentState;

        public DisplayItemStateMachine(Game1 game)
        {
            this.game = game;
            currentState = ItemState.WoodenSword;
        }

        public void ChangeSprite(int nextOrPrevious)
        {
            switch (currentState)
            {
                case ItemState.WoodenSword:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Fairy;
                        game.DisplayItem = new FairyItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.WhiteSword;
                        game.DisplayItem = new WhiteSwordItem(game, 600, 250);
                    }
                    break;
                case ItemState.WhiteSword:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.WoodenSword;
                        game.DisplayItem = new WoodenSwordItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.MagicalSword;
                        game.DisplayItem = new MagicalSwordItem(game, 600, 250);
                    }
                    break;
                case ItemState.MagicalSword:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.WhiteSword;
                        game.DisplayItem = new WhiteSwordItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.MagicalShield;
                        game.DisplayItem = new MagicalShieldItem(game, 600, 250);
                    }
                    break;
                case ItemState.MagicalShield:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.MagicalSword;
                        game.DisplayItem = new MagicalSwordItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Boomerang;
                        game.DisplayItem = new BoomerangItem(game, 600, 250);
                    }
                    break;
                case ItemState.Boomerang:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.MagicalShield;
                        game.DisplayItem = new MagicalShieldItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.MagicalBoomerang;
                        game.DisplayItem = new MagicalBoomerangItem(game, 600, 250);
                    }
                    break;
                case ItemState.MagicalBoomerang:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Boomerang;
                        game.DisplayItem = new BoomerangItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Bomb;
                        game.DisplayItem = new BombItem(game, 600, 250);
                    }
                    break;
                case ItemState.Bomb:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.MagicalBoomerang;
                        game.DisplayItem = new MagicalBoomerangItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Bow;
                        game.DisplayItem = new BowItem(game, 600, 250);
                    }
                    break;
                case ItemState.Bow:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Bomb;
                        game.DisplayItem = new BombItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Arrow;
                        game.DisplayItem = new ArrowItem(game, 600, 250);
                    }
                    break;
                case ItemState.Arrow:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Bow;
                        game.DisplayItem = new BowItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.SilverArrow;
                        game.DisplayItem = new SilverArrowItem(game, 600, 250);
                    }
                    break;
                case ItemState.SilverArrow:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Arrow;
                        game.DisplayItem = new ArrowItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.BlueCandle;
                        game.DisplayItem = new BlueCandleItem(game, 600, 250);
                    }
                    break;
                case ItemState.BlueCandle:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.SilverArrow;
                        game.DisplayItem = new SilverArrowItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.RedCandle;
                        game.DisplayItem = new RedCandleItem(game, 600, 250);
                    }
                    break;
                case ItemState.RedCandle:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.BlueCandle;
                        game.DisplayItem = new BlueCandleItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Recorder;
                        game.DisplayItem = new RecorderItem(game, 600, 250);
                    }
                    break;
                case ItemState.Recorder:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.RedCandle;
                        game.DisplayItem = new RedCandleItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Food;
                        game.DisplayItem = new FoodItem(game, 600, 250);
                    }
                    break;
                case ItemState.Food:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Recorder;
                        game.DisplayItem = new RecorderItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Letter;
                        game.DisplayItem = new LetterItem(game, 600, 250);
                    }
                    break;
                case ItemState.Letter:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Food;
                        game.DisplayItem = new FoodItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.LifePotion;
                        game.DisplayItem = new LifePotionItem(game, 600, 250);
                    }
                    break;
                case ItemState.LifePotion:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Letter;
                        game.DisplayItem = new LetterItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Potion2nd;
                        game.DisplayItem = new Potion2ndItem(game, 600, 250);
                    }
                    break;
                case ItemState.Potion2nd:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.LifePotion;
                        game.DisplayItem = new LifePotionItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.MagicalRod;
                        game.DisplayItem = new MagicalRodItem(game, 600, 250);
                    }
                    break;
                case ItemState.MagicalRod:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Potion2nd;
                        game.DisplayItem = new Potion2ndItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Raft;
                        game.DisplayItem = new RaftItem(game, 600, 250);
                    }
                    break;
                case ItemState.Raft:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.MagicalRod;
                        game.DisplayItem = new MagicalRodItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.BookOfMagic;
                        game.DisplayItem = new BookOfMagicItem(game, 600, 250);
                    }
                    break;
                case ItemState.BookOfMagic:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Raft;
                        game.DisplayItem = new RaftItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.BlueRing;
                        game.DisplayItem = new BlueRingItem(game, 600, 250);
                    }
                    break;
                case ItemState.BlueRing:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.BookOfMagic;
                        game.DisplayItem = new BookOfMagicItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.RedRing;
                        game.DisplayItem = new RedRingItem(game, 600, 250);
                    }
                    break;
                case ItemState.RedRing:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.BlueRing;
                        game.DisplayItem = new BlueRingItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Stepladder;
                        game.DisplayItem = new StepladderItem(game, 600, 250);
                    }
                    break;
                case ItemState.Stepladder:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.RedRing;
                        game.DisplayItem = new RedRingItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.MagicalKey;
                        game.DisplayItem = new MagicalKeyItem(game, 600, 250);
                    }
                    break;
                case ItemState.MagicalKey:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Stepladder;
                        game.DisplayItem = new StepladderItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.PowerBracelet;
                        game.DisplayItem = new PowerBraceletItem(game, 600, 250);
                    }
                    break;
                case ItemState.PowerBracelet:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.MagicalKey;
                        game.DisplayItem = new MagicalKeyItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Compass;
                        game.DisplayItem = new CompassItem(game, 600, 250);
                    }
                    break;
                case ItemState.Compass:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.PowerBracelet;
                        game.DisplayItem = new PowerBraceletItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.DungeonMap;
                        game.DisplayItem = new DungeonMapItem(game, 600, 250);
                    }
                    break;
                case ItemState.DungeonMap:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Compass;
                        game.DisplayItem = new CompassItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.SmallKey;
                        game.DisplayItem = new SmallKeyItem(game, 600, 250);
                    }
                    break;
                case ItemState.SmallKey:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.DungeonMap;
                        game.DisplayItem = new DungeonMapItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.TriforceFragment;
                        game.DisplayItem = new TriforceFragmentItem(game, 600, 250);
                    }
                    break;
                case ItemState.TriforceFragment:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.SmallKey;
                        game.DisplayItem = new SmallKeyItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.RecoveryHeart;
                        game.DisplayItem = new RecoveryHeartItem(game, 600, 250);
                    }
                    break;
                case ItemState.RecoveryHeart:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.TriforceFragment;
                        game.DisplayItem = new TriforceFragmentItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.HeartContainer;
                        game.DisplayItem = new HeartContainerItem(game, 600, 250);
                    }
                    break;
                case ItemState.HeartContainer:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.RecoveryHeart;
                        game.DisplayItem = new RecoveryHeartItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Clock;
                        game.DisplayItem = new ClockItem(game, 600, 250);
                    }
                    break;
                case ItemState.Clock:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.HeartContainer;
                        game.DisplayItem = new HeartContainerItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.OrangeRupee;
                        game.DisplayItem = new OrangeRupeeItem(game, 600, 250);
                    }
                    break;
                case ItemState.OrangeRupee:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.Clock;
                        game.DisplayItem = new ClockItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.BlueRupee;
                        game.DisplayItem = new BlueRupeeItem(game, 600, 250);
                    }
                    break;
                case ItemState.BlueRupee:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.OrangeRupee;
                        game.DisplayItem = new OrangeRupeeItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.Fairy;
                        game.DisplayItem = new FairyItem(game, 600, 250);
                    }
                    break;
                case ItemState.Fairy:
                    if (nextOrPrevious < 0)
                    {
                        currentState = ItemState.BlueRupee;
                        game.DisplayItem = new BlueRupeeItem(game, 600, 250);
                    }
                    else
                    {
                        currentState = ItemState.WoodenSword;
                        game.DisplayItem = new WoodenSwordItem(game, 600, 250);
                    }
                    break;

            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            //game.DisplayItem.DrawItem();
        }

        public void Update(GameTime gameTime)
        {
            //game.DisplayItem.UpdateItem(gameTime);
        }


    }
}