示例#1
0
        private void CreatePlayer()
        {
            Guid id = stateSpaceComponents.CreateEntity();

            stateSpaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Player;
            //Set Position
            int X = 0;
            int Y = 0;

            do
            {
                X = random.Next(0, (int)dungeonDimensions.X);
                Y = random.Next(0, (int)dungeonDimensions.Y);
            } while (dungeonGrid[X, Y].Type != TileType.TILE_FLOOR);
            stateSpaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = new Vector2(X, Y)
            };
            //Set Health
            stateSpaceComponents.HealthComponents[id] = new HealthComponent()
            {
                CurrentHealth = 50, MaxHealth = 100, MinHealth = 0
            };
            //Set Display
            stateSpaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                Color = Color.Red, Texture = player
            };
            //Set Sightradius
            stateSpaceComponents.SightRadiusComponents[id] = new SightRadiusComponent()
            {
                Radius = 12
            };
        }
示例#2
0
        private static void CreateObserver(StateSpaceComponents spaceComponents, PositionComponent position)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Observer;
            spaceComponents.PositionComponents[id]  = position;
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                Solid = false, CollidedObjects = new List <Guid>()
            };
            spaceComponents.InputMovementComponents[id] = new InputMovementComponent()
            {
                InitialWait = .3f, IsButtonDown = false, LastKeyPressed = Keys.None, TimeIntervalBetweenMovements = .1f, TimeSinceLastMovement = 0f, TotalTimeButtonDown = 0f
            };
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                Color        = Colors.Messages.Special,
                Rotation     = 0f,
                Origin       = Vector2.Zero,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                AlwaysDraw   = true,
                Opacity      = .6f
            };
        }
示例#3
0
 public static void CreateFire(int x, int y, StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid)
 {
     dungeonGrid[x, y].ChanceToIgnite = 0;
     spaceComponents.DelayedActions.Add(new Action(() =>
     {
         dungeonGrid[x, y].Type           = TileType.TILE_FIRE;
         dungeonGrid[x, y].Symbol         = Tiles.FireSymbol;
         dungeonGrid[x, y].SymbolColor    = Tiles.FireSymbolColor;
         dungeonGrid[x, y].TurnsToBurn    = spaceComponents.random.Next(3, 10);
         dungeonGrid[x, y].ChanceToIgnite = Tiles.FireIgniteChance;
         if (dungeonGrid[x, y].AttachedEntity == Guid.Empty)
         {
             Guid idFire = spaceComponents.CreateEntity();
             spaceComponents.Entities.Where(c => c.Id == idFire).First().ComponentFlags = Component.COMPONENT_POSITION | Component.COMPONENT_SIGHTRADIUS;
             spaceComponents.PositionComponents[idFire] = new PositionComponent()
             {
                 Position = new Vector2(x, y)
             };
             spaceComponents.SightRadiusComponents[idFire] = new SightRadiusComponent()
             {
                 DrawRadius = true, CurrentRadius = 5, MaxRadius = 5
             };
             dungeonGrid[x, y].AttachedEntity = idFire;
             foreach (Guid id in spaceComponents.PositionComponents.Where(z => z.Value.Position == new Vector2(x, y)).Select(z => z.Key))
             {
                 if (spaceComponents.SkillLevelsComponents.ContainsKey(id))
                 {
                     StatusSystem.ApplyBurnEffect(spaceComponents, id, StatusEffects.Burning.Turns, StatusEffects.Burning.MinDamage, StatusEffects.Burning.MaxDamage);
                 }
             }
         }
     }));
 }
示例#4
0
 public static bool TestUse(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, Guid item, Guid user, Vector2 targetPosition)
 {
     spaceComponents.GameMessageComponent.GameMessages.Add(new Tuple <Color, string>(Colors.Messages.StatusChange, "You use this item and something happens."));
     spaceComponents.DelayedActions.Add(new Action(() =>
     {
         Guid id = spaceComponents.CreateEntity();
         spaceComponents.Entities.Where(c => c.Id == id).First().ComponentFlags = ComponentMasks.DrawableOutline | Component.COMPONENT_TIME_TO_LIVE | ComponentMasks.GlowingOutline;
         spaceComponents.PositionComponents[id] = new PositionComponent()
         {
             Position = targetPosition
         };
         spaceComponents.OutlineComponents[id] = new OutlineComponent()
         {
             Color = Color.CornflowerBlue, Opacity = .8f
         };
         spaceComponents.TimeToLiveComponents[id] = new TimeToLiveComponent()
         {
             CurrentSecondsAlive = 0f, SecondsToLive = 4f
         };
         spaceComponents.SecondaryOutlineComponents[id] = new SecondaryOutlineComponent()
         {
             AlternateColor = Color.Red, Seconds = 0f, SwitchAtSeconds = .6f
         };
     }));
     return(true);
 }
