Example #1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public Character()
 {
     _destination   = _dimensions = _isometricOffset = Vector2.Zero;
     _location      = Point.Zero;
     _currentTile   = _destinationTile = new CombatTile();
     _movementNodes = new List <Point>();
     _currentAction = Activity.None;
 }
    //Function called from CombatActionPanelUI.cs. Returns all combat tiles within the given range of the starting tile
    public static List <CombatTile> FindTilesInActionRange(CombatTile startingTile_, int actionRange_, bool ignoreObstacles_ = true)
    {
        //The list of combat tiles that are returned
        List <CombatTile> allTilesInRange = new List <CombatTile>();

        //The list of each group of tiles in every range incriment. The index is the range
        List <List <CombatTile> > tilesInEachIncriment = new List <List <CombatTile> >();
        //Creating the first range incriment which always includes the starting tile
        List <CombatTile> range0 = new List <CombatTile>()
        {
            startingTile_
        };

        range0[0].ourPathPoint.hasBeenChecked = true;
        tilesInEachIncriment.Add(range0);

        for (int r = 1; r <= actionRange_; ++r)
        {
            //Creating a new list of tiles for this range incriment
            List <CombatTile> newRange = new List <CombatTile>();

            //Looping through each tile in the previous range
            foreach (CombatTile tile in tilesInEachIncriment[r - 1])
            {
                //Looping through each tile connected to the one we're checking
                foreach (PathPoint connection in tile.ourPathPoint.connectedPoints)
                {
                    //If the connected tile hasn't already been checked
                    if (!connection.hasBeenChecked)
                    {
                        //If we ignore obstacles OR if the the tile doesn't have obstacles on it
                        if (ignoreObstacles_ || connection.GetComponent <CombatTile>().objectOnThisTile == null)
                        {
                            //Adding the connected tile to this new range and marking it as checked
                            newRange.Add(connection.GetComponent <CombatTile>());
                            connection.hasBeenChecked = true;
                        }
                    }
                }
            }

            //Adding this range incriment to the list
            tilesInEachIncriment.Add(newRange);
        }

        //Grouping all of the tiles into the list that is returned
        foreach (List <CombatTile> rangeList in tilesInEachIncriment)
        {
            foreach (CombatTile tile in rangeList)
            {
                allTilesInRange.Add(tile);
                //Resetting the tile to say it hasn't been checked
                tile.ourPathPoint.hasBeenChecked = false;
            }
        }

        return(allTilesInRange);
    }
Example #3
0
    //Function inherited from AttackAction.cs and called from CombatManager.cs so we can attack a target
    public override void PerformAction(CombatTile targetTile_)
    {
        base.PerformAction(targetTile_);

        //Once the attack is performed, this spell needs to recharge
        Character actingChar = CombatManager.globalReference.actingCharacters[0];

        actingChar.charActionList.StartSpellRecharge(this);
    }
Example #4
0
        public void CenterIsometric(CombatTile tile)
        {
            _currentTile = tile;

            // Center the duders on the tiles
            _isometricOffset.X = (_currentTile.SourceTile.Dimensions.X - _dimensions.X) / 2; //64 - 32 / 2
            _isometricOffset.Y = -(_currentTile.SourceTile.Dimensions.Y - _dimensions.Y);

            _image.Position = _currentTile.SourceTile.Position + _isometricOffset;
        }
Example #5
0
    //Function called when the player's mouse starts hovering over this tile
    public void OnPointerEnter(PointerEventData eventData_)
    {
        //Hilighting this tile's image
        this.HighlightTile(true);

        mouseOverTile = this;

        //Highlighting any effect radius if there's a selected attack ability
        this.HighlightEffectRadius(true);
    }
Example #6
0
    //Function inherited from Action.cs
    public override void PerformAction(CombatTile targetTile_)
    {
        //Calling the base function to start the cooldown time
        base.PerformAction(targetTile_);

        //If the acting character is an enemy, we need to set the movement path since we're not mousing over tiles
        if (CombatManager.globalReference.enemyCharactersInCombat.Contains(this.actingCharacter))
        {
            this.movementPath = PathfindingAlgorithms.BreadthFirstSearchCombat(this.movementPath[0], targetTile_, true, true);
        }

        //Makes it so that the Update function will now move the character through the movement path
        this.moveCharacter        = true;
        this.currentNumTilesMoved = 0;
    }
Example #7
0
    //Function called from CombatTile.cs to see if a specific tile is in the current movement path
    public bool IsTileInMovementPath(CombatTile tileToCheck_)
    {
        //Looping through each tile in the current movement path
        foreach (CombatTile ct in this.movementPath)
        {
            //Returns true if the current tile is the one we're looking for
            if (ct == tileToCheck_)
            {
                return(true);
            }
        }

        //If we make it through the loop, the tile we're looking for isn't in the movement path
        return(false);
    }
Example #8
0
    //Function called when the player's mouse is no longer over this tile
    public void OnPointerExit(PointerEventData eventData_)
    {
        //If a character is moving right now and this tile is in the movement path, we don't stop highlighting
        if (CombatActionPanelUI.globalReference.selectedAction != null && CombatActionPanelUI.globalReference.selectedAction.GetComponent <MoveAction>())
        {
            //If this tile isn't in the movement path, this tile isn't highlighted
            if (!CombatActionPanelUI.globalReference.selectedAction.GetComponent <MoveAction>().IsTileInMovementPath(this))
            {
                this.HighlightTile(false);

                //If we have a character on this tile, we make sure they're hidden again
                if (this.inActionRange && this.objectOnThisTile != null && this.objectOnThisTile.GetComponent <Character>())
                {
                    //Making sure the character isn't the acting character
                    if (CombatManager.globalReference.actingCharacters.Count > 0 && this.objectOnThisTile.GetComponent <Character>() != CombatManager.globalReference.actingCharacters[0])
                    {
                        //Getting the sprite base for the character
                        CharacterSpriteBase cSprite = CombatManager.globalReference.GetCharacterSprite(this.objectOnThisTile.GetComponent <Character>());
                        cSprite.MakeSpritesTransparent();
                    }
                }
            }
        }
        else
        {
            //Stops hilighting this tile's image
            this.HighlightTile(false);

            //Stops highlighting any effect radius if there's a selected attack ability
            this.HighlightEffectRadius(false);

            //If we have a character on this tile, we make sure they're hidden again
            if (this.inActionRange && this.objectOnThisTile != null && this.objectOnThisTile.GetComponent <Character>())
            {
                //Making sure the character isn't the acting character
                if (this.objectOnThisTile.GetComponent <Character>() != CombatManager.globalReference.actingCharacters[0])
                {
                    //Getting the sprite base for the character
                    CharacterSpriteBase cSprite = CombatManager.globalReference.GetCharacterSprite(this.objectOnThisTile.GetComponent <Character>());
                    cSprite.MakeSpritesTransparent();
                }
            }
        }

        mouseOverTile = null;
    }
