コード例 #1
0
        public void SpawnNewMeteor(Point2 playerPosition)
        {
            var rotationSpeed = _random.Next(-10, 10) * 0.1f;
            var spawnCircle   = new CircleF(playerPosition, 630);
            var spawnAngle    = MathHelper.ToRadians(_random.Next(0, 360));
            var spawnPosition = spawnCircle.GetPointAlongEdge(spawnAngle);
            var velocity      = (playerPosition - spawnPosition).Rotate(MathHelper.ToRadians(_random.Next(-15, 15))) * _random.Next(3, 10) * 0.01f;
            var textureRegion = GetMeteorRegion(4);
            var meteor        = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, 3);

            _entityManager.AddEntity(meteor);
        }
コード例 #2
0
        public void SpawnNewMeteor(Vector2 playerPosition)
        {
            var rotationSpeed = _random.Next(-10, 10) * 0.1f;
            var spawnCircle = new CircleF(playerPosition, 630);
            var spawnAngle = MathHelper.ToRadians(_random.Next(0, 360));
            var spawnPosition = spawnCircle.GetPointAlongEdge(spawnAngle);
            var velocity = (playerPosition - spawnPosition).Rotate(MathHelper.ToRadians(_random.Next(-15, 15))) * _random.Next(3, 10) * 0.01f;
            var textureRegion = GetMeteorRegion(4);
            var meteor = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, 3);

            _entityManager.AddEntity(meteor);
        }
コード例 #3
0
        public void SplitMeteor(Meteor meteor)
        {
            if (meteor.Size <= 1)
            {
                throw new InvalidOperationException("Meteor size less than 2 can't be split");
            }

            for (var i = 0; i < 2; i++)
            {
                var size          = meteor.Size - 1;
                var rotationSpeed = _random.Next(-10, 10) * 0.1f;
                var spawnPosition = meteor.Position;
                var velocity      = i == 0 ? meteor.Velocity.PerpendicularClockwise() + meteor.Velocity : meteor.Velocity.PerpendicularCounterClockwise() + meteor.Velocity;
                var textureRegion = GetMeteorRegion(size);
                var newMeteor     = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, size);

                _entityManager.AddEntity(newMeteor);
            }
        }
コード例 #4
0
        public void SplitMeteor(Meteor meteor)
        {
            if (meteor.Size <= 1)
            {
                throw new InvalidOperationException("Meteor size less than 2 can't be split");
            }

            for (var i = 0; i < 2; i++)
            {
                var size = meteor.Size - 1;
                var rotationSpeed = _random.Next(-10, 10) * 0.1f;
                var spawnPosition = meteor.Position;
                var velocity = i == 0 ? meteor.Velocity.PerpendicularClockwise() + meteor.Velocity : meteor.Velocity.PerpendicularCounterClockwise() + meteor.Velocity;
                var textureRegion = GetMeteorRegion(size);
                var newMeteor = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, size);

                _entityManager.AddEntity(newMeteor);
            }
        }