コード例 #1
0
 public override bool Action(LivingEntity interactor, String interaction)
 {
     if (item == null || !base.Action(interactor, interaction))
         return false;
     interactor.inventory.Add(item);
     this.item = null;
     this.markForDelete = true;
     return true;
 }
コード例 #2
0
 //constructor
 public Mugging(string name, string objective, string description, Vector2 start, Player player)
     : base(name, objective, description, start, player, WinCondition.EnemyDies, 0, 10)
 {
     mugger = new LivingEntity(new FloatRectangle(start.X, start.Y, MUGGER_WIDTH, MUGGER_WIDTH), Sprites.spritesDictionary["mugger"], 10);
     knife = new Weapon(20, 1, 3, "Knife", 1, 99);
     muggerAI = new LowAI(mugger);
     mugger.ai = muggerAI;
     entitites = new List<Entity.Entity>();
     entitites.Add(mugger);
     EnemyToKill = mugger;
     //manager.CurrentWorld.manager.AddEntity(mugger);
 }
コード例 #3
0
ファイル: Entity.cs プロジェクト: dgg5503/The-Chicago-Project
        public virtual bool Action(LivingEntity interactor, String interaction)
        {
            if (markForDelete || interactData == null || interactData.Dialogue[interaction] == null)
            {
                return(false);
            }
            Response r = interactData.Dialogue[interaction];

            //Send the message to the Render Manager here.
            switch (r.Action)
            {
            case ResponseAction.StartQuest:
                //How do we start quests?
                break;

            case ResponseAction.GiveItem:
                interactor.inventory.Add((Item.Item)r.Data);
                break;

            case ResponseAction.TakeItem:
                if (interactor.inventory.EntityInventory.Contains((Item.Item)r.Data))
                {
                    interactor.inventory.EntityInventory.Remove(((Item.Item)r.Data));
                }
                break;

            case ResponseAction.Heal:
                interactor.health = Math.Min(interactor.health + (int)r.Data, interactor.maxHealth);
                break;

            default:
                break;
            }

            return(true);
        }
コード例 #4
0
ファイル: MidAI.cs プロジェクト: dgg5503/The-Chicago-Project
 public MidAI(LivingEntity entity)
     : base(entity)
 {
 }
コード例 #5
0
ファイル: HighAI.cs プロジェクト: dgg5503/The-Chicago-Project
 public HighAI(LivingEntity entity)
     : base(entity)
 {
 }
コード例 #6
0
ファイル: Entity.cs プロジェクト: dgg5503/The-Chicago-Project
        public virtual bool Action(LivingEntity interactor, String interaction)
        {
            if (markForDelete || interactData == null || interactData.Dialogue[interaction] == null)
                return false;
            Response r = interactData.Dialogue[interaction];
            //Send the message to the Render Manager here.
            switch (r.Action) {
                case ResponseAction.StartQuest:
                    //How do we start quests?
                    break;
                case ResponseAction.GiveItem:
                    interactor.inventory.Add((Item.Item) r.Data);
                    break;
                case ResponseAction.TakeItem:
                    if (interactor.inventory.EntityInventory.Contains((Item.Item) r.Data))
                        interactor.inventory.EntityInventory.Remove(((Item.Item) r.Data));
                    break;
                case ResponseAction.Heal:
                    interactor.health = Math.Min(interactor.health + (int) r.Data, interactor.maxHealth);
                    break;
                default:
                    break;
            }

            return true;
        }
コード例 #7
0
ファイル: LowAI.cs プロジェクト: dgg5503/The-Chicago-Project
 public LowAI(LivingEntity entity)
     : base(entity)
 {
 }
コード例 #8
0
        private int mapToUse; //Which map this AI is currently going for.

        #endregion Fields

        #region Constructors

        public CivilianAI(LivingEntity entity)
            : base(entity)
        {
            mapToUse = Game1.Instance.random.Next(0, 1);
            entity.color = Color.Green;
        }