示例#5
0
        public static bool SpawnTestConsumable(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.GlowingOutline | ComponentMasks.PickupItem | ComponentMasks.Consumable;
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                AlwaysDraw   = false,
                Color        = Colors.Messages.LootPickup,
                Opacity      = 1f,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                Symbol       = "!",
                SymbolColor  = Color.White
            };
            Vector2 position = freeTiles[spaceComponents.random.Next(0, freeTiles.Count)];

            freeTiles.Remove(position);
            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = position
            };
            spaceComponents.OutlineComponents[id] = new OutlineComponent()
            {
                Color = Color.Purple, Opacity = 1f
            };
            spaceComponents.SecondaryOutlineComponents[id] = new SecondaryOutlineComponent()
            {
                AlternateColor = Color.LightBlue, Seconds = 0f, SwitchAtSeconds = .75f
            };
            spaceComponents.PickupComponents[id] = new PickupComponent()
            {
                PickupType = ItemType.CONSUMABLE
            };
            spaceComponents.ValueComponents[id] = new ValueComponent()
            {
                Gold = spaceComponents.random.Next(0, 231)
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name        = "Test Potion",
                Description = "It is... green."
            };
            spaceComponents.ItemFunctionsComponents[id] = new ItemFunctionsComponent()
            {
                Ranged = false, UseFunctionValue = ItemUseFunctions.TESTUSE, Uses = 3, CostToUse = 20
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                CollidedObjects = new List <Guid>(), Solid = false
            };
            return(true);
        }
示例#6
0
        public static bool SpawnDownStairway(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.GlowingOutline | ComponentMasks.PickupItem;
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                AlwaysDraw   = false,
                Color        = Color.Black,
                Opacity      = 1f,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                Symbol       = "<",
                SymbolColor  = Color.White
            };
            Vector2 position = freeTiles[spaceComponents.random.Next(0, freeTiles.Count)];

            freeTiles.Remove(position);
            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = position
            };
            spaceComponents.OutlineComponents[id] = new OutlineComponent()
            {
                Color = Color.Goldenrod, Opacity = 1f
            };
            spaceComponents.SecondaryOutlineComponents[id] = new SecondaryOutlineComponent()
            {
                AlternateColor = Color.White, Seconds = 0f, SwitchAtSeconds = 2f
            };
            spaceComponents.PickupComponents[id] = new PickupComponent()
            {
                PickupType = ItemType.DOWNSTAIRS
            };
            spaceComponents.ValueComponents[id] = new ValueComponent()
            {
                Gold = spaceComponents.random.Next(0, 231)
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name        = "A Path Downward",
                Description = "A small passageway leading deeper into this cave system.  There's no telling what waits at the other end, but you have a feeling there's no going back once you descend."
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                CollidedObjects = new List <Guid>(), Solid = true
            };
            return(true);
        }
示例#7
0
        public static bool SpawnGold(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.GlowingOutline | ComponentMasks.PickupItem;
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                AlwaysDraw   = false,
                Color        = Colors.Messages.Special,
                Opacity      = 1f,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                Symbol       = "$",
                SymbolColor  = Color.White
            };
            Vector2 position = freeTiles[spaceComponents.random.Next(0, freeTiles.Count)];

            freeTiles.Remove(position);
            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = position
            };
            spaceComponents.OutlineComponents[id] = new OutlineComponent()
            {
                Color = Color.Purple, Opacity = 1f
            };
            spaceComponents.SecondaryOutlineComponents[id] = new SecondaryOutlineComponent()
            {
                AlternateColor = Color.LightBlue, Seconds = 0f, SwitchAtSeconds = .75f
            };
            spaceComponents.PickupComponents[id] = new PickupComponent()
            {
                PickupType = ItemType.GOLD
            };
            spaceComponents.ValueComponents[id] = new ValueComponent()
            {
                Gold = spaceComponents.random.Next(0, 231)
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name        = "Gold",
                Description = "Some people try and use fancy names for this mass of wealth. Credits, Stardust, Gil... it buys shelter and women all the same."
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                CollidedObjects = new List <Guid>(), Solid = false
            };
            return(true);
        }
