public void DrawPath() { Cell destination = null; if (CurrentRange.Contains(MouseToCell())) { if (arrow != null) { ClearDrawnPath(); } arrow = new List <Cell>(); destination = MouseToCell(); } else { return; } CurrentPath = QPath.FindPath(Fighter, Map.UnitTile(Fighter), destination, Cell.EstimateDistance); if (CurrentPath.Length == 1) { return; } foreach (Cell c in CurrentPath) { GameObject a = null; if (!ObjectPool.ContainsKey("arrow") || ObjectPool.GetFirstInactiveObject("arrow") == null) { a = Instantiate(arrowPrefab, new Vector3(c.position.x, c.position.y), Quaternion.identity); } else { a = ObjectPool.GetFirstInactiveObject("arrow"); } ArrowDisplay display = a.GetComponent <ArrowDisplay>(); arrow.Add(display); display.layer = arrowLayer; Map.Add(display, arrowLayer, true); a.GetComponent <SpriteRenderer>().enabled = false; a.transform.position = new Vector3(c.position.x, c.position.y); a.SetActive(true); display.AssignSprite(); a.GetComponent <SpriteRenderer>().enabled = true; ObjectPool.AddToPool("arrow", a); } }
void OnLeftClick() { if (ActionMenu.Selection == ActionMenu.SelectionState.closed) { if (Fighter == null) { Cell cell = MouseToCell(); Selected = cell; startCell = Selected; if (cell != null && cell.unitInTile != null && cell.unitInTile.Unit.alignment == Unit.Alignment.Player && !cell.unitInTile.TurnOver) { Fighter = Map.GetCellData(Selected.position).unitInTile; //ClearHighlightedArea(); DoHighlights(Fighter, CurrentRange.ToArray(), true, 0.01f); } } else if (Fighter != null && CurrentRange.Contains(MouseToCell())) { pathApplied = true; Selected = MouseToCell(); MovementUsed = Map.AggregateCost(QPath.FindPath(Fighter, startCell, Selected, Cell.EstimateDistance), Fighter.Unit); } } else if (ActionMenu.Selection == ActionMenu.SelectionState.target) { if (ActionMenu.CanSelect) { SelectTarget(); } else { ActionMenu.CanSelect = true; } } }