private bool GenericCheck(eButtonColor i_MySymbol, eButtonColor i_OpponentSymbol, int i_row, int i_col, Board i_gameBoard, string i_direction)
        {
            bool isSeenOtherPlayer = false;
            bool isSeenSelfAndLegal = false;
            int deltaPositionRow = i_row;
            int deltaPositionCol = i_col;
            int addCellToFlipCounter = 0;
            incrementDelta(ref deltaPositionRow, ref deltaPositionCol, i_direction);

            while ((deltaPositionRow >= 0) && (deltaPositionRow < i_gameBoard.Size) && (deltaPositionCol >= 0)
                && (deltaPositionCol < i_gameBoard.Size))
            {
                if (i_gameBoard.GameBoard[deltaPositionRow, deltaPositionCol].IsCellEmpty )
                {
                    break;
                }

                if (i_gameBoard.GameBoard[deltaPositionRow, deltaPositionCol].Color == i_MySymbol && !isSeenOtherPlayer)
                {
                    break;
                }

                if (i_gameBoard.GameBoard[deltaPositionRow, deltaPositionCol].Color == i_OpponentSymbol)
                {
                    isSeenOtherPlayer = true;
                }

                if (i_gameBoard.GameBoard[deltaPositionRow, deltaPositionCol].Color == i_MySymbol && isSeenOtherPlayer)
                {
                    isSeenSelfAndLegal = true;
                    break;
                }

                if (isSeenOtherPlayer && !isSeenSelfAndLegal)
                {
                    addCellToFlip(i_gameBoard, i_row, i_col, deltaPositionRow, deltaPositionCol);
                    addCellToFlipCounter++;
                }

                incrementDelta(ref deltaPositionRow, ref deltaPositionCol, i_direction);
            }

            if (!isSeenSelfAndLegal)
            {
                int indexToRemove = i_gameBoard.GameBoard[i_row, i_col].m_CellsToFlip.Count - addCellToFlipCounter;
                i_gameBoard.GameBoard[i_row, i_col].m_CellsToFlip.RemoveRange(indexToRemove, addCellToFlipCounter);
            }

            return isSeenSelfAndLegal;
        }
Exemple #2
0
        public Player(int i_playerNumber, bool i_isComputerPlayer)
        {
            m_score = 2;
            r_isComputer = i_isComputerPlayer;
            if (i_playerNumber == 1)
            {
                r_name = "Black Player";
                r_PlayerColor = eButtonColor.Black;
                r_OpponentColor = eButtonColor.White;
            }
            else
            {
                r_name = "White Player";
                r_PlayerColor = eButtonColor.White;
                r_OpponentColor = eButtonColor.Black;
            }

            m_MypossibleMoves = new PossibleMoves(r_PlayerColor, r_OpponentColor);
        }
 public PossibleMoves(eButtonColor i_myColor, eButtonColor i_opponentColor)
 {
     m_MyColor = i_myColor;
     m_OpponentColor = i_opponentColor;
     m_ListPossibleMoves = new List<Coordinates>();
 }
