コード例 #1
0
 public static IRange <int> ToRange(
     this int minimum, int maximum, RangeComparisonOptions rangeComparisonOptions = null
     ) => Int32Range.Create()
 .WithMinimum(minimum)
 .WithMaximum(maximum)
 .WithRangeComparsionOptions(rangeComparisonOptions)
 .Build();
コード例 #2
0
 public void Range_MinGreaterThanMax()
 {
     // Act & Assert
     Assert.Throws(typeof(ArgumentException),
                   // ReSharper disable once ObjectCreationAsStatement
                   () => Int32Range.Range(20, 10));
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="view"></param>
        /// <param name="columnRange"></param>
        /// <param name="rowRange"></param>
        /// <returns></returns>
        public static MatrixBase <T> SubMatrix(
            MatrixBase <T> view,
            Int32Range columnRange,
            Int32Range rowRange)
        {
            if (!view.DataColumnRange.Contains(columnRange))
            {
                throw new ArgumentOutOfRangeException("columnRange");
            }
            if (!view.DataRowRange.Contains(rowRange))
            {
                throw new ArgumentOutOfRangeException("rowRange");
            }

            MatrixBase <T> result
                = new MatrixBase <T>(view.DataSource,
                                     new Int32Range(
                                         columnRange.Start + view.DataColumnRange.Start,
                                         columnRange.End + view.DataColumnRange.Start),
                                     new Int32Range(
                                         rowRange.Start + view.DataRowRange.Start,
                                         rowRange.End + view.DataRowRange.Start));

            return(result);
        }
コード例 #4
0
 /// <summary>
 /// Reset Stats of previously selected Session.Party.Players stats from preview
 /// </summary>
 private void ResetFromPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange        = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange  = new Int32Range();
 }
コード例 #5
0
        /// <summary>
        /// Apply the action's spell to the given target.
        /// </summary>
        /// <returns>True if there was any effect on the target.</returns>
        private bool ApplySpell(Combatant spellTarget)
        {
            StatisticsValue effectStatistics = CalculateSpellDamage(combatant, spell);

            if (spell.IsOffensive)
            {
                // calculate the defense
                Int32Range defenseRange = spellTarget.Character.MagicDefenseRange +
                                          spellTarget.Statistics.MagicalDefense;
                Int32 defense = defenseRange.GenerateValue(Session.Random);
                // subtract the defense
                effectStatistics -= new StatisticsValue(defense,
                                                        defense, defense, defense, defense, defense);
                // make sure that this only contains damage
                effectStatistics.ApplyMinimum(new StatisticsValue());
                // damage the target
                spellTarget.Damage(effectStatistics, spell.TargetDuration);
            }
            else
            {
                // make sure that this only contains healing
                effectStatistics.ApplyMinimum(new StatisticsValue());
                // heal the target
                spellTarget.Heal(effectStatistics, spell.TargetDuration);
            }

            return(!effectStatistics.IsZero);
        }
コード例 #6
0
 /// <summary>
 /// Calculate for selected Session.Party.Players stats for preview
 /// </summary>
 private void CalculateForPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange        = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange  = new Int32Range();
     if (isUseAllowed && !isGearUsed)
     {
         if (usedGear is Item)
         {
             // no preview for items
         }
         else if (usedGear is Armor)
         {
             Armor armor = usedGear as Armor;
             previewStatisticsModifier = armor.OwnerBuffStatistics;
             previewHealthDefenseRange = armor.OwnerHealthDefenseRange;
             previewMagicDefenseRange  = armor.OwnerMagicDefenseRange;
         }
         else if (usedGear is Weapon)
         {
             Weapon weapon = usedGear as Weapon;
             previewStatisticsModifier = weapon.OwnerBuffStatistics;
             previewDamageRange        = weapon.TargetDamageRange;
         }
     }
 }
コード例 #7
0
 public static int Map(
     this int @this,
     Int32Range startRange,
     Int32Range endRange)
 {
     throw new NetworkInformationException();
 }
コード例 #8
0
        public void Range_MinEqualToMax()
        {
            // Act
            var range = Int32Range.Range(10, 10);

            // Assert
            AssertChunks(range, 10, 10);
        }
