예제 #1
0
 public SpaceshipRunner(ITargetDetector detector, ITargetPicker picker, IPilot pilot, IKnowsCurrentTarget knower)
 {
     _detector = detector;
     _picker   = picker;
     _pilot    = pilot;
     _knower   = knower;
 }
 public TurretRunner(ITargetDetector targetDetector, ITargetPicker targetPicker, ITurretTurner turretTurner, IFireControl fireControl, IKnowsCurrentTarget knower)
 {
     _targetDetector = targetDetector;
     _targetPicker   = targetPicker;
     _turretTurner   = turretTurner;
     _fireControl    = fireControl;
     _knower         = knower;
 }
예제 #3
0
 public RocketRunner(ITargetDetector targetDetector, ITargetPicker targetPicker, IPilot engineControl, IDetonator detonator, IKnowsCurrentTarget knower)
 {
     _targetDetector = targetDetector;
     _targetPicker   = targetPicker;
     _pilot          = engineControl;
     _detonator      = detonator;
     _knower         = knower;
 }
예제 #4
0
        public void Construct(ITargetPicker targetPicker, SignalBus bus)
        {
            this.targetPicker = targetPicker;
            this.bus          = bus;
            this.navMeshAgent = this.GetComponent <NavMeshAgent>();

            bus.Subscribe <EnemyState.EnemyHealthChanged>(this.HealthChanged);
        }
    // Use this for initialization
    void Start()
    {
        var rigidbody    = GetComponent <Rigidbody>();
        var emitterCount = EmitterParent.childCount;

        _emitters = new List <Transform>();
        for (int i = 0; i < emitterCount; i++)
        {
            _emitters.Add(EmitterParent.GetChild(i));
        }

        _reload = LoadTime;

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

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

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

        _targetPicker = new CombinedTargetPicker(pickers);

        _turner = new UnityTurretTurner(rigidbody, TurnTable, ElevationHub, RestTarget, ProjectileSpeed);

        _fireControl = new UnityFireControl(this, ElevationHub.transform, ShootAngle);

        _runner = new TurretRunner(_detector, _targetPicker, _turner, _fireControl, this)
        {
            name = transform.name
        };
    }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        _rigidbody = GetComponent("Rigidbody") as Rigidbody;
        _detector  = new ChildTagTargetDetector
        {
            Tags = _tags
        };

        _tagPicker = new HasTagTargetPicker(null);
        _currentlyFollowingPicker = new PreviousTargetPicker(this)
        {
            AdditionalScore = AdditionalScoreForSameTagOrCurrentlyFllowed
        };

        var watchPickers = new List <ITargetPicker>
        {
            _tagPicker,
            _currentlyFollowingPicker,
            new ProximityTargetPicker(transform)
        };

        if (_rigidbody != null)
        {
            watchPickers.Add(new LookingAtTargetPicker(_rigidbody));
        }

        if (MinimumMass > 0)
        {
            watchPickers.Add(new MassTargetPicker {
                MinMass = MinimumMass
            });
        }

        _watchPicker = new CombinedTargetPicker(watchPickers);

        var followPickers = new List <ITargetPicker>
        {
            new ProximityTargetPicker(transform)
        };

        if (_rigidbody != null)
        {
            followPickers.Add(new ApproachingTargetPicker(_rigidbody, ApproachTargetPickerWeighting));
        }

        if (MinimumMass > 0)
        {
            followPickers.Add(new MassTargetPicker
            {
                MinMass = MinimumMass
            });
        }
        _followPicker = new CombinedTargetPicker(followPickers);
    }
예제 #7
0
 public AverageTargetLocationDestinationChooser(ITargetDetector detector, ITargetPicker picker, Rigidbody destination)
 {
     _detector    = detector;
     _destination = destination;
     _picker      = picker;
 }
예제 #8
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");
    }
    // Use this for initialization
    void Start()
    {
        var rigidbody    = GetComponent <Rigidbody>();
        var emitterCount = BeamsParent.childCount;

        _beams = new List <Beam>();
        for (int i = 0; i < emitterCount; i++)
        {
            var beam = BeamsParent.GetChild(i);
            beam.localScale = Vector3.zero;
            beam.SetColor(BeamColour);
            _beams.Add(new Beam(beam, ShootTime, LoadTime)
            {
                BeamForce     = BeamForce,
                HitEffect     = HitEffect,
                BeamDamage    = BeamDamage,
                FriendlyTag   = tag,
                InitialRadius = InitialRadius,
                Divergence    = Divergence
            });
        }

        _detector = new MultiTagTargetDetector()
        {
            ProjectileSpeed = 0,
            EnemyTags       = EnemyTags
        };

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

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

        _targetPicker = new CombinedTargetPicker(pickers);

        _turner = new UnityTurretTurner(rigidbody, TurnTable, ElevationHub, RestTarget, null);

        _fireControl = new UnityFireControl(this, ElevationHub.transform, ShootAngle);

        _runner = new TurretRunner(_detector, _targetPicker, _turner, _fireControl, this)
        {
            name = transform.name
        };
    }