コード例 #9
0
        /// <summary>
        /// Takes a path to a quest file and parses it to a quest object
        /// </summary>
        /// <param name="filename">the file path</param>
        /// <returns>A quest</returns>
        public static Quest ParseQuest(string filename)
        {
            Quest quest = null;
            Console.WriteLine("Quest file name: \n\t" + filename);
            using (StreamReader input = new StreamReader(filename))
            {

                string data = input.ReadToEnd();
                if (data.Substring(5, 12).Contains("Storyline"))
                {
                    /*
                    //load individual quests
                    int index, end;
                    index = data.IndexOf("Folder") + 8;
                    end = data.IndexOf('"', index);
                    string folder = data.Substring(index, end - index);
                    storylineFolder = QUEST_DIRECTORY + folder;

                    Storyline newStoryline;

                    string[] files = Directory.GetFiles(storylineFolder);
                    Quest loaded;

                    //loop through all of the files in the directory
                    foreach (string path in files)
                    {
                        //try and parse the quest from each file
                        loaded = ParseQuest(path);

                        //if the parse was successfull, add it to the log
                        if (loaded != null)
                        {
                            newStoryline.Add(loaded);
                        }
                    }
                     */
                }
                else
                {
                    int index, end;
                    string attribute;
                    //get name
                    index = data.IndexOf("Name:") + 6;
                    end = data.IndexOf('"', index);
                    string name = data.Substring(index, end - index);

                    //get world key
                    index = data.IndexOf("World:") + 7;
                    end = data.IndexOf('"', index);
                    string key = data.Substring(index, end - index);

                    //get the description
                    index = data.IndexOf("Description:") + 13;
                    end = data.IndexOf('"', index);
                    string description = data.Substring(index, end - index);

                    //get objective
                    index = data.IndexOf("Objective:") + 11;
                    end = data.IndexOf('"', index);
                    string objective = data.Substring(index, end - index);

                    //get reward
                    index = data.IndexOf("Reward:");
                    index = data.IndexOf("Cash:", index) + 5;
                    end = data.IndexOf("\n", index);
                    attribute = data.Substring(index, end - index);
                    int cash;
                    if (!int.TryParse(attribute, out cash))
                        cash = 0;
                    index = data.IndexOf("Q-Points:", index) + 9;
                    end = data.IndexOf("\n", index);
                    attribute = data.Substring(index, end - index);
                    int qPoints;
                    if (!int.TryParse(attribute, out qPoints))
                        qPoints = 0;

                    //get start point
                    index = data.IndexOf("Start:");
                    index = data.IndexOf("X:", index) + 2;
                    end = data.IndexOf("\n", index);
                    attribute = data.Substring(index, end - index);
                    int X;
                    if (!int.TryParse(attribute, out X))
                        X = 10;
                    index = data.IndexOf("Y:", index) + 2;
                    end = data.IndexOf("\r", index);
                    attribute = data.Substring(index, end - index);
                    int Y;
                    if (!int.TryParse(attribute, out Y))
                        Y = 10;
                    Vector2 start = new Vector2(X, Y);

                    //get the win condition
                    index = data.IndexOf("Condition:") + 10;
                    end = data.IndexOf("\r", index);
                    attribute = data.Substring(index, end - index);
                    WinCondition condition; //win state
                    switch (attribute)
                    {
                        case "EnemyDies":
                            condition = WinCondition.EnemyDies;
                            break;
                        case "ObtainItem":
                            condition = WinCondition.ObtainItem;
                            break;
                        case "DeliverItem":
                            condition = WinCondition.DeliverItem;
                            break;
                        case "AllEnemiesDead":
                        default:
                            condition = WinCondition.AllEnemiesDead;
                            break;
                    }

                    //get the id of the entity or item that satisfies the quest condition
                    string target = "";
                    string recipient = "";
                    switch (condition)
                    {
                        case WinCondition.EnemyDies:
                        case WinCondition.ObtainItem:
                            //get the name of the entity
                            index = data.IndexOf("Target:") + 7;
                            string test = data.Substring(index);
                            end = data.IndexOf('\n', index) - 1;
                            target = data.Substring(index, end - index);
                            break;
                        case WinCondition.DeliverItem:
                            //get the target item
                            index = data.IndexOf("Target:") + 7;
                            target = data.Substring(index);

                            //get destination
                            index = data.IndexOf("Recipient:") + 10;
                            end = data.IndexOf('\n');
                            recipient = data.Substring(index, index - end);
                            break;
                    }
            #region Read Enemies
                    //read all of the living entities
                    Dictionary<string, Entity.LivingEntity> livingEntities = new Dictionary<string, Entity.LivingEntity>();
                    int endEntity = data.Length;
                    FloatRectangle EntityRect;
                    AI.AI ai;
                    //string test = data.Substring(index, 10);
                    index = 1;
                    while((index = data.IndexOf("Living Entity:", index)) > 0)
                    {
                        ai = null;
                        endEntity = data.IndexOf("End Living Enity", index);

                        //get the id
                        index = data.IndexOf("ID:", index) + 3;
                        end = data.IndexOf('\r', index);
                        string id = data.Substring(index, end - index);

                        //get the start position
                        //get start point
                        index = data.IndexOf("Start:", index);
                        index = data.IndexOf("X:", index) + 2;
                        end = data.IndexOf("\n", index);
                        attribute = data.Substring(index, end - index);
                        int sX;
                        if (!int.TryParse(attribute, out sX))
                            sX = 10;
                        index = data.IndexOf("Y:", index) + 2;
                        end = data.IndexOf("\r", index);
                        attribute = data.Substring(index, end - index);
                        int sY;
                        if (!int.TryParse(attribute, out sY))
                            sY = 10;

                        //get texture
                        index = data.IndexOf("Texture:", index) + 9;
                        end = data.IndexOf('"', index);
                        string texturePath = data.Substring(index, end - index);
                        GUI.Sprite sprite = GUI.Sprites.spritesDictionary[texturePath];

                        //create rectangle
                        EntityRect = new FloatRectangle(sX, sY, sprite.Width, sprite.Height);

                        //get the health
                        index = data.IndexOf("Health:", index) + 7;
                        end = data.IndexOf('\n', index);
                        attribute = data.Substring(index, end - index);
                        int health;
                        if(!int.TryParse(attribute, out health))
                        {
                            health = 0;
                        }

                        livingEntities[id] = new Entity.LivingEntity(EntityRect, sprite, health, null);
                        livingEntities[id].Name = id;

                        //get the ai
                        index = data.IndexOf("AI:", index) + 3;
                        end = data.IndexOf('\n', index) - 1;
                        if (index >= 0)
                        {
                            attribute = data.Substring(index, end - index);

                            switch (attribute)
                            {
                                case "Low":
                                    ai = new AI.LowAI(livingEntities[id]);
                                    break;
                                case "Mid":
                                    ai = new AI.HighAI(livingEntities[id]);
                                    break;
                                case "High":
                                    ai = new AI.HighAI(livingEntities[id]);
                                    break;
                                default:
                                    ai = null;
                                    break;
                            }

                            livingEntities[id].ai = ai;
                            livingEntities[id].inventory.Add(new Item.Weapon(50, 1, 10, "Bam", 100, 0.5));
                            livingEntities[id].inventory.ActiveWeapon = 0;

                        }

                    }

            #endregion

            #region Read Items
                    Dictionary<string, QuestItem> items = new Dictionary<string,QuestItem>();
                    index = 0;
                    int endItem = data.Length;
                    while((index = data.IndexOf("Item:", index)) > 0)
                    {
                        endItem = data.IndexOf("End Item", index);

                        //get the id
                        index = data.IndexOf("ID:", index) + 3;
                        end = data.IndexOf('\n', index);
                        string id = data.Substring(index, end - index);

                        //get the texture
                        index = data.IndexOf("Texture:", index) + 9;
                        end = data.IndexOf('"', index);
                        string texturePath = data.Substring(index, end - index);
                        GUI.Sprite sprite = GUI.Sprites.spritesDictionary[texturePath];

                        //create item
                        items[id] = new QuestItem(id);
                        items[id].Item = new Item.Item();
                        items[id].Item.previewSprite = sprite;

                    }
            #endregion

                    //Create the quest
                    quest = new Quest(name, objective, description, start, null, condition, qPoints, cash);
                    quest.worldKey = key;
                    quest.Status = 1;
                    //add the entities to the quests entitiy list
                    foreach (Entity.LivingEntity entity in livingEntities.Values.ToList())
                    {
                        quest.entitites.Add(entity);
                    }

                    //items too
                    /* Quest needs to be updated
                    foreach(Item.Item item in items.Values.ToArray())
                    {
                        quest.
                    }
                     */

                    switch (condition)
                    {
                        case WinCondition.EnemyDies:
                            quest.EnemyToKill = livingEntities[target];
                            break;
                        case WinCondition.AllEnemiesDead:
                            break;
                        case WinCondition.ObtainItem:
                            quest.FindThis = items[target].Item;
                            break;
                        case WinCondition.DeliverItem:
                            quest.Delivery = items[target].Item;
                            quest.Recipient = livingEntities[recipient];
                            break;
                        default:
                            break;
                    }
                }

            }
            return quest;
        }
