public virtual void UnitCreated(HexCell cell, CardManager owner, int health) { Cell = cell; Owner = owner; Health = health; cell.AddUnit(this); }
public void Travel(List <HexCell> path) { location.RemoveUnit(this); if (unit.IsSomethingToAttack()) { location = path[path.Count - 2]; } else { location = path[path.Count - 1]; } location.AddUnit(this); pathToTravel = path; StopAllCoroutines(); StartCoroutine(TravelPath()); }
//processes one tile worth of movement for the unit. returns true if it should be called immediately again public bool DoMove() { if (movementRemaining <= 0) { Debug.Log("Unit out of movement."); return(false); } if (currentPath == null || currentPath.Count <= 0) { Debug.Log("Unit finished path."); return(false); } HexCell leavingCell = currentPath[0]; HexCell newCell = currentPath[1]; int costToEnterNewCell = newCell.MovementCost; leavingCell.RemoveUnit(this); currentPath.RemoveAt(0); if (currentPath.Count == 1) { //only hex left, so we have arrived. currentPath.Clear(); currentPath = null; } location = newCell; location.AddUnit(this); pathTraveledThisTurn.Add(location); movementRemaining = Mathf.Max(movementRemaining - costToEnterNewCell, 0); return(currentPath != null && movementRemaining > 0); }
public virtual void UnitMoveTo(HexCell cell) { Cell.RemoveUnit(this); cell.AddUnit(this); Cell = cell; }