예제 #1
0
        public bool CheckDownCell(Monster[] monsterList, int x, int y, string[,] border)
        {
            bool isEmpty = true;
            foreach (var monster in monsterList)
            {
                if (x == monster.GetPosX() && y + 1 == monster.GetPosY())
                {
                    isEmpty = false;
                }
            }

            if (border[y + 1, x] == "#")
            {
                isEmpty = false;
            }

            return isEmpty;
        }
예제 #2
0
        public bool CheckLeftCell(Monster[] monsterList, int x, int y, string[,] border)
        {
            bool isEmpty = true;
            foreach (var monster in monsterList)
            {
                if (x - 1 == monster.GetPosX() && y == monster.GetPosY())
                {
                    isEmpty = false;
                    break;
                }
            }

            if (border[y, x - 1] == "#")
            {
                isEmpty = false;
            }

            return isEmpty;
        }
예제 #3
0
        public BoardElements CheckCell(string[,] border, string direction, Monster[] monsterList)
        {
            switch (direction)
            {
                case "up":
                    switch (border[this.pacManPos.Y - 1, this.pacManPos.X])
                    {
                        case "#":
                            return BoardElements.Wall;
                        case ".":
                            return BoardElements.Dot;
                        case "*":
                            return BoardElements.Star;
                        //case "☻":
                        //  return BoardElements.Monster;
                        default:
                            if (checkIfMonsterAppears(monsterList, this.pacManPos.Y - 1, this.pacManPos.X))
                            {
                                return BoardElements.Monster;
                            }
                            else
                            {
                                return BoardElements.Empty;
                            }
                    }

                //return BoardElements.Empty;
                case "right":
                    switch (border[this.pacManPos.Y, this.pacManPos.X + 1])
                    {
                        case "#":
                            return BoardElements.Wall;
                        case ".":
                            return BoardElements.Dot;
                        case "*":
                            return BoardElements.Star;
                        default:
                            if (checkIfMonsterAppears(monsterList, this.pacManPos.Y, this.pacManPos.X + 1))
                            {
                                return BoardElements.Monster;
                            }
                            else
                            {
                                return BoardElements.Empty;
                            }
                    }

                //return BoardElements.Empty;
                case "down":
                    switch (border[this.pacManPos.Y + 1, this.pacManPos.X])
                    {
                        case "#":
                            return BoardElements.Wall;
                        case ".":
                            return BoardElements.Dot;
                        case "*":
                            return BoardElements.Star;
                        default:
                            if (checkIfMonsterAppears(monsterList, this.pacManPos.Y + 1, this.pacManPos.X))
                            {
                                return BoardElements.Monster;
                            }
                            else
                            {
                                return BoardElements.Empty;
                            }
                    }

                //return BoardElements.Empty;
                case "left":
                    switch (border[this.pacManPos.Y, this.pacManPos.X - 1])
                    {
                        case "#":
                            return BoardElements.Wall;
                        case ".":
                            return BoardElements.Dot;
                        case "*":
                            return BoardElements.Star;
                        default:
                            if (checkIfMonsterAppears(monsterList, this.pacManPos.Y, this.pacManPos.X - 1))
                            {
                                return BoardElements.Monster;
                            }
                            else
                            {
                                return BoardElements.Empty;
                            }
                    }

                //return BoardElements.Empty;
                default:
                    if (checkIfMonsterAppears(monsterList, pacManPos.Y, pacManPos.X))
                    {
                        return BoardElements.Monster;
                    }
                    else
                    {
                        return BoardElements.Empty;
                    }
            }
            //return BoardElements.Empty;
        }
예제 #4
0
        public bool checkIfMonsterAppears(Monster[] monsterList, int pacManPosY, int pacManPosX)
        {
            foreach (var monster in monsterList)
            {
                if (monster.GetPosX() == pacManPosX && monster.GetPosY() == pacManPosY)
                {
                    return true;
                }

            }

            return false;
        }