コード例 #9
0
        public void Range_MinLowerThanMax()
        {
            // Act
            var range = Int32Range.Range(10, 20);

            // Assert
            AssertChunks(range, 10, 20);
        }
コード例 #10
0
 /// <summary>Instatiates a general matrix with the provided matrix data source,
 /// limited to the specified column and row ranges</summary>
 /// <param name="matrixData">Matrix data source</param>
 /// <param name="columnRange">Visible column range</param>
 /// <param name="rowRange">Visible row range</param>
 protected MatrixBase(
     MatrixDataSource <T> matrixData,
     Int32Range columnRange,
     Int32Range rowRange)
 {
     _dataSource      = matrixData;
     _dataColumnRange = columnRange;
     _dataRowRange    = rowRange;
 }
コード例 #11
0
        /// <summary>
        ///A test for MatrixBase`1 Constructor
        ///</summary>
        public void MatrixBaseConstructorTest2Helper <T>()
        {
            MatrixDataSource <T>    matrixData  = null; // TODO: Initialize to an appropriate value
            Int32Range              columnRange = null; // TODO: Initialize to an appropriate value
            Int32Range              rowRange    = null; // TODO: Initialize to an appropriate value
            MatrixBase_Accessor <T> target      = new MatrixBase_Accessor <T>(matrixData, columnRange, rowRange);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
コード例 #12
0
        /// <summary>
        /// Draw the equipment statistics
        /// </summary>
        /// <param name="selectedPlayer">The selected Player</param>
        private void DrawEquipmentStatistics(Player selectedPlayer)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            Vector2    position          = weaponPosition;
            Int32Range healthDamageRange = new Int32Range();

            healthDamageRange.Minimum = healthDamageRange.Maximum =
                selectedPlayer.CurrentStatistics.PhysicalOffense;
            Weapon weapon = selectedPlayer.GetEquippedWeapon();

            if (weapon != null)
            {
                weapon.DrawIcon(ScreenManager.SpriteBatch, position);
                healthDamageRange += weapon.TargetDamageRange;
            }

            position = armorPosition;
            Int32Range healthDefenseRange = new Int32Range();

            healthDefenseRange.Minimum = healthDefenseRange.Maximum =
                selectedPlayer.CurrentStatistics.PhysicalDefense;
            Int32Range magicDefenseRange = new Int32Range();

            magicDefenseRange.Minimum = magicDefenseRange.Maximum =
                selectedPlayer.CurrentStatistics.MagicalDefense;
            for (int i = 0; i < (int)4; i++)
            {
                Armor armor = selectedPlayer.GetEquippedArmor((Armor.ArmorSlot)i);
                if (armor != null)
                {
                    armor.DrawIcon(ScreenManager.SpriteBatch, position);
                    healthDefenseRange += armor.OwnerHealthDefenseRange;
                    magicDefenseRange  += armor.OwnerMagicDefenseRange;
                }
                position.X += 68;
            }

            position = weaponTextPosition;
            spriteBatch.DrawString(Fonts.DescriptionFont, "Weapon Attack: " + "(" +
                                   healthDamageRange.Minimum + "," +
                                   healthDamageRange.Maximum + ")",
                                   position, Color.Black);

            position.Y += 130;
            spriteBatch.DrawString(Fonts.DescriptionFont, "Weapon Defense: " + "(" +
                                   healthDefenseRange.Minimum + "," +
                                   healthDefenseRange.Maximum + ")",
                                   position, Color.Black);

            position.Y += 30;
            spriteBatch.DrawString(Fonts.DescriptionFont, "Spell Defense: " + "(" +
                                   magicDefenseRange.Minimum + "," +
                                   magicDefenseRange.Maximum + ")",
                                   position, Color.Black);
        }
コード例 #13
0
ファイル: TestRange.cs プロジェクト: anderscui/cslib
        public void TestGetEnumerator()
        {
            int        start = 0, end = 9;
            Int32Range range = new Int32Range(start, end);

            Assert.AreEqual(10, range.Count());

            Dictionary <int, string> dic = new Dictionary <int, string>();
            Hashtable ht = new Hashtable();
        }