示例#8
0
 public static void CreateFire(int x, int y, StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid)
 {
     dungeonGrid[x, y].ChanceToIgnite = 0;
     spaceComponents.DelayedActions.Add(new Action(() =>
     {
         dungeonGrid[x, y].Type = TileType.TILE_FIRE;
         dungeonGrid[x, y].Symbol = Tiles.FireSymbol;
         dungeonGrid[x, y].SymbolColor = Tiles.FireSymbolColor;
         dungeonGrid[x, y].TurnsToBurn = spaceComponents.random.Next(3, 10);
         dungeonGrid[x, y].ChanceToIgnite = Tiles.FireIgniteChance;
         if(dungeonGrid[x, y].AttachedEntity == Guid.Empty)
         {
             Guid idFire = spaceComponents.CreateEntity();
             spaceComponents.Entities.Where(c => c.Id == idFire).First().ComponentFlags = Component.COMPONENT_POSITION | Component.COMPONENT_SIGHTRADIUS;
             spaceComponents.PositionComponents[idFire] = new PositionComponent() { Position = new Vector2(x, y) };
             spaceComponents.SightRadiusComponents[idFire] = new SightRadiusComponent() { DrawRadius = true, CurrentRadius = 5, MaxRadius = 5 };
             dungeonGrid[x, y].AttachedEntity = idFire;
             foreach (Guid id in spaceComponents.PositionComponents.Where(z => z.Value.Position == new Vector2(x, y)).Select(z => z.Key))
             {
                 if (spaceComponents.SkillLevelsComponents.ContainsKey(id))
                 {
                     StatusSystem.ApplyBurnEffect(spaceComponents, id, StatusEffects.Burning.Turns, StatusEffects.Burning.MinDamage, StatusEffects.Burning.MaxDamage);
                 }
             }
         }
     }));
 }
示例#9
0
        private static void CreateObserver(StateSpaceComponents spaceComponents, PositionComponent position)
        {
            Guid id = spaceComponents.CreateEntity();
            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Observer;
            spaceComponents.PositionComponents[id] = position;
            spaceComponents.CollisionComponents[id] = new CollisionComponent() { Solid = false, CollidedObjects = new List<Guid>() };
            spaceComponents.InputMovementComponents[id] = new InputMovementComponent() { InitialWait = .3f, IsButtonDown = false, LastKeyPressed = Keys.None, TimeIntervalBetweenMovements = .1f, TimeSinceLastMovement = 0f, TotalTimeButtonDown = 0f };
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                Color = Colors.Messages.Special,
                Rotation = 0f,
                Origin = Vector2.Zero,
                Scale = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                AlwaysDraw = true,
                Opacity = .6f
            };

        }
示例#10
0
        public static void DropWholeInventory(StateSpaceComponents spaceComponents, Guid droppingEntity, Vector2 entityPos)
        {
            Entity entity = spaceComponents.Entities.Where(x => x.Id == droppingEntity).FirstOrDefault();

            if (entity != null && (entity.ComponentFlags & Component.COMPONENT_INVENTORY) == Component.COMPONENT_INVENTORY)
            {
                InventoryComponent invo = spaceComponents.InventoryComponents[entity.Id];
                foreach (Guid artifact in invo.Artifacts)
                {
                    Entity item = spaceComponents.Entities.Where(x => x.Id == artifact).FirstOrDefault();
                    if (item != null)
                    {
                        item.ComponentFlags |= Component.COMPONENT_POSITION;
                        spaceComponents.PositionComponents[item.Id] = new PositionComponent()
                        {
                            Position = entityPos
                        };
                        invo.Artifacts.Remove(item.Id);
                    }
                }

                foreach (Guid consumable in invo.Consumables)
                {
                    Entity item = spaceComponents.Entities.Where(x => x.Id == consumable).FirstOrDefault();
                    if (item != null)
                    {
                        item.ComponentFlags |= Component.COMPONENT_POSITION;
                        spaceComponents.PositionComponents[item.Id] = new PositionComponent()
                        {
                            Position = entityPos
                        };
                        invo.Consumables.Remove(item.Id);
                    }
                }

                if ((entity.ComponentFlags & Component.COMPONENT_SKILL_LEVELS) == Component.COMPONENT_SKILL_LEVELS)
                {
                    SkillLevelsComponent skills = spaceComponents.SkillLevelsComponents[entity.Id];
                    if (skills.Wealth > 0)
                    {
                        spaceComponents.DelayedActions.Add(new Action(() =>
                        {
                            Guid id = spaceComponents.CreateEntity();
                            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.GlowingOutline | ComponentMasks.PickupItem;
                            spaceComponents.DisplayComponents[id] = new DisplayComponent()
                            {
                                AlwaysDraw   = false,
                                Color        = Colors.Messages.Special,
                                Opacity      = 1f,
                                Origin       = Vector2.Zero,
                                Rotation     = 0f,
                                Scale        = 1f,
                                SpriteEffect = SpriteEffects.None,
                                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                                Symbol       = "$",
                                SymbolColor  = Color.White
                            };
                            Vector2 position = entityPos;
                            spaceComponents.PositionComponents[id] = new PositionComponent()
                            {
                                Position = position
                            };
                            spaceComponents.OutlineComponents[id] = new OutlineComponent()
                            {
                                Color = Color.Purple, Opacity = 1f
                            };
                            spaceComponents.SecondaryOutlineComponents[id] = new SecondaryOutlineComponent()
                            {
                                AlternateColor = Color.LightBlue, Seconds = 0f, SwitchAtSeconds = .75f
                            };
                            spaceComponents.PickupComponents[id] = new PickupComponent()
                            {
                                PickupType = ItemType.GOLD
                            };
                            spaceComponents.ValueComponents[id] = new ValueComponent()
                            {
                                Gold = skills.Wealth
                            };
                            spaceComponents.NameComponents[id] = new NameComponent()
                            {
                                Name        = "Gold",
                                Description = "Some people try and use fancy names for this mass of wealth. Credits, Stardust, Gil... it buys shelter and women all the same."
                            };
                            spaceComponents.CollisionComponents[id] = new CollisionComponent()
                            {
                                CollidedObjects = new List <Guid>(), Solid = false
                            };
                        }));
                    }
                }
            }
        }
