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); } }
// V V V Handles Pull/ Push iniatilation public void SpellPullPush(SpellCreator.SpellAttribute spell, Tile caster, Tile target, Tile mouseTile) { //rajaus rajaa pushin ja pullin liike rataa int rajaus = 0; //side määrittää veto/työntö suunnan Side side; // Chooses what tiles are used in Pull/Push Actions switch (spell.mySpellPullPushType) { case SpellPullPushType.BothTowardsMouse: side = WhichSide(mouseTile, target, spell.isItPull); PullPushMotor(side, spell, target, rajaus); break; case SpellPullPushType.BothTowardsPlayer: side = WhichSide(caster, target, spell.isItPull); PullPushMotor(side, spell, target, rajaus); break; case SpellPullPushType.DiagonalTowardsMouse: rajaus = 1; side = WhichSide(mouseTile, target, spell.isItPull); PullPushMotor(side, spell, target, rajaus); break; case SpellPullPushType.DiagonalTowardsPlayer: rajaus = 1; side = WhichSide(caster, target, spell.isItPull); PullPushMotor(side, spell, target, rajaus); break; case SpellPullPushType.LineTowardsMouse: rajaus = 2; side = WhichSide(mouseTile, target, spell.isItPull); PullPushMotor(side, spell, target, rajaus); break; case SpellPullPushType.LineTowardsPlayer: rajaus = 2; side = WhichSide(caster, target, spell.isItPull); PullPushMotor(side, spell, target, rajaus); break; } }
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); } }
public void SpellWalkToAway(Tile target, Tile caster, SpellCreator.SpellAttribute attribute) { Side side; side = WhichSide(caster, target, attribute.moveTowards); GridController.Directions tempDir = GridController.Directions.none; switch (side) { case Side.up: tempDir = GridController.Directions.up; break; case Side.down: tempDir = GridController.Directions.down; break; case Side.left: tempDir = GridController.Directions.left; break; case Side.right: tempDir = GridController.Directions.right; break; } Tile korjaus = caster; // for luuppi käydään läpi vetojen verran for (int i = 0; i < attribute.movemenPoints; i++) { Tile temp = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, tempDir); if (temp.myType == Tile.BlockType.BaseBlock && temp.CharCurrentlyOnTile == false) { PullPushMove(korjaus, temp, PlayerMovement.MovementMethod.Teleport); korjaus = temp; } else { Debug.Log("wall hit"); break; } } }
// Attribute casting public void CastAttribute(SpellCreator.SpellAttribute spellAttribute, CharacterValues caster, CharacterValues target, Tile currentMouseTile) { // V V V Gets targets and Casters Tile casterTile = gridController.GetTile(caster.currentTile.x, caster.currentTile.z); Tile targetTile = null; if (target == null) { targetTile = currentMouseTile; } else { targetTile = gridController.GetTile(target.currentTile.x, target.currentTile.z); } // V V V Checks the type of attribute and acts accordinly switch (spellAttribute.attributeType) { // V V V Damage attribute case SpellCreator.SpellAttribute.AttributeType.damage: int damageStuff = 0; if (spellAttribute.hurtsAlly == true || spellAttribute.hurtsAlly == false && target.team != caster.team) { damageStuff = spellCalculators.TrueDamageCalculator(spellAttribute.spellDamageMax, spellAttribute.spellDamageMin, caster.damageChange, target.armorChange, caster.damagePlus, target.armorPlus); spellCalculators.GetHit(target, damageStuff); } break; // V V V Heal attribute case SpellCreator.SpellAttribute.AttributeType.heal: int healingIsFun = 0; if (target.team == caster.team || spellAttribute.healsAll == true) { if (spellCalculators == null) { Debug.Log("calulator is shit"); } healingIsFun = spellCalculators.TrueHealCalculator(spellAttribute.spellHealMax, spellAttribute.spellHealMin, target.healsReceived); spellCalculators.GetHealed(target, healingIsFun); } break; // V V V Steal attribute case SpellCreator.SpellAttribute.AttributeType.steal: int steal = 0; if (spellAttribute.stealHurtsAlly == true || spellAttribute.stealHurtsAlly == false && target.team != caster.team) { steal = spellCalculators.TrueDamageCalculator(spellAttribute.stealDamageMax, spellAttribute.stealDamageMin, caster.damageChange, target.armorChange, caster.damagePlus, target.armorPlus); spellCalculators.GetHit(target, steal); spellCalculators.GetHealed(caster, Mathf.RoundToInt(steal / 2)); } break; // V V V Effect attribute case SpellCreator.SpellAttribute.AttributeType.effect: if (spellAttribute.effectOnTarget == true && target != caster) { ////////sEffects.ApplyEffect(caster, effect, target); } if (spellAttribute.effectOnCaster == true && target == caster) { //////////sEffects.ApplyEffect(caster, effect, target); } break; // V V V Pull or Push attribute case SpellCreator.SpellAttribute.AttributeType.pullpush: spellFormulaes.SpellPullPush(spellAttribute, casterTile, targetTile, currentMouseTile); break; // V V V Other Manipulation attribute case SpellCreator.SpellAttribute.AttributeType.walk: spellFormulaes.SpellWalkToAway(currentMouseTile, casterTile, spellAttribute); break; case SpellCreator.SpellAttribute.AttributeType.teleport: if (spellAttribute.switchWithTarget == true) { Debug.Log("f**k the what"); spellFormulaes.TeleportSwitch(casterTile, targetTile); } if (spellAttribute.switchWithTarget == false) { Debug.Log("what the f**k"); spellFormulaes.CasterTeleport(casterTile, currentMouseTile); } break; } }
// V V V Pull/Push methods motor public void PullPushMotor(Side tempSide, SpellCreator.SpellAttribute attribute, Tile start, int rajaaja) { // korjaus on temp tile Tile korjaus = start; //korjaus.locX = start.locX; //korjaus.locZ = start.locZ; // tempdir ja helpdir ovat tilapäisiä suuntia joilla ohjataan tarkistuksia GridController.Directions tempDir = GridController.Directions.none; GridController.Directions helpDir = GridController.Directions.none; // inline määrittää onko veto lineaarinen [+] vai diagonaalinen [X] bool inline = true; switch (tempSide) { case Side.up: tempDir = GridController.Directions.down; break; case Side.down: tempDir = GridController.Directions.up; break; case Side.left: tempDir = GridController.Directions.right; break; case Side.right: tempDir = GridController.Directions.left; break; case Side.upLeft: tempDir = GridController.Directions.down; helpDir = GridController.Directions.right; inline = false; break; case Side.upRight: tempDir = GridController.Directions.down; helpDir = GridController.Directions.left; inline = false; break; case Side.downLeft: tempDir = GridController.Directions.up; helpDir = GridController.Directions.right; inline = false; break; case Side.downRight: tempDir = GridController.Directions.up; helpDir = GridController.Directions.left; inline = false; break; } // kun veto on lineaarinen if (inline == true) { if (rajaaja == 0 || rajaaja == 2) { // for luuppi käydään läpi vetojen verran for (int i = 0; i < attribute.spellPullPush; i++) { Tile temp = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, tempDir); if (temp.myType == Tile.BlockType.BaseBlock && temp.CharCurrentlyOnTile == false) { PullPushMove(korjaus, temp, PlayerMovement.MovementMethod.Teleport); korjaus = temp; } else { Debug.Log("wall hit"); break; } } } } else { if (rajaaja == 0 || rajaaja == 1) { for (int i = 0; i < attribute.spellPullPush; i++) { Tile temp1 = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, tempDir); Tile temp2 = gridController.GetTileInDirection(gridController.GetTile(korjaus.locX, korjaus.locZ), 1, helpDir); Tile temp3 = gridController.GetTileInDirection(gridController.GetTile(temp1.locX, temp1.locZ), 1, helpDir); if (temp1.myType == Tile.BlockType.BaseBlock && temp1.CharCurrentlyOnTile == false && temp2.myType == Tile.BlockType.BaseBlock && temp2.CharCurrentlyOnTile == false && temp3.myType == Tile.BlockType.BaseBlock && temp3.CharCurrentlyOnTile == false) { PullPushMove(korjaus, temp3, PlayerMovement.MovementMethod.Teleport); korjaus = temp3; //item.locX = temp3.locX; //item.locZ = temp3.locZ; } else { break; } } } } inline = true; }