// Use this for initialization
    void Start()
    {
        _rigidbody = GetComponent <Rigidbody>();

        var initialAngularDrag = _rigidbody.angularDrag;
        var torqueApplier      = new MultiTorquerTorqueAplier(_rigidbody, TorqueMultiplier, initialAngularDrag);

        _pilot = new RocketPilot(torqueApplier, _rigidbody, Engines, StartDelay)
        {
            LocationAimWeighting             = LocationAimWeighting,
            TurningStartDelay                = TurningStartDelay,
            VectorArrow                      = VectorArrow,
            TimeThresholdForMaximumEvasion   = TimeThresholdForMaximumEvasion,
            TimeThresholdForMediumEvasion    = TimeThresholdForMediumEvasion,
            TimeThresholdForMinimalEvasion   = TimeThresholdForMinimalEvasion,
            EvasionModeTime                  = EvasionModeTime,
            MinimumFriendlyDetectionDistance = MinimumFriendlyDetectionDistance
        };

        var exploder = new ShrapnelExploder(_rigidbody, Shrapnel, ExplosionEffect, ShrapnelCount)
        {
            EnemyTags             = TargetChoosingMechanism.EnemyTagKnower.KnownEnemyTags,
            TagShrapnel           = TagShrapnel,
            SetEnemyTagOnShrapnel = SetEnemyTagOnShrapnel,
            ShrapnelSpeed         = ShrapnelSpeed
        };

        _detonator = new ProximityApproachDetonator(exploder, _rigidbody, TimeToTargetForDetonation, ShrapnelSpeed);

        _runner = new RocketRunner(TargetChoosingMechanism, _pilot, _detonator, Tank)
        {
            name = transform.name
        };
    }
    private void Initialise()
    {
        _thisSpaceship = GetComponent <Rigidbody>();
        var _detector = new MultiTagTargetDetector()
        {
            EnemyTags = EnemyTags
        };

        var torqueApplier = new MultiTorquerTorqueAplier(_thisSpaceship, _torquers, TorqueMultiplier, AngularDragForTorquers);

        _pilot = new SpaceshipPilot(torqueApplier, _thisSpaceship, _engines, ShootAngle, Fuel)
        {
            StartDelay               = StartDelay,
            SlowdownWeighting        = SlowdownWeighting,
            TangentialSpeedWeighting = TangentialSpeedWeighting,
            LocationAimWeighting     = LocationAimWeighting,
            VectorArrow              = VectorArrow,
            MaxRange             = MaxRange,
            MinRange             = MinRange,
            MaxTangentialSpeed   = MaxTangentialVelocity,
            MinTangentialSpeed   = MinTangentialVelocity,
            RadialSpeedThreshold = RadialSpeedThreshold
        };

        var pickers = new List <ITargetPicker>
        {
            new ProximityTargetPicker(_thisSpaceship)
            {
                DistanceMultiplier = PickerDistanceMultiplier
            }
        };

        if (MinimumMass > 0 || PickerMasMultiplier != 0)
        {
            pickers.Add(new MassTargetPicker
            {
                MinMass          = MinimumMass,
                MassMultiplier   = PickerMasMultiplier,
                OverMinMassBonus = PickerOverMinMassBonus
            });
        }

        var picker = new CombinedTargetPicker(pickers);

        _runner = new SpaceshipRunner(_detector, picker, _pilot, this);

        foreach (var engine in _engines)
        {
            engine.tag = tag;
        }
    }
