Exemplo n.º 1
0
    public static GameDirection RotateCCW(GameDirection input)
    {
        if (input == Nil)
        {
            return(Nil);
        }
        if (input == All)
        {
            return(All);
        }

        GameDirection output = Nil;

        if (input.Test(GameDirection.North))
        {
            output |= GameDirection.West;
        }
        if (input.Test(GameDirection.East))
        {
            output |= GameDirection.South;
        }
        if (input.Test(GameDirection.South))
        {
            output |= GameDirection.East;
        }
        if (input.Test(GameDirection.West))
        {
            output |= GameDirection.North;
        }
        return(output);
    }
Exemplo n.º 2
0
    public static GameDirection RandomSingle(this GameDirection input)
    {
        List <GameDirection> options = new List <GameDirection>();

        if (input.Test(GameDirection.North))
        {
            options.Add(GameDirection.North);
        }
        if (input.Test(GameDirection.East))
        {
            options.Add(GameDirection.East);
        }
        if (input.Test(GameDirection.South))
        {
            options.Add(GameDirection.South);
        }
        if (input.Test(GameDirection.West))
        {
            options.Add(GameDirection.West);
        }
        if (options.Count == 0)
        {
            return(GameDirectionHelper.Nil);
        }
        return(options[Random.Range(0, options.Count)]);
    }
Exemplo n.º 3
0
    public static List <GameDirection> ToList(this GameDirection input)
    {
        List <GameDirection> results = new List <GameDirection>();

        if (input.Test(GameDirection.North))
        {
            results.Add(GameDirection.North);
        }
        if (input.Test(GameDirection.East))
        {
            results.Add(GameDirection.East);
        }
        if (input.Test(GameDirection.South))
        {
            results.Add(GameDirection.South);
        }
        if (input.Test(GameDirection.West))
        {
            results.Add(GameDirection.West);
        }
        return(results);
    }
Exemplo n.º 4
0
    public static int Count(this GameDirection input)
    {
        int total = 0;

        if (input.Test(GameDirection.North))
        {
            total++;
        }
        if (input.Test(GameDirection.East))
        {
            total++;
        }
        if (input.Test(GameDirection.South))
        {
            total++;
        }
        if (input.Test(GameDirection.West))
        {
            total++;
        }
        return(total);
    }
Exemplo n.º 5
0
    public static int CountContains(this GameDirection input, params GameDirection[] tests)
    {
        int count = 0;

        foreach (GameDirection test in tests)
        {
            if (input.Test(test))
            {
                count++;
            }
        }
        return(count);
    }