/// <summary>
        /// Creates a mundane map item from the parameters.
        /// </summary>
        /// <param name="internalName">The internal name</param>
        /// <param name="name">The name to be shown when the user clicks on it</param>
        /// <param name="description">A description shown when the item is examined</param>
        /// <param name="graphic">The graphic to show</param>
        /// <param name="canHaveItems">Whether it can have items placed on it or not</param>
        /// <returns></returns>
        public MapItem CreateItem(string name, string description, string graphic, string canHaveItems)
        {
            MapItem item = new MapItem();
            item.Description = description;

            string chosenGraphic = String.Empty;

            //Does graphic contain multiple choices?
            if (graphic.Contains(","))
            {
                //yes, lets split it
                var graphics = graphic.Split(',');

                //use random to determine which one we want
                chosenGraphic = graphics[_random.Next(graphics.Length)];

                item.Graphic = SpriteManager.GetSprite((LocalSpriteName)Enum.Parse(typeof(LocalSpriteName), chosenGraphic));
            }
            else
            {
                //nope
                item.Graphic = SpriteManager.GetSprite((LocalSpriteName)Enum.Parse(typeof(LocalSpriteName), graphic));
            }

            item.MayContainItems = Boolean.Parse(canHaveItems);
            item.Name = name;

            return item;
        }
        public static void GenerateDungeon()
        {
            MapCoordinate start = null;
            Actor[] actors = null;
            List<PointOfInterest> pointsOfInterest = null;

            string getOwner = ActorGeneration.GetEnemyType(true);

            Dungeon dungeon = null;

            MapBlock[,] generatedMap = DungeonGenerator.GenerateDungeonLevel(1, 30, out start, out actors,out dungeon);

            GameState.LocalMap = new LocalMap(500, 500, 1, 0);
            GameState.LocalMap.PointsOfInterest = pointsOfInterest;
            GameState.LocalMap.IsUnderground = true;
            GameState.LocalMap.Location = dungeon;

            for(int i=0; i < 21; i++)
            {
                GameState.LocalMap.MinuteChanged(null,null); //Summon!
            }

            List<MapBlock> collapsedMap = new List<MapBlock>();

            foreach (MapBlock block in generatedMap)
            {
                collapsedMap.Add(block);
            }

            GameState.LocalMap.AddToLocalMap(collapsedMap.ToArray());
            GameState.LocalMap.Actors = actors.ToList<Actor>();

            MapItem player = new MapItem();
            player.Coordinate = start;
            player.Description = "The player character";
            player.Graphic = SpriteManager.GetSprite(LocalSpriteName.PLAYERCHAR_MALE);
            player.InternalName = "Player Char";
            player.MayContainItems = false;
            player.Name = "Player";

            MapBlock playerBlock = GameState.LocalMap.GetBlockAtCoordinate(start);
            playerBlock.PutItemOnBlock(player);

            GameState.PlayerCharacter = new Actor();
            GameState.PlayerCharacter.MapCharacter = player;
            GameState.PlayerCharacter.IsPlayerCharacter = true;

            GameState.PlayerCharacter.Attributes = ActorGeneration.GenerateAttributes("human", DRObjects.ActorHandling.CharacterSheet.Enums.ActorProfession.WARRIOR, 10, GameState.PlayerCharacter);
            GameState.PlayerCharacter.Anatomy = ActorGeneration.GenerateAnatomy("human");

            GameState.PlayerCharacter.Attributes.Health = GameState.PlayerCharacter.Anatomy;

            GameState.LocalMap.Actors.Add(GameState.PlayerCharacter);

            //Generate the pathfinding map
            GameState.LocalMap.GeneratePathfindingMap();
        }
        /// <summary>
        /// Creates a mundane map item from the parameters.
        /// </summary>
        /// <param name="internalName">The internal name</param>
        /// <param name="name">The name to be shown when the user clicks on it</param>
        /// <param name="description">A description shown when the item is examined</param>
        /// <param name="graphic">The graphic to show</param>
        /// <param name="canHaveItems">Whether it can have items placed on it or not</param>
        /// <returns></returns>
        public MapItem CreateItem(string name, string description, string graphic, string canHaveItems,string tags)
        {
            MapItem item = new MapItem();
            item.Description = description;
            item.Graphic = SpriteManager.GetSprite((LocalSpriteName)Enum.Parse(typeof(LocalSpriteName), graphic));
            item.MayContainItems = Boolean.Parse(canHaveItems);
            item.Name = name;
            item.InternalName = tags;

            return item;
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out DRObjects.Enums.InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            actionType = null;
            internalActionType = null;
            args = null;
            coord = null;
            destroy = false;
            itm = null;

            //Clicked on a context menu item?
            foreach (var contextMenu in contextMenuChoices)
            {
                if (contextMenu.Rect.Contains(x, y))
                {
                    //Yes. Perform the action
                    //this.selectedItem.PerformAction(contextMenu.Action, this.CurrentActor, contextMenu.Args);
                    actionType = contextMenu.Action;
                    args = contextMenu.Args;
                    itm = selectedItem;
                }
            }

            //remove the contextual menu
            this.contextMenu = new Rectangle(0, 0, 0, 0);
            contextMenuChoices = new List<ContextMenuItem>();
            selectedItem = null;

            for (int i=0; i < categories.Count; i++)
            {
                if (categories[i].Contains(x, y))
                {
                    //Change category!
                    this.ChosenCategory = i;

                    //remove the contextual menu
                    contextMenu = new Rectangle(0, 0, 0, 0);
                    contextMenuChoices = new List<ContextMenuItem>();
                    selectedItem = null;

                    //Handled. Naught else
                    return true;
                }
            }

            //Have we clicked on an item ?
            List<InventoryItemRectangle> allItemBoxes = new List<InventoryItemRectangle>();
            allItemBoxes.AddRange(row1Items);
            allItemBoxes.AddRange(row2Items);
            allItemBoxes.AddRange(row3Items);

            foreach (InventoryItemRectangle rect in allItemBoxes)
            {
                if (rect.Rect.Contains(x, y))
                {
                    //remove the contextual menu
                    contextMenu = new Rectangle(0, 0, 0, 0);
                    contextMenuChoices = new List<ContextMenuItem>();
                    selectedItem = null;

                    //Does it contain an item?
                    if (rect.Item != null)
                    {
                        //Yes - open contextual menu
                        contextMenu = new Rectangle(x+15, y+15, 0, 0);
                        selectedItem = rect.Item;

                        foreach (var action in rect.Item.GetPossibleActions(this.CurrentActor))
                        {
                            AddContextMenuItem(action, new object[0] { }, content);
                        }

                        //done
                        return true;
                    }
                    else
                    {
                        return true; //Empty box
                    }

                }
            }

            //Have we clicked on an equipped item?
            foreach (EquippedItemRectangle rect in equipmentRectangles)
            {
                if (rect.Rect.Contains(x, y))
                {
                    //remove the contextual menu
                    contextMenu = new Rectangle(0, 0, 0, 0);
                    contextMenuChoices = new List<ContextMenuItem>();
                    selectedItem = null;

                    //Does it contain an item?
                    if (rect.InventoryItem != null)
                    {
                        //Yes - open contextual menu
                        contextMenu = new Rectangle(x + 15, y + 15, 0, 0);
                        selectedItem = rect.InventoryItem;

                        foreach (var action in rect.InventoryItem.GetPossibleActions(this.CurrentActor))
                        {
                            AddContextMenuItem(action, new object[0] { }, content);
                        }

                        //done
                        return true;
                    }
                    else
                    {
                        return true; //Empty box
                    }
                }
            }

            return true;
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            Point point = new Point(x, y);

            item = null;
            args = null;
            coord = null;
            destroy = false;
            actionType = null;
            internalActionType = null;

            if (!visible)
            {
                return false; //don't do anything
            }

            //If we pressed a stance button, just change it
            if (this.defensiveStatusRect.Contains(point))
            {
                //Swap stance to defensive
                attacker.CombatStance = DRObjects.ActorHandling.ActorStance.DEFENSIVE;
                return true;
            }
            else if (this.aggressiveStatusRect.Contains(point))
            {
                //Aggressive
                attacker.CombatStance = DRObjects.ActorHandling.ActorStance.AGGRESSIVE;
                return true;
            }
            else if (this.normalStatusRect.Contains(point))
            {
                //Normal
                attacker.CombatStance = DRObjects.ActorHandling.ActorStance.NEUTRAL;
                return true;
            }

            //Where did the user click?
            if (attackButtonRectangle.Contains(point))
            {
                //Then attack
                actionType = ActionType.ATTACK;
                List<object> argumentList = new List<object>();
                argumentList.Add(this.attacker);
                argumentList.Add(this.TargetActor);
                argumentList.Add(currentAttackLocation);

                args = argumentList.ToArray();

                return true;
            }

            //Did they click on something? Change the target
            if (headRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.HEAD;
                return true;
            }

            if (leftArmRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.LEFT_ARM;
                return true;
            }

            if (chestRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.CHEST;
                return true;

            }

            if (rightArmRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.RIGHT_ARM;
                return true;
            }

            if (legRect.Contains(point))
            {
                this.currentAttackLocation = AttackLocation.LEGS;
                return true;
            }

            if (closeRect.Contains(point))
            {
                //Then close it
                destroy = true;

                return true;
            }

            //Did we click on a special attack?
            for(int i=0; i < saRects.Length; i++)
            {
                var rectangle = saRects[i];
                if (rectangle.Contains(x,y))
                {
                    //Valid special attack?
                    if (attacker.SpecialAttacks[i] != null && attacker.SpecialAttacks[i].TimeOutLeft == 0)
                    {
                        //Then attack
                        actionType = ActionType.ATTACK;
                        List<object> argumentList = new List<object>();
                        argumentList.Add(this.attacker);
                        argumentList.Add(this.TargetActor);
                        argumentList.Add(AttackLocation.CHEST);
                        argumentList.Add(attacker.SpecialAttacks[i]);

                        args = argumentList.ToArray();

                        return true;

                        //Attack!
                    }
                }
            }

            return visible; //If it's visible - block it. Otherwise do nothing
        }
        bool IGameInterfaceComponent.HandleClick(int x, int y, MouseActionEnum mouse, out DRObjects.Enums.ActionType? actionType,out InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            //This component will 'absorb' the click, but do nothing whatsoever.
            actionType = null;
            args = null;
            coord = null;
            destroy = false;
            internalActionType = null;
            itm = null;

            return true;
        }
        public override void Initialize()
        {
            base.Initialize();
            if (parameters.Length == 0)
            {
                TestFunctions.PrepareFileTestMap();
            }
            else if (parameters[0].ToString().Equals("Village"))
            {
                //TestFunctions.ParseXML();
                TestFunctions.GenerateSettlement();

                InventoryItemManager mgr = new InventoryItemManager();

                for (int i = 0; i < 500; i++)
                {
                    var block = GameState.LocalMap.GetBlockAtCoordinate(new MapCoordinate(GameState.Random.Next(GameState.LocalMap.localGameMap.GetLength(0)), GameState.Random.Next(GameState.LocalMap.localGameMap.GetLength(1)), 0, MapType.LOCAL));

                    if (block.MayContainItems)
                    {
                        var item = mgr.CreateItem(DatabaseHandling.GetItemIdFromTag(Archetype.INVENTORYITEMS, "loot")) as InventoryItem;
                        item.Coordinate = new MapCoordinate(block.Tile.Coordinate);
                        block.ForcePutItemOnBlock(item);
                    }
                }

                //Create the new character stuff
                MultiDecisionComponent mdc = new MultiDecisionComponent(PlayableWidth / 2 - 250, 150, CharacterCreation.GenerateCharacterCreation());
                mdc.Visible = true;

                interfaceComponents.Add(mdc);

                GameState.LocalMap.IsGlobalMap = false;

            }
            else if (parameters[0].ToString().Equals("Continue"))
            {
                GameState.LoadGame();
            }
            else if (parameters[0].ToString().Equals("WorldMap"))
            {
                //Load from the world map
                var worldMap = GameState.GlobalMap.globalGameMap;

                List<MapBlock> collapsedMap = new List<MapBlock>();

                foreach (var block in worldMap)
                {
                    collapsedMap.Add(block);
                }

                GameState.LocalMap = new LocalMap(GameState.GlobalMap.globalGameMap.GetLength(0), GameState.GlobalMap.globalGameMap.GetLength(1), 1, 0);

                //Go through each of them, add them to the local map
                GameState.LocalMap.AddToLocalMap(collapsedMap.ToArray());

                //Let's start the player off at the first capital
                var coordinate = GameState.GlobalMap.WorldSettlements.Where(w => w.IsCapital).Select(w => w.Coordinate).FirstOrDefault();

                //Create the player character. For now randomly. Later we'll start at a capital
                MapItem player = new MapItem();
                player.Coordinate = new MapCoordinate(coordinate);
                player.Description = "The player character";
                player.Graphic = SpriteManager.GetSprite(LocalSpriteName.PLAYERCHAR_MALE);
                player.InternalName = "Player Char";
                player.MayContainItems = false;
                player.Name = "Player";

                MapBlock playerBlock = GameState.LocalMap.GetBlockAtCoordinate(player.Coordinate);
                playerBlock.PutItemOnBlock(player);

                GameState.PlayerCharacter = new Actor();
                GameState.PlayerCharacter.MapCharacter = player;
                GameState.PlayerCharacter.IsPlayerCharacter = true;

                GameState.PlayerCharacter.Attributes = ActorGeneration.GenerateAttributes("human", DRObjects.ActorHandling.CharacterSheet.Enums.ActorProfession.WARRIOR, 10, GameState.PlayerCharacter);
                GameState.PlayerCharacter.Anatomy = ActorGeneration.GenerateAnatomy("human");

                GameState.PlayerCharacter.Attributes.Health = GameState.PlayerCharacter.Anatomy;

                GameState.PlayerCharacter.Inventory.EquippedItems = ActorGeneration.GenerateEquippedItems(250); //give him 250 worth of stuff

                foreach (var item in GameState.PlayerCharacter.Inventory.EquippedItems.Values)
                {
                    GameState.PlayerCharacter.Inventory.Inventory.Add(item.Category, item);
                }

                GameState.LocalMap.Actors.Add(GameState.PlayerCharacter);

                //What attributes do we want?
                MultiDecisionComponent mdc = new MultiDecisionComponent(PlayableWidth / 2 - 250, 150, CharacterCreation.GenerateCharacterCreation());
                mdc.Visible = true;

                interfaceComponents.Add(mdc);

                GameState.LocalMap.IsGlobalMap = true;

            }
            else if (parameters[0].ToString().Equals("Camp"))
            {

                TestFunctions.ParseXML();
            }
            else
            {
                TestFunctions.GenerateDungeon();

                //Give him random stats so he won't completly suck
                CharacterCreation.ProcessParameters(CharacterCreation.GenerateRandom());

                //Also give him a bow of some sort
                InventoryItemManager iim = new InventoryItemManager();

                InventoryItem item = iim.GetBestCanAfford("WEAPON", 500);

                GameState.PlayerCharacter.SpecialAttacks[0] = SpecialAttacksGenerator.GenerateSpecialAttack(1);
                GameState.PlayerCharacter.SpecialAttacks[1] = SpecialAttacksGenerator.GenerateSpecialAttack(2);
                GameState.PlayerCharacter.SpecialAttacks[2] = SpecialAttacksGenerator.GenerateSpecialAttack(3);

                GameState.PlayerCharacter.SpecialAttacks[1].TimeOutLeft = 5;

              //  GameState.PlayerCharacter.SpecialAttacks[3] = SpecialAttacksGenerator.GenerateSpecialAttack(4);
               // GameState.PlayerCharacter.SpecialAttacks[4] = SpecialAttacksGenerator.GenerateSpecialAttack(5);

                item.InInventory = true;

                //Give them a bunch of potions at random
                for (int i = 0; i < 5; i++ )
                {
                    var potionType = (PotionType[])Enum.GetValues(typeof(PotionType));
                    var potion = potionType.GetRandom();
                    var p = new Potion(potion);

                    p.InInventory = true;

                    GameState.PlayerCharacter.Inventory.Inventory.Add(p.Category, p);
                }

                GameState.PlayerCharacter.Inventory.Inventory.Add(item.Category, item);

            }

            //Add the health control
            HealthDisplayComponent hdc = new HealthDisplayComponent(50, 50, GameState.LocalMap.Actors.Where(a => a.IsPlayerCharacter).FirstOrDefault());
            hdc.Visible = false;
            interfaceComponents.Add(hdc);

            CharacterSheetComponent csc = new CharacterSheetComponent(50, 50, GameState.LocalMap.Actors.Where(a => a.IsPlayerCharacter).FirstOrDefault());
            csc.Visible = false;
            interfaceComponents.Add(csc);

            InventoryDisplayComponent ivt = new InventoryDisplayComponent(50, 50, GameState.LocalMap.Actors.Where(a => a.IsPlayerCharacter).FirstOrDefault());
            ivt.Visible = false;
            interfaceComponents.Add(ivt);

            TextLogComponent tlc = new TextLogComponent(10, GraphicsDevice.Viewport.Height - 50, GameState.NewLog);
            tlc.Visible = true;
            interfaceComponents.Add(tlc);

            log = tlc;

            AdventureDisplayComponent tdc = new AdventureDisplayComponent(GraphicsDevice.Viewport.Width / 2 - 100, 0);
            interfaceComponents.Add(tdc);

            var cemetry = SpriteManager.GetSprite(InterfaceSpriteName.DEAD);

            //Create the menu buttons
            menuButtons.Add(new AutoSizeGameButton("  Health  ", this.game.Content, InternalActionEnum.OPEN_HEALTH, new object[] { }, 50, GraphicsDevice.Viewport.Height - 35));
            menuButtons.Add(new AutoSizeGameButton(" Attributes ", this.game.Content, InternalActionEnum.OPEN_ATTRIBUTES, new object[] { }, 150, GraphicsDevice.Viewport.Height - 35));

            if (GameState.LocalMap.Location as Settlement != null)
            {
                menuButtons.Add(new AutoSizeGameButton(" Settlement ", this.game.Content, InternalActionEnum.TOGGLE_SETTLEMENT, new object[] { }, 270, GraphicsDevice.Viewport.Height - 35));
                LocationDetailsComponent ldc = new LocationDetailsComponent(GameState.LocalMap.Location as Settlement, PlayableWidth - 170, 0);
                ldc.Visible = true;
                interfaceComponents.Add(ldc);
            }

            menuButtons.Add(new AutoSizeGameButton(" Inventory ", this.game.Content, InternalActionEnum.OPEN_INVENTORY, new object[] { }, 350, GraphicsDevice.Viewport.Height - 35));

            //Invoke a size change
            Window_ClientSizeChanged(null, null);
        }