Exemple #4
0
        /// <summary>
        /// Overloaded. Deserializes the Item from the XmlElement.
        /// </summary>
        /// <param name="ItemXmlSource">Source XmlElement.</param>
        public override void Deserialize(ItemSerializationContext context)
        {
            base.Deserialize(context);

            System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;
            m_ImagePosition = (eImagePosition)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ImagePosition"));
            m_ButtonStyle = (eButtonStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ButtonStyle"));
            m_Checked = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("Checked"));
            m_VerticalPadding = System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("VerticalPadding"));
            m_HorizontalPadding = System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("HorizontalPadding"));

            m_MenuVisibility = (eMenuVisibility)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("MenuVisibility"));
            m_RecentlyUsed = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("RecentlyUsed"));

            if (ItemXmlSource.HasAttribute("forecolor"))
                m_ForeColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("forecolor"));
            else
                m_ForeColor = System.Drawing.Color.Empty;

            if (ItemXmlSource.HasAttribute("hottrack"))
                m_HotTrackingStyle = (eHotTrackingStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("hottrack"));
            else
                m_HotTrackingStyle = eHotTrackingStyle.Default;

            if (ItemXmlSource.HasAttribute("hotclr"))
                m_HotForeColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("hotclr"));
            else
                m_HotForeColor = System.Drawing.Color.Empty;

            if (ItemXmlSource.HasAttribute("hotfb"))
                m_HotFontBold = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("hotfb"));
            else
                m_HotFontBold = false;
            if (ItemXmlSource.HasAttribute("hotfu"))
                m_HotFontUnderline = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("hotfu"));
            else
                m_HotFontUnderline = false;

            if (ItemXmlSource.HasAttribute("optiongroup"))
                m_OptionGroup = ItemXmlSource.GetAttribute("optiongroup");
            else
                m_OptionGroup = "";

            if (ItemXmlSource.HasAttribute("fontbold"))
                m_FontBold = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontbold"));
            else
                m_FontBold = false;
            if (ItemXmlSource.HasAttribute("fontitalic"))
                m_FontItalic = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontitalic"));
            else
                m_FontItalic = false;
            if (ItemXmlSource.HasAttribute("fontunderline"))
                m_FontUnderline = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("fontunderline"));
            else
                m_FontUnderline = false;

            if (ItemXmlSource.HasAttribute("AlternateShortcutText"))
                m_AlternateShortcutText = ItemXmlSource.GetAttribute("AlternateShortcutText");
            else
                m_AlternateShortcutText = "";

            if (ItemXmlSource.HasAttribute("autoexpandclick"))
                m_AutoExpandOnClick = System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("autoexpandclick"));
            else
                m_AutoExpandOnClick = false;

            if (ItemXmlSource.HasAttribute("CustomColorName"))
                m_CustomColorName = ItemXmlSource.GetAttribute("CustomColorName");
            else
                m_CustomColorName = "";

            if (ItemXmlSource.HasAttribute("ColorTable"))
                m_ColorTable = (eButtonColor)Enum.Parse(m_ColorTable.GetType(), ItemXmlSource.GetAttribute("ColorTable"));
            else
                m_ColorTable = eButtonColor.Orange;

            m_ImageIndex = -1;
            m_HoverImageIndex = -1;
            m_DisabledImageIndex = -1;
            m_PressedImageIndex = -1;
            m_Icon = null;
            m_Image = null;
            m_ImageSmall = null;
            m_HoverImage = null;
            m_DisabledImage = null;
            m_DisabledImageCustom = false;
            m_PressedImage = null;

            // Load Images
            foreach (System.Xml.XmlElement xmlElem in ItemXmlSource.ChildNodes)
            {
                if (xmlElem.Name == "images")
                {
                    if (xmlElem.HasAttribute("imageindex"))
                        m_ImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("imageindex"));
                    if (xmlElem.HasAttribute("hoverimageindex"))
                        m_HoverImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("hoverimageindex"));
                    if (xmlElem.HasAttribute("disabledimageindex"))
                        m_DisabledImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("disabledimageindex"));
                    if (xmlElem.HasAttribute("pressedimageindex"))
                        m_PressedImageIndex = System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("pressedimageindex"));

                    foreach (System.Xml.XmlElement xmlElem2 in xmlElem.ChildNodes)
                    {
                        switch (xmlElem2.GetAttribute("type"))
                        {
                            case "default":
                                {
                                    m_Image = BarFunctions.DeserializeImage(xmlElem2);
                                    m_ImageIndex = -1;
                                    break;
                                }
                            case "icon":
                                {
                                    m_Icon = BarFunctions.DeserializeIcon(xmlElem2);
                                    m_ImageIndex = -1;
                                    break;
                                }
                            case "hover":
                                {
                                    m_HoverImage = BarFunctions.DeserializeImage(xmlElem2);
                                    m_HoverImageIndex = -1;
                                    break;
                                }
                            case "disabled":
                                {
                                    m_DisabledImage = BarFunctions.DeserializeImage(xmlElem2);
                                    m_DisabledImageIndex = -1;
                                    m_DisabledImageCustom = true;
                                    break;
                                }
                            case "pressed":
                                {
                                    m_PressedImage = BarFunctions.DeserializeImage(xmlElem2);
                                    m_PressedImageIndex = -1;
                                    break;
                                }
                            case "small":
                                {
                                    m_ImageSmall = BarFunctions.DeserializeImage(xmlElem2);
                                    break;
                                }
                        }
                    }
                    break;
                }
            }
            this.OnImageChanged();
        }
Exemple #5
0
 public Cell()
 {
     m_isCellEmpty = true;
     m_MyColor = eButtonColor.LightGray;
     m_CellsToFlip = new List<Coordinates>();
 }