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); }
public BasicGamePiece(BasicGamePiece piece) { IsStartForPattern = piece.IsStartForPattern; SquareIdentifier = piece.SquareIdentifier; IsEnemy = piece.IsEnemy; Position = piece.Position; Level = piece.Level; }
/// 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); } }
/// <summary> /// add a piece to the set /// </summary> /// <param name="pattern"></param> public void AddBasicGamePiece(BasicGamePiece piece) { arrayGamePieces.Add(piece); }
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); } }