Exemple #1
0
        private bool CreateNewBot()
        {
            // Pull plasma
            if (_plasma == null || _plasma.RemoveQuantity(_birthCost, true) > 0)
            {
                return(false);
            }

            #region get position

            // this was copied from ProjectileGun

            // Model coords
            Point3D modelPosition = this.Design.Position;

            double length = this.Design.Scale.Z / 2d;
            length *= 3;     // make it a bit longer so it doesn't collide with the bay
            Vector3D modelDirection = new Vector3D(0, 0, length);

            // World coords
            var worldLoc   = GetWorldLocation();
            var worldSpeed = GetWorldSpeed(null);

            Vector3D worldDirection     = worldLoc.Item2.GetRotatedVector(modelDirection);
            Vector3D worldDirectionUnit = worldDirection.ToUnit();

            Point3D worldPosition = worldLoc.Item1 + worldDirection;

            #endregion

            double radius = StaticRandom.NextPercent(_birthRadius, .07);

            //NOTE: Could come back null if this part is in some kind of tester
            IMapObject parent = GetParent();

            // Create the bot
            SwarmBot1b bot = new SwarmBot1b(radius, worldPosition, parent, _world, _map, _strokes, _material_SwarmBot, _itemOptions.SwarmBot_HealRate, _itemOptions.SwarmBot_DamageAtMaxSpeed, _itemOptions.SwarmBot_MaxHealth);

            SetBotConstraints(bot);

            bot.PhysicsBody.Velocity        = worldSpeed.Item1;
            bot.PhysicsBody.AngularVelocity = Math3D.GetRandomVector_Spherical(3d);

            _map.AddItem(bot);
            _bots.Add(bot);

            return(true);
        }
Exemple #2
0
        //TODO: A controller should actively manage these settings
        private void SetBotConstraints(SwarmBot1b bot)
        {
            const double SEARCHSLOPE      = .66d;
            const double STROKESEARCHMULT = 2d;
            const double NEIGHBORSLOPE    = .75d;
            const double ACCELSLOPE       = 1.33d;
            const double ANGACCELSLOPE    = .75d;
            const double ANGSPEEDSLOPE    = .25d;

            double ratio = bot.Radius / _birthRadius;

            bot.SearchRadius         = _itemOptions.SwarmBot_SearchRadius * SetBotConstraints_Mult(SEARCHSLOPE, ratio);
            bot.SearchRadius_Strokes = bot.SearchRadius * STROKESEARCHMULT;
            bot.ChaseNeighborCount   = (_itemOptions.SwarmBot_ChaseNeighborCount * SetBotConstraints_Mult(NEIGHBORSLOPE, ratio)).ToInt_Round();
            bot.MaxAccel             = _itemOptions.SwarmBot_MaxAccel * SetBotConstraints_Mult(ACCELSLOPE, 1 / ratio);
            bot.MaxAngularAccel      = _itemOptions.SwarmBot_MaxAngAccel * SetBotConstraints_Mult(ANGACCELSLOPE, 1 / ratio);
            bot.MinSpeed             = _itemOptions.SwarmBot_MinSpeed;
            bot.MaxSpeed             = _itemOptions.SwarmBot_MaxSpeed; // not adjusting this, or the swarm will pull apart when they get up to speed
            bot.MaxAngularSpeed      = _itemOptions.SwarmBot_MaxAngSpeed * SetBotConstraints_Mult(ANGSPEEDSLOPE, 1 / ratio);
        }