Exemplo n.º 1
0
    void DrawAttackState(ProjectedGameState projectedState)
    {
        Sprite tileTargetedSprite = ScenarioImageManager.GetTileTargetedSprite();

        for (int i = 0; i < projectedState.attackedPositions.Count; i++)
        {
            EntityData activeEntity     = projectedState.activeEntity;
            Vector2Int attackedPosition = projectedState.attackedPositions[i];
            GenerateAndPositionCellImage(attackedPosition, 0f, tileTargetedSprite, activeEntity.IdentifyingColor);

            AttackCardData cardData      = projectedState.action.card as AttackCardData;
            Sprite         pointerSprite = cardData.cardImage;

            float rotation = GetImageRotation(projectedState.action.direction);

            GameObject abilityPointer = ScenarioImageManager.GetAbilityPointer(pointerSprite, rotation, transform);
            abilityPointer.transform.position = GetPointerImagePosition(activeEntity.Position, projectedState.action.direction);

            if (!drawingSelectedEntity)
            {
                Color pointerColor = Color.white;
                pointerColor.a = deselectedEntityActionOpacity;
                abilityPointer.GetComponent <Image>().color = pointerColor;
            }
        }
    }
Exemplo n.º 2
0
    // TODO: Very rudimentary AI rn, assumes all enemies rushing at player, need some
    // switch logic for different AI types.
    public void CalculateAndQueueEnemyTurns(ScenarioState gameState)
    {
        GameBoard         currentBoard = BoardController.CurrentBoard;
        List <EntityData> enemies      = gameState.enemies;

        upcomingEntityTargets.Clear();

        currentlyOccupiedTiles = enemies.Select(enemy => currentBoard.GetTileAtPosition(enemy.Position)).ToList <Tile>();

        foreach (EntityData enemy in enemies)
        {
            Tile enemyTile = currentBoard.GetTileAtPosition(enemy.Position);

            MovementCardData enemyMovementCard = enemy.movementCard;
            int enemyMoveRange = enemyMovementCard.range + enemy.GetMovementModifierValue();

            AttackCardData enemyAttackCard  = enemy.attackCard;
            int            enemyAttackRange = enemyAttackCard.range;

            List <EntityTurnTargets> possibleEntityTurns  = enemyTile.GetAllPossibleEntityTurns(enemyMoveRange, enemyAttackRange);
            List <EntityTurnTargets> sortedPotentialTurns = SortTurnTargetsByValue(enemyTile, possibleEntityTurns, gameState);
            int turnIndex = 0;
            EntityTurnTargets selectedTurnTargets       = sortedPotentialTurns[turnIndex];
            List <Direction>  movesToTargetMovementTile = BoardHelperFunctions.FindPathBetweenTiles(enemyTile, selectedTurnTargets.targetMovementTile);
            List <Tile>       tilesToTargetMovementTile = BoardHelperFunctions.GetTilesOnPath(enemyTile, movesToTargetMovementTile);

            // Enemies will not move through traps if they have any other moves available.
            while (turnIndex < sortedPotentialTurns.Count &&
                   tilesToTargetMovementTile.Any(tile => gameState.DoesPositionContainItemWhere(tile.Position, item => item.itemCategory == ItemCategory.Trap) ||
                                                 gameState.IsTileOccupied(tile)))
            {
                turnIndex++;
                selectedTurnTargets       = sortedPotentialTurns[turnIndex];
                movesToTargetMovementTile = BoardHelperFunctions.FindPathBetweenTiles(enemyTile, selectedTurnTargets.targetMovementTile);
                tilesToTargetMovementTile = BoardHelperFunctions.GetTilesOnPath(enemyTile, movesToTargetMovementTile);
            }

            if (turnIndex == sortedPotentialTurns.Count)
            {
                selectedTurnTargets = sortedPotentialTurns[0];
            }

            upcomingEntityTargets.Add(selectedTurnTargets);
            int       rangeOfProjectedAttack = BoardHelperFunctions.GetLinearDistanceBetweenTiles(selectedTurnTargets.targetMovementTile, selectedTurnTargets.targetAttackTile);
            Direction attackDirection        = BoardHelperFunctions.GetDirectionFromPosition(selectedTurnTargets.targetMovementTile.Position, selectedTurnTargets.targetAttackTile.Position);

            Action enemyAction = new Action(enemyAttackCard, enemy, attackDirection, rangeOfProjectedAttack);

            Turn enemyTurn = new Turn(enemy, movesToTargetMovementTile, enemyAction);

            turnStackController.AddNewTurn(enemyTurn);
        }
    }
