public async Task <long> GetProductionCapacity(Player player, long resourceId)
        {
            long amount = 0;

            PlanetRepository planetRepository = IoC.Resolve <PlanetRepository>();
            var planets = await planetRepository.FindAll(p => p.PlayerId.Equals(player.Id));

            foreach (var planet in planets)
            {
                Dictionary <UnitTemplate, int> counts = await planetRepository.GetBuildingsCount(planet);

                Dictionary <IAbilities, int> extractors = counts
                                                          .Where(p => AbilitiesHelper.IsExtractor(p.Key))
                                                          .ToDictionary(p => AbilitiesHelper.AsExtractor(p.Key), p => (int)p.Value);

                foreach (var extCount in extractors)
                {
                    Resource resource = extCount.Key.ExtractedResource;
                    if (resource.Id == resourceId)
                    {
                        long production = extCount.Key.ExtractionCapacity;
                        int  count      = extCount.Value;
                        amount += count * production;
                    }
                }
            }
            return(amount);
        }
        protected override bool PostReceive(BinaryReader reader, int fromWho)
        {
            if (!IsResponse && Main.netMode == NetmodeID.MultiplayerClient)
            {
                IsResponse = true;
                Send(Main.myPlayer, Player.whoAmI);
            }

            if (!HeroSelected)
            {
                return(true);
            }

            ModPlayer.Hero  = HeroDefinitionManager.Instance[Hero];
            ModPlayer.Level = Level;

            if (!string.IsNullOrWhiteSpace(SerializedAbilities))
            {
                Dictionary <AbilityDefinition, PlayerAbility> acquiredAbilities = new Dictionary <AbilityDefinition, PlayerAbility>();
                PlayerAbility[] playerAbilities = AbilitiesHelper.DeserializeAbilities(SerializedAbilities);

                ModPlayer.AcquiredAbilities = acquiredAbilities;

                for (int i = 0; i < playerAbilities.Length; i++)
                {
                    acquiredAbilities.Add(playerAbilities[i].Ability, playerAbilities[i]);
                }
            }

            return(true);
        }
        public PlayerJoiningSynchronizationPacket(DoTariaPlayer dotariaPlayer)
        {
            HeroSelected = dotariaPlayer.HeroSelected;
            Hero         = HeroSelected ? dotariaPlayer.Hero.UnlocalizedName : HERO_UNDEFINED;

            Level = dotariaPlayer.Level;
            SerializedAbilities = AbilitiesHelper.SerializeAbilities(dotariaPlayer.AcquiredAbilities.Values.ToArray());
        }
Esempio n. 4
0
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Allows manipulation of fire elements. Each Exort instance provides increased attack damage to magic weapons.\n" +
 $"Damage per instance: {AbilitiesHelper.GenerateCleanSlashedString(GetExtraDamage, dotariaPlayer, this)}";
Esempio n. 5
0
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Allows manipulation of ice elements. Each Quas instance provides increased health regeneration.\n\n" +
 $"HP regen per instance:\n{AbilitiesHelper.GenerateCleanSlashedString(GetExtraHealthRegeneration, dotariaPlayer, this)}";
Esempio n. 6
0
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Allows manipulation of storm elements. Each Wex instance provides increased magic regen and movement speed.\n\n" +
 $"Attack speed per instance:\nNOT YET DONE\n" +     // {AbilitiesHelper.GenerateCleanSlashedString()}
 $"(Temp) MP regen per instance (%):\n{AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetManaRegenerationPercentage(player, ability) * 100, dotariaPlayer, this)}\n" +
 $"Move speed per instance:\n{AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetExtraMoveSpeedPercentage(player, ability) * 100, dotariaPlayer, this)}";
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 $"When activated, all damage dealt to you will heal instead of harm. Most negative buffs will also be removed. If the ability is not on cooldown, it will automatically activate if your health falls below {AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetHealthThreshold(player, ability), dotariaPlayer, this)}.\n\n" +
 $"Health threshold: {AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetHealthThreshold(player, ability), dotariaPlayer, this)}" +
 $"Duration: {AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetDuration(player, ability), dotariaPlayer, this)}";
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Shadow Fiend steals the soul from units he kills, gaining bonus damage. If the killed unit is a hero, he gains an additional 11 bonus souls. On death, he releases half of them from bondage.\n\n" +
 $"Damage per soul: {GetDamagePerSoul(dotariaPlayer, playerAbility)}\nMax souls: " +
 AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetMaxSouls(dotariaPlayer, ability), dotariaPlayer, this);
