Exemplo n.º 1
0
    IEnumerator SelectTargets_Power(NativePowerScriptableObject nativePower)
    {
        PlayerCombatObject       playerOnTurn = currentCardOwner;
        HealthEntityCombatObject caster       = playerOnTurn;

        stepNumber = 0;

        targetsPerAbilityStep = new List <List <HealthEntityCombatObject> >();

        AbilityStepsWithTargetingData_Player[] abilities = nativePower.abilityStepsWithTargetingData;

        // Let's cycle through all ability steps in order to determine targets.
        foreach (var abilityStepWithTargetingData in abilities)
        {
            chosenTargets = new List <HealthEntityCombatObject>();
            targetFound   = false;

            TargetData targetData = GetValidTargets(caster, abilityStepWithTargetingData.targetingData);
            if (targetData.multipleSpecificMode)
            {
                multipleSpecificMode     = true;
                numberOfSpecificTargets  = targetData.multipleSpecificNumber;
                multipleSpecificModeList = new List <HealthEntityCombatObject>();
            }
            else
            {
                multipleSpecificMode = false;
            }

            if (targetData.previousStepTargets > -1)
            {
                targetFound = true;
                foreach (var entity in targetsPerAbilityStep[targetData.previousStepTargets])
                {
                    chosenTargets.Add(entity);
                }
            }
            else if (targetData.targetDecided)
            {
                targetFound = true;
                foreach (var e in targetData.entities)
                {
                    chosenTargets.Add(e);
                }
            }
            else
            {
                if (targetData.entities.Count == 1 && targetData.entities[0] is PlayerCombatObject)
                {
                    targetFound = true;
                    chosenTargets.Add(targetData.entities[0]);
                }
                else
                {
                    infoText.text = abilityStepWithTargetingData.targetingData.textForChoosing;
                    ShowTargetingButton(targetData.entities);
                }
            }

            while (targetFound == false)
            {
                yield return(null);
            }

            stepNumber++;
            targetsPerAbilityStep.Add(chosenTargets);
        }

        // We have all chosen targets.
        // We now have to check whether any of those are multiple hits.

        for (int i = 0; i < targetsPerAbilityStep.Count; i++)
        {
            TargetingData_Base targetingData = nativePower.abilityStepsWithTargetingData[i].targetingData;

            if (targetingData.targetAlignment == TargetingData_Base.TargetAlignment.Hostile)
            {
                if (targetingData.targets == TargetingData_Base.Target.Multiple)
                {
                    EnemyCombatObject        chosenTarget  = (EnemyCombatObject)targetsPerAbilityStep[i][0];
                    List <EnemyCombatObject> nearbyEnemies = GetNearbyEnemies(chosenTarget, targetingData.numberOfTargets);
                    foreach (var e in nearbyEnemies)
                    {
                        targetsPerAbilityStep[i].Add(e);
                    }
                }
            }
        }

        // Now we have full lists of all targets for each attribute.
        // Let's do the card trick.

        DoPowerTrick();

        yield return(null);
    }
