public void addWaypoint(Vector3 movement, UnitControlMovement.OriginDirection direction)
    {
        if (Waypoint.Count >= 1)
        {
            Vector3 lastWaypoint = (Vector3)Waypoint [Waypoint.Count - 1];
            if (lastWaypoint.y != movement.y)
            {
                Vector3 travelchange = (movement - lastWaypoint).normalized * 0.4f;
                Vector3 prechangey   = lastWaypoint + travelchange;
                Vector3 postchangey  = movement - travelchange;
                Waypoint.Add(prechangey);
                Waypoint.Add(postchangey);
                Waypoint.Add(movement);

//				Debug.Log(prechangey);
//				Debug.Log(postchangey);

                addWaypointD(direction);
                addWaypointD(direction);
                addWaypointD(direction);
            }
            else
            {
                Waypoint.Add(movement);
                addWaypointD(direction);
            }
        }
        else
        {
            Waypoint.Add(movement);
            addWaypointD(direction);
        }
    }
    public static UnitRotationStatus OppositeRotationStatus(UnitControlMovement.OriginDirection rotation)
    {
        switch (rotation)
        {
        case UnitControlMovement.OriginDirection.E:
            return(UnitRotationStatus.W);

        case UnitControlMovement.OriginDirection.W:
            return(UnitRotationStatus.E);

        case UnitControlMovement.OriginDirection.S:
            return(UnitRotationStatus.N);

        case UnitControlMovement.OriginDirection.N:
            return(UnitRotationStatus.S);
        }

        return((UnitRotationStatus)rotation);
    }
 private void addWaypointD(UnitControlMovement.OriginDirection direction)
 {
     WaypointD.Add(OppositeRotationStatus(direction));
 }
    public void addWaypoint(Vector2 movement, UnitControlMovement.OriginDirection direction)
    {
        int        x                = (int)movement.x;
        int        y                = (int)movement.y;
        TileSelect tile             = PlayMap.Grid.getTileSpec(x, y);
        float      height           = tile.FloorHeight;
        bool       terrainDependent = true;

        if (UnitBodySpec.getUnitMovementType() == UnitSpec.UnitMove.Fly ||
            UnitBodySpec.getUnitMovementType() == UnitSpec.UnitMove.Sail ||
            UnitBodySpec.getUnitMovementType() == UnitSpec.UnitMove.Dive ||
            UnitBodySpec.getUnitMovementType() == UnitSpec.UnitMove.Heli)
        {
            terrainDependent = false;
        }

        if (terrainDependent)
        {
            // Hover units
            if (UnitBodySpec.getUnitMovementType() == UnitSpec.UnitMove.Float)
            {
                switch (tile.FloorType)
                {
                case TileSelect.TileMovementType.Mountain:
                    terrainStatus = UnitTerrainStatus.HighFloat;
                    break;

                default:
                    terrainStatus = UnitTerrainStatus.Float;
                    break;
                }
                if (height < 0.2f)
                {
                    height = 0.25f;
                }
                else
                {
                    height += 0.05f;
                }
            }            // Ground units
            else
            {
                switch (tile.FloorType)
                {
                case TileSelect.TileMovementType.Concrete:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.DeepWater:
                    terrainStatus = UnitTerrainStatus.Water;
                    break;

                case TileSelect.TileMovementType.Hill:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.Normal:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.Obstructed:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.Sand:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.DeepBridge:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.ShallowBridge:
                    terrainStatus = UnitTerrainStatus.Land;
                    break;

                case TileSelect.TileMovementType.ShallowWater:
                    terrainStatus = UnitTerrainStatus.Water;
                    break;

                case TileSelect.TileMovementType.Mountain:
                    terrainStatus = UnitTerrainStatus.High;
                    break;
                }
            }
        }
        else          // Sea and Air units
        {
            switch (terrainStatus)
            {
            case UnitTerrainStatus.Air:
                height = 0.5f;
                break;

            case UnitTerrainStatus.Deep:
                height = 0.15f;
                break;

            case UnitTerrainStatus.Water:
                height = 0.2f;
                break;
            }
        }

        addWaypoint(new Vector3(movement.x + 0.5f, height, movement.y + 0.5f), direction);
    }