Esempio n. 9
0
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 $"Base damage: {AbilitiesHelper.GenerateCleanSlashedString(InternalGetAbilityDamage, dotariaPlayer, this)}\n" +
 $"Range: {AbilitiesHelper.GenerateCleanSlashedString(InternalGetCastRange, dotariaPlayer, this)}\n" +
 $"Bonus per stack: {AbilitiesHelper.GenerateCleanSlashedString(GetDamageIncreasePerStack, dotariaPlayer, this)}\n" +
 $"Stack duration: {AbilitiesHelper.GenerateCleanSlashedString(GetStackDuration, dotariaPlayer, this)}";
Esempio n. 10
0
        private void DrawDescription(SpriteBatch spriteBatch, AbilityDefinition ability)
        {
            DoTariaPlayer doTariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer);
            PlayerAbility currentPlayerAbility;

            if (doTariaPlayer.HasAbility(ability))
            {
                currentPlayerAbility = doTariaPlayer.GetPlayerAbility(ability);
            }
            else
            {
                currentPlayerAbility = new PlayerAbility(ability, 1, 0);
            }

            int
                panelWidth  = 300,
                panelHeight = 34;

            Vector2 position = Main.MouseWorld + new Vector2(Main.cursorTextures[0].Width, Main.cursorTextures[0].Height * 2) - Main.screenPosition;

            StringBuilder description = new StringBuilder("Ability: ");


            if (ability.AbilityTargetType == AbilityTargetType.NoTarget && ability.AbilityType == AbilityType.Passive)
            {
                description.Append(ability.AbilityType);
            }
            else
            {
                description.Append(ability.AbilityTargetType.ToString().AddSpaceBeforeCapitals());
            }

            description.AppendLine();

            if (ability.AbilityTargetUnitType != AbilityTargetUnitType.None)
            {
                description.Append("Affects: ");

                if (!(ability.AbilityTargetUnitFaction == AbilityTargetFaction.Self || ability.AbilityTargetUnitFaction == (AbilityTargetFaction.Enemies & AbilityTargetFaction.Allies)))
                {
                    description.Append(ability.AbilityTargetUnitFaction).Append(" ");
                }

                description.Append(ability.AbilityTargetUnitType.ToString().AddSpaceBeforeCapitals()).AppendLine();
            }

            description.Append(ability.GetAbilityTooltip(doTariaPlayer, currentPlayerAbility));

            DispelType dispelType = ability.GetDispelType(doTariaPlayer, currentPlayerAbility);

            if (dispelType != DispelType.None)
            {
                description.AppendLine().Append("Dispel type: ").Append(dispelType.ToString()).Append(" Dispel");
            }

            description.AppendLine();
            string finaliziedDescription = SpliceText(description.ToString(), 34);

            panelHeight += finaliziedDescription.Split('\n').Length * 26;

            spriteBatch.Draw(Main.magicPixel, position, new Rectangle(0, 0, panelWidth, panelHeight), Color.Black * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            spriteBatch.Draw(Main.magicPixel, position + new Vector2(2, 2), new Rectangle(0, 0, panelWidth - 4, 32), Color.Gray * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            spriteBatch.DrawString(Main.fontMouseText, ability.DisplayName, position + new Vector2(6, 8), Color.White);
            spriteBatch.DrawString(Main.fontMouseText, "Level: " + CurrentLevel, position + new Vector2(panelWidth - 56, 12), Color.White, 0, Vector2.Zero, 0.75f, SpriteEffects.None, 1f);

            spriteBatch.DrawString(Main.fontMouseText, finaliziedDescription, position + new Vector2(10, 40), Color.Gray, 0, Vector2.Zero, 0.85f, SpriteEffects.None, 1f);

            Texture2D manacostTexture = DoTariaMod.Instance.GetTexture("UserInterfaces/Abilities/ManacostIcon");
            Texture2D cooldownTexture = DoTariaMod.Instance.GetTexture("UserInterfaces/Abilities/CooldownIcon");

            Func <DoTariaPlayer, PlayerAbility, float> cooldownGetter = (player, playerAbility) => (float)Math.Round((double)playerAbility.Ability.InternalGetCooldown(player, playerAbility), 2);

            List <float> differentCooldowns = AbilitiesHelper.GetDifferentValues(cooldownGetter, doTariaPlayer, ability);

            if (!(differentCooldowns.Count == 1 && differentCooldowns[0] == 0f))
            {
                spriteBatch.Draw(cooldownTexture, position + new Vector2(10, panelHeight - 22), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                spriteBatch.DrawString(Main.fontMouseText,
                                       AbilitiesHelper.GenerateCleanSlashedString(AbilitiesHelper.GetAllValues((player, pAbility) => (float)Math.Round((double)pAbility.Ability.InternalGetCooldown(player, pAbility), 2),
                                                                                                               doTariaPlayer, ability), differentCooldowns), position + new Vector2(30, panelHeight - 24), Color.Gray);
            }

            if (ability.AbilityType == AbilityType.Active)
            {
                spriteBatch.Draw(manacostTexture, position + new Vector2(panelWidth / 2, panelHeight - 22), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                spriteBatch.DrawString(Main.fontMouseText, AbilitiesHelper.GenerateCleanSlashedString((player, playerAbility) => (float)Math.Ceiling(playerAbility.Ability.InternalGetManaCost(player, playerAbility)), doTariaPlayer, ability),
                                       position + new Vector2(panelWidth / 2 + 20, panelHeight - 24), Color.Gray);
            }
        }
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Abaddon releases a coil of deathly mist that can damage an enemy unit or heal a friendly unit at the cost of some of Abaddon's health.\n\n" +
 $"Self damage: {AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetSelfDamage(dotariaPlayer, ability), dotariaPlayer, this)}\n" +
 $"Damage/Heal: {AbilitiesHelper.GenerateCleanSlashedString((player, ability) => InternalGetAbilityDamage(dotariaPlayer, ability), dotariaPlayer, this)}";
Esempio n. 12
0
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Shadow Fiend's presence reduces the armor of nearby enemies.\n\n" +
 $"Reduction (%): {AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetDefenseReduction(player, ability) * 100, dotariaPlayer, this)}\n" +
 $"Range: {AbilitiesHelper.GenerateCleanSlashedString(InternalGetCastRange, dotariaPlayer, this)}";
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Invoker draws the heat from an enemy, chilling them to their very core for a duration based on the level of Quas. The enemy will take damage and be briefly frozen. Further damage taken in this state will freeze the enemy again, dealing bonus damage. The enemy can only be frozen so often, but the freeze cooldown decreases based on the level of Quas.\n\n" +
 $"Cold snap duration (quas):\n{AbilitiesHelper.GenerateCleanSlashedString(GetColdSnapDuration, dotariaPlayer, AbilityDefinitionManager.Instance.Quas)}\n" +
 $"Freeze duration: {AbilitiesHelper.GenerateCleanSlashedString(GetFreezeDuration, dotariaPlayer, this)}\n" +
 $"Freeze cooldown (quas):\n{AbilitiesHelper.GenerateCleanSlashedString(GetFreezeCooldown, dotariaPlayer, AbilityDefinitionManager.Instance.Quas)}\n" +
 $"Freeze damage (quas):\n{AbilitiesHelper.GenerateCleanSlashedString(GetFreezeDamage, dotariaPlayer, AbilityDefinitionManager.Instance.Quas)}";
 public override string GetAbilityTooltip(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility) =>
 "Generates a wall of solid ice directly in front of Invoker for a duration based on the level of Quas. The bitter cold emanating from it greatly slows nearby enemies based on the level of Quas and deals damage each second based on the level of Exort.\n\n" +
 $"Duration: {AbilitiesHelper.GenerateCleanSlashedString(GetDuration, dotariaPlayer, AbilityDefinitionManager.Instance.Quas)}\n" +
 $"Radius: {AbilitiesHelper.GenerateCleanSlashedString(InternalGetCastRange, dotariaPlayer, AbilityDefinitionManager.Instance.Quas)}\n" +
 $"Enemy slow (Quas) (%):\n{AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetEnemyMoveSpeedChange(player, ability) * 100, dotariaPlayer, AbilityDefinitionManager.Instance.Quas)}\n" +
 $"Self slow (Wex) (%):\n{AbilitiesHelper.GenerateCleanSlashedString((player, ability) => GetSelfMoveSpeedChange(player, ability) * 100, dotariaPlayer, AbilityDefinitionManager.Instance.Wex)}";