示例#11
0
        public static bool SpawnPlayer(StateSpaceComponents stateSpaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, int cellSize, List <Vector2> freeTiles)
        {
            Entity player = stateSpaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Player) == ComponentMasks.Player).FirstOrDefault();

            if (player == null)
            {
                Guid id = stateSpaceComponents.CreateEntity();
                stateSpaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Player | Component.COMPONENT_INPUTMOVEMENT | ComponentMasks.InventoryPickup;
                //Set Position
                int tileIndex = stateSpaceComponents.random.Next(0, freeTiles.Count);
                stateSpaceComponents.PositionComponents[id] = new PositionComponent()
                {
                    Position = freeTiles[tileIndex]
                };
                freeTiles.RemoveAt(tileIndex);
                dungeonGrid[(int)stateSpaceComponents.PositionComponents[id].Position.X, (int)stateSpaceComponents.PositionComponents[id].Position.Y].Occupiable = true;
                //Set Display
                stateSpaceComponents.DisplayComponents[id] = new DisplayComponent()
                {
                    Color        = Color.White,
                    SpriteSource = new Rectangle(0 * cellSize, 0 * cellSize, cellSize, cellSize),
                    Origin       = Vector2.Zero,
                    SpriteEffect = SpriteEffects.None,
                    Scale        = 1f,
                    Rotation     = 0f,
                    Opacity      = 1f,
                    AlwaysDraw   = true
                };
                //Set Sightradius
                stateSpaceComponents.SightRadiusComponents[id] = new SightRadiusComponent()
                {
                    CurrentRadius = 15, MaxRadius = 15, DrawRadius = true
                };
                //Set first turn
                stateSpaceComponents.PlayerComponent = new PlayerComponent()
                {
                    PlayerJustLoaded = true
                };
                //Collision information
                stateSpaceComponents.CollisionComponents[id] = new CollisionComponent()
                {
                    CollidedObjects = new List <Guid>(), Solid = true
                };
                //Set name of player
                stateSpaceComponents.NameComponents[id] = new NameComponent()
                {
                    Name = "You", Description = "This is me.  I came to these caves to find my fortune."
                };
                //Set Input of the player
                stateSpaceComponents.InputMovementComponents[id] = new InputMovementComponent()
                {
                    TimeIntervalBetweenMovements = .09f, TimeSinceLastMovement = 0f, InitialWait = .5f, TotalTimeButtonDown = 0f, LastKeyPressed = Keys.None
                };
                //Set an alignment for AI to communicate with
                stateSpaceComponents.AIAlignmentComponents[id] = new AIAlignment()
                {
                    Alignment = AIAlignments.ALIGNMENT_FRIENDLY
                };
                //Set combat messages
                stateSpaceComponents.EntityMessageComponents[id] = new EntityMessageComponent()
                {
                    NormalDodgeMessages = new string[]
                    {
                        " and the attack misses you!",
                        " but nothing happened.",
                        " ... but it failed!",
                        " and your defense protects you.",
                        " but it fails to connect."
                    },
                    StreakDodgeMessages = new string[]
                    {
                        " but you don't even notice.",
                        " and you laugh at the attempt.",
                        " but you easily dodge it again.",
                        " and misses you. Again!"
                    },
                    AttackNPCMessages = new string[]
                    {
                        "{0} attack the {1}",
                        "{0} take a swing at the {1}",
                        "{0} swipe at {1}",
                        "{0} try to damage the {1}",
                        "{0} slash viciously at the {1}"
                    },
                    NormalTakeDamageMessages = new string[]
                    {
                        " and you take {0} damage.",
                        " and it hurts! You take {0} damage.",
                        "! Ow. You lose {0} health.",
                        " and hits you for {0} damage."
                    },
                    BrokenDodgeStreakTakeDamageMessages = new string[]
                    {
                        " and you finally take {0} damage.",
                        " and this time you lose {0} health! Ow!",
                        " and hits you for {0} THIS time.",
                        "! {0} damage taken! Don't get cocky..."
                    },
                    PickupItemMessages = new string[]
                    {
                        "{0} pick up the {1}.",
                        "{0} find a {1}.",
                        "{0} got a {1}!"
                    },
                    ConsumablesFullMessages = new string[]
                    {
                        "You cannot carry any more consumables.",
                        "Your consumable slots are full!",
                        "You don't have any place to store this consumable."
                    },
                    ArtifactsFullMessages = new string[]
                    {
                        "Your artifact slots are too full for another.",
                        "Drop or scrap one of your artifacts to pick this up.",
                        "You can't pick up this artifact; you already have enough."
                    }
                };
                //Inventory
                stateSpaceComponents.InventoryComponents[id] = new InventoryComponent()
                {
                    Artifacts = new List <Guid>(), Consumables = new List <Guid>(), MaxArtifacts = 3, MaxConsumables = 2
                };
            }
            else
            {
                //If there's already a player, just make a new starting location on the floor
                //Set Position
                int tileIndex = stateSpaceComponents.random.Next(0, freeTiles.Count);
                stateSpaceComponents.PositionComponents[player.Id] = new PositionComponent()
                {
                    Position = freeTiles[tileIndex]
                };
                freeTiles.RemoveAt(tileIndex);
                dungeonGrid[(int)stateSpaceComponents.PositionComponents[player.Id].Position.X, (int)stateSpaceComponents.PositionComponents[player.Id].Position.Y].Occupiable = true;
            }

            return(true);
        }
