public override void UseAbility(Unit host, Vector3Int targetPosInt) { base.UseAbility(host, targetPosInt); if (canUseAbility || host is AIEnemy) { if (host is AIEnemy) { OverlayProperties properties = new OverlayProperties(); properties.canUseAbility = host.unitData.stats.Ap > apCost; properties.canSelfCastOnly = canCastSelfOnly; properties.canCastOnFriendlies = canCastOnFriendlies; properties.canDamageFriendlies = canDamageFriendlies; Tuple <OverlayProperties, Ability> tuple = new Tuple <OverlayProperties, Ability>(properties, this); GridManager.DrawRangeOverlay(OverlayType.Diamond, area, targetPosInt, tuple.Item1, host); } if (abilityEffect != null) { GameObject go = Instantiate(abilityEffect, GridManager.GetTileToCellFromWorld(targetPosInt), Quaternion.identity); Destroy(go, 1f); } SetAnimationClip(host, AnimationManager.aoeTrigger); AreaDamage(GridManager.GetUnitsInRange()); if (host is AIEnemy) { GridManager.RangeOverlayTiles.Clear(); } } }
/// <summary> /// This method sets the properties of the STATIC overlay. This will ensure that the correct tiles are shown on the grid depending on the effect the spell has on different units. /// </summary> /// <param name="overlayType"></param> /// <param name="range"></param> /// <param name="op"></param> public static void DrawRangeOverlay(OverlayType overlayType, int range, Vector3Int currentMousePosition, OverlayProperties op, Unit unit = null) { overlayProperties = op; switch (overlayType) { case OverlayType.Cross: DrawCrossOverlay(currentMousePosition, range); break; case OverlayType.Diamond: DrawDiamondOverlay(currentMousePosition, range); break; case OverlayType.Square: DrawSquareOverlay(currentMousePosition, range); break; case OverlayType.Self: DrawSelfOverlay(currentMousePosition); break; default: break; } if (overlayType != OverlayType.Self && unit == null) { if (floorsTilemap.HasTile(currentMousePosition)) { DrawRangeOverlay(currentMousePosition); } } }
/// <summary> /// This method sets the properties of the REALTIME overlay. This will ensure that the correct tiles are shown on the grid depending on the effect the spell has on different units. /// </summary> /// <param name="overlayType"></param> /// <param name="range"></param> /// <param name="op"></param> public static void DrawRealtimeOverlay(OverlayType overlayType, int range, OverlayProperties op) { overlayProperties = op; realtimeOverlay.isEnabled = true; realtimeOverlay.overlayType = overlayType; realtimeOverlay.range = range; }
private OverlayProperties SetProperties(OverlayProperties properties, bool ability, params bool[] conditions) { properties.canUseAbility = ability; properties.canSelfCastOnly = conditions[0]; properties.canCastOnFriendlies = conditions[1]; properties.canDamageFriendlies = conditions[2]; return(properties); }
private Tuple <OverlayProperties, Ability> GetOverlay(OverlayProperties properties, Unit unit, Ability ab, bool ability) { ability = false; if (unit.unitData.stats.Ap >= ab.apCost) { ability = true; } properties = SetProperties(properties, ability, ab.canCastSelfOnly, ab.canCastOnFriendlies, ab.canDamageFriendlies); return(Tuple.Create(properties, ab)); }
public override void UseAbility(Unit host, Vector3Int targetPosInt) { base.UseAbility(host, targetPosInt); if (canUseAbility || host is AIEnemy) { SetAnimationClip(host, AnimationManager.spellTrigger); OverlayProperties properties = new OverlayProperties(); properties.canUseAbility = host.unitData.stats.Ap > apCost; properties.canSelfCastOnly = canCastSelfOnly; properties.canCastOnFriendlies = canCastOnFriendlies; properties.canDamageFriendlies = canDamageFriendlies; Tuple <OverlayProperties, Ability> tuple = new Tuple <OverlayProperties, Ability>(properties, this); //if (host is AIEnemy) GridManager.ClearTiles(); GridManager.DrawRangeOverlay(OverlayType.Cross, range - 1, targetPosInt, tuple.Item1, host); List <Unit> units = GridManager.GetUnitsInRange(); if (host is AIEnemy) { GridManager.RangeOverlayTiles.Clear(); } List <Unit> ToRemove = new List <Unit>(); foreach (var unit in units) { if (host.positionGrid.x == targetPosInt.x) { if (unit.positionGrid.y == targetPosInt.y) { ToRemove.Add(unit); } } else if (host.positionGrid.y == targetPosInt.y) { if (unit.positionGrid.x == targetPosInt.x) { ToRemove.Add(unit); } } } foreach (var item in ToRemove) { units.Remove(item); } if (UnitManager.Instance.unitDictionnary.ContainsKey(targetPosInt)) { units.Add(UnitManager.Instance.unitDictionnary[targetPosInt]); } if (units.Contains(host)) { units.Remove(host); } AreaDamage(units); if (abilityEffect != null) { GameObject go = Instantiate(abilityEffect, GridManager.GetTileToCellFromWorld(host.positionGrid), Quaternion.identity); go.AddComponent <MoveLineAbility>().end = targetPosInt; } } }