void FixedUpdate() { if (center != null) { transform.position += (center.position - lastCenter); transform.RotateAround(center.position, Vector3.up, rotationSpeed * Time.deltaTime); transform.rotation = Quaternion.identity; lastCenter = center.position; } else if (destroyController != null) { destroyController.Destroy(); } }
public IEnumerator ExecuteMove(HexPosition target) { switch (unit) { case UnitType.Sword: SFXController.PlayMove(); Board.Get[target].unit = unit; Board.Get[target].alerted = false; unit = UnitType.Empty; alerted = false; AlertNeighbors(target); var directions = ((HexDirection[])Enum.GetValues(typeof(HexDirection))).Where(x => { var neighbor = position.Neighbor(x); return(neighbor.Equals(target)); }); yield return(new WaitForSeconds(0.3f)); if (directions.Any()) { var stabTile = Board.Get[target.Neighbor(directions.Single())]; if (stabTile.Friendliness != Friendliness.Neutral) { SFXController.PlayFire(); yield return(DestroyController.Destroy(stabTile)); yield return(new WaitForSeconds(0.3f)); } } break; case UnitType.Arrow: SFXController.PlayFire(); yield return(new WaitForSeconds(0.3f)); var direction = ((HexDirection[])Enum.GetValues(typeof(HexDirection))) .Where(x => position.Neighbors(x).Contains(target)) .Single(); var tile = Board.Get[position.Neighbor(direction)]; while (tile.position.IsInBounds && tile.Friendliness == Friendliness.Neutral) { tile = Board.Get[tile.position.Neighbor(direction)]; } if (tile.position.IsInBounds) { yield return(DestroyController.Destroy(tile)); } yield return(new WaitForSeconds(0.5f)); alerted = true; break; case UnitType.Shield: SFXController.PlayMove(); Board.Get[target].unit = unit; Board.Get[target].alerted = true; unit = UnitType.Empty; alerted = false; AlertNeighbors(target); yield return(new WaitForSeconds(0.3f)); break; } yield return(YieldFast.Get); }