Exemple #8
0
 /// <summary>
 /// Removes a particular item in the block
 /// </summary>
 /// <param name="item"></param>
 public void RemoveItem(MapItem item)
 {
     this.mapItems.Remove(item);
 }
Exemple #9
0
        /// <summary>
        /// Adds a local map item in the current block.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public ActionFeedback[] PutItemOnBlock(MapItem item)
        {
            //First check whether the top item in question allows items to be placed upon it

            MapItem top = this.GetTopItem();

            if (top == null || !top.MayContainItems)
            {
                //can't do it
                return new ActionFeedback[] { new TextFeedback("Can't do that") };
            }
            else
            {
                //move the item - we'll remove it from the list lazily later
                item.Coordinate = Tile.Coordinate;
                this.mapItems.Add(item);

                return new ActionFeedback[0];
            }
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out DRObjects.Enums.InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            actionType = null;
            internalActionType = null;
            args = null;
            coord = null;
            destroy = false;
            itm = null;

            feedbackText = String.Empty;
            feedbackColour = Color.White;

            //Clicked on the button?
            if (swapButton.Contains(x, y))
            {
                Buy = !Buy;

                //Remove all selections
                foreach (var item in row1Items.Union(row2Items).Union(row3Items))
                {
                    item.Selected = false;
                }

                return true;
            }

            if (closeButton.Contains(x, y))
            {
                //Close it
                destroy = true;
                return true;
            }

            if (confirmButton.Contains(x, y))
            {
                //Are they next to each other?
                if (this.VendorActor.MapCharacter.Coordinate - this.PlayerActor.MapCharacter.Coordinate > 2)
                {
                    feedbackText = "You're too far away";
                    feedbackColour = Color.DarkRed;
                    return true; //invalid
                }

                //Valid ?
                if (this.Buy)
                {
                    if (this.totalSelected > PlayerActor.Inventory.TotalMoney)
                    {
                        feedbackText = "You can't afford that";
                        feedbackColour = Color.DarkRed;
                        //Nope
                        return true;
                    }

                    //Allright, lets do this

                    //Take the items
                    foreach (var item in GetSelected())
                    {
                        this.VendorActor.VendorDetails.Stock.Remove(item.Item.Category, item.Item);
                        this.PlayerActor.Inventory.Inventory.Add(item.Item.Category, item.Item);
                    }

                    //Give him the money
                    this.PlayerActor.Inventory.TotalMoney -= totalSelected;
                    this.VendorActor.VendorDetails.Money += totalSelected;

                    //Remove all selections
                    foreach (var item in row1Items.Union(row2Items).Union(row3Items))
                    {
                        item.Selected = false;
                    }

                    feedbackText = "You finalise your purchase";
                    feedbackColour = Color.DarkGreen;
                }
                else
                {
                    if (this.totalSelected > this.VendorActor.VendorDetails.Money)
                    {
                        //Nope
                        feedbackText = "The Vendor hasn't got enough money to pay for those";
                        feedbackColour = Color.DarkRed;
                        return true;
                    }

                    //Allright, lets do this

                    //Take the items
                    foreach (var item in GetSelected())
                    {
                        this.PlayerActor.Inventory.Inventory.Remove(item.Item.Category, item.Item);
                        this.VendorActor.VendorDetails.Stock.Add(item.Item.Category, item.Item);
                    }

                    //Give him the money
                    this.PlayerActor.Inventory.TotalMoney += totalSelected;
                    this.VendorActor.VendorDetails.Money -= totalSelected;

                    //Remove all selections
                    foreach (var item in row1Items.Union(row2Items).Union(row3Items))
                    {
                        item.Selected = false;
                    }

                    feedbackText = "You finalise your trade";
                    feedbackColour = Color.DarkGreen;
                }

            }

            for (int i = 0; i < categories.Count; i++)
            {
                if (categories[i].Contains(x, y))
                {
                    //Change category!
                    this.ChosenCategory = i;

                    //Remove all selections
                    foreach (var item in row1Items.Union(row2Items).Union(row3Items))
                    {
                        item.Selected = false;
                    }

                    //Handled. Naught else
                    return true;
                }
            }

            //Have we clicked on an item ?
            List<InventoryItemRectangle> allItemBoxes = new List<InventoryItemRectangle>();
            allItemBoxes.AddRange(row1Items);
            allItemBoxes.AddRange(row2Items);
            allItemBoxes.AddRange(row3Items);

            foreach (InventoryItemRectangle rect in allItemBoxes)
            {
                if (rect.Rect.Contains(x, y))
                {
                    //Does it contain an item?
                    if (rect.Item != null)
                    {
                        //Toggle the selection
                        rect.Selected = !rect.Selected;
                    }
                    else
                    {
                        return true; //Empty box
                    }

                }
            }

            return true;
        }
        public static void GenerateSettlement()
        {
            var settlement = SettlementGenerator.GenerateSettlement(new MapCoordinate(50, 50, 0, DRObjects.Enums.MapType.GLOBAL), GameState.Random.Next(10) + 2, new List<DRObjects.Enums.GlobalResourceType>(), new Civilisation() { Name = "Llama Empire", ID = 0 });

            GameState.LocalMap = new LocalMap(250, 250, 1, 0);
            GameState.LocalMap.Location = settlement;

            settlement.Civilisation = new Civilisation()
            {
                Faction = OwningFactions.HUMANS,
                ID = 1,
                Name = "Holy Llama Kingdom"
            };

            List<Actor> actors = null;

            PointOfInterest startPoint = null;

            var gennedMap = SettlementGenerator.GenerateMap(settlement, out actors, out startPoint);

            List<MapBlock> collapsedMap = new List<MapBlock>();

            foreach (MapBlock block in gennedMap)
            {
                collapsedMap.Add(block);
            }

            GameState.LocalMap.AddToLocalMap(collapsedMap.ToArray());

            MapItem player = new MapItem();
            player.Coordinate = startPoint.Coordinate;
            player.Description = "The player character";
            player.Graphic = SpriteManager.GetSprite(LocalSpriteName.PLAYERCHAR_MALE);
            player.InternalName = "Player Char";
            player.MayContainItems = false;
            player.Name = "Player";

            MapBlock playerBlock = GameState.LocalMap.GetBlockAtCoordinate(player.Coordinate);
            playerBlock.PutItemOnBlock(player);

            GameState.PlayerCharacter = new Actor();
            GameState.PlayerCharacter.MapCharacter = player;
            GameState.PlayerCharacter.IsPlayerCharacter = true;

            GameState.PlayerCharacter.Attributes = ActorGeneration.GenerateAttributes("human", DRObjects.ActorHandling.CharacterSheet.Enums.ActorProfession.WARRIOR, 10, GameState.PlayerCharacter);

            GameState.PlayerCharacter.Anatomy = ActorGeneration.GenerateAnatomy("human");

            GameState.PlayerCharacter.Attributes.Health = GameState.PlayerCharacter.Anatomy;

            GameState.LocalMap.Actors.Add(GameState.PlayerCharacter);
            GameState.LocalMap.Actors.AddRange(actors);
        }
        public static void PrepareFileTestMap()
        {
            GameState.LocalMap = new LocalMap(15, 15, 0, 0);

            //GameState.LocalMap.LoadLocalMap(mgr.GetMap("testmap"),0);

            //Add player character
            //Player character
            DivineRightGame.GameState.PlayerCharacter = new DRObjects.Actor();
            GameState.PlayerCharacter.IsPlayerCharacter = true;
            GameState.PlayerCharacter.Anatomy = ActorGeneration.GenerateAnatomy("human");

            MapBlock block = GameState.LocalMap.GetBlockAtCoordinate(new MapCoordinate(5, 5, 0, DRObjects.Enums.MapType.LOCAL));

            MapItem player = new MapItem();
            player.Coordinate = new MapCoordinate(5, 5, 0, DRObjects.Enums.MapType.LOCAL);
            player.Description = "The player character";
            player.Graphic = SpriteManager.GetSprite(LocalSpriteName.PLAYERCHAR_MALE);
            player.InternalName = "Player Char";
            player.MayContainItems = false;
            player.Name = "Player";

            block.PutItemOnBlock(player);
            GameState.PlayerCharacter.MapCharacter = player;
        }
        public static void ParseXML()
        {
            LocalMapXMLParser parser = new LocalMapXMLParser();

            //Maplet maplet = parser.ParseMaplet(@"Maplets/IronMine.xml");

            Actor[] tempy = null;

            //MapBlock[,] generatedMap = gen.GenerateMap(0, null, maplet, true,"human",DRObjects.Enums.OwningFactions.HUMANS,out tempy);

            //put in the map

            ////Generate it
            LocalMapGenerator gen = new LocalMapGenerator();

            SiteData siteData = new SiteData();
            siteData.SiteTypeData = SiteDataManager.GetData(SiteType.STABLES);

            siteData.Biome = GlobalBiome.DENSE_FOREST;
            siteData.Owners = OwningFactions.HUMANS;

            //Locate the right actor counts
            siteData.LoadAppropriateActorCounts();

            MapBlock[,] generatedMap = SiteGenerator.GenerateSite(siteData, out tempy);

            GameState.LocalMap = new LocalMap(50, 50, 1, 0);
            GameState.LocalMap.Actors = tempy.ToList();

            List<MapBlock> collapsedMap = new List<MapBlock>();

            foreach (MapBlock block in generatedMap)
            {
                collapsedMap.Add(block);
            }

            GameState.LocalMap.AddToLocalMap(collapsedMap.ToArray());

            MapItem player = new MapItem();
            player.Coordinate = new MapCoordinate(10, 5, 0, DRObjects.Enums.MapType.LOCAL);
            player.Description = "The player character";
            player.Graphic = SpriteManager.GetSprite(LocalSpriteName.PLAYERCHAR_MALE);
            player.InternalName = "Player Char";
            player.MayContainItems = false;
            player.Name = "Player";

            MapBlock playerBlock = GameState.LocalMap.GetBlockAtCoordinate(new MapCoordinate(5, 5, 0, DRObjects.Enums.MapType.LOCAL));
            playerBlock.PutItemOnBlock(player);
            GameState.PlayerCharacter = new Actor();
            GameState.PlayerCharacter.MapCharacter = player;
            GameState.PlayerCharacter.IsPlayerCharacter = true;

            GameState.LocalMap.Actors.Add(GameState.PlayerCharacter);

            GameState.PlayerCharacter.Attributes = ActorGeneration.GenerateAttributes("human", DRObjects.ActorHandling.CharacterSheet.Enums.ActorProfession.WARRIOR, 10, GameState.PlayerCharacter);
            GameState.PlayerCharacter.Anatomy = ActorGeneration.GenerateAnatomy("human");

            GameState.PlayerCharacter.Attributes.Health = GameState.PlayerCharacter.Anatomy;
        }
        /// <summary>
        /// Performs the action and handles feedback
        /// </summary>
        /// <param name="?"></param>
        public void PerformAction(MapCoordinate coord, MapItem item, DRObjects.Enums.ActionType actionType, object[] args)
        {
            //remove any viewtiletext components or contextmenu components
            for (int i = 0; i < interfaceComponents.Count; i++)
            {
                var type = interfaceComponents[i].GetType();
                if (type.Equals(typeof(ViewTileTextComponent)) || type.Equals(typeof(ContextMenuComponent)))
                {
                    //delete
                    interfaceComponents.RemoveAt(i);
                    i--;
                }
            }

            ActionFeedback[] fb = UserInterfaceManager.PerformAction(coord, item, actionType, args);

            //go through all the feedback

            for (int i = 0; i < fb.Length; i++)
            {
                ActionFeedback feedback = fb[i];

                if (feedback == null)
                {
                    continue;
                }

                if (feedback.GetType().Equals(typeof(AttackFeedback)))
                {
                    AttackFeedback af = feedback as AttackFeedback;

                    var combatAf = CombatManager.Attack(af.Attacker, af.Defender, AttackLocation.CHEST); //always attack the chest

                    var tempFBList = fb.ToList();
                    tempFBList.AddRange(combatAf);

                    fb = tempFBList.ToArray();

                }
                else if (feedback.GetType().Equals(typeof(OpenInterfaceFeedback)))
                {
                    OpenInterfaceFeedback oif= feedback as OpenInterfaceFeedback;

                    //Generate one
                    if (oif.Interface.GetType() == typeof(CombatManualInterface))
                    {
                        var cmi = oif.Interface as CombatManualInterface;

                        CombatManualComponent cmc = new CombatManualComponent(GraphicsDevice.Viewport.Width / 2 - 200, GraphicsDevice.Viewport.Height / 2 - 150, cmi.Manual);

                        interfaceComponents.Add(cmc);
                    }
                    else if (oif.Interface.GetType() == typeof(ThrowItemInterface))
                    {
                        var tii = oif.Interface as ThrowItemInterface;

                        //Do we have LoS to that point?
                        if (GameState.LocalMap.HasDirectPath(GameState.PlayerCharacter.MapCharacter.Coordinate,tii.Coordinate))
                        {
                            ThrowItemComponent tic = new ThrowItemComponent(Mouse.GetState().X, Mouse.GetState().Y, tii.Coordinate, GameState.PlayerCharacter);
                            interfaceComponents.Add(tic);
                        }
                        else
                        {
                            var tempFBList = fb.ToList();
                            tempFBList.Add(new TextFeedback("You can't see there"));

                            fb = tempFBList.ToArray();
                        }
                    }
                }
                else
                if (feedback.GetType().Equals(typeof(TextFeedback)))
                {
                    MouseState mouse = Mouse.GetState();

                    //Display it
                    interfaceComponents.Add(new ViewTileTextComponent(mouse.X + 15, mouse.Y, (feedback as TextFeedback).Text));
                }
                else if (feedback.GetType().Equals(typeof(LogFeedback)))
                {
                    GameState.NewLog.Add(feedback as LogFeedback);
                }
                else if (feedback.GetType().Equals(typeof(InterfaceToggleFeedback)))
                {
                    InterfaceToggleFeedback iop = feedback as InterfaceToggleFeedback;

                    if (iop.InterfaceComponent == InternalActionEnum.OPEN_ATTACK && iop.Open)
                    {
                        //Open the attack interface for a particular actor. If one is not open already
                        //Identify the actor in question
                        var actorMapItem = iop.Argument as LocalCharacter;

                        //Locate the actual actor
                        Actor actor = GameState.LocalMap.Actors.Where(lm => lm.MapCharacter == actorMapItem).FirstOrDefault(); //Yep, it's a pointer equals

                        bool openAlready = false;

                        //Do we have one open already?
                        foreach (AttackActorComponent aac in interfaceComponents.Where(ic => ic.GetType().Equals(typeof(AttackActorComponent))))
                        {
                            if (aac.TargetActor.Equals(actor))
                            {
                                openAlready = true;
                                break;
                            }
                        }

                        if (!openAlready)
                        {
                            //Open it. Otherwise don't do anything
                            interfaceComponents.Add(new AttackActorComponent(150, 150, GameState.PlayerCharacter, actor) { Visible = true });
                        }

                    }
                    else if (iop.InterfaceComponent == InternalActionEnum.OPEN_ATTACK && !iop.Open)
                    {
                        //Close it
                        var actor = iop.Argument as Actor;

                        AttackActorComponent component = null;

                        foreach (AttackActorComponent aac in interfaceComponents.Where(ic => ic.GetType().Equals(typeof(AttackActorComponent))))
                        {
                            if (aac.TargetActor.Equals(actor))
                            {
                                component = aac;
                            }
                        }

                        //Did we have a match?
                        if (component != null)
                        {
                            //remove it
                            interfaceComponents.Remove(component);
                        }

                    }
                    else if (iop.InterfaceComponent == InternalActionEnum.OPEN_TRADE && iop.Open)
                    {
                        //Open trade
                        var arguments = iop.Argument as object[];

                        TradeDisplayComponent tdc = new TradeDisplayComponent(100, 100, arguments[1] as Actor, arguments[0] as Actor);

                        interfaceComponents.Add(tdc);
                    }
                    else if (iop.InterfaceComponent == InternalActionEnum.OPEN_LOOT)
                    {
                        //Open Loot
                        TreasureChest lootContainer = (iop.Argument as object[])[0] as TreasureChest;

                        LootComponent lc = new LootComponent(100, 100, lootContainer);

                        interfaceComponents.Add(lc);
                    }
                }
                else if (feedback.GetType().Equals(typeof(CreateEventFeedback)))
                {
                    CreateEventFeedback eventFeedback = feedback as CreateEventFeedback;

                    var gameEvent = EventHandlingManager.CreateEvent(eventFeedback.EventName);

                    //Create the actual control
                    interfaceComponents.Add(new DecisionPopupComponent(PlayableWidth / 2 - 150, PlayableHeight / 2 - 150, gameEvent));

                }
                else if (feedback.GetType().Equals(typeof(ReceiveEffectFeedback)))
                {
                    ReceiveEffectFeedback recFeed = feedback as ReceiveEffectFeedback;

                    EffectsManager.PerformEffect(recFeed.Effect.Actor, recFeed.Effect);
                }
                else if (feedback.GetType().Equals(typeof(ReceiveBlessingFeedback)))
                {
                    ReceiveBlessingFeedback blessFeedback = feedback as ReceiveBlessingFeedback;

                    LogFeedback lg = null;

                    //Bless him!
                    //Later we're going to want to do this properly so other characters can get blessed too
                    BlessingManager.GetAndApplyBlessing(GameState.PlayerCharacter, out lg);

                    if (lg != null)
                    {
                        //Log it
                        GameState.NewLog.Add(lg);
                    }
                }
                else if (feedback.GetType().Equals(typeof(ReceiveItemFeedback)))
                {
                    ReceiveItemFeedback receiveFeedback = feedback as ReceiveItemFeedback;

                    //Determine which item we're going to generate
                    InventoryItemManager iim = new InventoryItemManager();

                    InventoryItem itm = iim.GetBestCanAfford(receiveFeedback.Category.ToString(), receiveFeedback.MaxValue);

                    if (itm != null)
                    {
                        itm.InInventory = true;

                        GameState.PlayerCharacter.Inventory.Inventory.Add(itm.Category, itm);

                        GameState.NewLog.Add(new LogFeedback(InterfaceSpriteName.SUN, Color.DarkGreen, "You throw in your offering. You then see something glimmer and take it out"));
                    }
                    else
                    {
                        GameState.NewLog.Add(new LogFeedback(InterfaceSpriteName.MOON, Color.DarkBlue, "You throw in your offering. Nothing appears to be there. Hmm..."));
                    }

                }
                else if (feedback.GetType().Equals(typeof(LocationChangeFeedback)))
                {
                    //Remove settlement button and interface
                    var locDetails = this.interfaceComponents.Where(ic => ic.GetType().Equals(typeof(LocationDetailsComponent))).FirstOrDefault();

                    if (locDetails != null)
                    {
                        this.interfaceComponents.Remove(locDetails);
                    }

                    var button = this.menuButtons.Where(mb => (mb as AutoSizeGameButton).Action == InternalActionEnum.TOGGLE_SETTLEMENT).FirstOrDefault();

                    if (button != null)
                    {
                        this.menuButtons.Remove(button);
                    }

                    LocationChangeFeedback lce = feedback as LocationChangeFeedback;

                    if (lce.Location != null)
                    {
                        LoadLocation(lce.Location);

                        if (lce.Location is Settlement)
                        {

                            //Makde the components visible
                            LocationDetailsComponent ldc = new LocationDetailsComponent(GameState.LocalMap.Location as Settlement, PlayableWidth - 170, 0);
                            ldc.Visible = true;
                            interfaceComponents.Add(ldc);
                            menuButtons.Add(new AutoSizeGameButton(" Settlement ", this.game.Content, InternalActionEnum.TOGGLE_SETTLEMENT, new object[] { }, 270, GraphicsDevice.Viewport.Height - 35));
                            Window_ClientSizeChanged(null, null); //button is in the wrong position for some reason
                        }

                        GameState.LocalMap.IsGlobalMap = false;
                    }
                    else if (lce.VisitMainMap)
                    {
                        //If it's a bandit camp or a site, update the values of the members
                        if (GameState.LocalMap.Location as MapSite != null || GameState.LocalMap.Location as BanditCamp != null)
                        {
                            if (GameState.LocalMap.Location as BanditCamp != null)
                            {
                                var banditCamp = GameState.LocalMap.Location as BanditCamp;

                                banditCamp.BanditTotal = GameState.LocalMap.Actors.Count(a => a.IsActive && a.IsAlive && !a.IsPlayerCharacter
                                    && a.EnemyData != null && a.EnemyData.Profession == ActorProfession.WARRIOR);

                                //Has it been cleared?
                                if (banditCamp.BanditTotal == 0)
                                {
                                    //Find the item
                                    var campItem = GameState.GlobalMap.CampItems.FirstOrDefault(ci => ci.Camp == (GameState.LocalMap.Location as BanditCamp));

                                    if (campItem != null)
                                    {
                                        campItem.IsActive = false;

                                        GameState.GlobalMap.CampItems.Remove(campItem);

                                        //Also find the coordinate of the camp, grab a circle around it and remove the owner
                                        var mapblocks = GameState.GlobalMap.GetBlocksAroundPoint(campItem.Coordinate, WorldGenerationManager.BANDIT_CLAIMING_RADIUS);

                                        foreach (var block in mapblocks)
                                        {
                                            var tile = (block.Tile as GlobalTile);

                                            //Owned by bandit
                                            if (tile.Owner == 50)
                                            {
                                                tile.RemoveOwner();
                                            }
                                        }

                                        //Yes. Let's clear the camp
                                        GameState.NewLog.Add(new LogFeedback(InterfaceSpriteName.SWORD, Color.Black, "You drive the bandits away from the camp"));
                                    }

                                }

                            }
                            else if (GameState.LocalMap.Location as MapSite != null)
                            {
                                var site = GameState.LocalMap.Location as MapSite;

                                site.SiteData.ActorCounts.Clear();

                                foreach (var actorProfession in (ActorProfession[])Enum.GetValues(typeof(ActorProfession)))
                                {
                                    int count = GameState.LocalMap.Actors.Count(a => a.IsActive && a.IsAlive && !a.IsPlayerCharacter
                                    && a.EnemyData != null && a.EnemyData.Profession == actorProfession);

                                    site.SiteData.ActorCounts.Add(actorProfession, count);
                                }

                                if (site.SiteData.ActorCounts[ActorProfession.WARRIOR] == 0)
                                {
                                    //Out of warriors, abandon it. We'll decide who really owns it later
                                    site.SiteData.OwnerChanged = true;
                                    site.SiteData.MapRegenerationRequired = true;
                                    site.SiteData.Owners = OwningFactions.ABANDONED;
                                    site.SiteData.ActorCounts = new Dictionary<ActorProfession, int>();
                                }
                            }
                        }
                        //Serialise the old map
                        GameState.LocalMap.SerialiseLocalMap();

                        //Clear the stored location items
                        GameState.LocalMap.Location = null;

                        LoadGlobalMap(GameState.PlayerCharacter.GlobalCoordinates);

                        GameState.LocalMap.IsGlobalMap = true;

                    }
                    else if (lce.RandomEncounter != null)
                    {
                        //Get the biome
                        LoadRandomEncounter(lce.RandomEncounter.Value);
                    }
                }
                else if (feedback.GetType().Equals(typeof(DropItemFeedback)))
                {
                    DropItemFeedback dif = feedback as DropItemFeedback;

                    //Drop the item underneath the player
                    GameState.LocalMap.GetBlockAtCoordinate(dif.ItemToDrop.Coordinate).PutItemUnderneathOnBlock(dif.ItemToDrop);

                    //Remove from inventory
                    dif.ItemToDrop.InInventory = false;

                    GameState.PlayerCharacter.Inventory.Inventory.Remove(dif.ItemToDrop.Category, dif.ItemToDrop);
                }
                else if (feedback.GetType().Equals(typeof(TimePassFeedback)))
                {
                    TimePassFeedback tpf = feedback as TimePassFeedback;

                    //Move time forth
                    GameState.IncrementGameTime(DRTimeComponent.MINUTE, tpf.TimePassInMinutes);

                    //Is the character dead?
                    if (!GameState.PlayerCharacter.IsAlive)
                    {
                        var gameEvent = EventHandlingManager.CreateEvent("Hunger Death");

                        //Create the actual control
                        interfaceComponents.Add(new DecisionPopupComponent(PlayableWidth / 2 - 150, PlayableHeight / 2 - 150, gameEvent));
                    }
                }
                else if (feedback.GetType().Equals(typeof(VisitedBlockFeedback)))
                {
                    VisitedBlockFeedback vbf = feedback as VisitedBlockFeedback;

                    //Visit a region equal to the line of sight of the player character -
                    var blocks = GameState.LocalMap.GetBlocksAroundPoint(vbf.Coordinate, GameState.PlayerCharacter.LineOfSight);

                    //Only do the ones which can be ray traced
                    foreach (var block in RayTracingHelper.RayTraceForExploration(blocks, GameState.PlayerCharacter.MapCharacter.Coordinate))
                    {
                        block.WasVisited = true;
                    }
                }
                else if (feedback.GetType().Equals(typeof(DescendDungeonFeedback)))
                {
                    DescendDungeonFeedback ddf = feedback as DescendDungeonFeedback;

                    (GameState.LocalMap.Location as Dungeon).DifficultyLevel++;

                    this.LoadLocation(GameState.LocalMap.Location, true);
                }

            }

            //Update the log control
            log.UpdateLog();
        }
        /// <summary>
        /// Performs an action on a particular or a particular item.
        /// If item is not null, will use the item. Otherwise will use the coordinate
        /// </summary>
        /// <param name="coordinate"></param>
        /// <param name="actionType"></param>
        /// <param name="args"></param>
        public static ActionFeedback[] PerformAction(MapCoordinate coordinate,MapItem item, ActionType actionType, object[] args)
        {
            List<ActionFeedback> feedback = new List<ActionFeedback>();

            bool validAttack = false;

            if (actionType == ActionType.ATTACK)
            {
                //Handle this seperatly
                //Argument 0 - attacker
                //Argument 1 - target
                //Argument 2 - Body part to attack
                //Argument 3 - Special attack if there

                //Are we in the right place?
                Actor attacker = args[0] as Actor;
                Actor defender = args[1] as Actor;
                AttackLocation location = (AttackLocation) args[2];

                int distance = attacker.MapCharacter.Coordinate - defender.MapCharacter.Coordinate;

                if (defender.MapCharacter == null)
                {
                    //Something went wrong
                    validAttack = false;

                }

                if ( distance < 2)
                {
                    //Hand to hand

                    if (args.Length > 3)
                    {
                        //Special attack!
                        feedback.AddRange(CombatManager.PerformSpecialAttack(attacker, defender, args[3] as SpecialAttack));
                    }
                    else
                    {
                        feedback.AddRange(CombatManager.Attack(attacker, defender, location));
                    }
                    validAttack = true; //perform the tick
                }
                else
                {
                    //Is the attacker armed properly?
                    if (attacker.Inventory.EquippedItems.ContainsKey(EquipmentLocation.BOW))
                    {
                        //Do they have line of sight?
                        if (GameState.LocalMap.HasDirectPath(attacker.MapCharacter.Coordinate, defender.MapCharacter.Coordinate))
                        {
                            //Are they within a reasonable distance?
                            if (distance <= attacker.LineOfSight)
                            {
                                //Yes!
                                if (args.Length > 3)
                                {
                                    //Special attack!
                                    feedback.AddRange(CombatManager.PerformSpecialAttack(attacker, defender, args[3] as SpecialAttack));
                                }
                                else
                                {
                                    feedback.AddRange(CombatManager.Attack(attacker, defender, location));
                                }
                                validAttack = true;
                            }
                            else
                            {
                                validAttack = false;
                                return new ActionFeedback[] { new LogFeedback(InterfaceSpriteName.PERC,Color.Black, "This target is outside of your range") };
                            }
                        }
                        else
                        {
                            validAttack = false;
                            return new ActionFeedback[] { new LogFeedback(null, Color.Black, "You don't have a clear line of sight to the target") };
                        }

                    }
                    else
                    {
                        validAttack = false;
                        //Invalid - no tick
                        return new ActionFeedback[] { new LogFeedback(null, Color.Black, "You are too far away to hit your target") };
                    }
                }
            }
            else if (actionType == ActionType.THROW_ITEM)
            {
                //Throw it
                Potion potion = args[2] as Potion;
                Actor attacker = args[0] as Actor;
                List<Actor> victims = args[1] as List<Actor>;

                //Also create a temporary icon to show what was done
                foreach(var victim in victims)
                {
                    TemporaryGraphic tg = new TemporaryGraphic()
                    {
                        Coord = victim.MapCharacter.Coordinate,
                        Graphic = SpriteManager.GetSprite(InterfaceSpriteName.POTION_BREAK),
                        LifeTime = 2
                    };

                    GameState.LocalMap.TemporaryGraphics.Add(tg);
                }

                feedback.AddRange(potion.ThrowUpon(attacker, victims));
            }
            else if (actionType == ActionType.IDLE)
            {
                //Do nothing
            }
            else
            {
                if (item == null)
                {
                    switch (coordinate.MapType)
                    {
                        case MapType.LOCAL:
                            feedback.AddRange(GameState.LocalMap.GetBlockAtCoordinate(coordinate).PerformAction(actionType, GameState.PlayerCharacter, args));
                            break;
                        case MapType.GLOBAL:
                            feedback.AddRange(GameState.GlobalMap.GetBlockAtCoordinate(coordinate).PerformAction(actionType, GameState.PlayerCharacter, args));
                            break;
                        default:
                            throw new NotImplementedException("There is no support for that particular maptype");
                    }
                }
                else
                {
                    //Perform it on the item
                    feedback.AddRange(item.PerformAction(actionType, GameState.PlayerCharacter, args));
                }
            }

            if (actionType == ActionType.EXAMINE || actionType == ActionType.THROW_ITEM || actionType == ActionType.MOVE || (actionType == ActionType.ATTACK && validAttack) || actionType == ActionType.IDLE)
            {
                //Perform a tick
                //Clear the Log
                GameState.NewLog.Clear();
                feedback.AddRange(UserInterfaceManager.PerformLocalTick());
            }

            //Is the player stunned?
            while (GameState.PlayerCharacter.IsStunned && GameState.PlayerCharacter.IsAlive)
            {
                feedback.AddRange(UserInterfaceManager.PerformLocalTick());
            }

            return feedback.ToArray();
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType,out InternalActionEnum? internalActionType, out object[] args,out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            if (!visible)
            {
                itm = null;
                actionType = null;
                destroy = false;
                coord = null;
                args = null;
                internalActionType = null;
                return false;
            }

            //Check if we're in the middle of an animation cycle
            if (this.bigSizeSwitch == 0 || this.bigSizeSwitch == BIGSIZE)
            {
                //toggle big mode
                this.bigMode = !this.bigMode;

                if (this.bigMode)
                {
                    //Expand rectangle by 200 pixels - gradually

                    this.bigSizeSwitch = 0;

                    //  this.rect.Y -= 200;
                    // this.rect.Height += 200;
                }
                else
                {
                    this.bigSizeSwitch = 200;

                    // this.rect.Y += 200;
                    // this.rect.Height -= 200;
                }
            }

            actionType = null;
            destroy = false;
            coord = null;
            args = null;
            internalActionType = null;
            itm = null;
            return true;
        }