コード例 #14
0
        /// <summary>
        ///		Extension method that allows for <see cref="IntegralRangeBase{TIntegralType}.Constrain"/>
        ///		to be called on a <see cref="Int32"/> subject with the range and exclusivity passed as a
        ///		parameter, rather than on the <see cref="IntegralRangeBase{TIntegralType}"/> object
        ///		with a <see cref="Int32"/> parameter.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="Int32"/> value in which to check against the <paramref name="range"/>
        ///		parameter to constrain a value within a range with an implicit inclusive comparison mode.
        /// </param>
        /// <param name="range">
        ///		An instance of the type <see cref="Int32Range"/>, describing a range of numeric values in
        ///		which the <paramref name="this"/> subject is to be compared against.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="Int32"/> value that is the <paramref name="this"/> subject value adjusted to
        ///		force the range of possible values to be within the provided <paramref cref="range"/>
        ///		parameter, using <see cref="EndpointExclusivity.Inclusive"/> as the comparison mode.
        /// </returns>
        public static Int32 Constrain(
            this Int32 @this,
            [NotNull] Int32Range range)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .Constrain(
                       @this));
        }
コード例 #15
0
        /// <summary>
        ///		Extension method that allows for <see cref="IntegralRangeBase{TIntegralType}.IsNotWithin"/>
        ///		to be called on a <see cref="Int32"/> subject with the range and exclusivity passed as a
        ///		parameter, rather than on the <see cref="IntegralRangeBase{TIntegralType}"/> object
        ///		with a <see cref="Int32"/> parameter.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="Int32"/> value in which to check against the <paramref name="range"/>
        ///		parameter to determine whether it is within the range, taking into account the exclusivity.
        /// </param>
        /// <param name="range">
        ///		An instance of the type <see cref="Int32Range"/>, describing a range of numeric values in
        ///		which the <paramref name="this"/> subject is to be compared against.
        /// </param>
        /// <param name="exclusivity">
        ///		A value indicating whether to perform the upper and lower bounds comparisons including
        ///		the range's Minimum and Maximum bounds, or to exclude them. This parameter is optional,
        ///		and the default value is <see cref="EndpointExclusivity.Inclusive"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="Int32"/> value indicating whether or not the <paramref name="this"/> subject
        ///		is within the provided <paramref cref="range"/> parameter, taking into account the
        ///		<see cref="EndpointExclusivity"/> mode via the <paramref name="exclusivity"/> parameter.
        ///		This comparison is the logical inverse of the <see cref="IsNotWithin"/> extension method.
        /// </returns>
        public static bool IsNotWithin(
            this Int32 @this,
            [NotNull] Int32Range range,
            EndpointExclusivity exclusivity = EndpointExclusivity.Inclusive)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .IsNotWithin(
                       @this,
                       exclusivity));
        }
コード例 #16
0
        /// <summary>
        ///A test for SubMatrix
        ///</summary>
        public void SubMatrixTest1Helper <T>()
        {
            MatrixBase <T> target      = new MatrixBase <T>(); // TODO: Initialize to an appropriate value
            Int32Range     columnRange = null;                 // TODO: Initialize to an appropriate value
            Int32Range     rowRange    = null;                 // TODO: Initialize to an appropriate value
            MatrixBase <T> expected    = null;                 // TODO: Initialize to an appropriate value
            MatrixBase <T> actual;

            actual = target.SubMatrix(columnRange, rowRange);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #17
0
        public void AddChunk_Error()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act & Assert
            Assert.Throws(typeof(ArgumentException),
                          // ReSharper disable once ObjectCreationAsStatement
                          () => range.Range(20, 10));
        }
コード例 #18
0
        public void AddChunk_MinImmediatelyBeforeMin()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(9, 15);

            // Assert
            AssertChunks(range, 9, 20);
        }
コード例 #19
0
        public void AddChunk_ContainingMin()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(5, 14);

            // Assert
            AssertChunks(range, 5, 20);
        }
コード例 #20
0
        public void AddChunk_BetweenMinMax()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(12, 14);

            // Assert
            AssertChunks(range, 10, 20);
        }
