// Casting the spell
        public void CastSpell(SpellCreator spell, CharacterValues caster, Tile currentMouseTile)
        {
            playerBehaviour.aControll.PlayAttack(caster);
            playerBehaviour.aControll.PlaySpell(spell);
            Tile casterTile = gridController.GetTile(caster.currentTile.x, caster.currentTile.z);
            Tile targetTile = currentMouseTile;
            //Tile temp1 = gridController.GetTile(caster.currentTile.x,caster.currentTile.z);
            //Tile temp2 = gridController.GetTile(target.currentTile.x,target.currentTile.z);

            // V V V gets a list of tiles in AOE
            List <Tile> targetsList = spellHandler.AreaType(spell.areaType);

            // V V V goes through every attribute in the spells attribute list
            foreach (var temp in spell.spellArvot)
            {
                // V V V i need to make stuff here for attributes that dont need target and are single use
                if (temp.isSingleUse == true)
                {
                    TargetChecker(spell, temp, caster, currentMouseTile, currentMouseTile);
                }
                else
                {
                    foreach (var item in targetsList)
                    {
                        TargetChecker(spell, temp, caster, currentMouseTile, item);
                    }
                }
            }
            // V V V update UI and cooldowns
            spellCalculators.HandleCoolDownIncrease(spell);
            spellButtons.UpdateHpApMp();
        }
 // handles cooldown increase <-- are you even trying
 public void HandleCoolDownIncrease(SpellCreator spell)
 {
     if (spell.spellCastPerturn != 0)
     {
         spell.spellCastPerturncounter++;
     }
     if ((spell.spellCastPerturncounter >= spell.spellCastPerturn && spell.spellCastPerturn != 0) || spell.spellCooldown > 0)
     {
         spell.spellCooldownLeft = spell.spellCooldown;
     }
 }
Example #3
0
 public bool CastNoTargetNeeded(SpellCreator spell, SpellCreator.SpellAttribute attribute)
 {
     if (attribute.attributeType == SpellCreator.SpellAttribute.AttributeType.walk || attribute.attributeType == SpellCreator.SpellAttribute.AttributeType.teleport && attribute.switchWithTarget == false)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        // handles cooldown decrease <-- oh REALLY. i would have never guessed
        public void HandleCooldownDecrease(SpellCreator spell)
        {
            if (spell.spellInitialCooldowncounter > 0)
            {
                spell.spellInitialCooldowncounter--;
            }

            if (spell.spellCooldownLeft > 0)
            {
                spell.spellCooldownLeft--;
            }


            spell.spellCastPerturncounter = 0;
        }
Example #5
0
        public List <CharacterValues> TargetChecker(SpellCreator currentSpell)
        {
            List <Tile>            targetTileList = spellHandler.AreaType(currentSpell.areaType);
            List <CharacterValues> targetList     = new List <CharacterValues>();

            foreach (var item in targetTileList)
            {
                PlayerInfo      checker = item.CharCurrentlyOnTile;
                CharacterValues target  = null;
                if (checker)
                {
                    target = checker.thisCharacter;
                    targetList.Add(target);
                }
            }
            return(targetList);
        }
        public void TargetChecker(SpellCreator spell, SpellCreator.SpellAttribute spellAttribute, CharacterValues caster, Tile currentMouseTile, Tile item)
        {
            bool iNeedThis = spellChecker.CastNoTargetNeeded(spell, spellAttribute);
            // V V V checks if tile has a player
            PlayerInfo      checker = item.CharCurrentlyOnTile;
            CharacterValues target  = null;

            if (checker)
            {
                target = checker.thisCharacter;
            }

            // V V V cast the attribute if player is on tile
            if (target || iNeedThis == true)
            {
                CastAttribute(spellAttribute, caster, target, currentMouseTile);
            }
        }
Example #7
0
 // canceling spells
 public void SpellCancel()
 {
     if (mc.rangeTiles != null)
     {
         mc.ResetTileMaterials(mc.rangeTiles);
         mc.rangeTiles = null;
     }
     if (mc.nullTiles != null)
     {
         mc.ResetTileMaterials(mc.nullTiles);
         mc.nullTiles = null;
     }
     if (mc.targetedTiles != null)
     {
         mc.ResetTileMaterials(mc.targetedTiles);
         mc.targetedTiles = null;
     }
     currentSpell = null;
     spellOpen    = false;
 }
Example #8
0
        public bool TargetInRangeCheck(SpellCreator spell, Tile target)
        {
            //// ---------------------- nämä conflictas, muut oli ok -------------------------
            List <Tile> range   = spellHandler.RangeType(spell.rangeType, false);
            bool        correct = false;

            foreach (var temp in range)
            {
                if (temp == target)
                {
                    correct = true;
                }
            }
            if (correct == false)
            {
                return(false);
            }
            //// --------------------- Pasta carbonara on hyvää vai mitä ---------------------
            return(true);
        }
Example #9
0
 // Checks spell Cast rules and are they fullfilled
 public bool CheckCastability(SpellCreator spell, Tile target)
 {
     if (TargetInRangeCheck(spell, target) == false)
     {
         return(false);
     }
     if (playerBehaviour.currentCharacter.currentAp < spell.spellApCost)
     {
         return(false);
     }
     if (spell.needTarget == true && target.CharCurrentlyOnTile == false)
     {
         return(false);
     }
     if (spell.needFreeSquare == true && target.CharCurrentlyOnTile == true)
     {
         return(false);
     }
     if (SpellCooldownCheck(spell) == false)
     {
         return(false);
     }
     return(true);
 }
 // resets cooldown calculators to default values
 public void HandleCooldownReset(SpellCreator spell)
 {
     spell.spellInitialCooldowncounter = spell.spellInitialCooldown;
     spell.spellCooldownLeft           = 0;
     spell.spellCastPerturncounter     = 0;
 }
 void OnEnable()
 {
     creto     = (SpellCreator)target;
     GetTarget = new SerializedObject(creto);
     attriList = GetTarget.FindProperty("spellArvot"); // Find the List in our script and create a refrence of it
 }
Example #12
0
 public void Spell4Cast()
 {
     SpellCancel();
     currentSpell = cv.spell_4;
     spellOpen    = true;
 }