Exemplo n.º 3
0
    public void LoadCardData(AttackCardData card)
    {
        cardData = card;

        LoadRegularCardData(card);

        AttackCard attackCard = (AttackCard)GetComponent <AttackCard>();

        attackCard.costText       = costText;
        attackCard.baseDamageText = baseDamageText;
        attackCard.playableEffect = playableEffect;

        attackCard.originalCost = card.cost;
        attackCard.baseDamage   = card.baseDamage;
        attackCard.type         = card.attackType;

        attackCard.statTestStrength = card.statTestStrength;
        attackCard.statTestAgility  = card.statTestAgility;
        attackCard.statTestWisdom   = card.statTestWisdom;
        attackCard.statTestSpirit   = card.statTestSpirit;

        attackCard.outStatStrength = card.outStatStrength;
        attackCard.outStatAgility  = card.outStatAgility;
        attackCard.outStatWisdom   = card.outStatWisdom;
        attackCard.outStatSpirit   = card.outStatSpirit;

        attackCard.statFailStrength = card.statFailStrength;
        attackCard.statFailAgility  = card.statFailAgility;
        attackCard.statFailWisdom   = card.statFailWisdom;
        attackCard.statFailSpirit   = card.statFailSpirit;

        attackCard.modifyUserStrength = card.modifyUserStrength;
        attackCard.modifyUserAgility  = card.modifyUserAgility;
        attackCard.modifyUserWisdom   = card.modifyUserWisdom;
        attackCard.modifyUserSpirit   = card.modifyUserSpirit;

        attackCard.modifyEnemyStrength = card.modifyEnemyStrength;
        attackCard.modifyEnemyAgility  = card.modifyEnemyAgility;
        attackCard.modifyEnemyWisdom   = card.modifyEnemyWisdom;
        attackCard.modifyEnemySpirit   = card.modifyEnemySpirit;
    }
Exemplo n.º 4
0
    static ProjectedGameState GetNextStateFromAction_Attack(ScenarioState newState, EntityData entity, Action action)
    {
        GameBoard      testBoard        = BoardController.CurrentBoard;
        AttackCardData card             = action.card as AttackCardData;
        TargetType     attackTargetType = card.targetType;

        Tile attackOriginTile = BoardController.CurrentBoard.GetTileAtPosition(entity.Position);

        List <Tile> targetTiles = new List <Tile>();

        switch (attackTargetType)
        {
        case TargetType.Single:
            targetTiles.Add(newState.FindFirstOccupiedTileInDirection(attackOriginTile, action.direction, action.distance));
            break;

        case TargetType.AreaOfEffect:
            Tile impactTile = newState.FindFirstOccupiedTileInDirection(attackOriginTile, action.direction, action.distance);
            targetTiles.Add(impactTile);
            targetTiles.AddRange(impactTile.Neighbors);
            break;

        case TargetType.Line:
            targetTiles.AddRange(attackOriginTile.GetAllTilesInDirection(action.direction, action.card.range));
            break;

        default:
            break;
        }

        ProjectedGameState newProjectedState = new ProjectedGameState(entity, newState, action);

        newProjectedState.AddAttackedPositions(targetTiles.Select(t => t.Position));

        List <EntityData> affectedEntities = targetTiles
                                             .Select(t => newState.GetTileOccupant(t))
                                             .Where(o => o != null)
                                             .ToList();

        if (affectedEntities.Count == 0)
        {
            List <ModifierData> modifiersToResolve = action.card.modifiers
                                                     .Where(m =>
                                                            m.modifierCategory == ModifierCategory.Blowback ||
                                                            m.modifierCategory == ModifierCategory.FollowUp)
                                                     .ToList();

            for (int i = 0; i < modifiersToResolve.Count; i++)
            {
                ModifierData modifier = modifiersToResolve[i];
                ApplyModifierToAttack_BlowbackFollowUp(modifier, entity, newState, action.direction, modifier.modifierCategory);
            }

            return(newProjectedState);
        }

        for (int i = 0; i < affectedEntities.Count; i++)
        {
            EntityData affectedEntity = affectedEntities[i];

            int cardDamage = card.damage + entity.GetAttackModifierValue();
            affectedEntity.DealDamage(cardDamage, newState);

            List <ModifierData> attackModifiers = action.card.modifiers;
            if (attackModifiers != null && attackModifiers.Count > 0)
            {
                for (int j = 0; i < attackModifiers.Count; i++)
                {
                    ApplyModifierToAttack(affectedEntity, attackModifiers[j], entity, newState, action.direction);
                }
            }
        }

        return(newProjectedState);
    }