Ejemplo n.º 1
0
 public RbacPrincipal(IPrincipal principal, IRbacSession session)
 {
     _principal = principal;
     _session = session;
     CanDo = new CanDoAction(this);
     Is = new IsUserInRole(this);
 }
Ejemplo n.º 2
0
    private void ProcessHiddenEnemy(
        EnemyMarker enemy
        )
    {
        int leftFlankers =
            HumanoidAttackPlannerCommunications.GetLeftFlankersOnHiddenEnemy(
                enemy
                );
        int rightFlankers =
            HumanoidAttackPlannerCommunications.GetRightFlankersOnHiddenEnemy(
                enemy
                );
        int suppressors =
            HumanoidAttackPlannerCommunications.GetSuppressorsOnHiddenEnemy(
                enemy
                );

        bool canFlankLeft  = leftFlankers < flankParticipationLimit;
        bool canFlankRight = rightFlankers < flankParticipationLimit;
        bool canSuppress   = suppressors < suppressiveFireParticipationLimit;

        CanDoAction flankLeftResult = new CanDoAction(
            canFlankLeft,
            leftFlankers,
            AttackAction.FLANK_LEFT
            );
        CanDoAction flankRightResult = new CanDoAction(
            canFlankRight,
            rightFlankers,
            AttackAction.FLANK_RIGHT
            );
        CanDoAction suppressorResult = new CanDoAction(
            canSuppress,
            suppressors,
            AttackAction.SUPPRESS_FIRE
            );
        List <CanDoAction> potentialActions = new List <CanDoAction>();

        potentialActions.Add(flankLeftResult);
        potentialActions.Add(flankRightResult);
        potentialActions.Add(suppressorResult);

        potentialActions.OrderBy(pa => {
            return(pa.number);
        });

        foreach (CanDoAction action in potentialActions)
        {
            if (action.canDo)
            {
                attackAction = action.action;
                switch (action.action)
                {
                case AttackAction.FLANK_LEFT:
                    HumanoidAttackPlannerCommunications.FlankLeftHiddenEnemy(
                        enemy
                        );
                    break;

                case AttackAction.FLANK_RIGHT:
                    HumanoidAttackPlannerCommunications.FlankRightHiddenEnemy(
                        enemy
                        );
                    break;

                case AttackAction.SUPPRESS_FIRE:
                    HumanoidAttackPlannerCommunications.SuppressHiddenEnemy(
                        enemy
                        );
                    break;
                }
                return;
            }
        }

        int rightRelocators =
            HumanoidAttackPlannerCommunications.GetRightRelocators().Count;

        int leftRelocators =
            HumanoidAttackPlannerCommunications.GetLeftRelocators().Count;

        if (rightRelocators < leftRelocators)
        {
            if (rightRelocators < relocateParticipationLimit)
            {
                attackAction = AttackAction.RELOCATE_RIGHT;
            }
        }
        else
        {
            if (leftRelocators < relocateParticipationLimit)
            {
                attackAction = AttackAction.RELOCATE_LEFT;
            }
        }
    }