Example #1
0
        public FieldViewModel(SuperField superField, int fieldY, int fieldX)
        {
            Field        = superField.Fields[fieldY][fieldX];
            FieldY       = fieldY;
            FieldX       = fieldX;
            Interactable = IsInteractable(superField, fieldY, fieldX);
            if (superField.HighlightMove)
            {
                if (fieldY == superField.HighlightMoveFieldY && fieldX == superField.HighlightMoveFieldX)
                {
                    HighlightMove = true;
                }
                else
                {
                    HighlightMove = false;
                }
            }
            else
            {
                HighlightMove = false;
            }

            HighlightMoveSquareY = superField.HighlightMoveSquareY;
            HighlightMoveSquareX = superField.HighlightMoveSquareX;
        }
Example #2
0
        public SuperField(SuperField superField)
        {
            Winner = superField.Winner;

            PlayersTurn = superField.PlayersTurn;

            TurnRestrictedToField = superField.TurnRestrictedToField;
            RestrictedToFieldY    = superField.RestrictedToFieldY;
            RestrictedToFieldX    = superField.RestrictedToFieldX;

            HighlightMove        = superField.HighlightMove;
            HighlightMoveFieldY  = superField.HighlightMoveFieldY;
            HighlightMoveFieldX  = superField.HighlightMoveFieldX;
            HighlightMoveSquareY = superField.HighlightMoveSquareY;
            HighlightMoveSquareX = superField.HighlightMoveSquareX;

            Fields = new Field[][] {
                new Field[] { new Field(superField.Fields[0][0]), new Field(superField.Fields[0][1]), new Field(superField.Fields[0][2]) },
                new Field[] { new Field(superField.Fields[1][0]), new Field(superField.Fields[1][1]), new Field(superField.Fields[1][2]) },
                new Field[] { new Field(superField.Fields[2][0]), new Field(superField.Fields[2][1]), new Field(superField.Fields[2][2]) }
            };
        }
Example #3
0
        private bool IsInteractable(SuperField superField, int fieldY, int fieldX)
        {
            if (superField.Winner != FieldState.None)
            {
                return(false);
            }

            if (superField.Fields[fieldY][fieldX].winner != FieldState.None)
            {
                return(false);
            }

            if (!superField.TurnRestrictedToField)
            {
                return(true);
            }

            if (superField.RestrictedToFieldY == fieldY && superField.RestrictedToFieldX == fieldX)
            {
                return(true);
            }

            return(false);
        }