Exemplo n.º 2
0
    TargetData GetValidTargets(HealthEntityCombatObject caster, TargetingData_Base targetingData)
    {
        TargetData targetData = new TargetData();

        targetData.previousStepTargets = -1;
        List <HealthEntityCombatObject> targets = new List <HealthEntityCombatObject>();

        if (targetingData.targetingType == TargetingData_Base.TargetingType.NoTargeting)
        {
            // There is no targeting. Don't bother.
        }
        // We will use other step's targets.
        else if (targetingData.targetingType == TargetingData_Base.TargetingType.PreviousStep)
        {
            targetData.previousStepTargets = targetingData.useTargetsFromStepNumber;
        }
        // If the target is only self, do not check for anything else.
        else if (targetingData.onlySelf)
        {
            targets.Add(caster);
            targetData.targetDecided = true;
        }
        else
        {
            // Can we add self?
            bool selfIncluded = targetingData.selfIncluded;

            // Let's skip the check if we can only target ourselves.
            if (targetingData.onlySelf)
            {
                targets.Add(caster);
            }
            // We can target more than ourselves. Let's first check if we can target at all.
            else if (targetingData.targets != TargetingData_Base.Target.All)
            {
                switch (targetingData.targetAlignment)
                {
                case TargetingData_Base.TargetAlignment.Both:
                    switch (targetingData.targets)
                    {
                    case TargetingData_Base.Target.One:
                        // Select one from friendlies and from enemies.
                        foreach (var f in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Both, selfIncluded))
                        {
                            targets.Add(f);
                        }
                        break;

                    case TargetingData_Base.Target.MultipleSpecific:
                        // Select multiple specific from friendlies or enemies.

                        // Add ourselves to the list.
                        if (targetingData.selfIncluded)
                        {
                        }
                        break;
                    }
                    break;

                case TargetingData_Base.TargetAlignment.Friendly:
                    switch (targetingData.targets)
                    {
                    case TargetingData_Base.Target.One:
                        // Select one from friendlies taking into account whether to add self.
                        foreach (var f in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Friendly, selfIncluded))
                        {
                            targets.Add(f);
                        }
                        break;

                    case TargetingData_Base.Target.MultipleSpecific:
                        // Select multiple specific friendlies taking into account whether to add self.
                        break;

                    case TargetingData_Base.Target.Multiple:
                        // Select multiple friendlies taking into account whether to add self.
                        foreach (var f in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Friendly, selfIncluded))
                        {
                            targets.Add(f);
                        }
                        break;
                    }
                    break;

                case TargetingData_Base.TargetAlignment.Hostile:
                    switch (targetingData.targets)
                    {
                    case TargetingData_Base.Target.One:
                        // Select one from enemies.
                        foreach (var e in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Hostile))
                        {
                            targets.Add(e);
                        }
                        break;

                    case TargetingData_Base.Target.MultipleSpecific:
                        // Select multiple specific from enemies.
                        targetData.multipleSpecificMode   = true;
                        targetData.multipleSpecificNumber = targetingData.numberOfTargets;
                        foreach (var e in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Hostile))
                        {
                            targets.Add(e);
                        }
                        break;

                    case TargetingData_Base.Target.Multiple:
                        // Select multiple from enemies.
                        foreach (var e in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Hostile))
                        {
                            targets.Add(e);
                        }
                        break;
                    }
                    break;
                }
            }
            // We cannot target so we choose all.
            else
            {
                switch (targetingData.targetAlignment)
                {
                case TargetingData_Base.TargetAlignment.Both:
                    // Select all targets.
                    foreach (var a in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Both, selfIncluded))
                    {
                        targets.Add(a);
                    }
                    break;

                case TargetingData_Base.TargetAlignment.Friendly:
                    // Select all allies taking into account if self included
                    foreach (var a in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Friendly, selfIncluded, false, targetingData.canTargetDead))
                    {
                        targets.Add(a);
                    }
                    break;

                case TargetingData_Base.TargetAlignment.Hostile:
                    // Select all enemies.
                    foreach (var e in GetEntitiesWithRelationTo(caster, TargetingData_Base.TargetAlignment.Hostile))
                    {
                        targets.Add(e);
                    }
                    break;
                }
                targetData.targetDecided = true;
            }
        }

        targetData.entities = targets;

        return(targetData);
    }
