예제 #1
0
 public void SetMovePrediction(ref List <Vector2f> l_list, ref ChessMan l_chess)
 {
     m_prediction.Clear();
     for (int i = 0; i < l_list.Count; ++i)
     {
         RectangleShape r = new RectangleShape(new Vector2f(m_board.m_cases[0].m_boundaries.Width, m_board.m_cases[0].m_boundaries.Height));
         r.Origin           = new Vector2f(r.Size.X / 2.0f, r.Size.Y / 2.0f);
         r.Position         = l_list[i];
         r.OutlineThickness = 5.0f;
         r.OutlineColor     = SFML.Graphics.Color.Red;
         r.FillColor        = SFML.Graphics.Color.Transparent;
         m_prediction.Add(r);
     }
 }
예제 #2
0
파일: Tour.cs 프로젝트: StillOP/Chess
        public override List <Vector2f> PossibleMovement()
        {
            List <Vector2f> m_possibleMove = new List <Vector2f>();

            foreach (Case kz in m_board.m_cases)
            {
                if (kz.m_center.Y == m_position.Y)
                {
                    m_possibleMove.Add(kz.m_center);
                }
                if (kz.m_center.X == m_position.X)
                {
                    m_possibleMove.Add(kz.m_center);
                }
            }

            List <Vector2f> m_toRemove = new List <Vector2f>();

            for (int i = 0; i < m_possibleMove.Count; ++i)
            {
                ChessMan chessman = m_board.IsOccuped(m_possibleMove[i]);
                if (chessman != null)
                {
                    if (chessman.Color == Color)
                    {
                        // m_possibleMove.Remove(m_possibleMove[i]);
                        m_toRemove.Add(m_possibleMove[i]);

                        if (m_possibleMove[i].Y == m_position.Y)
                        {
                            if (m_position.X > chessman.Position.X)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.Y == m_position.Y)
                                    {
                                        if (kz.m_center.X == chessman.Position.X)
                                        {
                                            break;
                                        }
                                        //m_possibleMove.Remove(kz.m_center);
                                        m_toRemove.Add(kz.m_center);
                                    }
                                }
                            }
                            else if (m_position.X < chessman.Position.X)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.Y == m_position.Y)
                                    {
                                        if (kz.m_center.X > chessman.Position.X)
                                        {
                                            //m_possibleMove.Remove(kz.m_center);
                                            m_toRemove.Add(kz.m_center);
                                        }
                                    }
                                }
                            }
                        }

                        if (m_possibleMove[i].X == m_position.X)
                        {
                            if (m_position.Y > chessman.Position.Y)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.X == m_position.X)
                                    {
                                        if (kz.m_center.Y == chessman.Position.Y)
                                        {
                                            break;
                                        }
                                        //m_possibleMove.Remove(kz.m_center);
                                        m_toRemove.Add(kz.m_center);
                                    }
                                }
                            }
                            else if (m_position.Y < chessman.Position.Y)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.X == m_position.X)
                                    {
                                        if (kz.m_center.Y > chessman.Position.Y)
                                        {
                                            //m_possibleMove.Remove(kz.m_center);
                                            m_toRemove.Add(kz.m_center);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (chessman.Color != Color)
                    {
                        if (m_possibleMove[i].Y == m_position.Y)
                        {
                            if (m_position.X > chessman.Position.X)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.Y == m_position.Y)
                                    {
                                        if (kz.m_center.X == chessman.Position.X)
                                        {
                                            break;
                                        }
                                        //m_possibleMove.Remove(kz.m_center);
                                        m_toRemove.Add(kz.m_center);
                                    }
                                }
                            }
                            else if (m_position.X < chessman.Position.X)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.Y == m_position.Y)
                                    {
                                        if (kz.m_center.X > chessman.Position.X)
                                        {
                                            //m_possibleMove.Remove(kz.m_center);
                                            m_toRemove.Add(kz.m_center);
                                        }
                                    }
                                }
                            }
                        }

                        if (m_possibleMove[i].X == m_position.X)
                        {
                            if (m_position.Y > chessman.Position.Y)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.X == m_position.X)
                                    {
                                        if (kz.m_center.Y == chessman.Position.Y)
                                        {
                                            break;
                                        }
                                        //m_possibleMove.Remove(kz.m_center);
                                        m_toRemove.Add(kz.m_center);
                                    }
                                }
                            }
                            else if (m_position.Y < chessman.Position.Y)
                            {
                                foreach (Case kz in m_board.m_cases)
                                {
                                    if (kz.m_center.X == m_position.X)
                                    {
                                        if (kz.m_center.Y > chessman.Position.Y)
                                        {
                                            //m_possibleMove.Remove(kz.m_center);
                                            m_toRemove.Add(kz.m_center);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < m_toRemove.Count; ++i)
            {
                m_possibleMove.Remove(m_toRemove[i]);
            }
            return(m_possibleMove);
        }
예제 #3
0
        public override List <Vector2f> PossibleMovement()
        {
            List <Vector2f> m_possibleMove = new List <Vector2f>();

            if (Color == Color.Black)
            {
                ChessMan chessman1 = m_board.IsOccuped(new Vector2f(m_position.X, m_position.Y + m_move));
                ChessMan chessman2 = m_board.IsOccuped(new Vector2f(m_position.X + m_move, m_position.Y + m_move));
                ChessMan chessman3 = m_board.IsOccuped(new Vector2f(m_position.X - m_move, m_position.Y + m_move));

                if (chessman1 == null)
                {
                    m_possibleMove.Add(new Vector2f(m_position.X, m_position.Y + m_move));
                }

                if (chessman2 != null)
                {
                    if (chessman2.Color != Color)
                    {
                        m_possibleMove.Add(new Vector2f(m_position.X + m_move, m_position.Y + m_move));
                    }
                }
                if (chessman3 != null)
                {
                    if (chessman3.Color != Color)
                    {
                        m_possibleMove.Add(new Vector2f(m_position.X - m_move, m_position.Y + m_move));
                    }
                }

                return(m_possibleMove);
            }

            if (Color == Color.White)
            {
                ChessMan chessman1 = m_board.IsOccuped(new Vector2f(m_position.X, m_position.Y - m_move));
                ChessMan chessman2 = m_board.IsOccuped(new Vector2f(m_position.X + m_move, m_position.Y - m_move));
                ChessMan chessman3 = m_board.IsOccuped(new Vector2f(m_position.X - m_move, m_position.Y - m_move));

                if (chessman1 == null)
                {
                    m_possibleMove.Add(new Vector2f(m_position.X, m_position.Y - m_move));
                }

                if (chessman2 != null)
                {
                    if (chessman2.Color != Color)
                    {
                        m_possibleMove.Add(new Vector2f(m_position.X + m_move, m_position.Y - m_move));
                    }
                }
                if (chessman3 != null)
                {
                    if (chessman3.Color != Color)
                    {
                        m_possibleMove.Add(new Vector2f(m_position.X - m_move, m_position.Y - m_move));
                    }
                }
                // Console.WriteLine(m_possibleMove.Count);
                return(m_possibleMove);
            }

            m_possibleMove = null;
            return(m_possibleMove);
        }