Example #9
0
    //Function called when the player's mouse starts hovering over this tile
    public void OnPointerEnter(PointerEventData eventData_)
    {
        //Hilighting this tile's image
        this.HighlightTile(true);

        mouseOverTile = this;

        //Highlighting any effect radius if there's a selected attack ability
        this.HighlightEffectRadius(true);

        //If we have a character on this tile, we make sure they're visible
        if (this.inActionRange && this.objectOnThisTile != null && this.objectOnThisTile.GetComponent <Character>())
        {
            //Making sure the character isn't the acting character
            if (CombatManager.globalReference.actingCharacters.Count > 0 && this.objectOnThisTile.GetComponent <Character>() != CombatManager.globalReference.actingCharacters[0])
            {
                //Getting the sprite base for the character
                CharacterSpriteBase cSprite = CombatManager.globalReference.GetCharacterSprite(this.objectOnThisTile.GetComponent <Character>());
                cSprite.MakeSpritesVisible();
            }
        }
    }
Example #10
0
    //Function called when the player's mouse is no longer over this tile
    public void OnPointerExit(PointerEventData eventData_)
    {
        //If a character is moving right now and this tile is in the movement path, we don't stop highlighting
        if (CombatActionPanelUI.globalReference.selectedAction != null && CombatActionPanelUI.globalReference.selectedAction.GetComponent <MoveAction>())
        {
            //If this tile isn't in the movement path, this tile isn't highlighted

            /*if (!CombatActionPanelUI.globalReference.selectedAction.GetComponent<MoveAction>().IsTileInMovementPath(this))
             * {
             *  this.HighlightTile(false);
             * }*/
        }
        else
        {
            //Stops hilighting this tile's image
            this.HighlightTile(false);

            //Stops highlighting any effect radius if there's a selected attack ability
            this.HighlightEffectRadius(false);
        }

        mouseOverTile = null;
    }