示例#12
0
        public static bool CrazedMiner(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, int cellSize, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.CombatReadyAI | ComponentMasks.AIView | ComponentMasks.InventoryPickup;

            int tileIndex = spaceComponents.random.Next(0, freeTiles.Count);

            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = freeTiles[tileIndex]
            };
            freeTiles.RemoveAt(tileIndex);
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                Color        = Color.MediumPurple, // Color.DarkRed,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * cellSize, 0 * cellSize, cellSize, cellSize),
                Symbol       = "C",
                SymbolColor  = Color.White,
                Opacity      = 1f
            };
            spaceComponents.SkillLevelsComponents[id] = new SkillLevelsComponent()
            {
                CurrentHealth = 25, DieNumber = 1, Health = 25, Defense = 4, Accuracy = 80, Wealth = 100, MinimumDamage = 2, MaximumDamage = 7
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                Solid = true, CollidedObjects = new List <Guid>()
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name = "CRAZED MINER", Description = "An injured, shambling husk of a man.  He clutches a pickaxe in his hands and precious gems are stuffed in his pockets.  It looks like greed got the better of his mind long ago."
            };
            spaceComponents.AIAlignmentComponents[id] = new AIAlignment()
            {
                Alignment = AIAlignments.ALIGNMENT_HOSTILE
            };
            spaceComponents.AICombatComponents[id] = new AICombat()
            {
                AttackType = AIAttackTypes.ATTACK_TYPE_NORMAL, FleesWhenLowHealth = true
            };
            spaceComponents.AIStateComponents[id] = new AIState()
            {
                State = AIStates.STATE_ROAMING
            };
            spaceComponents.AIFieldOfViewComponents[id] = new AIFieldOfView()
            {
                DrawField = false, Opacity = .3f, radius = 3, SeenTiles = new List <Vector2>(), Color = FOVColors.Roaming
            };
            spaceComponents.AISleepComponents[id] = new AISleep()
            {
                ChanceToWake = 10, FOVRadiusChangeOnWake = 1
            };
            spaceComponents.AIRoamComponents[id] = new AIRoam()
            {
                ChanceToDetect = 25
            };
            spaceComponents.AIFleeComponents[id] = new AIFlee()
            {
                DoesFlee = false, FleeAtHealthPercent = 25, FleeUntilHealthPercent = 30
            };
            spaceComponents.EntityMessageComponents[id] = new EntityMessageComponent()
            {
                AttackNPCMessages = new string[]
                {
                    "{0} swings its pickaxe at {1}",
                    "{0} shambles toward {1}",
                    "{0} claws madly at {1}",
                },
                AttackPlayerMessages = new string[]
                {
                    "{0} swings its pickaxe at you",
                    "{0} shambles toward you",
                    "{0} claws madly at you",
                },
                NormalDodgeMessages = new string[]
                {
                    " but the attack missed!",
                    " and the creature dodges the attack.",
                    " but the creature's defense protects it.",
                },
                StreakDodgeMessages = new string[]
                {
                    " and, as always, the attack misses.",
                    " and it misses again!",
                    " and it laughs madly.",
                    " and taunts at the attack. \"Give up!\""
                },
                NormalTakeDamageMessages = new string[]
                {
                    " and it takes {0} damage.",
                    " and it cries out, {0} health weaker.",
                    " for {0} damage."
                },
                BrokenDodgeStreakTakeDamageMessages = new string[]
                {
                    " and against all odds deals {0} damage!",
                    " and the cocky creature allows {0} damage to go through!",
                    ", breaking impossible odds, landing {0} damage!!",
                }
            };
            spaceComponents.InventoryComponents[id] = new InventoryComponent()
            {
                Artifacts = new List <Guid>(), Consumables = new List <Guid>(), MaxArtifacts = 0, MaxConsumables = 0
            };

            return(true);
        }