コード例 #21
0
        public void AddChunk_AfterMax()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(30, 40);

            // Assert
            AssertChunks(range, 10, 20, 30, 40);
        }
コード例 #22
0
        public void AddChunk_BeforeMin()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(5, 8);

            // Assert
            AssertChunks(range, 5, 8, 10, 20);
        }
コード例 #23
0
        public void AddChunk_InfinityBeforeMin()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(Int32Range.MinValue, 8);

            // Assert
            AssertChunks(range, Int32Range.MinValue, 8, 10, 20);
        }
コード例 #24
0
        public void AddChunk_ContainingMax()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(12, 25);

            // Assert
            AssertChunks(range, 10, 25);
        }
コード例 #25
0
        public void AddChunk_MaxImmediatelyAfterMax()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(15, 21);

            // Assert
            AssertChunks(range, 10, 21);
        }
コード例 #26
0
        public void AddChunk_AfterMaxInfinity()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            // Assume
            AssertChunks(range, 10, 20);

            // Act
            range.Range(30, Int32Range.MaxValue);

            // Assert
            AssertChunks(range, 10, 20, 30, Int32Range.MaxValue);
        }
コード例 #27
0
        /// <summary>
        ///		Extension method that performs a transformation on the <see cref="Int32"/> subject using
        ///		linear mapping to re-map from the provided initial range <paramref name="startRange"/>
        ///		to the target range <paramref name="endRange"/>.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="Int32"/> to perform the linear map range re-mapping upon.
        /// </param>
        /// <param name="startRange">
        ///		An instance of the type <see cref="Int32Range"/>, describing a range of numeric values in
        ///		which the linear re-mapping uses as the inital range of the subject.
        /// </param>
        /// <param name="endRange">
        ///		An instance of the type <see cref="Int32Range"/>, describing a range of numeric values in
        ///		which the linear re-mapping uses as the target range of the return value.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when either the <paramref name="startRange"/> or the <paramref name="endRange"/>
        ///		parameters are equal to <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="Int32"/> value that has been linearly mapped to the <paramref name="startRange"/>
        ///		parameter and re-mapped to the <paramref name="endRange"/> parameter.
        /// </returns>
        public static Int32 LinearMap(
            this Int32 @this,
            [NotNull] Int32Range startRange,
            [NotNull] Int32Range endRange)
        {
            startRange.IsNotNull(nameof(startRange));
            endRange.IsNotNull(nameof(endRange));

            return((
                       (@this - startRange.Minimum) *
                       (endRange.Maximum - endRange.Minimum) /
                       (startRange.Maximum - startRange.Minimum) +
                       endRange.Minimum)
                   .To <Int32>());
        }
コード例 #28
0
        public void Roll_Returns_Value_Between_1_And_6()
        {
            // Arrange
            var expectedRange = new Int32Range(1, 6);
            var sut           = new Die();

            // Act
            Enumerable.Range(1, 100)
            .ForEach(
                _ => {
                sut.Roll();
                // Assert
                Assert.True(expectedRange.IsInRange(sut.Value));
            }
                );
        }
コード例 #29
0
        public void AddChunkThatCompleteBoth()
        {
            // Arrange
            var range = Int32Range.Range(1, Int32Range.MaxValue);

            range.Range(Int32Range.MinValue, -1);

            // Assume
            AssertChunks(range, Int32Range.MinValue, -1, 1, Int32Range.MaxValue);

            // Act
            range.Range(0, 0);

            // Assert
            AssertChunks(range, Int32Range.MinValue, Int32Range.MaxValue);
        }
コード例 #30
0
        public void AddChunk2_ImmediatelyAfterMax2_Infinity()
        {
            // Arrange
            var range = Int32Range.Range(10, 20);

            range.Range(30, 40);

            // Assume
            AssertChunks(range, 10, 20, 30, 40);

            // Act
            range.Range(41, Int32Range.MaxValue);

            // Assert
            AssertChunks(range, 10, 20, 30, Int32Range.MaxValue);
        }
コード例 #31
0
 /// <summary>
 /// Reset Stats of previously selected Session.Party.Players stats from preview
 /// </summary>
 private void ResetFromPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange = new Int32Range();
 }
