Exemple #1
0
        public static int CalculateMeleeDamage(StateSpaceComponents spaceComponents, SkillLevelsComponent attackingStats, Guid attacker)
        {
            attackingStats = InventorySystem.ApplyStatModifications(spaceComponents, attacker, attackingStats);

            int damage = 0;

            for (int i = 0; i < attackingStats.DieNumber; i++)
            {
                damage += spaceComponents.random.Next((int)(attackingStats.MinimumDamage / attackingStats.DieNumber), (int)(attackingStats.MaximumDamage / attackingStats.DieNumber) + 1);
            }
            return(damage);
        }
Exemple #2
0
 public static double CalculateAccuracy(StateSpaceComponents spaceComponents, SkillLevelsComponent attacker, Guid attackerId, SkillLevelsComponent defender, Guid defenderId)
 {
     attacker = InventorySystem.ApplyStatModifications(spaceComponents, attackerId, attacker);
     defender = InventorySystem.ApplyStatModifications(spaceComponents, defenderId, defender);
     return(attacker.Accuracy * (Math.Pow(.95, defender.Defense)));
 }
Exemple #3
0
        public static void WriteMessages(StateSpaceComponents spaceComponents, SpriteBatch spriteBatch, Camera camera, SpriteFont font, DungeonTile[,] dungeonGrid)
        {
            float opacity        = 1.15f;
            float decrement      = .09f;
            int   messageNumber  = 0;
            int   messageSpacing = (int)font.MeasureString("g").Y + 1;;

            //Draw message log
            if (spaceComponents.GameMessageComponent.IndexBegin > 0)
            {
                float textHeight = font.MeasureString(Messages.ScrollingMessages).Y;
                spriteBatch.DrawString(font, Messages.ScrollingMessages, new Vector2(10, (int)camera.DungeonUIViewport.Bounds.Bottom - (int)textHeight - 10 - (messageNumber * messageSpacing)), Color.MediumVioletRed);
                messageNumber += 1;
            }
            foreach (Tuple <Color, string> message in spaceComponents.GameMessageComponent.GameMessages.Reverse <Tuple <Color, string> >().Skip(spaceComponents.GameMessageComponent.IndexBegin))
            {
                if (opacity < 0)
                {
                    break;
                }
                opacity -= decrement;
                string text = MessageDisplaySystem.WordWrap(font, message.Item2, camera.DungeonUIViewport.Width - 20);

                float textHeight = font.MeasureString(text).Y;
                spriteBatch.DrawString(font, text, new Vector2(10, (int)camera.DungeonUIViewport.Bounds.Bottom - (int)textHeight - 10 - (messageNumber * messageSpacing)), message.Item1 * opacity);
                messageNumber += Regex.Matches(text, System.Environment.NewLine).Count;
                messageNumber += 1;
            }
            while (spaceComponents.GameMessageComponent.GameMessages.Count > spaceComponents.GameMessageComponent.MaxMessages)
            {
                spaceComponents.GameMessageComponent.GameMessages.RemoveAt(0);
            }
            spriteBatch.DrawString(font, spaceComponents.GameMessageComponent.GlobalMessage, new Vector2(10, camera.Bounds.Height - messageSpacing), spaceComponents.GameMessageComponent.GlobalColor);

            messageNumber = 0;
            //Draw statistics
            List <Tuple <Color, string> > statsToPrint = new List <Tuple <Color, string> >();
            GameplayInfoComponent         gameplayInfo = spaceComponents.GameplayInfoComponent;

            statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Floor {0}", gameplayInfo.FloorsReached)));
            statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Steps: {0}", gameplayInfo.StepsTaken)));
            statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Kills: {0}", gameplayInfo.Kills)));
            Entity player = spaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.Player) == ComponentMasks.Player).FirstOrDefault();

            if (player != null)
            {
                SkillLevelsComponent skills    = InventorySystem.ApplyStatModifications(spaceComponents, player.Id, spaceComponents.SkillLevelsComponents[player.Id]);
                InventoryComponent   inventory = spaceComponents.InventoryComponents[player.Id];
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Health:  {0} / {1}", skills.CurrentHealth, skills.Health)));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Wealth: {0}", skills.Wealth)));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Damage: {0}-{1}", skills.MinimumDamage, skills.MaximumDamage)));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Accuracy: {0}", skills.Accuracy)));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, string.Format("Defense: {0}", skills.Defense)));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                //Status Effects:
                Statuses statuses = StatusSystem.GetStatusEffectsOfEntity(spaceComponents, player.Id, dungeonGrid);
                if (statuses == Statuses.NONE)
                {
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, Messages.StatusMessages.Normal));
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                }
                //If there are status effects on the player..
                else
                {
                    if ((statuses & Statuses.BURNING) == Statuses.BURNING)
                    {
                        BurningComponent burning = spaceComponents.BurningComponents[player.Id];
                        statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Bad, string.Format(Messages.StatusMessages.Burning, burning.MinDamage, burning.MaxDamage, burning.TurnsLeft)));
                    }
                    if ((statuses & Statuses.UNDERWATER) == Statuses.UNDERWATER)
                    {
                        statsToPrint.Add(new Tuple <Color, string>(Colors.Caves.WaterInRange, Messages.StatusMessages.Underwater));
                    }
                    if ((statuses & Statuses.HEALTHREGEN) == Statuses.HEALTHREGEN)
                    {
                        HealthRegenerationComponent healthRegen = spaceComponents.HealthRegenerationComponents[player.Id];
                        statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Good, string.Format(Messages.StatusMessages.HealthRegen, healthRegen.HealthRegain, healthRegen.RegenerateTurnRate)));
                    }
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                }

                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Special, string.Format(Messages.InventoryArtifacts + " ({0}/{1})", inventory.Artifacts.Count, inventory.MaxArtifacts)));
                foreach (Guid id in inventory.Artifacts)
                {
                    NameComponent          name          = spaceComponents.NameComponents[id];
                    ArtifactStatsComponent artifactStats = spaceComponents.ArtifactStatsComponents[id];
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.LootPickup, string.Format("{0} Lv{1}", name.Name, artifactStats.UpgradeLevel)));
                }

                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Special, string.Format(Messages.InventoryConsumables + " ({0}/{1})", inventory.Consumables.Count, inventory.MaxConsumables)));
                if (inventory.Consumables.Count > 0)
                {
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                    NameComponent          name  = spaceComponents.NameComponents[inventory.Consumables[0]];
                    ItemFunctionsComponent funcs = spaceComponents.ItemFunctionsComponents[inventory.Consumables[0]];
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.LootPickup, string.Format("{0}({1})", name.Name, funcs.Uses)));
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, "Q - Use"));
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, "X - Throw"));
                    statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, System.Environment.NewLine));
                    if (inventory.Consumables.Count > 1)
                    {
                        name  = spaceComponents.NameComponents[inventory.Consumables[1]];
                        funcs = spaceComponents.ItemFunctionsComponents[inventory.Consumables[1]];
                        statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.LootPickup, string.Format("{0}({1})", name.Name, funcs.Uses)));
                        statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, "E - Use"));
                        statsToPrint.Add(new Tuple <Color, string>(Colors.Messages.Normal, "C - Throw"));
                    }
                }
            }

            if (font != null)
            {
                foreach (Tuple <Color, string> stat in statsToPrint)
                {
                    string  text        = MessageDisplaySystem.WordWrap(font, stat.Item2, camera.DungeonUIViewportLeft.Width - messageSpacing);
                    Vector2 messageSize = font.MeasureString(stat.Item2);
                    spriteBatch.DrawString(font, text, new Vector2(camera.DungeonUIViewportLeft.X + 10, 10 + (messageSpacing * messageNumber)), stat.Item1);
                    messageNumber += 1;
                    messageNumber += Regex.Matches(text, System.Environment.NewLine).Count;
                }
            }
        }