public Cell GetCellToCastSpell(TargetCell target, Spell spell, bool LoS, bool nearFirst = true) { var moveZone = GetMoveZone(); Set castRange; if (spell.CurrentSpellLevel.CastInLine || spell.CurrentSpellLevel.CastInDiagonal) { castRange = new CrossSet(target.Point, Fighter.GetSpellRange(spell.CurrentSpellLevel), spell.CurrentSpellLevel.MinRange != 0 ? (int)spell.CurrentSpellLevel.MinRange : CellInformationProvider.IsCellWalkable(target.Cell.Id) ? 0 : 1) { Diagonal = spell.CurrentSpellLevel.CastInDiagonal, AllDirections = spell.CurrentSpellLevel.CastInLine && spell.CurrentSpellLevel.CastInDiagonal } } ; else { castRange = new LozengeSet(target.Point, Fighter.GetSpellRange(spell.CurrentSpellLevel), spell.CurrentSpellLevel.MinRange != 0 ? (int)spell.CurrentSpellLevel.MinRange : CellInformationProvider.IsCellWalkable(target.Cell.Id) ? 0 : 1); } var intersection = castRange.EnumerateValidPoints().Intersect(moveZone); var closestPoint = intersection.Where(x => Fight.Cells[x.CellId].Walkable && (target.Direction == DirectionFlagEnum.ALL_DIRECTIONS || target.Direction == DirectionFlagEnum.NONE || (x.OrientationTo(target.Point).GetFlag() & target.Direction) != 0) && (!LoS || Fight.CanBeSeen(x, MapPoint.GetPoint(target.Cell), false, Fighter))). OrderBy(x => (nearFirst ? 1 : -1) * x.ManhattanDistanceTo(Fighter.Position.Point)).FirstOrDefault(); return(closestPoint != null ? Fighter.Fight.Cells[closestPoint.CellId] : null); }
public TargetColumn() { CellTemplate = new TargetCell() { TargetColumn = this }; }
public override object Clone() { TargetCell targetCell = (TargetCell)base.Clone(); targetCell.TargetColumn = TargetColumn; return(targetCell); }
static ProbableWord MakeAWord(List <Word> F1, Word C, List <Word> F2) { ProbableWord W = new ProbableWord(); List <TargetCell> List = new List <TargetCell>(); string ret = ""; foreach (Word s in F1) { ret = ret + s.Tiles.Replace(",", "") + ","; TargetCell Cell = new TargetCell { Target = s.Tiles, Index = s.Index }; List.Add(Cell); } { ret = ret + C.Tiles.Replace(",", "") + ","; TargetCell Cell = new TargetCell { Target = C.Tiles, Index = C.Index }; List.Add(Cell); } foreach (Word s in F2) { ret = ret + s.Tiles.Replace(",", "") + ","; TargetCell Cell = new TargetCell { Target = s.Tiles, Index = s.Index }; List.Add(Cell); } ret = ret.Trim(','); W.String = ret; W.Cells = List; return(W); }
public override void Success() { TargetCell.Explore(); base.Success(); var plan = new ReturnToNestPlan(Player, Ants); Player.Planer.TryToAddPlan(plan); }
//Vector2 _attPos; #endregion #region Gameflow #endregion #region Functions public void DecideAction(ChrController unit) { _curUnit = unit; if (unit._turn < 200) { _target = AStarPathfinding.Instance.FindRandomTarget(); if (_curUnit._AIPattern == ChrController.AIPatterns.Guard && _target == null) { Invoke("DecideActionDelay", _delay * 0.5f); } else { Invoke("DecideActionDelay", _delay); } } }
private void Target_ActivatedChanged(TargetCell obj) { if (obj.Activated) { Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = CellSize, Color = obj is IColor colorObj?MirrorDrawing.GetColor(colorObj.Color) : Colors.Black, ShadowDepth = 0, Opacity = 1, RenderingBias = System.Windows.Media.Effects.RenderingBias.Quality, }; } else { ClearValue(EffectProperty); } }
private void UpdateTargetCell() { Vector2Int newCell = _grid.GetCell(transform.position); if (TargetCell.Equals(newCell)) { return; } TargetCell = newCell; TargetValid = _grid.IsValidCell(TargetCell); onTargetCellChange?.Invoke(this, new GrabData { Cell = TargetCell, Position = _grid.GetPosition(TargetCell), Valid = TargetValid }); }
public override void Execute() { var cell = (TargetCell as EnviromentCellData); if (cell == null || cell.Source == null || cell.Source.IsDepleted) { Fail(); return; } if (Ants.Position != TargetCell) { MoveToTarget(); return; } TargetCell.Explore(); if (!cell.IsGatherable) { if (isGathered) { Success(); } else { Fail(); } return; } isGathered = true; var source = cell.Source; var power = Player.Anter.CalculateGatherPower(Ants); var amount = source.Gather(power); Player.Resourcer.Store(source.ResourceType, amount); if (source.IsDepleted) { Success(); } }
public override void Execute() { if (Ants.Position != TargetCell) { MoveToTarget(); return; } var tg = (TargetCell as EnviromentCellData); if (tg != null) { TargetCell.Explore(); Success(); return; } Fail(); }