Example #11
0
    //Overrided function from Effect.cs to trigger this damage effect
    public override void TriggerEffect(Character usingCharacter_, Character targetCharacter_, float timeDelay_ = 0)
    {
        //Setting the character references of who is attacking and who is being attacked
        this.characterToEffect     = targetCharacter_;
        this.characterWhoTriggered = usingCharacter_;

        //Int to hold all of the damage for the attack
        int totalDamage = 0;

        //Adding the base damage
        totalDamage += this.baseDamage;

        //Looping through each individual die rolled
        for (int d = 0; d < this.diceRolled; ++d)
        {
            //Finding the value rolled on the current die
            totalDamage += Random.Range(1, this.diceSides);
        }

        //Rolling to see if this effect crits
        float critRoll = Random.Range(0, 1);
        bool  isCrit   = false;

        if (critRoll < this.critChance)
        {
            totalDamage = totalDamage * this.critMultiplier;
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in usingCharacter_.charPerks.allPerks)
        {
            //If the perk boosts a damage type that's the same as this damage type, we boost it
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.type == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                totalDamage += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(usingCharacter_, isCrit, false, this.type);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in targetCharacter_.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current damage type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.type)
                {
                    //Checking to see if the damage is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        //If the resist type for this spell isn't on absorb, we can negate it. ALWAYS have preference to absorb because it heals
                        if (magicResistType != SpellResistTypes.Absorb)
                        {
                            magicResistType = SpellResistTypes.Negate;
                        }
                    }
                    //Checking to see if the damage is absorbed to heal the target
                    else if (resistPerk.absorbDamage)
                    {
                        magicResistType = SpellResistTypes.Absorb;
                        //Applying the damage reduction so the defender isn't healed as much
                        totalDamage -= resistPerk.GetSpellResistAmount(this.characterToEffect, isCrit, false);
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        totalDamage -= resistPerk.GetSpellResistAmount(this.characterToEffect, isCrit, false);
                    }
                }
            }
        }

        //Subtracting the target character's armor resist and magic resistances
        switch (this.type)
        {
        case CombatManager.DamageType.Slashing:
            if (targetCharacter_.charInventory.totalSlashingArmor > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalSlashingArmor;
            }
            break;

        case CombatManager.DamageType.Stabbing:
            if (targetCharacter_.charInventory.totalStabbingArmor > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalStabbingArmor;
            }
            break;

        case CombatManager.DamageType.Crushing:
            if (targetCharacter_.charInventory.totalCrushingArmor > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalCrushingArmor;
            }
            break;

        case CombatManager.DamageType.Fire:
            if (targetCharacter_.charInventory.totalFireResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalFireResist;
            }
            break;

        case CombatManager.DamageType.Water:
            if (targetCharacter_.charInventory.totalWaterResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalWaterResist;
            }
            break;

        case CombatManager.DamageType.Electric:
            if (targetCharacter_.charInventory.totalElectricResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalElectricResist;
            }
            break;

        case CombatManager.DamageType.Wind:
            if (targetCharacter_.charInventory.totalWindResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalWindResist;
            }
            break;

        case CombatManager.DamageType.Nature:
            if (targetCharacter_.charInventory.totalNatureResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalNatureResist;
            }
            break;

        case CombatManager.DamageType.Arcane:
            if (targetCharacter_.charInventory.totalArcaneResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalArcaneResist;
            }
            break;

        case CombatManager.DamageType.Holy:
            if (targetCharacter_.charInventory.totalHolyResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalHolyResist;
            }
            break;

        case CombatManager.DamageType.Dark:
            if (targetCharacter_.charInventory.totalDarkResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalDarkResist;
            }
            break;

        case CombatManager.DamageType.Bleed:
            if (targetCharacter_.charInventory.totalBleedResist > 0)
            {
                totalDamage -= targetCharacter_.charInventory.totalBleedResist;
            }
            break;
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this effect or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.type || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(totalDamage, isCrit, false);
                }
            }
        }

        //Finding the combat tile that the target character is on
        CombatTile targetCharTile = CombatManager.globalReference.FindCharactersTile(targetCharacter_);

        //If the damage was dealt normally
        if (magicResistType == SpellResistTypes.Normal)
        {
            //Dealing damage to the target character and telling the combat manager to display how much was dealt
            targetCharacter_.charPhysState.DamageCharacter(totalDamage);
            CombatManager.globalReference.DisplayDamageDealt(timeDelay_, totalDamage, type, targetCharTile, isCrit);

            //If this character has the EnemyCombatAI component, we increase the threat for the character who put this effect on
            if (this.characterToEffect.GetComponent <EnemyCombatAI_Basic>())
            {
                //If the character who cast this effect is a player character, we increase threat against the caster
                if (!this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
                {
                    //If the attack didn't crit
                    if (!isCrit)
                    {
                        //Applying threat to the targeted character
                        this.characterToEffect.GetComponent <EnemyCombatAI_Basic>().IncreaseThreat(this.characterWhoTriggered, totalDamage + bonusThreat);
                    }
                    //If the attack did crit, we boost threat against all enemies by 25%
                    else
                    {
                        //Finding the bonus amount of threat that's applied to all enemies
                        int boostedThreat = totalDamage + bonusThreat;
                        boostedThreat = Mathf.RoundToInt(boostedThreat * 0.25f);
                        CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, boostedThreat, true);

                        //Applying the rest of the threat to the target character
                        CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, this.characterToEffect, totalDamage + bonusThreat - boostedThreat, false);
                    }
                }
            }
        }
        //If the damage was negated completely
        else if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display no damage dealt
            CombatManager.globalReference.DisplayDamageDealt(timeDelay_, 0, type, targetCharTile, isCrit);
        }
        //If the damage was abosrbed and healed the character
        else if (magicResistType == SpellResistTypes.Absorb)
        {
            //Telling the combat manager to display the damage healed
            targetCharacter_.charPhysState.HealCharacter(totalDamage);
            CombatManager.globalReference.DisplayDamageDealt(timeDelay_, totalDamage, type, targetCharTile, isCrit, true);

            //If the caster of this effect and the target are player characters, we increase the threat for the character who put this effect on them
            if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>() && !this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //Applying threat to all enemies for the amount that's healed
                CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, totalDamage + bonusThreat, true);
            }
        }

        //Creating the visual effect for this effect
        CharacterSpriteBase targetCharSprite = CombatManager.globalReference.GetCharacterSprite(targetCharacter_);

        this.SpawnVisualAtLocation(targetCharSprite.transform.localPosition, targetCharSprite.transform);


        //Increasing the threat to the target based on damage dealt
        //If the attack is a crit, ALL enemies have their threat increased for 25% of the damage
        if (isCrit)
        {
            //Getting 25% of the damage to pass to all enemies
            int threatForAll = (totalDamage + bonusThreat) / 4;
            CombatManager.globalReference.ApplyActionThreat(usingCharacter_, null, threatForAll, true);

            //Applying the rest of the threat to the target character
            CombatManager.globalReference.ApplyActionThreat(usingCharacter_, targetCharacter_, (totalDamage + bonusThreat) - threatForAll, false);
        }
        //If the attack wasn't a crit, only the target character takes threat
        else
        {
            CombatManager.globalReference.ApplyActionThreat(usingCharacter_, targetCharacter_, totalDamage + bonusThreat, false);
        }

        //Destroying this effect once everything is finished up
        Destroy(this.gameObject);
    }
    //Function called externally from the buttons on the action panel. Tells the combat manager to hilight an action's range
    public void SelectActionAtIndex(int actionIndex_)
    {
        //Clearing all tile highlights before we highlight different ones
        CombatManager.globalReference.ClearCombatTileHighlights();

        //Getting a reference to the character that's currently acting
        Character actingCharacter = CombatManager.globalReference.actingCharacters[0];
        //Finding out which tile the acting character is on
        CombatTile actingCharsTile = CombatManager.globalReference.FindCharactersTile(actingCharacter);

        //If the currently selected action is a move action, we need to clear tile highlights along its movement path
        if (this.selectedAction != null && this.selectedAction.GetComponent <MoveAction>())
        {
            this.selectedAction.GetComponent <MoveAction>().ClearMovePathHighlights();
        }

        //Destroying the game object that holds the currently selected action
        if (this.selectedAction != null)
        {
            Destroy(this.selectedAction.gameObject);
        }

        //Creating an instance of the newly selected action prefab object
        GameObject actionObj = null;

        //Finding the range of the action based on the button hit
        int actionRange = 0;

        switch (this.actionTypeShown)
        {
        case Action.ActionType.Major:
            actionRange = actingCharacter.charActionList.majorActions[actionIndex_].range;
            actionObj   = GameObject.Instantiate(actingCharacter.charActionList.majorActions[actionIndex_].gameObject);
            //this.selectedAction = actingCharacter.charActionList.standardActions[actionIndex_];
            break;

        case Action.ActionType.Minor:
            actionRange = actingCharacter.charActionList.minorActions[actionIndex_].range;
            actionObj   = GameObject.Instantiate(actingCharacter.charActionList.minorActions[actionIndex_].gameObject);
            break;

        case Action.ActionType.Fast:
            actionRange = actingCharacter.charActionList.fastActions[actionIndex_].range;
            actionObj   = GameObject.Instantiate(actingCharacter.charActionList.fastActions[actionIndex_].gameObject);
            break;

        case Action.ActionType.Massive:
            actionRange = actingCharacter.charActionList.massiveActions[actionIndex_].range;
            actionObj   = GameObject.Instantiate(actingCharacter.charActionList.massiveActions[actionIndex_].gameObject);
            break;
        }

        //Getting the action component reference from the created action object
        this.selectedAction = actionObj.GetComponent <Action>();

        //Finding out which tiles need to be hilighted if this action isn't a move action
        List <CombatTile> tilesToHighlight;
        List <CombatTile> tilesToCheckForCharacters = new List <CombatTile>();

        if (!this.selectedAction.GetComponent <MoveAction>())
        {
            tilesToHighlight          = PathfindingAlgorithms.FindTilesInActionRange(actingCharsTile, actionRange);
            tilesToCheckForCharacters = tilesToHighlight;
        }
        //If this action is a move action, we have to find the selected tiles based on environment obstacles
        else
        {
            MoveAction ourMoveAct = this.selectedAction.GetComponent <MoveAction>();

            //Looping through all of the acting character's perks to see if there are any movement boost perks
            int rangeModifier = 0;
            foreach (Perk charPerk in actingCharacter.charPerks.allPerks)
            {
                //If the current perk is a movement boost perk that applies to this movement's action type, we apply the number of added spaces
                if (charPerk.GetType() == typeof(MovementBoostPerk) && ourMoveAct.type == charPerk.GetComponent <MovementBoostPerk>().actionTypeToBoost)
                {
                    rangeModifier += charPerk.GetComponent <MovementBoostPerk>().addedMovementSpaces;
                }
            }

            //Highlighting all tiles in range
            tilesToHighlight          = PathfindingAlgorithms.FindTilesInActionRange(actingCharsTile, actionRange + rangeModifier, ourMoveAct.ignoreObstacles);
            tilesToCheckForCharacters = PathfindingAlgorithms.FindTilesInActionRange(actingCharsTile, actionRange + rangeModifier + 1);
        }

        //Looping through all tiles in range and hilighting them
        foreach (CombatTile tile in tilesToHighlight)
        {
            tile.inActionRange = true;
            tile.HighlightTile(false);
        }

        //Looping through all of the tiles around the action highlights to check for characters
        foreach (CombatTile checkedTile in tilesToCheckForCharacters)
        {
            //If there's a character sprite on this tile, we hide it a bit
            if (checkedTile.objectOnThisTile != null)
            {
                if (checkedTile.objectOnThisTile.GetComponent <Character>())
                {
                    //Getting the sprite base for the character
                    CharacterSpriteBase cSprite = CombatManager.globalReference.GetCharacterSprite(checkedTile.objectOnThisTile.GetComponent <Character>());
                    //If the character on the tile isn't the one that's acting
                    if (cSprite.ourCharacter != CombatManager.globalReference.actingCharacters[0])
                    {
                        cSprite.MakeSpritesTransparent();
                    }
                }
            }
        }

        //Displays the action's details
        this.UpdateActionDetailsPanel();
    }
