public bool PatternDirectionAboveLeft()
        {
            if (GamePieces.Count == 1)
            {
                return(false);
            }

            BasicGamePiece piece = null;

            for (int i = 1; i < GamePieces.Count; i++)
            {
                piece = ( BasicGamePiece )GamePieces[i];

                if (piece.Position == PIECEPOSITION.ABOVELEFT)
                {
                    return(true);
                }
                if (piece.Position == PIECEPOSITION.BELOWRIGHT)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
 public BasicGamePiece(BasicGamePiece piece)
 {
     IsStartForPattern = piece.IsStartForPattern;
     SquareIdentifier  = piece.SquareIdentifier;
     IsEnemy           = piece.IsEnemy;
     Position          = piece.Position;
     Level             = piece.Level;
 }
예제 #3
0
        /// required object overrides because of comparison operators

        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            BasicGamePiece temp = ( BasicGamePiece )obj;

            return(this == temp);
        }
        public CONNECTFOURPATTERNDIRECTION GetPatternDirection()
        {
            if (GamePieces.Count == 1)
            {
                return(CONNECTFOURPATTERNDIRECTION.ERROR);
            }

            System.Diagnostics.Debug.Assert(GamePieces[1] != null, "Error first piece in the pattern is invalid");

            BasicGamePiece piece = ( BasicGamePiece )GamePieces[1];

            if (piece.Position == PIECEPOSITION.ABOVE)
            {
                return(CONNECTFOURPATTERNDIRECTION.VERTICAL);
            }
            else if (piece.Position == PIECEPOSITION.ABOVERIGHT)
            {
                return(CONNECTFOURPATTERNDIRECTION.LEFTDIAGONAL);
            }
            else if (piece.Position == PIECEPOSITION.RIGHT)
            {
                return(CONNECTFOURPATTERNDIRECTION.RIGHTHORIZONTAL);
            }
            else if (piece.Position == PIECEPOSITION.BELOWRIGHT)
            {
                return(CONNECTFOURPATTERNDIRECTION.RIGHTDIAGONAL);
            }
            else if (piece.Position == PIECEPOSITION.BELOW)
            {
                return(CONNECTFOURPATTERNDIRECTION.VERTICAL);
            }
            else if (piece.Position == PIECEPOSITION.BELOWLEFT)
            {
                return(CONNECTFOURPATTERNDIRECTION.LEFTDIAGONAL);
            }
            else if (piece.Position == PIECEPOSITION.LEFT)
            {
                return(CONNECTFOURPATTERNDIRECTION.LEFTHORIZONTAL);
            }
            else if (piece.Position == PIECEPOSITION.ABOVELEFT)
            {
                return(CONNECTFOURPATTERNDIRECTION.RIGHTDIAGONAL);
            }
            else
            {
                return(CONNECTFOURPATTERNDIRECTION.ERROR);
            }
        }
예제 #5
0
 /// <summary>
 /// add a piece to the set
 /// </summary>
 /// <param name="pattern"></param>
 public void AddBasicGamePiece(BasicGamePiece piece)
 {
     arrayGamePieces.Add(piece);
 }
예제 #6
0
        public virtual void Load(XmlReader xmlReader)
        {
            while (xmlReader.Name != "PatternID")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            xmlReader.Read();
            nPatternID = int.Parse(xmlReader.Value);

            bool bBreak = false;

            for ( ;;)
            {
                xmlReader.Read();
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:
                {
                    switch (xmlReader.Name)
                    {
                    case "BasicGamePiece":
                    {
                        BasicGamePiece temp = new BasicGamePiece();
                        temp.Load(xmlReader);
                        arrayGamePieces.Add(temp);
                        break;
                    }

                    case "NumberOfTimesSeen": bBreak = true; break;
                    }
                } break;
                }

                if (bBreak == true)
                {
                    break;
                }
            }

            /// should be on Number of times seen but doesn't hurt to check
            if (xmlReader.Name != "NumberOfTimesSeen")
            {
                return;
            }

            xmlReader.Read();
            nNumberOfTimesSeen = int.Parse(xmlReader.Value);

            while (xmlReader.Name != "NumberOfTimesSeenInWinningGame")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            xmlReader.Read();
            nNumberOfTimesSeenInWinningGame = int.Parse(xmlReader.Value);

            while (xmlReader.Name != "NumberOfTimesSeenInLosingGame")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            xmlReader.Read();
            nNumberOfTimesSeenInLosingGame = int.Parse(xmlReader.Value);

            while (xmlReader.Name != "EndingPattern")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            xmlReader.Read();
            if (xmlReader.Value == "True")
            {
                bIsEndingPattern = true;
            }
            else
            {
                bIsEndingPattern = false;
            }

            while (xmlReader.Name != "Weighting")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            xmlReader.Read();
            nWeighting = int.Parse(xmlReader.Value);

            while (xmlReader.Name != "Response")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            while (xmlReader.Name != "ResponsePresent")
            {
                xmlReader.Read();
                if (xmlReader.EOF == true)
                {
                    return;
                }
            }

            xmlReader.Read();
            int nResponse = int.Parse(xmlReader.Value);

            if (nResponse != 0)
            {
                bResponsePresent = true;
                bgpResponse      = new BasicGamePiece();
                bgpResponse.Load(xmlReader);
            }
        }