コード例 #32
0
        /// <summary>
        /// Draw a player's Details
        /// </summary>
        /// <param name="player">Players whose details have to be drawn</param>
        /// <param name="isSelected">Whether player is selected or not</param>
        private void DrawPlayerDetails(Player player, bool isSelected)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            Vector2 position = new Vector2();
            Vector2 equipEffectPosition = new Vector2();
            Color textColor;
            Color nameColor, classColor, levelColor;
            string text;
            int length;

            if (isSelected)
            {
                textColor = Color.Black;
                nameColor = new Color(241, 173, 10);
                classColor = new Color(207, 131, 42);
                levelColor = new Color(151, 150, 148);
            }
            else
            {
                textColor = Color.DarkGray;
                nameColor = new Color(117, 88, 18);
                classColor = new Color(125, 78, 24);
                levelColor = new Color(110, 106, 99);
            }

            position = currentTextPosition;
            position.Y -= 5f;
            if (isSelected)
            {
                spriteBatch.Draw(playerSelTexture, position, Color.White);
            }
            else
            {
                spriteBatch.Draw(playerUnSelTexture, position, Color.White);
            }
            position.Y += 5f;

            // Draw portrait
            portraitPosition.X = position.X + 3f;
            portraitPosition.Y = position.Y + 16f;
            spriteBatch.Draw(player.ActivePortraitTexture, portraitPosition, 
                Color.White);
            if (isGearUsed && isSelected)
            {
                spriteBatch.Draw(tickMarkTexture, position, Color.White);
            }

            // Draw Player Name
            playerNamePosition.X = position.X + 90f;
            playerNamePosition.Y = position.Y + 15f;
            spriteBatch.DrawString(Fonts.PlayerNameFont,
                player.Name.ToUpper(), playerNamePosition, nameColor);

            // Draw Player Class
            playerNamePosition.Y += 25f;
            spriteBatch.DrawString(Fonts.PlayerNameFont, player.CharacterClass.Name,
                playerNamePosition, classColor);

            // Draw Player Level
            playerNamePosition.Y += 26f;
            spriteBatch.DrawString(Fonts.PlayerNameFont, "LEVEL: " +
                player.CharacterLevel,
                playerNamePosition, levelColor);
            position = currentTextPosition;
            position.X += playerSelTexture.Width + 5f;
            DrawPlayerStats(player, isSelected, ref position);

            equipEffectPosition = position;
            equipEffectPosition.X += 100f;
            equipEffectPosition.Y = currentTextPosition.Y;

            text = "Weapon Atk: (";
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            spriteBatch.DrawString(Fonts.DescriptionFont, text, equipEffectPosition,
                Fonts.CountColor);
            equipEffectPosition.X += length;

            // calculate weapon damage
            previewDamageRange = new Int32Range();
            previewHealthDefenseRange = new Int32Range();
            previewMagicDefenseRange = new Int32Range();
            if (isSelected && isUseAllowed && !isGearUsed)
            {
                if (usedGear is Equipment)
                {
                    Equipment equipment = usedGear as Equipment;
                    if (equipment is Weapon)
                    {
                        Weapon weapon = equipment as Weapon;
                        previewDamageRange = weapon.TargetDamageRange;
                        Weapon equippedWeapon = player.GetEquippedWeapon();
                        if (equippedWeapon != null)
                        {
                            previewDamageRange -= equippedWeapon.TargetDamageRange;
                            previewDamageRange -=
                                equippedWeapon.OwnerBuffStatistics.PhysicalOffense;
                            previewHealthDefenseRange -= 
                                equippedWeapon.OwnerBuffStatistics.PhysicalDefense;
                            previewMagicDefenseRange -= 
                                equippedWeapon.OwnerBuffStatistics.MagicalDefense;
                        }
                    }
                    else if (equipment is Armor)
                    {
                        Armor armor = usedGear as Armor;
                        previewHealthDefenseRange = armor.OwnerHealthDefenseRange;
                        previewMagicDefenseRange = armor.OwnerMagicDefenseRange;
                        Armor equippedArmor = player.GetEquippedArmor(armor.Slot);
                        if (equippedArmor != null)
                        {
                            previewHealthDefenseRange -=
                                equippedArmor.OwnerHealthDefenseRange;
                            previewMagicDefenseRange -=
                                equippedArmor.OwnerMagicDefenseRange;
                            previewDamageRange -=
                                equippedArmor.OwnerBuffStatistics.PhysicalOffense;
                            previewHealthDefenseRange -=
                                equippedArmor.OwnerBuffStatistics.PhysicalDefense;
                            previewMagicDefenseRange -=
                                equippedArmor.OwnerBuffStatistics.MagicalDefense;
                        }
                    }
                    previewDamageRange += equipment.OwnerBuffStatistics.PhysicalOffense;
                    previewHealthDefenseRange +=
                        equipment.OwnerBuffStatistics.PhysicalDefense;
                    previewMagicDefenseRange +=
                        equipment.OwnerBuffStatistics.MagicalDefense;
                }
            }

            Int32Range drawWeaponDamageRange = player.TargetDamageRange +
                previewDamageRange + player.CharacterStatistics.PhysicalOffense;
            text = drawWeaponDamageRange.Minimum.ToString();
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            textColor = GetRangeColor(previewDamageRange.Minimum, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, text,
                equipEffectPosition, textColor);
            equipEffectPosition.X += length;

            text = ",";
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            spriteBatch.DrawString(Fonts.DescriptionFont,
                text, equipEffectPosition,
                Fonts.CountColor);
            equipEffectPosition.X += length;

            text = drawWeaponDamageRange.Maximum.ToString(); ;
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            textColor = GetRangeColor(previewDamageRange.Maximum, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, text,
                equipEffectPosition, textColor);
            equipEffectPosition.X += length;

            spriteBatch.DrawString(Fonts.DescriptionFont, ")", equipEffectPosition,
                Fonts.CountColor);

            equipEffectPosition.X = position.X + 100f;
            equipEffectPosition.Y += Fonts.DescriptionFont.LineSpacing;
            text = "Weapon Def: (";
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            spriteBatch.DrawString(Fonts.DescriptionFont, text, equipEffectPosition,
                Fonts.CountColor);
            equipEffectPosition.X += length;

            Int32Range drawHealthDefenseRange = player.HealthDefenseRange + 
                previewHealthDefenseRange + player.CharacterStatistics.PhysicalDefense;
            text = drawHealthDefenseRange.Minimum.ToString();
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            textColor = GetRangeColor(previewHealthDefenseRange.Minimum, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, text,
                equipEffectPosition, textColor);
            equipEffectPosition.X += length;

            text = ",";
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            spriteBatch.DrawString(Fonts.DescriptionFont, text, equipEffectPosition,
                Fonts.CountColor);
            equipEffectPosition.X += length;

            text = drawHealthDefenseRange.Maximum.ToString();
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            textColor = GetRangeColor(previewHealthDefenseRange.Maximum, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, text,
                equipEffectPosition, textColor);
            equipEffectPosition.X += length;

            spriteBatch.DrawString(Fonts.DescriptionFont, ")", equipEffectPosition,
                Fonts.CountColor);


            equipEffectPosition.X = position.X + 100f;
            equipEffectPosition.Y += Fonts.DescriptionFont.LineSpacing;
            text = "Spell Def: (";
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            spriteBatch.DrawString(Fonts.DescriptionFont, text, equipEffectPosition,
                Fonts.CountColor);
            equipEffectPosition.X += length;

            Int32Range drawMagicDefenseRange = player.MagicDefenseRange + 
                previewMagicDefenseRange + player.CharacterStatistics.MagicalDefense;
            text = drawMagicDefenseRange.Minimum.ToString();
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            textColor = GetRangeColor(previewMagicDefenseRange.Minimum, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, text,
                equipEffectPosition, textColor);
            equipEffectPosition.X += length;

            text = ",";
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            spriteBatch.DrawString(Fonts.DescriptionFont, text, equipEffectPosition,
                Fonts.CountColor);
            equipEffectPosition.X += length;

            text = drawMagicDefenseRange.Maximum.ToString();
            length = (int)Fonts.DescriptionFont.MeasureString(text).X;

            textColor = GetRangeColor(previewMagicDefenseRange.Maximum, isSelected);
            spriteBatch.DrawString(Fonts.DescriptionFont, text,
                equipEffectPosition, textColor);
            equipEffectPosition.X += length;

            spriteBatch.DrawString(Fonts.DescriptionFont, ")", equipEffectPosition,
                Fonts.CountColor);

            currentTextPosition.Y = position.Y + 3f;

         //   spriteBatch.Draw(lineTexture, currentTextPosition, Color.White);

            currentTextPosition.Y += 20f;
        }