コード例 #10
0
ファイル: AI.cs プロジェクト: dgg5503/The-Chicago-Project
 public AI(LivingEntity entity)
 {
     this.entity = entity;
 }
コード例 #11
0
        //Josiah S DeVizia, implemented world importation
        public WorldManager()
        {
            worlds = new Dictionary<String, World>();
            worldQuests = new QuestLog();
            //TODO: Load/Save worlds.
            current = "main";

            player = new Player(new FloatRectangle(384, 72, 32, 32), Sprites.spritesDictionary["player"]);

            player.inventory.ActiveWeapon = 0;

            if(!worlds.ContainsKey(current))
                worlds.Add(current, Game1.Instance.saveManager.LoadWorld(current));

            worlds["main"].manager.AddEntity(player);
            // DEBUG
            #region debug
            #if false

            LivingEntity mugger = new LivingEntity(new FloatRectangle(384, 150, 32, 32), Sprites.spritesDictionary["player"], 10);
            mugger.ai = new MidAI(mugger);
            mugger.inventory.Add(new Item.Weapon(50, 1, 10, "Bam", 100, 0.5));
            mugger.inventory.ActiveWeapon = 0;
            //mugger.interactData = new Entity.Entity.InteractionData(new List<String>() { "I bite my thumb at you, sir!" });
            worlds["main"].manager.AddEntity(mugger);

            //LivingEntity civvie = new LivingEntity(new FloatRectangle(384, 247, 32, 32), Sprites.spritesDictionary["player"], 4);
            //civvie.ai = new CivilianAI(civvie);
            //civvie.interactData = new Entity.Entity.InteractionData(new List<String>() { "pls no." });
            //worlds["main"].manager.AddEntity(civvie);

            worlds["main"].manager.AddEntity(player);

            Quest mugging = SaveManager.ParseQuest("./Content/Quests/Mugging.quest");
            mugging.SetAvailable();
            mugging.worldManager = this;
            player.log.Add(mugging);
            this.worldQuests.Add(mugging);
            mugging.player = player;

            Quest gunman = SaveManager.ParseQuest("./Content/Quests/Crazed Gunman.quest");
            gunman.SetAvailable();
            player.log.Add(gunman);
            this.worldQuests.Add(gunman);

            Quest war = SaveManager.ParseQuest("./Content/Quests/Gang war.quest");
            war.SetAvailable();
            player.log.Add(war);
            this.worldQuests.Add(war);

            Quest sniper = SaveManager.ParseQuest("./Content/Quests/Sniper.quest");
            sniper.SetAvailable();
            player.log.Add(sniper);
            this.worldQuests.Add(sniper);
            /*
            Quest sniper1 = SaveManager.ParseQuest("./Content/Quests/Sniper1.quest");
            sniper1.SetAvailable();
            player.log.Add(sniper1);
            this.worldQuests.Add(sniper1);

            Quest sniper2 = SaveManager.ParseQuest("./Content/Quests/Sniper2.quest");
            sniper2.SetAvailable();
            player.log.Add(sniper2);
            this.worldQuests.Add(sniper2);

            Quest sniper3 = SaveManager.ParseQuest("./Content/Quests/Sniper3.quest");
            sniper3.SetAvailable();
            player.log.Add(sniper3);
            this.worldQuests.Add(sniper3);

            Quest mugging1 = SaveManager.ParseQuest("./Content/Quests/Mugging1.quest");
            mugging1.SetAvailable();
            player.log.Add(mugging1);
            this.worldQuests.Add(mugging1);

            Quest mugging2 = SaveManager.ParseQuest("./Content/Quests/Mugging2.quest");
            mugging2.SetAvailable();
            player.log.Add(mugging2);
            this.worldQuests.Add(mugging2);

            Quest mugging3 = SaveManager.ParseQuest("./Content/Quests/Mugging3.quest");
            mugging3.SetAvailable();
            player.log.Add(mugging3);
            this.worldQuests.Add(mugging3);
            */
            /*
            Quest test = new Quest("Mugging", "Kill the mugger", "You are being attacked", new Vector2(100, 1000), player, this, WinCondition.EnemyDies, 4, 50);
            test.EnemyToKill = mugger;
            test.entitites.Add(mugger);
            test.Status = 1;
            player.log.Add(test);
             */
            #endif
            // need to fix fleemap lag before renabling the above.
            #endregion
            worldQuests = new QuestLog();
            spawnDaemon = new SpawnDaemon();
            spawnThread = new Thread(new ThreadStart(spawnDaemon.startDaemon));
        }
