Ejemplo n.º 1
0
        public void FireIfYouLike(StaticItem source, World world)
        {
            Direction firingDirection = DetermineFiringDirection(source.TilePosition, world.Player.TilePosition);
            if (firingDirection == Direction.None)
                return;
            if (!DoesMonsterHaveClearShotAtPlayer(world, source.TilePosition, firingDirection))
                return;

            var startPos = source.TilePosition.ToPosition() + firingDirection.ToVector() * new Vector2(Tile.Width, Tile.Height) / 2;
            var shot = new StandardShot(world, startPos, firingDirection, source.Energy >> 2, ShotType.Monster);
            world.AddShot(shot);
            world.Game.SoundPlayer.Play(GameSound.MonsterShoots);
        }
Ejemplo n.º 2
0
        public void Fire(StaticItem source, World world, FiringState firingState, Direction direction)
        {
            if (direction == Direction.None)
                throw new ArgumentOutOfRangeException("direction");

            if (firingState != FiringState.Pulse || source.Energy < 4)
                return;
            var startPos = source.TilePosition.ToPosition();
            var shot = new StandardShot(world, startPos, direction, source.Energy >> 2, ShotType.Player);
            if (!shot.CanMoveInDirection(direction))
                return;
            startPos += direction.ToVector() * Tile.Size / 2;
            shot.SetPosition(startPos);

            world.AddShot(shot);
            world.Game.SoundPlayer.Play(GameSound.PlayerShoots);
            _countOfShotsBeforeCostingEnergy--;
            if (_countOfShotsBeforeCostingEnergy < 0)
                {
                _countOfShotsBeforeCostingEnergy = 3;
                source.ReduceEnergy(1);
                }
        }