コード例 #33
0
        /// <summary>
        /// Draw the equipment statistics
        /// </summary>
        /// <param name="selectedPlayer">The selected Player</param>
        private void DrawEquipmentStatistics(Player selectedPlayer)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            Vector2 position = weaponPosition;
            Int32Range healthDamageRange = new Int32Range();
            healthDamageRange.Minimum = healthDamageRange.Maximum =
                selectedPlayer.CurrentStatistics.PhysicalOffense;
            Weapon weapon = selectedPlayer.GetEquippedWeapon();
            if (weapon != null)
            {
                weapon.DrawIcon(ScreenManager.SpriteBatch, position);
                healthDamageRange += weapon.TargetDamageRange;
            }

            position = armorPosition;
            Int32Range healthDefenseRange = new Int32Range();
            healthDefenseRange.Minimum = healthDefenseRange.Maximum =
                selectedPlayer.CurrentStatistics.PhysicalDefense;
            Int32Range magicDefenseRange = new Int32Range();
            magicDefenseRange.Minimum = magicDefenseRange.Maximum =
                selectedPlayer.CurrentStatistics.MagicalDefense;
            for (int i = 0; i < (int)4; i++)
            {
                Armor armor = selectedPlayer.GetEquippedArmor((Armor.ArmorSlot)i);
                if (armor != null)
                {
                    armor.DrawIcon(ScreenManager.SpriteBatch, position);
                    healthDefenseRange += armor.OwnerHealthDefenseRange;
                    magicDefenseRange += armor.OwnerMagicDefenseRange;
                }
                position.X += 68 * ScaledVector2.ScaleFactor;
            }

            position = weaponTextPosition;
            spriteBatch.DrawString(Fonts.DescriptionFont, "Weapon Attack: " + "(" +
                healthDamageRange.Minimum + "," +
                healthDamageRange.Maximum + ")",
                position, Color.Black);

            position.Y += 130 *ScaledVector2.ScaleFactor;
            spriteBatch.DrawString(Fonts.DescriptionFont, "Weapon Defense: " + "(" +
                healthDefenseRange.Minimum + "," +
                healthDefenseRange.Maximum + ")",
                position, Color.Black);

            position.Y += 30* ScaledVector2.ScaleFactor;
            spriteBatch.DrawString(Fonts.DescriptionFont, "Spell Defense: " + "(" +
                magicDefenseRange.Minimum + "," +
                magicDefenseRange.Maximum + ")",
                position, Color.Black);
        }
コード例 #34
0
 /// <summary>
 /// Calculate for selected Session.Party.Players stats for preview
 /// </summary>
 private void CalculateForPreview()
 {
     previewStatisticsModifier = new StatisticsValue();
     previewDamageRange = new Int32Range();
     previewHealthDefenseRange = new Int32Range();
     previewMagicDefenseRange = new Int32Range();
     if (isUseAllowed && !isGearUsed)
     {
         if (usedGear is Item)
         {
             // no preview for items
         }
         else if (usedGear is Armor)
         {
             Armor armor = usedGear as Armor;
             previewStatisticsModifier = armor.OwnerBuffStatistics;
             previewHealthDefenseRange = armor.OwnerHealthDefenseRange;
             previewMagicDefenseRange = armor.OwnerMagicDefenseRange;
         }
         else if (usedGear is Weapon)
         {
             Weapon weapon = usedGear as Weapon;
             previewStatisticsModifier = weapon.OwnerBuffStatistics;
             previewDamageRange = weapon.TargetDamageRange;
         }
     }
 }