Example #13
0
 //Function that is overrided by inheriting classes and called from the CombatManager to use this ability
 public virtual void PerformAction(CombatTile targetTile_)
 {
     //Nothing here because the inheriting classes act differently
 }
Example #14
0
        /// <summary>
        /// Handles player position during a move
        /// </summary>
        /// <param name="gameTime"></param>
        public void Move(GameTime gameTime)
        {
            // Get our new position and location, and update our current tile if our location has changed
            _image.Position += _velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
            Point newLoc = _combatGrid.GetTileAtPosition(_image.Position + _dimensions / 2, _currentTile.Height).GridPosition;

            if (!_reachedNode && _location != newLoc)
            {
                _location    = newLoc;
                _currentTile = _combatGrid.GetTileAtPosition(_image.Position + _dimensions / 2, _currentTile.Height);
            }

            // Check if we reaced a node
            if (_reachedNode || _currentTile == _destinationTile)
            {
                _reachedNode = true;

                // Now we need to make sure that our image is moving to align with the top left corner of the square
                // Left up
                if (_movingDirection == Direction.Northwest)
                {
                    if (_image.Position.X <= _destinationTile.Position.X + _isometricOffset.X)
                    {
                        _image.Position = _destinationTile.Position + _isometricOffset;
                        _aligned        = true;
                    }
                }
                // Right up
                else if (_movingDirection == Direction.Northeast)
                {
                    if (_image.Position.X >= _destinationTile.Position.X + _isometricOffset.X)
                    {
                        _image.Position = _destinationTile.Position + _isometricOffset;
                        _aligned        = true;
                    }
                }
                // Right down
                else if (_movingDirection == Direction.Southeast)
                {
                    if (_image.Position.X >= _destinationTile.Position.X + _isometricOffset.X)
                    {
                        _image.Position = _destinationTile.Position + _isometricOffset;
                        _aligned        = true;
                    }
                }
                // Left down
                else if (_movingDirection == Direction.Southwest)
                {
                    if (_image.Position.X <= _destinationTile.Position.X + _isometricOffset.X)
                    {
                        _image.Position = _destinationTile.Position + _isometricOffset;
                        _aligned        = true;
                    }
                }

                if (_aligned)
                {
                    _movementNodes.RemoveAt(0);
                    Console.WriteLine(">> Reached Node <<");

                    // Check if we reached the last node
                    if (_movementNodes.Count == 0)
                    {
                        _velocity = Vector2.Zero;
                        _moving   = false;
                        _busy     = false;
                        Console.WriteLine(">>> Movement complete <<<");
                        this.TurnIsOver();
                    }
                    else
                    {
                        this.ExecuteMove();
                    }
                    _aligned     = false;
                    _reachedNode = false;
                }
            }
        }
    //Overrided function from Effect.cs to trigger this heal effect
    public override void TriggerEffect(Character usingCharacter_, Character targetCharacter_, float timeDelay_ = 0)
    {
        //Setting the character references of who is attacking and who is being attacked
        this.characterToEffect     = targetCharacter_;
        this.characterWhoTriggered = usingCharacter_;

        //Int to hold the heal total for the effect
        int totalHeal = 0;

        //Adding the base heal
        totalHeal += this.baseHeal;

        //Looping through each individual die rolled
        for (int d = 0; d < this.diceRolled; ++d)
        {
            //Finding the value rolled on the current die
            totalHeal += Random.Range(1, this.diceSides);
        }

        //Rolling to see if this effect crits
        float critRoll = Random.Range(0, 1);
        bool  isCrit   = false;

        if (critRoll < this.critChance)
        {
            totalHeal = Mathf.RoundToInt(totalHeal * this.critMultiplier);
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in usingCharacter_.charPerks.allPerks)
        {
            //If the perk boosts a damage type that's the same as this damage (heal) type, we boost it
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.type == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                totalHeal += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(usingCharacter_, isCrit, false, this.type);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in this.characterToEffect.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current heal type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.type)
                {
                    //Checking to see if the heal is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        magicResistType = SpellResistTypes.Negate;
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        totalHeal -= resistPerk.GetSpellResistAmount(this.characterToEffect, isCrit, false);
                    }
                }
            }
        }

        //Subtracting the target character's magic resistances
        switch (this.type)
        {
        case CombatManager.DamageType.Slashing:
            if (targetCharacter_.charInventory.totalSlashingArmor > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalSlashingArmor;
            }
            break;

        case CombatManager.DamageType.Stabbing:
            if (targetCharacter_.charInventory.totalStabbingArmor > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalStabbingArmor;
            }
            break;

        case CombatManager.DamageType.Crushing:
            if (targetCharacter_.charInventory.totalCrushingArmor > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalCrushingArmor;
            }
            break;

        case CombatManager.DamageType.Fire:
            if (targetCharacter_.charInventory.totalFireResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalFireResist;
            }
            break;

        case CombatManager.DamageType.Water:
            if (targetCharacter_.charInventory.totalWaterResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalWaterResist;
            }
            break;

        case CombatManager.DamageType.Electric:
            if (targetCharacter_.charInventory.totalElectricResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalElectricResist;
            }
            break;

        case CombatManager.DamageType.Wind:
            if (targetCharacter_.charInventory.totalWindResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalWindResist;
            }
            break;

        case CombatManager.DamageType.Nature:
            if (targetCharacter_.charInventory.totalNatureResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalNatureResist;
            }
            break;

        case CombatManager.DamageType.Arcane:
            if (targetCharacter_.charInventory.totalArcaneResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalArcaneResist;
            }
            break;

        case CombatManager.DamageType.Holy:
            if (targetCharacter_.charInventory.totalHolyResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalHolyResist;
            }
            break;

        case CombatManager.DamageType.Dark:
            if (targetCharacter_.charInventory.totalDarkResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalDarkResist;
            }
            break;

        case CombatManager.DamageType.Bleed:
            if (targetCharacter_.charInventory.totalBleedResist > 0)
            {
                totalHeal -= targetCharacter_.charInventory.totalBleedResist;
            }
            break;
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this effect or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.type || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(totalHeal, isCrit, false);
                }
            }
        }

        //Finding the combat tile that the target character is on
        CombatTile targetCharTile = CombatManager.globalReference.FindCharactersTile(targetCharacter_);

        //If the heal was negated completely
        if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display that no damage was healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, 0, this.type, healedCharTile, isCrit, true);
        }
        //Otherwise, the heal happens normally
        else
        {
            //Healing the damage to the effected character
            this.characterToEffect.charPhysState.HealCharacter(totalHeal);

            //Telling the combat manager to display the damage healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, totalHeal, this.type, healedCharTile, isCrit, true);

            //If the acting character is a player character, we need to increase the threat against them
            if (!this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //If this character DOESN'T have the EnemyCombatAI component, we increase the threat for the character who put this effect on
                if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>())
                {
                    //Applying threat to all enemies based on the amount healed
                    CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, totalHeal + bonusThreat, true);
                }
            }
        }

        //Creating the visual effect for this effect
        CharacterSpriteBase targetCharSprite = CombatManager.globalReference.GetCharacterSprite(targetCharacter_);

        this.SpawnVisualAtLocation(targetCharSprite.transform.localPosition, targetCharSprite.transform);

        //Destroying this effect once everything is finished up
        Destroy(this.gameObject);
    }
    //Pathfinding algorithm that uses Breadth First Search to check all directions equally. Returns the tile path taken to get to the target tile.
    public static List <CombatTile> BreadthFirstSearchCombat(CombatTile startingPoint_, CombatTile targetPoint_, bool avoidObjects_ = true, bool avoidCharacters_ = true)
    {
        //Creating the 2D list of tiles that will be returned
        List <CombatTile> tilePath = new List <CombatTile>();

        //The list of path points that make up the frontier
        List <CombatTile> frontier = new List <CombatTile>();

        //Adding the starting tile to the fronteir and making sure its previous point is cleared
        frontier.Add(startingPoint_);

        //The list of path points that have already been visited
        List <CombatTile> visitedPoints = new List <CombatTile>();

        visitedPoints.Add(startingPoint_);

        startingPoint_.ourPathPoint.previousPoint  = null;
        startingPoint_.ourPathPoint.hasBeenChecked = true;

        //Loop through each path point until the frontier is empty
        while (frontier.Count != 0)
        {
            //Getting the reference to the next path point to check
            CombatTile currentPoint = frontier[0];

            //If the current point is the path point we're looking for
            if (currentPoint == targetPoint_)
            {
                //If the target tile has nothing on it
                if (currentPoint.typeOnTile == CombatTile.ObjectType.Nothing)
                {
                    //Adding the current point's tile to the list of returned objects
                    tilePath.Add(currentPoint);
                }

                //Creating a variable to hold the reference to the previous point
                CombatTile prev = currentPoint.ourPathPoint.previousPoint.GetComponent <CombatTile>();

                //Looping through the trail of points back to the starting point
                while (true)
                {
                    //Adding the point's game object to the list of returned objects
                    tilePath.Add(prev);

                    //If the point isn't the starting point
                    if (prev != startingPoint_)
                    {
                        //Setting the previous point to the next point in the path
                        prev = prev.ourPathPoint.previousPoint.GetComponent <CombatTile>();
                    }
                    //If the point is the starting point
                    else
                    {
                        //We break out of the loop
                        break;
                    }
                }

                //Reversing the list of path points since it's currently backward
                tilePath.Reverse();

                //Exiting early since there's no reason to continue
                break;
            }
            //If the current point isn't the point we're looking for
            else
            {
                //Looping through each path point that's connected to the current point
                foreach (PathPoint connection in currentPoint.ourPathPoint.connectedPoints)
                {
                    if (connection != null)
                    {
                        //If the connected point hasn't been visited yet
                        if (!connection.hasBeenChecked)
                        {
                            //Telling the connected point came from the current point we're checking
                            connection.previousPoint = currentPoint.ourPathPoint;

                            CombatTile connectedCombatTile = connection.GetComponent <CombatTile>();
                            //If the connected tile isn't empty, we have to check it first
                            if (connectedCombatTile.typeOnTile != CombatTile.ObjectType.Nothing)
                            {
                                //Making sure that this type of movement can safely travel across the type of object on the tile
                                if (connectedCombatTile == targetPoint_ ||
                                    (connectedCombatTile.typeOnTile == CombatTile.ObjectType.Object && !avoidObjects_) ||
                                    (connectedCombatTile.typeOnTile == CombatTile.ObjectType.Enemy && !avoidCharacters_) ||
                                    (connectedCombatTile.typeOnTile == CombatTile.ObjectType.Player && !avoidCharacters_))
                                {
                                    //Adding the connected point to the frontier and list of visited tiles
                                    frontier.Add(connectedCombatTile);
                                }
                            }
                            else
                            {
                                //Adding the connected point to the frontier and list of visited tiles
                                frontier.Add(connectedCombatTile);
                            }
                            visitedPoints.Add(connectedCombatTile);
                            //Marking the tile as already checked so that it isn't added again
                            connection.hasBeenChecked = true;
                        }
                    }
                }

                //Adding the current point to the list of visited points and removing it from the frontier
                frontier.Remove(currentPoint);
            }
        }

        //Looping through all path points in the list of visited points to clear their data
        foreach (CombatTile point in visitedPoints)
        {
            point.ourPathPoint.ClearPathfinding();
        }

        //Returning the completed list of tiles
        return(tilePath);
    }
    //Function called whenever this effect heals the target character
    private void HealCharacter()
    {
        //Making sure the character isn't dead before healing
        if (this.characterToEffect.charPhysState.currentHealth <= 0)
        {
            return;
        }

        //Seeing if this effect will trigger
        float triggerRoll = Random.Range(0, 1);

        if (triggerRoll > this.chanceToTrigger)
        {
            //If we roll over the trigger chance, nothing happens and we don't tick
            return;
        }

        //Finding out how much health we heal this tick
        int damagehealed = Mathf.RoundToInt(Random.Range(this.healPerTickRange.x, this.healPerTickRange.y));

        //Finding out if we crit
        float critRoll    = Random.Range(0, 1);
        bool  didThisCrit = false;

        if (critRoll < this.critChance)
        {
            //If we crit this tick, the amount healed is multiplied
            damagehealed = damagehealed * this.critMultiplier;
            didThisCrit  = true;
        }

        //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && this.healType == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
            {
                damagehealed += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(this.characterWhoTriggered, didThisCrit, true, this.healType);
            }
        }

        //Looping through the defending character's perks to see if they have any spell resist or absorb perks
        SpellResistTypes magicResistType = SpellResistTypes.Normal;

        foreach (Perk defPerk in this.characterToEffect.charPerks.allPerks)
        {
            if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
            {
                SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                //Checking to see if the current heal type is the same as this spell resist perk
                if (resistPerk.typeToResist == this.healType)
                {
                    //Checking to see if the heal is negated entirely
                    if (resistPerk.negateAllDamage)
                    {
                        magicResistType = SpellResistTypes.Negate;
                    }
                    //Otherwise we just get the amount that it normally resists
                    else
                    {
                        damagehealed -= resistPerk.GetSpellResistAmount(this.characterToEffect, didThisCrit, false);
                    }
                }
            }
        }

        //Subtracting any magic resistance from the amount that we're trying to heal
        switch (this.healType)
        {
        case CombatManager.DamageType.Arcane:
            damagehealed -= this.characterToEffect.charInventory.totalArcaneResist;
            break;

        case CombatManager.DamageType.Fire:
            damagehealed -= this.characterToEffect.charInventory.totalFireResist;
            break;

        case CombatManager.DamageType.Water:
            damagehealed -= this.characterToEffect.charInventory.totalWaterResist;
            break;

        case CombatManager.DamageType.Electric:
            damagehealed -= this.characterToEffect.charInventory.totalElectricResist;
            break;

        case CombatManager.DamageType.Wind:
            damagehealed -= this.characterToEffect.charInventory.totalWindResist;
            break;

        case CombatManager.DamageType.Nature:
            damagehealed -= this.characterToEffect.charInventory.totalNatureResist;
            break;

        case CombatManager.DamageType.Holy:
            damagehealed -= this.characterToEffect.charInventory.totalHolyResist;
            break;

        case CombatManager.DamageType.Dark:
            damagehealed -= this.characterToEffect.charInventory.totalDarkResist;
            break;
            //Pure damage type has no resist
        }

        //Looping through the attacking character's perks to see if there's any bonus threat to add to this effect
        int bonusThreat = 0;

        foreach (Perk charPerk in this.characterWhoTriggered.charPerks.allPerks)
        {
            //If the perk is a threat boosting perk
            if (charPerk.GetType() == typeof(ThreatBoostPerk))
            {
                ThreatBoostPerk threatPerk = charPerk.GetComponent <ThreatBoostPerk>();

                //If the perk has the same damage type as this HoT or it affects all damage types
                if (threatPerk.damageTypeToThreaten == this.healType || threatPerk.threatenAllDamageTypes)
                {
                    bonusThreat += threatPerk.GetAddedActionThreat(damagehealed, didThisCrit, true);
                }
            }
        }

        //If the heal was negated completely
        if (magicResistType == SpellResistTypes.Negate)
        {
            //Telling the combat manager to display that no damage was healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, 0, this.healType, healedCharTile, didThisCrit, true);
        }
        //Otherwise, the heal happens normally
        else
        {
            //Healing the damage to the effected character
            this.characterToEffect.charPhysState.HealCharacter(damagehealed);

            //Telling the combat manager to display the damage healed
            CombatTile healedCharTile = CombatManager.globalReference.combatTileGrid[this.characterToEffect.charCombatStats.gridPositionCol][this.characterToEffect.charCombatStats.gridPositionRow];
            CombatManager.globalReference.DisplayDamageDealt(0, damagehealed, this.healType, healedCharTile, didThisCrit, true);

            //If the target character and the character who cast this effect are player characters, we need to increase threat
            if (!this.characterToEffect.GetComponent <EnemyCombatAI_Basic>() && !this.characterWhoTriggered.GetComponent <EnemyCombatAI_Basic>())
            {
                //Applying threat to all enemies for the amount that's healed
                CombatManager.globalReference.ApplyActionThreat(this.characterWhoTriggered, null, damagehealed + bonusThreat, true);
            }
        }

        //Creating the visual effect for this effect
        CharacterSpriteBase targetCharSprite = CombatManager.globalReference.GetCharacterSprite(this.characterToEffect);

        this.SpawnVisualAtLocation(targetCharSprite.transform.localPosition, targetCharSprite.transform);

        //If this effect isn't unlimited, we need to reduce the ticks remaining
        if (!this.unlimitedTicks)
        {
            this.ticksLeft -= 1;

            //If there are no more ticks left, this effect is over and the object is destroyed
            if (this.ticksLeft <= 0)
            {
                this.RemoveEffect();
            }
        }
    }