示例#13
0
        public static bool SpawnWildVines(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, int cellSize, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.CombatReadyAI | ComponentMasks.AIView | ComponentMasks.InventoryPickup;

            int tileIndex = spaceComponents.random.Next(0, freeTiles.Count);

            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = freeTiles[tileIndex]
            };
            freeTiles.RemoveAt(tileIndex);
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                Color        = Colors.Monsters.Red, // Color.DarkRed,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * cellSize, 0 * cellSize, cellSize, cellSize),
                Symbol       = "W",
                SymbolColor  = Color.White,
                Opacity      = 1f
            };
            spaceComponents.SkillLevelsComponents[id] = new SkillLevelsComponent()
            {
                CurrentHealth = 45, DieNumber = 2, Health = 45, Defense = 10, Accuracy = 135, Wealth = 25, MinimumDamage = 5, MaximumDamage = 14
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                Solid = true, CollidedObjects = new List <Guid>()
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name = "WILD ROOTS", Description = "Imported fresh from Japan."
            };
            spaceComponents.AIAlignmentComponents[id] = new AIAlignment()
            {
                Alignment = AIAlignments.ALIGNMENT_HOSTILE
            };
            spaceComponents.AICombatComponents[id] = new AICombat()
            {
                AttackType = AIAttackTypes.ATTACK_TYPE_NORMAL, FleesWhenLowHealth = true
            };
            spaceComponents.AIStateComponents[id] = new AIState()
            {
                State = AIStates.STATE_ROAMING
            };
            spaceComponents.AIFieldOfViewComponents[id] = new AIFieldOfView()
            {
                DrawField = false, Opacity = .3f, radius = 5, SeenTiles = new List <Vector2>(), Color = FOVColors.Roaming
            };
            spaceComponents.AISleepComponents[id] = new AISleep()
            {
                ChanceToWake = 10, FOVRadiusChangeOnWake = 2
            };
            spaceComponents.AIRoamComponents[id] = new AIRoam()
            {
                ChanceToDetect = 40
            };
            spaceComponents.AIFleeComponents[id] = new AIFlee()
            {
                DoesFlee = false, FleeAtHealthPercent = 25, FleeUntilHealthPercent = 30
            };
            spaceComponents.EntityMessageComponents[id] = new EntityMessageComponent()
            {
                AttackNPCMessages = new string[]
                {
                    "{0} swings its tentacles toward {1}",
                    "{0} applies fury to the {1}'s face",
                    "{0} attempts brute force against {1}",
                    "{0} uses a walking attack fearlessly at {1}"
                },
                AttackPlayerMessages = new string[]
                {
                    "{0} wiggles its tentacles at you",
                    "The {0} swipes at you multiple times",
                    "Gross.. the tentacles of {0} smear around you"
                },
                NormalDodgeMessages = new string[]
                {
                    " but the attack missed!",
                    " and the creature dodges the attack.",
                    " but the creature's defense protects it.",
                    " but it uses its tentacle vines to protect itself.",
                    " but the vines are too thick for the attack!"
                },
                StreakDodgeMessages = new string[]
                {
                    " and, as always, the attack misses.",
                    " and it misses again!",
                    " and it slithers around, cackling",
                    " and taunts at the attack. \"Give up!\""
                },
                NormalTakeDamageMessages = new string[]
                {
                    " and it takes {0} damage.",
                    " and it cries out, {0} health weaker.",
                    " and takes {0}, some of its vines dropping dead",
                    " for {0} damage."
                },
                BrokenDodgeStreakTakeDamageMessages = new string[]
                {
                    " and against all odds deals {0} damage!",
                    " and the cocky creature allows {0} damage to go through!",
                    ", breaking impossible odds, landing {0} damage!!",
                    " and the test is broken! It takes {0} damage!"
                }
            };
            spaceComponents.InventoryComponents[id] = new InventoryComponent()
            {
                Artifacts = new List <Guid>(), Consumables = new List <Guid>(), MaxArtifacts = 0, MaxConsumables = 0
            };

            return(true);
        }