Exemple #17
0
 /// <summary>
 /// Puts a local map item int he current block. Whether the tile lets it or not.
 /// </summary>
 /// <param name="item"></param>
 public void ForcePutItemOnBlock(MapItem item)
 {
     item.Coordinate = new MapCoordinate(Tile.Coordinate);
     this.mapItems.Add(item);
 }
        public bool HandleClick(int x, int y, MouseActionEnum mouseAction, out ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out MapCoordinate coord, out bool destroy)
        {
            itm = null;
            internalActionType = null;

            //We only handle left clicks properly
            if (mouseAction.Equals(MouseActionEnum.LEFT_CLICK))
            {
                //check whether x and y was within a context menu item
                foreach (ContextMenuItem item in this.contextMenuItems)
                {
                    if (item.Rect.Contains(new Point(x, y)))
                    {
                        actionType = item.Action;
                        args = item.Args;
                        coord = this.coordinate;

                        //destroy the component
                        destroy = true;

                        return true;
                    }

                }
                args = null;
                actionType = null;
                coord = null;
                destroy = false;

                return false;
            }
            else
            {
                actionType = null;
                args = null;
                coord = null;
                //destroy it
                destroy = true;

                return false;
            }
        }
Exemple #19
0
 /// <summary>
 /// Puts a local map item in the current block. Whether the tile lets it or not.
 /// Will put it in second place (underneath the top item)
 /// </summary>
 /// <param name="item"></param>
 public void PutItemUnderneathOnBlock(MapItem item)
 {
     item.Coordinate = new MapCoordinate(Tile.Coordinate);
     if (this.mapItems.Count > 0)
     {
         this.mapItems.Insert(0, item);
     }
     else
     {
         this.mapItems.Add(item);
     }
 }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            //This does nothing

            item = null;
            args = null;
            coord = null;
            destroy = false;
            actionType = null;
            internalActionType = null;

            return visible; //If it's visible - block it. Otherwise do nothing
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            Point point = new Point(x, y);

            item = null;
            actionType = null;
            args = null;
            coord = null;
            destroy = false;
            internalActionType = null;

            if (!Visible)
            {
                return false;
            }

            //Did the user click on one of the choices?
            foreach (var decision in decisions)
            {
                if (decision.Rect.Contains(point))
                {
                    //Send the details pertaing to this decision
                    actionType = decision.ActionType;
                    internalActionType = decision.InternalAction;
                    args = decision.Args;
                    destroy = true; //User has made a choice, so close it

                    return true;
                }
            }

            //Not handled. But if it's modal, we expect it to catch all handling
            if (IsModal())
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool HandleClick(int x, int y, Objects.Enums.MouseActionEnum mouseAction, out DRObjects.Enums.ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem item, out DRObjects.MapCoordinate coord, out bool destroy)
        {
            Point point = new Point(x, y);

            item = null;
            actionType = null;
            args = null;
            coord = null;
            destroy = false;
            internalActionType = null;

            if (!Visible)
            {
                return false;
            }

            if (mouseAction != Objects.Enums.MouseActionEnum.LEFT_CLICK)
            {
                return true;
            }

            //Did the user click on one of the choices?
            foreach (var decision in this.currentEvent.Choices)
            {
                if (decision.Rect.Contains(point))
                {
                    //Decision has been made
                    choicesMade.Add(decision.ChoiceName);

                    //Do we have a next choice?
                    if (decision.NextChoice != null)
                    {
                        //Change the current choice
                        this.currentEvent = decision.NextChoice;
                        this.PerformDrag(0, 0); //force recreation
                    }
                    else
                    {
                        //terminate! Send back that its a multidecision, and the event name and the choices made
                        internalActionType = InternalActionEnum.MULTIDECISION;
                        args = new object[] { this.currentEvent.EventName, this.choicesMade };
                        destroy = true;
                    }
                }
            }

            //Not handled. But if it's modal, we expect it to catch all handling
            if (IsModal())
            {
                return true;
            }
            else
            {
                return false;
            }
        }