Advertisement
Guest User

/Write Direction.cs

a guest
Oct 7th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace fCraft
  7. {
  8.     public enum Direction
  9.     {
  10.         Null,
  11.         one,
  12.         two,
  13.         three,
  14.         four
  15.     }
  16.     public class DirectionFinder
  17.     {
  18.        
  19.         public static Direction GetDirection(Vector3I[] marks)
  20.         {
  21.             if (Math.Abs(marks[1].X - marks[0].X) > Math.Abs(marks[1].Y - marks[0].Y))
  22.             {
  23.                 if (marks[0].X < marks[1].X)
  24.                 {
  25.                     return Direction.one;
  26.                 }
  27.                 else
  28.                 {
  29.                     return Direction.two;
  30.                 }
  31.             }
  32.             else if (Math.Abs(marks[1].X - marks[0].X) < Math.Abs(marks[1].Y - marks[0].Y))
  33.             {
  34.                 if (marks[0].Y < marks[1].Y)
  35.                 {
  36.                     return Direction.three;
  37.                 }
  38.                 else
  39.                 {
  40.                     return Direction.four;
  41.                 }
  42.             }
  43.             else
  44.                 return Direction.Null;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement