コード例 #1
0
ファイル: MissileTube.cs プロジェクト: Maxii/CodeEnv.Master
    /// <summary>
    /// Tries to develop a firing solution from this WeaponMount to the provided target. If successful, returns <c>true</c> and provides the
    /// firing solution, otherwise <c>false</c>.
    /// </summary>
    /// <param name="enemyTarget">The enemy target.</param>
    /// <param name="firingSolution"></param>
    /// <returns></returns>
    public override bool TryGetFiringSolution(IElementAttackable enemyTarget, out WeaponFiringSolution firingSolution) {
        D.Assert(enemyTarget.IsOperational);
        D.Assert(enemyTarget.IsAttackByAllowed(Weapon.Owner));

        if (!ConfirmInRangeForLaunch(enemyTarget)) {
            //D.Log("{0}.CheckFiringSolution({1}) has determined target is out of range.", DebugName, enemyTarget.DebugName);
            firingSolution = null;
            return false;
        }
        firingSolution = new WeaponFiringSolution(Weapon, enemyTarget);
        return true;
    }
コード例 #2
0
 /// <summary>
 /// Initiates the process of firing the provided weapon at the enemy target defined by the provided firing solution.
 /// If the conditions for firing the weapon at the target are satisfied (within range, can be borne upon,
 /// no interfering obstacles, etc.), the weapon will be fired.
 /// </summary>
 /// <param name="firingSolution">The firing solution.</param>
 protected void InitiateFiringSequence(WeaponFiringSolution firingSolution) {
     StartEffectSequence(EffectSequenceID.Attacking);
     LosWeaponFiringSolution losFiringSolution = firingSolution as LosWeaponFiringSolution;
     if (losFiringSolution != null) {
         var losWeapon = losFiringSolution.Weapon;
         losWeapon.weaponAimed += LosWeaponAimedEventHandler;
         losWeapon.AimAt(losFiringSolution);
     }
     else {
         // no aiming reqd, just launch the ordnance
         var weapon = firingSolution.Weapon;
         var target = firingSolution.EnemyTarget;
         LaunchOrdnance(weapon, target);
     }
 }
コード例 #3
0
ファイル: LOSTurret.cs プロジェクト: Maxii/CodeEnv.Master
    /// <summary>
    /// Tries to develop a firing solution from this WeaponMount to the provided target. If successful, returns <c>true</c> and provides the
    /// firing solution, otherwise <c>false</c>.
    /// </summary>
    /// <param name="enemyTarget">The enemy target.</param>
    /// <param name="firingSolution"></param>
    /// <returns></returns>
    public override bool TryGetFiringSolution(IElementAttackable enemyTarget, out WeaponFiringSolution firingSolution) {
        D.Assert(enemyTarget.IsOperational);
        D.Assert(enemyTarget.IsAttackByAllowed(Weapon.Owner));

        firingSolution = null;
        if (!ConfirmInRangeForLaunch(enemyTarget)) {
            //D.Log(ShowDebugLog, "{0}: Target {1} is out of range.", DebugName, enemyTarget.DebugName);
            return false;
        }

        Vector3 targetPosition = enemyTarget.Position;
        Quaternion reqdHubRotation, reqdBarrelElevation;
        bool canTraverseToTarget = TryCalcTraverse(targetPosition, out reqdHubRotation, out reqdBarrelElevation);
        if (!canTraverseToTarget) {
            //D.Log(ShowDebugLog, "{0}: Target {1} is out of traverse range.", DebugName, enemyTarget.DebugName);
            return false;
        }

        bool isLosClear = CheckLineOfSight(enemyTarget);
        if (!isLosClear) {
            return false;
        }
        firingSolution = new LosWeaponFiringSolution(Weapon, enemyTarget, reqdHubRotation, reqdBarrelElevation);
        return true;
    }
コード例 #4
0
ファイル: AWeaponMount.cs プロジェクト: Maxii/CodeEnv.Master
 /// <summary>
 /// Tries to develop a firing solution from this WeaponMount to the provided target. If successful, returns <c>true</c> and provides the
 /// firing solution, otherwise <c>false</c>.
 /// </summary>
 /// <param name="enemyTarget">The enemy target.</param>
 /// <param name="firingSolution"></param>
 /// <returns></returns>
 public abstract bool TryGetFiringSolution(IElementAttackable enemyTarget, out WeaponFiringSolution firingSolution);