Пример #1
0
        /// <summary>
        /// Generic throw method for most normal items
        /// </summary>
        /// <param name="item"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public Point ThrowItemGeneric(IEquippableItem item, Point target, int damageOrStunTurns, bool stunDamage)
        {
            Item itemAsItem = item as Item;

            LogFile.Log.LogEntryDebug("Throwing " + itemAsItem.SingleItemDescription, LogDebugLevel.Medium);

            //Find target

            List<Point> targetSquares = Game.Dungeon.CalculateTrajectory(target);
            Monster monster = Game.Dungeon.FirstMonsterInTrajectory(targetSquares);

            //Find where it landed

            //Destination will be the last square in trajectory
            Point destination;
            if (targetSquares.Count > 0)
                destination = targetSquares[targetSquares.Count - 1];
            else
                //Threw it on themselves!
                destination = LocationMap;

            //Stopped by a monster
            if (monster != null)
            {
                destination = monster.LocationMap;
            }

            //Make throwing sound AT target location
            Game.Dungeon.AddSoundEffect(item.ThrowSoundMagnitude(), LocationLevel, destination);

            //Draw throw
            Screen.Instance.DrawAreaAttackAnimation(targetSquares, ColorPresets.Gray);

            if (stunDamage)
            {
                if (monster != null && damageOrStunTurns > 0)
                {
                    ApplyStunDamageToMonster(monster, damageOrStunTurns);
                }
            }
            else
            {
                if (monster != null && damageOrStunTurns > 0)
                {
                    AttackMonsterThrown(monster, damageOrStunTurns);
                }
            }

            return destination;
        }
Пример #2
0
        /// <summary>
        /// Stun grenade - goes through walls
        /// Should sync with above method
        /// </summary>
        /// <param name="item"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static Point ThrowItemGrenadeLikeStun(IEquippableItem item, Point target, double size, int damage)
        {
            Item itemAsItem = item as Item;

            LogFile.Log.LogEntryDebug("Throwing " + itemAsItem.SingleItemDescription, LogDebugLevel.Medium);

            Player player = Game.Dungeon.Player;

            //Find target

            List<Point> targetSquares = Game.Dungeon.CalculateTrajectory(target);
            Monster monster = Game.Dungeon.FirstMonsterInTrajectory(targetSquares);

            //Find where it landed

            //Destination will be the last square in trajectory
            Point destination;
            if (targetSquares.Count > 0)
                destination = targetSquares[targetSquares.Count - 1];
            else
                //Threw it on themselves!
                destination = player.LocationMap;

            //Stopped by a monster
            if (monster != null)
            {
                destination = monster.LocationMap;
            }

            //Make throwing sound AT target location
            Game.Dungeon.AddSoundEffect(item.ThrowSoundMagnitude(), Game.Dungeon.Player.LocationLevel, destination);

            //Work out grenade splash and damage

            List<Point> grenadeAffects = Game.Dungeon.GetPointsForGrenadeTemplate(destination, Game.Dungeon.Player.LocationLevel, size);

            //Draw attack
            Screen.Instance.DrawAreaAttackAnimation(grenadeAffects, ColorPresets.DodgerBlue);

            //Attack all monsters in the area

            foreach (Point sq in grenadeAffects)
            {
                SquareContents squareContents = Game.Dungeon.MapSquareContents(player.LocationLevel, sq);

                Monster m = squareContents.monster;

                //Hit the monster if it's there
                if (m != null)
                {
                    string combatResultsMsg = "PvM (" + m.Representation + ") Grenade: Stun: " + damage;
                    LogFile.Log.LogEntryDebug(combatResultsMsg, LogDebugLevel.Medium);

                    //Apply damage
                    player.ApplyStunDamageToMonster(m, damage);
                }
            }

            //Doesn't affect the player

            return(destination);
        }
Пример #3
0
        /// <summary>
        /// Stun grenade - goes through walls
        /// Should sync with above method
        /// </summary>
        /// <param name="item"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static Point ThrowItemGrenadeLikeStun(IEquippableItem item, Point target, double size, int damage)
        {
            Item itemAsItem = item as Item;

            LogFile.Log.LogEntryDebug("Throwing " + itemAsItem.SingleItemDescription, LogDebugLevel.Medium);

            Player player = Game.Dungeon.Player;

            //Find target

            List <Point> targetSquares = Game.Dungeon.CalculateTrajectory(target);
            Monster      monster       = Game.Dungeon.FirstMonsterInTrajectory(targetSquares);

            //Find where it landed

            //Destination will be the last square in trajectory
            Point destination;

            if (targetSquares.Count > 0)
            {
                destination = targetSquares[targetSquares.Count - 1];
            }
            else
            {
                //Threw it on themselves!
                destination = player.LocationMap;
            }


            //Stopped by a monster
            if (monster != null)
            {
                destination = monster.LocationMap;
            }

            //Make throwing sound AT target location
            Game.Dungeon.AddSoundEffect(item.ThrowSoundMagnitude(), Game.Dungeon.Player.LocationLevel, destination);

            //Work out grenade splash and damage

            List <Point> grenadeAffects = Game.Dungeon.GetPointsForGrenadeTemplate(destination, Game.Dungeon.Player.LocationLevel, size);

            //Draw attack
            Screen.Instance.DrawAreaAttackAnimation(grenadeAffects, ColorPresets.DodgerBlue);

            //Attack all monsters in the area

            foreach (Point sq in grenadeAffects)
            {
                SquareContents squareContents = Game.Dungeon.MapSquareContents(player.LocationLevel, sq);

                Monster m = squareContents.monster;

                //Hit the monster if it's there
                if (m != null)
                {
                    string combatResultsMsg = "PvM (" + m.Representation + ") Grenade: Stun: " + damage;
                    LogFile.Log.LogEntryDebug(combatResultsMsg, LogDebugLevel.Medium);

                    //Apply damage
                    player.ApplyStunDamageToMonster(m, damage);
                }
            }

            //Doesn't affect the player

            return(destination);
        }