static int GetRange(SpellDto spellDto, SpellRangeType rangeType) { switch (rangeType) { case SpellRangeType.DistanceFeet: case SpellRangeType.SelfPlusFeetLine: case SpellRangeType.DistanceMiles: case SpellRangeType.SelfPlusFlatRadius: case SpellRangeType.SelfPlusSphereRadius: case SpellRangeType.SelfPlusCone: case SpellRangeType.SelfPlusCube: return(spellDto.range.GetFirstInt()); } return(0); }
public bool HasRange(int value, SpellRangeType spellRangeType) { return(Range == value && RangeType == spellRangeType); }
// Makes a list of Tiles on Spells range public List <Tile> RangeType(SpellRangeType mySpellRangeType, bool kumpitile) { List <Tile> rangetiles = new List <Tile>(); List <Tile> returnables = new List <Tile>(); int i = spellButtons.currentSpell.rangeMin; int x = spellButtons.currentSpell.rangeMin; if (i == 0 && spellButtons.currentSpell.rangeType != SpellRangeType.Normal) { rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile)); i++; x++; } switch (mySpellRangeType) { case SpellRangeType.Diagonal: for (i = x; i <= spellButtons.currentSpell.rangeMax; i++) { rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + i, playerBehaviour.currentCharacter.currentTile.z + i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + i, playerBehaviour.currentCharacter.currentTile.z - i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x - i, playerBehaviour.currentCharacter.currentTile.z + i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x - i, playerBehaviour.currentCharacter.currentTile.z - i)); } break; case SpellRangeType.Linear: for (i = x; i <= spellButtons.currentSpell.rangeMax; i++) { rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x, playerBehaviour.currentCharacter.currentTile.z + i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + i, playerBehaviour.currentCharacter.currentTile.z)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x, playerBehaviour.currentCharacter.currentTile.z - i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x - i, playerBehaviour.currentCharacter.currentTile.z)); } break; case SpellRangeType.Normal: List <Tile> badTiles = new List <Tile>(); if (spellButtons.currentSpell.rangeMin != 0) { List <Tile> tempo = new List <Tile>(); for (int z = 0 - spellButtons.currentSpell.rangeMin; z < spellButtons.currentSpell.rangeMin; z++) { for (int j = 0 - spellButtons.currentSpell.rangeMin; j <= spellButtons.currentSpell.rangeMin; j++) { if (Mathf.Abs(z) + Mathf.Abs(j) < spellButtons.currentSpell.rangeMin) { tempo.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + j, playerBehaviour.currentCharacter.currentTile.z + z)); } } } foreach (var tile in tempo) { if (tile != null) { badTiles.Add(tile); } } } for (i = 0 - spellButtons.currentSpell.rangeMax; i <= spellButtons.currentSpell.rangeMax; i++) { for (int j = 0 - spellButtons.currentSpell.rangeMax; j <= spellButtons.currentSpell.rangeMax; j++) { if (Mathf.Abs(i) + Mathf.Abs(j) <= spellButtons.currentSpell.rangeMax) { rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + j, playerBehaviour.currentCharacter.currentTile.z + i)); } } } foreach (var tile in rangetiles) { if (tile != null) { if (spellButtons.currentSpell.needLineOfSight == true) { if (kumpitile == false) { if (lOS.LoSCheck(gridController.GetTile(playerBehaviour.currentCharacter.currentTile), tile) == true) { if (badTiles != null) { bool isOk = true; foreach (var item in badTiles) { if (gridController.GetTile(item.locX, item.locZ) == gridController.GetTile(tile.locX, tile.locZ)) { isOk = false; } } if (tile.myType == Tile.BlockType.BaseBlock && isOk == true) { returnables.Add(tile); } } else { if (tile.myType == Tile.BlockType.BaseBlock) { returnables.Add(tile); } } } } else { if (lOS.LoSCheck(gridController.GetTile(playerBehaviour.currentCharacter.currentTile), tile) == false) { if (badTiles != null) { bool isOk = true; foreach (var item in badTiles) { if (gridController.GetTile(item.locX, item.locZ) == gridController.GetTile(tile.locX, tile.locZ)) { isOk = false; } } if (tile.myType == Tile.BlockType.BaseBlock && isOk == true) { returnables.Add(tile); } } else { if (tile.myType == Tile.BlockType.BaseBlock) { returnables.Add(tile); } } } } } else { if (badTiles != null) { bool isOk = true; foreach (var item in badTiles) { if (gridController.GetTile(item.locX, item.locZ) == gridController.GetTile(tile.locX, tile.locZ)) { isOk = false; } } if (tile.myType == Tile.BlockType.BaseBlock && isOk == true) { returnables.Add(tile); } } else { if (tile.myType == Tile.BlockType.BaseBlock) { returnables.Add(tile); } } } } } break; case SpellRangeType.LinDiag: for (i = x; i <= spellButtons.currentSpell.rangeMax; i++) { rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x, playerBehaviour.currentCharacter.currentTile.z + i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + i, playerBehaviour.currentCharacter.currentTile.z)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x, playerBehaviour.currentCharacter.currentTile.z - i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x - i, playerBehaviour.currentCharacter.currentTile.z)); } for (i = x; i <= spellButtons.currentSpell.rangeMax; i++) { rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + i, playerBehaviour.currentCharacter.currentTile.z + i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x + i, playerBehaviour.currentCharacter.currentTile.z - i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x - i, playerBehaviour.currentCharacter.currentTile.z + i)); rangetiles.Add(gridController.GetTile(playerBehaviour.currentCharacter.currentTile.x - i, playerBehaviour.currentCharacter.currentTile.z - i)); } break; default: break; } if (spellButtons.currentSpell.rangeType != SpellRangeType.Normal) { foreach (var tile in rangetiles) { if (tile != null) { if (spellButtons.currentSpell.needLineOfSight == true) { if (kumpitile == false) { if (lOS.LoSCheck(gridController.GetTile(playerBehaviour.currentCharacter.currentTile), tile) == true) { if (tile.myType == Tile.BlockType.BaseBlock) { returnables.Add(tile); } } } else { if (lOS.LoSCheck(gridController.GetTile(playerBehaviour.currentCharacter.currentTile), tile) == false) { if (tile.myType == Tile.BlockType.BaseBlock) { returnables.Add(tile); } } } } else if (tile.myType == Tile.BlockType.BaseBlock) { returnables.Add(tile); } } } } return(returnables); }