コード例 #12
0
        /// <summary>
        /// Takes the equation of the bullet a figures out what, if anything, is hit
        /// </summary>
        /// <param name="x">The attacker x location</param>
        /// <param name="y">The attacker y location</param>
        /// <param name="i">The i component of the direction vector</param>
        /// <param name="j">The j component of the direction vector</param>
        public void FireBullet(float x, float y, float i, float j, int damage, LivingEntity shooter)
        {
            Vector2 bullet = new Vector2(x + i, y + j);
            Player player = Game1.Instance.worldManager.CurrentWorld.manager.GetPlayer();
            #region Screen Bounds
            int right = player.location.IntX + (RenderManager.ViewportWidth / 2);
            int left = player.location.IntX - (RenderManager.ViewportWidth / 2);
            int top = player.location.IntY - (RenderManager.ViewportHeight / 2);
            int bottom = player.location.IntY + (RenderManager.ViewportHeight / 2);
            #endregion

            bool go = true;
            for (int t = 1; bullet.X < right && bullet.X > left && bullet.Y < bottom && bullet.Y > top && go; t++) {
                int tileX = (int) (bullet.X / GUI.Tile.SIDE_LENGTH);
                int tileY = (int) (bullet.Y / GUI.Tile.SIDE_LENGTH);

                if (tileX < 0 || tileY < 0 || mainGame.worldManager.CurrentWorld.tiles.Length <= tileX || mainGame.worldManager.CurrentWorld.tiles[tileX].Length <= tileY) {
                    break;
                }

                if (!mainGame.worldManager.CurrentWorld.tiles[tileX][tileY].IsWalkable && !mainGame.worldManager.CurrentWorld.tiles[tileX][tileY].FileName.Equals("Water.png")) {
                    break;
                }

                for (int cntr = 0; cntr < entities.Count; cntr++) {
                    if (entities[cntr].location.Contains(bullet) && !entities[cntr].Equals(shooter)) {
                        go = false;
                        if (entities[cntr] is LivingEntity) {
                            (entities[cntr] as LivingEntity).health -= damage;
                        } else {
                            break;
                        }
                    }
                }

                bullet.X += i;
                bullet.Y += j;
            }

            // line is from x,y to bullet hit
            Game1.Instance.renderManager.EmitParticle(new Line(Color.LightGoldenrodYellow, 1, new Vector2(x, y), bullet, .05));
        }