示例#14
0
        public static bool SpawnTestEnemyNPC(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, int cellSize, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.CombatReadyAI | ComponentMasks.AIView | ComponentMasks.InventoryPickup;

            int tileIndex = spaceComponents.random.Next(0, freeTiles.Count);

            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = freeTiles[tileIndex]
            };
            freeTiles.RemoveAt(tileIndex);
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                Color        = Colors.Monsters.Red, //Color.DarkRed,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * cellSize, 0 * cellSize, cellSize, cellSize),
                Symbol       = "t",
                SymbolColor  = Color.White,
                Opacity      = 1f
            };
            spaceComponents.SkillLevelsComponents[id] = new SkillLevelsComponent()
            {
                CurrentHealth = 25, DieNumber = 1, Health = 25, Defense = 1, Accuracy = 100, Wealth = 25, MinimumDamage = 1, MaximumDamage = 2
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                Solid = true, CollidedObjects = new List <Guid>()
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name = "TEST ENEMY NPC", Description = "It seems harmless enough.  How dangerous could a red square be?"
            };
            spaceComponents.AIAlignmentComponents[id] = new AIAlignment()
            {
                Alignment = AIAlignments.ALIGNMENT_HOSTILE
            };
            spaceComponents.AICombatComponents[id] = new AICombat()
            {
                AttackType = AIAttackTypes.ATTACK_TYPE_NORMAL, FleesWhenLowHealth = true
            };
            spaceComponents.AIStateComponents[id] = new AIState()
            {
                State = AIStates.STATE_SLEEPING
            };
            spaceComponents.AIFieldOfViewComponents[id] = new AIFieldOfView()
            {
                DrawField = false, Opacity = .3f, radius = 2, SeenTiles = new List <Vector2>(), Color = FOVColors.Sleeping
            };
            spaceComponents.AISleepComponents[id] = new AISleep()
            {
                ChanceToWake = 15, FOVRadiusChangeOnWake = 2
            };
            spaceComponents.AIRoamComponents[id] = new AIRoam()
            {
                ChanceToDetect = 25
            };
            spaceComponents.AIFleeComponents[id] = new AIFlee()
            {
                DoesFlee = true, FleeAtHealthPercent = 25, FleeUntilHealthPercent = 30
            };
            spaceComponents.EntityMessageComponents[id] = new EntityMessageComponent()
            {
                AttackNPCMessages = new string[]
                {
                    "{0} swings at the {1}",
                    "{0} applies fury to the {1}'s face",
                    "{0} attempts brute force against {1}",
                    "{0} uses a walking attack fearlessly at {1}"
                },
                AttackPlayerMessages = new string[]
                {
                    "{0} tests a mighty attack on you",
                    "The {0} glitches out against you",
                    "Watch out! {0} tries to attack you"
                },
                NormalDodgeMessages = new string[]
                {
                    " but the attack missed!",
                    " and the creature dodges the attack.",
                    " but the creature's defense protects it.",
                    " and the defense test is a success.",
                    " but the combat system test makes the attack miss."
                },
                StreakDodgeMessages = new string[]
                {
                    " and, as always, the attack misses.",
                    " and it misses again!",
                    " and shows how advanced its AI is by dodging again.",
                    " and taunts at the attack. \"Give up!\""
                },
                NormalTakeDamageMessages = new string[]
                {
                    " and it takes {0} damage.",
                    " and it cries out, {0} health weaker.",
                    " and it glitches out, health dropping by {0}.",
                    " for {0} damage."
                },
                BrokenDodgeStreakTakeDamageMessages = new string[]
                {
                    " and against all odds deals {0} damage!",
                    " and the cocky creature allows {0} damage to go through!",
                    ", breaking impossible odds, landing {0} damage!!",
                    " and the test is broken! It takes {0} damage!"
                }
            };
            spaceComponents.InventoryComponents[id] = new InventoryComponent()
            {
                Artifacts = new List <Guid>(), Consumables = new List <Guid>(), MaxArtifacts = 0, MaxConsumables = 0
            };

            return(true);
        }