Exemplo n.º 3
0
    List <List <HealthEntityCombatObject> > SelectAbilityTargetEnemy(EnemyCombatObject enemy)
    {
        List <List <HealthEntityCombatObject> > targetsPerAbilityStep = new List <List <HealthEntityCombatObject> >();

        AbilityStepsWithTargetingData_Enemy[] abilityStepsWithTargetingData = enemy.NextAbility.abilityStepsWithTargetingData;

        // Let's cycle through all ability steps in order to determine targets.
        foreach (var abilityStepWithTargetingData in abilityStepsWithTargetingData)
        {
            List <HealthEntityCombatObject> selectedTargets = new List <HealthEntityCombatObject>();

            TargetData targetData = GetValidTargets(enemy, abilityStepWithTargetingData.targetingData);

            if (targetData.previousStepTargets > -1)
            {
                foreach (var entity in targetsPerAbilityStep[targetData.previousStepTargets])
                {
                    selectedTargets.Add(entity);
                }
            }
            else if (targetData.targetDecided)
            {
                foreach (var e in targetData.entities)
                {
                    selectedTargets.Add(e);
                }
            }
            else
            {
                switch (abilityStepWithTargetingData.targetingData.targets)
                {
                case TargetingData_Base.Target.One:
                    // Choose a random target for now
                    selectedTargets.Add(targetData.entities[Random.Range(0, targetData.entities.Count)]);
                    break;

                case TargetingData_Base.Target.Multiple:
                    // Choose a random target for now
                    selectedTargets.Add(targetData.entities[Random.Range(0, targetData.entities.Count)]);
                    break;

                case TargetingData_Base.Target.MultipleSpecific:
                    // Choose a random target for now

                    // If it happens that there are less available targets than our ability wants us to target,
                    // add them all.
                    if (abilityStepWithTargetingData.targetingData.numberOfTargets < targetData.entities.Count)
                    {
                        foreach (var entity in targetData.entities)
                        {
                            selectedTargets.Add(entity);
                        }
                    }
                    else
                    {
                        List <HealthEntityCombatObject> st = new List <HealthEntityCombatObject>(selectedTargets);
                        for (int i = 0; i < abilityStepWithTargetingData.targetingData.numberOfTargets; i++)
                        {
                            HealthEntityCombatObject entity = targetData.entities[Random.Range(0, targetData.entities.Count)];
                            selectedTargets.Add(entity);
                            st.Remove(entity);
                        }
                    }
                    break;
                }
            }

            targetsPerAbilityStep.Add(selectedTargets);
        }

        // We have all chosen targets.
        // We now have to check whether any of those are multiple hits.
        for (int i = 0; i < targetsPerAbilityStep.Count; i++)
        {
            TargetingData_Base targetingData = enemy.NextAbility.abilityStepsWithTargetingData[i].targetingData;

            if (targetingData.targetAlignment == TargetingData_Base.TargetAlignment.Friendly)
            {
                if (targetingData.targets == TargetingData_Base.Target.Multiple)
                {
                    EnemyCombatObject        chosenTarget  = (EnemyCombatObject)targetsPerAbilityStep[i][0];
                    List <EnemyCombatObject> nearbyEnemies = GetNearbyEnemies(chosenTarget, targetingData.numberOfTargets);
                    foreach (var e in nearbyEnemies)
                    {
                        targetsPerAbilityStep[i].Add(e);
                    }
                }
            }
        }

        return(targetsPerAbilityStep);
    }
Exemplo n.º 4
0
    IEnumerator SelectCardCoro(CardGameObject cardGO)
    {
        Player       playerOnTurn = currentCardOwner;
        HealthEntity caster       = playerOnTurn;

        targetsPerAbilityStep = new List <List <HealthEntity> >();

        AbilityStepsWithTargetingData_Player[] abilities = cardGO.card.abilityStepsWithTargetingData;

        // Let's cycle through all ability steps in order to determine targets.
        foreach (var abilityStepWithTargetingData in abilities)
        {
            chosenTargets = new List <HealthEntity>();
            targetFound   = false;

            TargetData targetData = GetValidTargets(caster, abilityStepWithTargetingData.targetingData);

            if (targetData.previousStepTargets > -1)
            {
                targetFound = true;
                foreach (var entity in targetsPerAbilityStep[targetData.previousStepTargets])
                {
                    chosenTargets.Add(entity);
                }
            }
            else if (targetData.targetDecided)
            {
                targetFound = true;
                foreach (var e in targetData.entities)
                {
                    chosenTargets.Add(e);
                }
            }
            else
            {
                if (targetData.entities.Count == 1 && targetData.entities[0] is Player)
                {
                    targetFound = true;
                    chosenTargets.Add(targetData.entities[0]);
                }
                else
                {
                    infoText.text = abilityStepWithTargetingData.targetingData.textForChoosing;
                    ShowTargetingButton(targetData.entities);
                }
            }

            while (targetFound == false)
            {
                stayUp = false;
                yield return(null);
            }

            targetsPerAbilityStep.Add(chosenTargets);
        }

        // We have all chosen targets.
        // We now have to check whether any of those are multiple hits.

        for (int i = 0; i < targetsPerAbilityStep.Count; i++)
        {
            TargetingData_Base targetingData = cardGO.card.abilityStepsWithTargetingData[i].targetingData;

            if (targetingData.targetAlignment == TargetingData_Base.TargetAlignment.Hostile)
            {
                if (targetingData.targets == TargetingData_Base.Target.Multiple)
                {
                    Enemy        chosenTarget  = (Enemy)targetsPerAbilityStep[i][0];
                    List <Enemy> nearbyEnemies = GetNearbyEnemies(chosenTarget, targetingData.numberOfTargets);
                    foreach (var e in nearbyEnemies)
                    {
                        targetsPerAbilityStep[i].Add(e);
                    }
                }
            }
        }

        // Now we have full lists of all targets for each attribute.
        // Let's do the card trick.

        DoCardTrick();

        yield return(null);
    }