コード例 #13
0
        /// <summary>
        /// Takes a path to a quest file and parses it to a quest object
        /// </summary>
        /// <param name="filename">the file path</param>
        /// <returns>A quest</returns>
        public static Quest ParseQuest(string filename)
        {
            Quest quest = null;

            Console.WriteLine("Quest file name: \n\t" + filename);
            using (StreamReader input = new StreamReader(filename))
            {
                string data = input.ReadToEnd();
                if (data.Substring(5, 12).Contains("Storyline"))
                {
                    /*
                     * //load individual quests
                     * int index, end;
                     * index = data.IndexOf("Folder") + 8;
                     * end = data.IndexOf('"', index);
                     * string folder = data.Substring(index, end - index);
                     * storylineFolder = QUEST_DIRECTORY + folder;
                     *
                     * Storyline newStoryline;
                     *
                     *
                     * string[] files = Directory.GetFiles(storylineFolder);
                     * Quest loaded;
                     *
                     * //loop through all of the files in the directory
                     * foreach (string path in files)
                     * {
                     *  //try and parse the quest from each file
                     *  loaded = ParseQuest(path);
                     *
                     *  //if the parse was successfull, add it to the log
                     *  if (loaded != null)
                     *  {
                     *      newStoryline.Add(loaded);
                     *  }
                     * }
                     */
                }
                else
                {
                    int    index, end;
                    string attribute;
                    //get name
                    index = data.IndexOf("Name:") + 6;
                    end   = data.IndexOf('"', index);
                    string name = data.Substring(index, end - index);

                    //get world key
                    index = data.IndexOf("World:") + 7;
                    end   = data.IndexOf('"', index);
                    string key = data.Substring(index, end - index);

                    //get the description
                    index = data.IndexOf("Description:") + 13;
                    end   = data.IndexOf('"', index);
                    string description = data.Substring(index, end - index);

                    //get objective
                    index = data.IndexOf("Objective:") + 11;
                    end   = data.IndexOf('"', index);
                    string objective = data.Substring(index, end - index);

                    //get reward
                    index     = data.IndexOf("Reward:");
                    index     = data.IndexOf("Cash:", index) + 5;
                    end       = data.IndexOf("\n", index);
                    attribute = data.Substring(index, end - index);
                    int cash;
                    if (!int.TryParse(attribute, out cash))
                    {
                        cash = 0;
                    }
                    index     = data.IndexOf("Q-Points:", index) + 9;
                    end       = data.IndexOf("\n", index);
                    attribute = data.Substring(index, end - index);
                    int qPoints;
                    if (!int.TryParse(attribute, out qPoints))
                    {
                        qPoints = 0;
                    }

                    //get start point
                    index     = data.IndexOf("Start:");
                    index     = data.IndexOf("X:", index) + 2;
                    end       = data.IndexOf("\n", index);
                    attribute = data.Substring(index, end - index);
                    int X;
                    if (!int.TryParse(attribute, out X))
                    {
                        X = 10;
                    }
                    index     = data.IndexOf("Y:", index) + 2;
                    end       = data.IndexOf("\r", index);
                    attribute = data.Substring(index, end - index);
                    int Y;
                    if (!int.TryParse(attribute, out Y))
                    {
                        Y = 10;
                    }
                    Vector2 start = new Vector2(X, Y);

                    //get the win condition
                    index     = data.IndexOf("Condition:") + 10;
                    end       = data.IndexOf("\r", index);
                    attribute = data.Substring(index, end - index);
                    WinCondition condition; //win state
                    switch (attribute)
                    {
                    case "EnemyDies":
                        condition = WinCondition.EnemyDies;
                        break;

                    case "ObtainItem":
                        condition = WinCondition.ObtainItem;
                        break;

                    case "DeliverItem":
                        condition = WinCondition.DeliverItem;
                        break;

                    case "AllEnemiesDead":
                    default:
                        condition = WinCondition.AllEnemiesDead;
                        break;
                    }

                    //get the id of the entity or item that satisfies the quest condition
                    string target    = "";
                    string recipient = "";
                    switch (condition)
                    {
                    case WinCondition.EnemyDies:
                    case WinCondition.ObtainItem:
                        //get the name of the entity
                        index = data.IndexOf("Target:") + 7;
                        string test = data.Substring(index);
                        end    = data.IndexOf('\n', index) - 1;
                        target = data.Substring(index, end - index);
                        break;

                    case WinCondition.DeliverItem:
                        //get the target item
                        index  = data.IndexOf("Target:") + 7;
                        target = data.Substring(index);

                        //get destination
                        index     = data.IndexOf("Recipient:") + 10;
                        end       = data.IndexOf('\n');
                        recipient = data.Substring(index, index - end);
                        break;
                    }
                    #region Read Enemies
                    //read all of the living entities
                    Dictionary <string, Entity.LivingEntity> livingEntities = new Dictionary <string, Entity.LivingEntity>();
                    int            endEntity = data.Length;
                    FloatRectangle EntityRect;
                    AI.AI          ai;
                    //string test = data.Substring(index, 10);
                    index = 1;
                    while ((index = data.IndexOf("Living Entity:", index)) > 0)
                    {
                        ai        = null;
                        endEntity = data.IndexOf("End Living Enity", index);

                        //get the id
                        index = data.IndexOf("ID:", index) + 3;
                        end   = data.IndexOf('\r', index);
                        string id = data.Substring(index, end - index);

                        //get the start position
                        //get start point
                        index     = data.IndexOf("Start:", index);
                        index     = data.IndexOf("X:", index) + 2;
                        end       = data.IndexOf("\n", index);
                        attribute = data.Substring(index, end - index);
                        int sX;
                        if (!int.TryParse(attribute, out sX))
                        {
                            sX = 10;
                        }
                        index     = data.IndexOf("Y:", index) + 2;
                        end       = data.IndexOf("\r", index);
                        attribute = data.Substring(index, end - index);
                        int sY;
                        if (!int.TryParse(attribute, out sY))
                        {
                            sY = 10;
                        }

                        //get texture
                        index = data.IndexOf("Texture:", index) + 9;
                        end   = data.IndexOf('"', index);
                        string     texturePath = data.Substring(index, end - index);
                        GUI.Sprite sprite      = GUI.Sprites.spritesDictionary[texturePath];

                        //create rectangle
                        EntityRect = new FloatRectangle(sX, sY, sprite.Width, sprite.Height);

                        //get the health
                        index     = data.IndexOf("Health:", index) + 7;
                        end       = data.IndexOf('\n', index);
                        attribute = data.Substring(index, end - index);
                        int health;
                        if (!int.TryParse(attribute, out health))
                        {
                            health = 0;
                        }

                        livingEntities[id]      = new Entity.LivingEntity(EntityRect, sprite, health, null);
                        livingEntities[id].Name = id;

                        //get the ai
                        index = data.IndexOf("AI:", index) + 3;
                        end   = data.IndexOf('\n', index) - 1;
                        if (index >= 0)
                        {
                            attribute = data.Substring(index, end - index);

                            switch (attribute)
                            {
                            case "Low":
                                ai = new AI.LowAI(livingEntities[id]);
                                break;

                            case "Mid":
                                ai = new AI.HighAI(livingEntities[id]);
                                break;

                            case "High":
                                ai = new AI.HighAI(livingEntities[id]);
                                break;

                            default:
                                ai = null;
                                break;
                            }

                            livingEntities[id].ai = ai;
                            livingEntities[id].inventory.Add(new Item.Weapon(50, 1, 10, "Bam", 100, 0.5));
                            livingEntities[id].inventory.ActiveWeapon = 0;
                        }
                    }

                    #endregion

                    #region Read Items
                    Dictionary <string, QuestItem> items = new Dictionary <string, QuestItem>();
                    index = 0;
                    int endItem = data.Length;
                    while ((index = data.IndexOf("Item:", index)) > 0)
                    {
                        endItem = data.IndexOf("End Item", index);

                        //get the id
                        index = data.IndexOf("ID:", index) + 3;
                        end   = data.IndexOf('\n', index);
                        string id = data.Substring(index, end - index);

                        //get the texture
                        index = data.IndexOf("Texture:", index) + 9;
                        end   = data.IndexOf('"', index);
                        string     texturePath = data.Substring(index, end - index);
                        GUI.Sprite sprite      = GUI.Sprites.spritesDictionary[texturePath];

                        //create item
                        items[id]      = new QuestItem(id);
                        items[id].Item = new Item.Item();
                        items[id].Item.previewSprite = sprite;
                    }
                    #endregion

                    //Create the quest
                    quest          = new Quest(name, objective, description, start, null, condition, qPoints, cash);
                    quest.worldKey = key;
                    quest.Status   = 1;
                    //add the entities to the quests entitiy list
                    foreach (Entity.LivingEntity entity in livingEntities.Values.ToList())
                    {
                        quest.entitites.Add(entity);
                    }

                    //items too

                    /* Quest needs to be updated
                     * foreach(Item.Item item in items.Values.ToArray())
                     * {
                     *  quest.
                     * }
                     */

                    switch (condition)
                    {
                    case WinCondition.EnemyDies:
                        quest.EnemyToKill = livingEntities[target];
                        break;

                    case WinCondition.AllEnemiesDead:
                        break;

                    case WinCondition.ObtainItem:
                        quest.FindThis = items[target].Item;
                        break;

                    case WinCondition.DeliverItem:
                        quest.Delivery  = items[target].Item;
                        quest.Recipient = livingEntities[recipient];
                        break;

                    default:
                        break;
                    }
                }
            }
            return(quest);
        }