Ejemplo n.º 1
0
 private void SetDirection(Map.Side side, AvaibleSides avaibleSides)
 {
     if (avaibleSides.CheckAvaiblity(side))
     {
         this.snake.ChangeDirection(side);
         this.SetInput();
     }
 }
Ejemplo n.º 2
0
    // private void ShiftNeighbours(Field[] neighbours)
    // {

    // }

    private bool CanDirectionBeFollowed(Field start, Field[] neighbours, Map.Side dir)
    {
        foreach (var neighbour in neighbours)
        {
            if (neighbour.IsWalkable() && dir == Map.Direction(start, neighbour))
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 3
0
    private void ChangeDirection(Map.Side side)
    {
        if (gotInput)
        {
            return;
        }

        if (ActualSide(this.rightAndLeft))
        {
            this.SetDirection(side, this.upAndDown);
        }
        else if (ActualSide(this.upAndDown))
        {
            this.SetDirection(side, this.rightAndLeft);
        }
    }
Ejemplo n.º 4
0
    public void Turn(Map.Side side)
    {
        switch (side)
        {
        case Map.Side.right:
            dir = Map.Right(dir);
            break;

        case Map.Side.left:
            dir = Map.Left(dir);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 5
0
 public bool CheckAvaiblity(Map.Side side)
 {
     return(side == this.one || side == this.another);
 }
Ejemplo n.º 6
0
 public AvaibleSides(Map.Side one, Map.Side another)
 {
     this.one     = one;
     this.another = another;
 }
Ejemplo n.º 7
0
 private Vector2 Direction(Map.Side side)
 {
     return(Map.Direction(side));
 }
Ejemplo n.º 8
0
 public void ChangeDirection(Map.Side side)
 {
     dir = side;
 }