Esempio n. 1
0
        public List<DamageObject> PlayerCastSpell(Player player, Spell spell, Creature target, GameTime gameTime)
        {
            List<DamageObject> DamagedMonsters = new List<DamageObject>();
            int currentTime = (int)gameTime.TotalGameTime.TotalMilliseconds;
            if (!spell.TargetSpell)
            {
                for (int i = 0; i < spell.Area.Length / 3; i++)
                {
                    for (int j = 0; j < spell.Area.Length / 3; j++)
                    {
                        if (spell.Area[i + j])
                        {
                            /* TODO: Make area spell healing possible! */
                            int creatureID = GetCreatureIDFromTile(new Coordinates(player.Position.X - Coordinates.Step + (i * Coordinates.Step), player.Position.Y - Coordinates.Step + (j * Coordinates.Step)));
                            if (creatureID != -1)
                            {
                                Creature creature = GetCreatureByID(creatureID);
                                if (creature.Health > 0)
                                {
                                    int DamageDealt = creature.ReceiveDamage(spell.Damage + (player.MagicStrength * 2), 0);
                                    DamagedMonsters.Add(new DamageObject(creature, DamageDealt, spell.HealSpell, currentTime, currentTime + DamageObject.DamageDuration));
                                    if (creature.Health < 1)
                                    {
                                        player.ReceiveExperience(creature.Experience);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if(spell.HealSpell)
                {
                    int damage = spell.Damage + (player.MagicStrength * 2);
                    if (player.Health + damage > player.MaxHealth)
                    {
                        damage = player.MaxHealth - player.Health;
                        player.Health = player.MaxHealth;
                    }
                    else
                    {
                        player.Health += damage;
                    }
                    DamagedMonsters.Add(new DamageObject(player, damage, spell.HealSpell, currentTime, currentTime + DamageObject.DamageDuration));
                }
                else
                {
                    int DamageDealt = target.ReceiveDamage(spell.Damage + (player.MagicStrength * 2), 0);
                    DamagedMonsters.Add(new DamageObject(target, DamageDealt, spell.HealSpell, currentTime, currentTime + DamageObject.DamageDuration));
                    if (target.Health < 1)
                    {
                        player.ReceiveExperience(target.Experience);
                    }
                }
            }

            return DamagedMonsters;
        }
Esempio n. 2
0
        internal List<DamageObject> PlayerCastSpell(Player player, Spell spell, Creature target, GameTime gameTime)
        {
            List<DamageObject> DamagedMonsters = new List<DamageObject>();
            int currentTime = (int)gameTime.TotalGameTime.TotalMilliseconds;
            if (spell.AreaSpell)
            {
                Coordinates TopLeftOfScreen = new Coordinates(player.Position.X - 7, player.Position.Y - 5);
                /* TODO: Make area spell healing possible! */
                int n = 1;
                int y = 0;
                int x = 0;
                int experience = 0;
                for (int i = 0; i < spell.Area.Length; i++)
                {
                    if (n % 15 == 0)
                    {
                        y++;
                        x = -1;
                    }
                    if (spell.Area[i] == 1)
                    {
                        //spriteBatch.Draw(spell.Sprite, new Vector2((float)(SpellDamage[index].Position.X - map.Players[0].Position.X + (Utility.ScreenX) - 7 + x) * Coordinates.Step, (float)(SpellDamage[index].Position.Y - map.Players[0].Position.Y + (Utility.ScreenY) - 5 + y) * Coordinates.Step), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                        List<Creature> CastOnCreatures = GetCreaturesFromTile(new Coordinates(TopLeftOfScreen.X + x, TopLeftOfScreen.Y + y, player.Position.Z));
                        for (int c = 0; c < CastOnCreatures.Count; c++)
                        {

                            Creature creature = CastOnCreatures[c];
                            if (creature.Health > 0)
                            {
                                int DamageDealt = creature.ReceiveDamage(spell.Damage + (player.MagicStrength * 2), 0);
                                int text_type = 0;
                                if (spell.HealSpell)
                                {
                                    text_type = DamageObject.Text_Healing;
                                }
                                else
                                {
                                    text_type = DamageObject.Text_Damage;
                                }
                                DamagedMonsters.Add(new DamageObject(creature, DamageDealt, text_type, currentTime, currentTime + DamageObject.DamageDuration));
                                if (creature.Health < 1)
                                {
                                    experience += CreatureDie(creature, player);
                                }
                            }
                        }
                    }
                    n++;
                    x++;
                }
                if (experience > 0)
                {
                    DamagedMonsters.Add(new DamageObject(player, experience, DamageObject.Text_Experience, currentTime, currentTime + DamageObject.DamageDuration));
                }
            }
            else
            {
                if (spell.HealSpell)
                {
                    int damage = spell.Damage + (player.MagicStrength * 2);
                    if (player.Health + damage > player.MaxHealth)
                    {
                        damage = player.MaxHealth - player.Health;
                        player.Health = player.MaxHealth;
                    }
                    else
                    {
                        player.Health += damage;
                    }
                    int text_type = 0;
                    if (spell.HealSpell)
                    {
                        text_type = DamageObject.Text_Healing;
                    }
                    else
                    {
                        text_type = DamageObject.Text_Damage;
                    }
                    DamagedMonsters.Add(new DamageObject(player, damage, text_type, currentTime, currentTime + DamageObject.DamageDuration));
                }
                else
                {
                    int DamageDealt = target.ReceiveDamage(spell.Damage + (player.MagicStrength * 2), 0);
                    int text_type = 0;
                    if (spell.HealSpell)
                    {
                        text_type = DamageObject.Text_Healing;
                    }
                    else
                    {
                        text_type = DamageObject.Text_Damage;
                    }
                    DamagedMonsters.Add(new DamageObject(target, DamageDealt, text_type, currentTime, currentTime + DamageObject.DamageDuration));
                    if (target.Health < 1)
                    {
                        int experience = CreatureDie(target, player);
                        DamagedMonsters.Add(new DamageObject(player, experience, DamageObject.Text_Experience, currentTime, currentTime + DamageObject.DamageDuration));
                    }
                }
            }

            return DamagedMonsters;
        }