Example #18
0
    //Function inherited from AttackAction.cs and called from CombatManager.cs so we can attack a target
    public override void PerformAction(CombatTile targetTile_)
    {
        //Calling the base function to start the cooldown time
        this.BeginActionCooldown();

        //Reference to the character performing this attack
        Character actingChar = CombatManager.globalReference.actingCharacters[0];
        //Reference to the character that's being attacked
        Character defendingChar;

        //Getting the tile that the acting character is on
        CombatTile          actingCharTile = CombatManager.globalReference.FindCharactersTile(actingChar);
        CharacterSpriteBase cSprite        = CombatManager.globalReference.GetCharacterSprite(actingChar);

        //Setting the direction the acting character faces
        this.SetDirectionFacing(targetTile_, actingCharTile, cSprite);

        //Looping through and triggering all combat effects on the acting character that happen on attack
        foreach (Effect e in actingChar.charCombatStats.combatEffects)
        {
            e.EffectOnAttack();

            //Checking to see if the character has died due to some effect. If so, we break the loop
            if (actingChar.charPhysState.currentHealth <= 0)
            {
                break;
            }
        }

        //Looping through and creating each of the launched projectiles for this attack
        Vector3 casterTile = CombatManager.globalReference.FindCharactersTile(CombatManager.globalReference.actingCharacters[0]).transform.position;

        foreach (ProjectileLauncher projectile in this.projectilesToLaunch)
        {
            GameObject newProjectile = GameObject.Instantiate(projectile.gameObject, casterTile, new Quaternion());
            //Parenting the projectile to the combat manager canvas
            newProjectile.transform.SetParent(CombatManager.globalReference.transform);
            //Telling the projectile to start moving
            newProjectile.GetComponent <ProjectileLauncher>().StartTravelPath(casterTile, targetTile_.transform.position);
        }

        //Making sure there's a character on the targeted tile
        if (targetTile_.objectOnThisTile != null && targetTile_.objectOnThisTile.GetComponent <Character>())
        {
            defendingChar = targetTile_.objectOnThisTile.GetComponent <Character>();
        }
        //If there isn't a character on the tile, nothing happens because it misses anything it could hit
        else
        {
            //If there are no attack damage rolls (like if the attack was just to inflict an effect) the "Miss" text isn't shown
            if (this.damageDealt.Count > 0)
            {
                CombatManager.globalReference.DisplayMissedAttack(this.timeToCompleteAction, targetTile_);
            }

            //If the visual effect doesn't require a hit to be spawned, we create it at the target tile
            if (this.spawnVisualOnMiss && this.visualEffectOnHit != null)
            {
                GameObject visual = GameObject.Instantiate(this.visualEffectOnHit.gameObject, targetTile_.transform.position, new Quaternion(), CombatManager.globalReference.transform);
            }

            //Looping through each effect that this attack can apply to see if any don't require the attack to land
            foreach (AttackEffect efc in this.effectsOnHit)
            {
                //If the effect doesn't require the attack to land, it's triggered
                if (!efc.requireHit)
                {
                    this.TriggerEffect(efc, targetTile_, actingChar);
                }
            }

            return;
        }

        //Before calculating damage, we need to find out if this attack hit. We start by rolling 1d100 to hit and adding this attack's accuracy bonus
        int hitRoll = this.FindAttackRoll(actingChar, defendingChar);

        //If the hit roll is still above 20%, they hit. If not, the attack misses
        if (hitRoll <= CombatManager.baseHitDC)
        {
            //If there are no attack damage rolls (like if the attack was just to inflict an effect) the "Miss" text isn't shown
            if (this.damageDealt.Count > 0)
            {
                //Miss
                CombatManager.globalReference.DisplayMissedAttack(this.timeToCompleteAction, targetTile_);
            }

            //If the visual effect doesn't require a hit to be spawned, we create it at the target tile
            if (this.spawnVisualOnMiss && this.visualEffectOnHit != null)
            {
                GameObject visual = GameObject.Instantiate(this.visualEffectOnHit.gameObject, targetTile_.transform.position, new Quaternion(), CombatManager.globalReference.transform);
            }

            //Looping through each effect that this attack can apply to see if any don't require the attack to land
            foreach (AttackEffect efc in this.effectsOnHit)
            {
                //If the effect doesn't require the attack to land, it's triggered
                if (!efc.requireHit)
                {
                    this.TriggerEffect(efc, targetTile_, actingChar);
                }
            }

            //Giving the attacking character skill EXP for a miss
            this.GrantSkillEXP(actingChar, this.weaponSkillUsed, true);

            return;
        }

        //Giving the attacking character skill EXP for a hit
        this.GrantSkillEXP(actingChar, this.weaponSkillUsed, false);

        //Looping through for each time this action hits
        for (int h = 0; h < this.numberOfHits; ++h)
        {
            //Checking to see if this attack crits
            float critMultiplier = 1; //Set to 1 in case we don't crit so it won't change anything
            float critRoll       = Random.Range(0, 1);
            bool  isCrit         = false;

            //Float for the bonus damage multiplier from perks
            float critMultiplierBoost = 0;

            //Looping through all of the acting character's perks to see if they have perks for crit chance or multiplier
            foreach (Perk charPerk in actingChar.charPerks.allPerks)
            {
                //If the current perk increases crit chance, we need to see if it applies to this attack
                if (charPerk.GetType() == typeof(CritChanceBoostPerk))
                {
                    CritChanceBoostPerk critPerk = charPerk.GetComponent <CritChanceBoostPerk>();

                    //If the perk applies to this attack's required skill check
                    if (critPerk.boostAllSkills || critPerk.skillCritToBoost == this.weaponSkillUsed)
                    {
                        //If the perk applies to any kind of weapon size or the size requirement matches this action's required size, we increase the crit chance
                        if (critPerk.noSizeRequirement || critPerk.weaponSizeRequirement == this.requiredWeaponHand)
                        {
                            critRoll -= critPerk.critChanceBoost;
                        }
                    }
                }
                //If the current perk increases crit damage multipliers, we see if it applies to this attack
                else if (charPerk.GetType() == typeof(CritMultiplierPerk))
                {
                    CritMultiplierPerk critPerk = charPerk.GetComponent <CritMultiplierPerk>();

                    //If the perk applies to this attack's required skill check
                    if (critPerk.boostAllSkills || critPerk.skillCritToBoost == this.weaponSkillUsed)
                    {
                        //If the perk applies to any kind of weapon size or the size requirement matches this action's required size, we increase the crit chance
                        if (critPerk.noSizeRequirement || critPerk.weaponSizeRequirement == this.requiredWeaponHand)
                        {
                            critMultiplierBoost += critPerk.critMultiplierBoost;
                        }
                    }
                }
            }

            //If the crit roll is below the crit chance, the attack crits and we change the multiplier
            if (critRoll < this.critChance)
            {
                critMultiplier = this.critMultiplier + critMultiplierBoost;
                isCrit         = true;
            }

            //Dictionary for the total amount of damage for each type that will be dealt with this attack
            Dictionary <CombatManager.DamageType, int> damageTypeTotalDamage = new Dictionary <CombatManager.DamageType, int>();
            //Dictionary for if all of the spell damage types for if the damage is completely negated
            Dictionary <CombatManager.DamageType, SpellResistTypes> spellResistDictionary = new Dictionary <CombatManager.DamageType, SpellResistTypes>();

            //Initializing the dictionaries correctly
            this.InitializeDamageDictionaries(damageTypeTotalDamage, spellResistDictionary);

            //Getting the damage from the used weapon
            this.GetWeaponDamage(actingChar, damageTypeTotalDamage, h);

            //Looping through each damage type for this attack
            foreach (AttackDamage atk in this.damageDealt)
            {
                //Int to hold all of the damage for the current attack
                int atkDamage = 0;

                //Adding the base damage
                atkDamage += atk.baseDamage;

                //Looping through each individual die rolled
                for (int d = 0; d < atk.diceRolled; ++d)
                {
                    //Finding the value rolled on the current die
                    atkDamage += Random.Range(1, atk.diceSides);
                }

                //Multiplying the damage by the crit multiplier
                atkDamage = Mathf.RoundToInt(atkDamage * critMultiplier);

                //Looping through the perks of the character that used this ability to see if they have any damage type boost perks
                foreach (Perk charPerk in actingChar.charPerks.allPerks)
                {
                    //If the perk boosts a damage type that's the same as this damage type, we boost it
                    if (charPerk.GetType() == typeof(DamageTypeBoostPerk) && atk.type == charPerk.GetComponent <DamageTypeBoostPerk>().damageTypeToBoost)
                    {
                        atkDamage += charPerk.GetComponent <DamageTypeBoostPerk>().GetDamageBoostAmount(actingChar, isCrit, false, atk.type);
                    }
                }

                //Looping through the defending character's perks to see if they have any spell resist or absorb perks
                foreach (Perk defPerk in defendingChar.charPerks.allPerks)
                {
                    if (defPerk.GetType() == typeof(SpellResistAbsorbPerk))
                    {
                        SpellResistAbsorbPerk resistPerk = defPerk.GetComponent <SpellResistAbsorbPerk>();

                        //Checking to see if the current damage type is the same as this spell resist perk
                        if (resistPerk.typeToResist == atk.type)
                        {
                            //Checking to see if the damage is negated entirely
                            if (resistPerk.negateAllDamage)
                            {
                                //If the resist type for this spell isn't on absorb, we can negate it. ALWAYS have preference to absorb because it heals
                                if (spellResistDictionary[atk.type] != SpellResistTypes.Absorb)
                                {
                                    spellResistDictionary[atk.type] = SpellResistTypes.Negate;
                                }
                            }
                            //Checking to see if the damage is absorbed to heal the target
                            else if (resistPerk.absorbDamage)
                            {
                                spellResistDictionary[atk.type] = SpellResistTypes.Absorb;
                                //Applying the damage reduction so the defender isn't healed as much
                                damageTypeTotalDamage[atk.type] -= resistPerk.GetSpellResistAmount(defendingChar, isCrit, false);
                            }
                            //Otherwise we just get the amount that it normally resists
                            else
                            {
                                damageTypeTotalDamage[atk.type] -= resistPerk.GetSpellResistAmount(defendingChar, isCrit, false);
                            }
                        }
                    }
                }

                //Adding the current attack's damage to the correct type
                damageTypeTotalDamage[atk.type] += atkDamage;
            }

            //Looping through the attacking character's perks to see if there's any bonus damage to add to this attack
            foreach (Perk charPerk in actingChar.charPerks.allPerks)
            {
                //If the perk is a damage boosting perk, we get the bonus damage from it
                if (charPerk.GetType() == typeof(SkillDamageBoostPerk))
                {
                    int perkDamage = charPerk.GetComponent <SkillDamageBoostPerk>().GetDamageBoostAmount(actingChar, isCrit, false);

                    //Applying the perk's added damage to the correct damage type
                    damageTypeTotalDamage[charPerk.GetComponent <SkillDamageBoostPerk>().damageBoostType] += perkDamage;
                }
            }

            //Subtracting the target's melee and spell damage resistance from our attack damage
            this.SubtractResistances(damageTypeTotalDamage, defendingChar);

            //Dealing damage to the target
            this.DealDamage(damageTypeTotalDamage, spellResistDictionary, defendingChar, targetTile_, isCrit);

            //Dealing threat to the target
            this.DealThreat(damageTypeTotalDamage, actingChar, defendingChar, isCrit);

            //Creating the visual effect at the target tile if it isn't null
            if (this.visualEffectOnHit != null)
            {
                GameObject visual = GameObject.Instantiate(this.visualEffectOnHit.gameObject, targetTile_.transform.position, new Quaternion(), CombatManager.globalReference.transform);
            }

            //Looping through each effect that this attack can cause and triggering them
            foreach (AttackEffect effect in this.effectsOnHit)
            {
                this.TriggerEffect(effect, targetTile_, actingChar);
            }
        }
    }