示例#15
0
        public static bool SpawnTestArtifact(StateSpaceComponents spaceComponents, DungeonTile[,] dungeonGrid, Vector2 dungeonDimensions, List <Vector2> freeTiles)
        {
            Guid id = spaceComponents.CreateEntity();

            spaceComponents.Entities.Where(x => x.Id == id).First().ComponentFlags = ComponentMasks.Drawable | ComponentMasks.GlowingOutline | ComponentMasks.PickupItem
                                                                                     | ComponentMasks.Artifact;
            spaceComponents.DisplayComponents[id] = new DisplayComponent()
            {
                AlwaysDraw   = false,
                Color        = Colors.Messages.LootPickup,
                Opacity      = 1f,
                Origin       = Vector2.Zero,
                Rotation     = 0f,
                Scale        = 1f,
                SpriteEffect = SpriteEffects.None,
                SpriteSource = new Rectangle(0 * DevConstants.Grid.CellSize, 0 * DevConstants.Grid.CellSize, DevConstants.Grid.CellSize, DevConstants.Grid.CellSize),
                Symbol       = "{}",
                SymbolColor  = Color.White
            };
            Vector2 position = freeTiles[spaceComponents.random.Next(0, freeTiles.Count)];

            freeTiles.Remove(position);
            spaceComponents.PositionComponents[id] = new PositionComponent()
            {
                Position = position
            };
            spaceComponents.OutlineComponents[id] = new OutlineComponent()
            {
                Color = Color.Purple, Opacity = 1f
            };
            spaceComponents.SecondaryOutlineComponents[id] = new SecondaryOutlineComponent()
            {
                AlternateColor = Color.LightBlue, Seconds = 0f, SwitchAtSeconds = .75f
            };
            spaceComponents.PickupComponents[id] = new PickupComponent()
            {
                PickupType = ItemType.ARTIFACT
            };
            spaceComponents.ValueComponents[id] = new ValueComponent()
            {
                Gold = 10
            };
            spaceComponents.StatModificationComponents[id] = new StatModificationComponent()
            {
                AccuracyChange      = 10,
                DefenseChange       = 25,
                DieNumberChange     = 1,
                HealthChange        = 50,
                MaximumDamageChange = 5,
                MinimumDamageChange = -2,
            };
            spaceComponents.NameComponents[id] = new NameComponent()
            {
                Name        = "Test Artifact",
                Description = "FORGED IN THE FIERY PITS OF HELL, THIS MESH OF STEEL AND MAGIC HAS ONLY ONE PURPOSE: THE UTTER DECIMATION OF ALL WHO WAGE WAR AGAINST ITS OWNER.  AS YOU EQUIP THIS ITEM YOU FEEL A FORBODING PULSE ALONG YOUR SPINE WHICH RIPPLES OUTWARD INTO EVERY INCH OF YOUR FLESH.  IS IT MADNESS THAT SEEKS A NEW HOME, OR SIMPLY THE GUILT OF DONNING SUCH AN EVIL DEFENSE?"
            };
            spaceComponents.CollisionComponents[id] = new CollisionComponent()
            {
                CollidedObjects = new List <Guid>(), Solid = false
            };
            spaceComponents.ArtifactStatsComponents[id] = new ArtifactStatsComponent()
            {
                UpgradeLevel = 1, FloorFound = spaceComponents.GameplayInfoComponent.FloorsReached
            };
            return(true);
        }