Example #1
0
    public virtual void Launch(IElementAttackableTarget target, AWeapon weapon, bool toShowEffects) {
        Target = target;
        Weapon = weapon;

        var tgtBearing = (target.Position - _transform.position).normalized;
        _transform.rotation = Quaternion.LookRotation(tgtBearing); // point ordnance in direction of target so _transform.forward is bearing

        var owner = weapon.RangeMonitor.ParentElement.Owner;
        _range = weapon.RangeCategory.GetWeaponRange(owner);

        ToShowEffects = toShowEffects;
    }
Example #2
0
    public override void Launch(IElementAttackableTarget target, AWeapon weapon, bool toShowEffects) {
        base.Launch(target, weapon, toShowEffects);
        weapon.OnFiringInitiated(target, this);
        _durationInSeconds = (weapon as BeamProjector).Duration / GameTime.HoursPerSecond;

        _lineRenderer.SetPosition(0, Vector3.zero);  // start beam where ordnance located
        //_lineRenderer.enabled = toShowEffects;
        //if (toShowEffects) {
        //    muzzleEffect.Play();
        //}
        _operateAndAnimateBeamJob = InitiateBeam();
    }
    /// <summary>
    /// Checks the firing solution of this weapon on the enemyTarget. Returns <c>true</c> if the target
    /// fits within the weapon's firing solution, aka within range and can be acquired, if required.
    /// </summary>
    /// <param name="weapon">The weapon.</param>
    /// <param name="enemyTarget">The enemy target.</param>
    /// <returns></returns>
    public override bool CheckFiringSolution(AWeapon weapon, IElementAttackableTarget enemyTarget) {
        D.Assert(enemyTarget.IsOperational);
        D.Assert(enemyTarget.Owner.IsEnemyOf(weapon.Owner));

        float distanceToPushover = TempGameValues.__ReqdMissileTravelDistanceBeforePushover;
        Vector3 vectorToPushover = CurrentFacing * distanceToPushover;
        Vector3 pushoverPosition = MuzzleLocation + vectorToPushover;

        Vector3 targetPosition = enemyTarget.Position;
        Vector3 vectorToTargetFromPushover = targetPosition - pushoverPosition;
        float targetDistanceFromPushover = vectorToTargetFromPushover.magnitude;
        if (distanceToPushover + targetDistanceFromPushover > weapon.RangeDistance) {
            D.Log("{0}.CheckFiringSolution({1}) has determined target is out of range.", Name, enemyTarget.FullName);
            return false;
        }
        return true;
    }
Example #4
0
    public override void Launch(IElementAttackableTarget target, AWeapon weapon, bool toShowEffects) {
        base.Launch(target, weapon, toShowEffects);
        weapon.OnFiringInitiated(target, this);
        _launchPosition = _transform.position;
        _rangeSqrd = _range * _range;

        if (toShowEffects) {
            ShowMuzzleEffect();
        }
        enabled = true;
        //D.Log("{0} launching from {1} on Heading: {2} (resultingRotation = {3}), Range: {4}.", _transform.name, _launchPosition, heading, _transform.rotation, range);
        //OnWeaponFiringComplete();
        weapon.OnFiringComplete(this);
    }
Example #5
0
 public TargetInfo(IElementAttackableTarget element, float standoffDistance) {
     Target = element;
     Destination = element.Position;
     CloseEnoughDistance = element.Radius + standoffDistance;
     CloseEnoughDistanceSqrd = CloseEnoughDistance * CloseEnoughDistance;
 }
Example #6
0
 /// <summary>
 /// Plots a course to a Element target and notifies the requester of the 
 /// outcome via the onCoursePlotCompleted event.
 /// </summary>
 /// <param name="element">The element target.</param>
 /// <param name="speed">The speed.</param>
 /// <param name="standoffDistance">The distance to standoff from the target. This is added to the radius of the target to
 /// determine how close the ship is allowed to approach the target.</param>
 private void PlotCourse(IElementAttackableTarget element, Speed speed, float standoffDistance) {
     _targetInfo = new TargetInfo(element, standoffDistance);
     Speed = speed;
     _isFleetMove = false;
     PlotCourse();
 }