Example #3
0
    private void Initialise()
    {
        var torqueApplier = new MultiTorquerTorqueAplier(_thisSpaceship, _torquers, TorqueMultiplier, AngularDragForTorquers);

        //ensure this starts active.
        torqueApplier.Activate();

        _pilot = new SpaceshipPilot(torqueApplier, _thisSpaceship, _engines, ShootAngle, Fuel)
        {
            StartDelay               = StartDelay,
            SlowdownWeighting        = SlowdownWeighting,
            TangentialSpeedWeighting = TangentialSpeedWeighting,
            LocationAimWeighting     = LocationAimWeighting,
            VectorArrow              = VectorArrow,
            MaxRange             = MaxRange,
            MinRange             = MinRange,
            MaxTangentialSpeed   = MaxTangentialVelocity,
            MinTangentialSpeed   = MinTangentialVelocity,
            RadialSpeedThreshold = RadialSpeedThreshold
        };
    }
    private void Initialise()
    {
        var torqueApplier = new MultiTorquerTorqueAplier(_thisSpaceship, _torquers, TorqueMultiplier, AngularDragForTorquers);

        //ensure this starts active.
        torqueApplier.Activate();

        //_autoPilot = new SpaceshipPilot(torqueApplier, _thisSpaceship, Engines, ShootAngle, Fuel)
        //{
        //    StartDelay = StartDelay,
        //    SlowdownWeighting = SlowdownWeighting,
        //    TangentialSpeedWeighting = TangentialSpeedWeighting,
        //    LocationAimWeighting = LocationAimWeighting,
        //    VectorArrow = VectorArrow,
        //    MaxRange = MaxRange,
        //    MinRange = MinRange,
        //    MaxTangentialSpeed = MaxTangentialVelocity,
        //    MinTangentialSpeed = MinTangentialVelocity,
        //    RadialSpeedThreshold = RadialSpeedThreshold
        //};

        _manualPilot = new ManualSpaceshipPilot(torqueApplier, _thisSpaceship, Engines, Fuel);
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        _rigidbody = GetComponent <Rigidbody>();

        _detector = new MultiTagTargetDetector()
        {
            EnemyTags = EnemyTags
        };

        var pickers = new List <ITargetPicker>
        {
            new ProximityTargetPicker(_rigidbody)
            {
                DistanceMultiplier = PickerDistanceMultiplier,
                InRangeBonus       = PickerInRangeBonus,
                Range = PickerRange
            },
            new LookingAtTargetPicker(_rigidbody)
            {
                Multiplier = PickerAimedAtMultiplier
            },
            new ApproachingTargetPicker(_rigidbody, PickerApproachWeighting)
        };

        if (MinimumMass > 0 || PickerMasMultiplier != 0)
        {
            pickers.Add(new MassTargetPicker
            {
                MinMass          = MinimumMass,
                MassMultiplier   = PickerMasMultiplier,
                OverMinMassBonus = PickerOverMinMassBonus
            });
        }

        _targetPicker = new CombinedTargetPicker(pickers);

        var initialAngularDrag = _rigidbody.angularDrag;
        var torqueApplier      = new MultiTorquerTorqueAplier(_rigidbody, TorqueMultiplier, initialAngularDrag);

        _pilot = new RocketPilot(torqueApplier, _rigidbody, Engines, ShootAngle, StartDelay)
        {
            LocationAimWeighting = LocationAimWeighting,
            TurningStartDelay    = TurningStartDelay,
            VectorArrow          = VectorArrow
        };

        var exploder = new ShrapnelAndDamageExploder(_rigidbody, Shrapnel, ExplosionEffect, ShrapnelCount)
        {
            ExplosionForce        = ExplosionForce,
            EnemyTags             = EnemyTags,
            TagShrapnel           = TagShrapnel,
            SetEnemyTagOnShrapnel = SetEnemyTagOnShrapnel,
            ExplosionBaseDamage   = ExplosionDamage,
            ShrapnelSpeed         = ShrapnelSpeed,
            ExplosionRadius       = ExplosionRadius
        };

        _detonator = new ProximityApproachDetonator(exploder, _rigidbody, TimeToTargetForDetonation, ShrapnelSpeed);

        _runner = new RocketRunner(_detector, _targetPicker, _pilot, _detonator, this)
        {
            name = transform.name
        };

        //Debug.Log("starting");
    }