示例#1
0
    public bool Canbeat()
    {
        CurrentStrokes.Clear();
        GetPossibleStrokes();

        return(CurrentStrokes.Any(s => s.BeatedCheker != null));
    }
示例#2
0
    public bool MakeAStroke(Vector2 point, out Checker beatedCheker)
    {
        if (Canbeat())
        {
            currentStrokes = GetPossibleStrokes();
            beatedCheker   = CurrentStrokes.FirstOrDefault(c => c.Point == point && c.BeatedCheker != null).BeatedCheker;
            return(currentStrokes.Any(s => s.Point == point && s.BeatedCheker != null));
        }


        currentStrokes = GetPossibleStrokes();
        beatedCheker   = CurrentStrokes.FirstOrDefault(c => c.Point == point).BeatedCheker;
        return(currentStrokes.Any(s => s.Point == point));
    }
    public override List <Stroke> GetPossibleStrokes()
    {
        beatedEnemiesWithDirection[NorthWestDirection] = new List <Stroke>();
        beatedEnemiesWithDirection[SouthWestDirection] = new List <Stroke>();
        beatedEnemiesWithDirection[SouthEathDirection] = new List <Stroke>();
        beatedEnemiesWithDirection[NorthEastDirection] = new List <Stroke>();

        currentStrokes = new List <Stroke>();
        var  blockedDirections = new List <Vector2>();
        bool directionIsLocked;

        for (int i = 1; i < 8; i++)
        {
            if (!blockedDirections.Contains(SouthEathDirection) &&
                !beatedEnemiesWithDirection[SouthEathDirection].Any())
            {
                var stroke1 = GetPossibleStrokes(SouthEathDirection, SouthEathDirection * i,
                                                 CurrentStrokes.Any(s => s.BeatedCheker != null),
                                                 out directionIsLocked);

                if (!directionIsLocked)
                {
                    currentStrokes.AddRange(stroke1);
                }
                else
                {
                    blockedDirections.Add(SouthEathDirection);
                }
            }

            if (!blockedDirections.Contains(NorthWestDirection) &&
                !beatedEnemiesWithDirection[NorthWestDirection].Any())
            {
                var stroke1 = GetPossibleStrokes(NorthWestDirection, NorthWestDirection * i,
                                                 CurrentStrokes.Any(s => s.BeatedCheker != null),
                                                 out directionIsLocked);

                if (!directionIsLocked)
                {
                    currentStrokes.AddRange(stroke1);
                }
                else
                {
                    blockedDirections.Add(NorthWestDirection);
                }
            }

            if (!blockedDirections.Contains(NorthEastDirection) &&
                !beatedEnemiesWithDirection[NorthEastDirection].Any())
            {
                var stroke1 = GetPossibleStrokes(NorthEastDirection, NorthEastDirection * i,
                                                 CurrentStrokes.Any(s => s.BeatedCheker != null),
                                                 out directionIsLocked);

                if (!directionIsLocked)
                {
                    currentStrokes.AddRange(stroke1);
                }
                else
                {
                    blockedDirections.Add(NorthEastDirection);
                }
            }

            if (!blockedDirections.Contains(SouthWestDirection) &&
                !beatedEnemiesWithDirection[SouthWestDirection].Any())
            {
                var stroke1 = GetPossibleStrokes(SouthWestDirection, SouthWestDirection * i,
                                                 CurrentStrokes.Any(s => s.BeatedCheker != null),
                                                 out directionIsLocked);

                if (!directionIsLocked)
                {
                    currentStrokes.AddRange(stroke1);
                }
                else
                {
                    blockedDirections.Add(SouthWestDirection);
                }
            }
        }

        return(currentStrokes);
    }
示例#4
0
 public void Deselect()
 {
     selectOutline.SetActive(false);
     CurrentStrokes.Clear();
     selected = false;
 }