Пример #1
0
        // THE GAME SUFFERS A SERIOUS LACK OF OPIMIZATION
        // So this method will now delete all border (useless in gameplay) walls:
        public void Clear()
        {
            LevelObject obj = new LevelObject();
            bool        con = false;

            for (int x = 0; x < LevelLength; x++)
            {
                for (int y = 0; y < LevelLength; y++)
                {
                    obj.Position_x = x;
                    obj.Position_y = y;
                    if (obj.GetType() == (new Wall()).GetType())
                    {
                        Objects.RemoveAll(o => o.Position_x == obj.Position_x && o.Position_y == obj.Position_y);
                    }
                    else
                    {
                        con = true;
                        break;
                    }
                }
                if (con)
                {
                    break;
                }
            }

            for (int x = 0; x < LevelLength; x++)
            {
                for (int y = 0; y < LevelLength; y++)
                {
                    obj.Position_x = LevelLength - x;
                    obj.Position_y = LevelLength - y;
                    if (obj.GetType() == (new Wall()).GetType())
                    {
                        Objects.RemoveAll(o => o.Position_x == obj.Position_x && o.Position_y == obj.Position_y);
                    }
                    else
                    {
                        con = true;
                        break;
                    }
                }
                if (con)
                {
                    break;
                }
            }
        }
Пример #2
0
 // Down-Left:
 private void CheckPositionView_4(LevelObject objToCheck)
 {
     if (objToCheck.IsViewable == true)
     {
         if (objToCheck.GetType() != (new Wall()).GetType() && objToCheck.GetType() != (new Door()).GetType())
         {
             if (toDisplay_4.Any(x => x.Position_x == objToCheck.Position_x - 1 && x.Position_y == objToCheck.Position_y))
             {
                 toDisplay_4[toDisplay_4.FindIndex(x => x.Position_x == objToCheck.Position_x - 1 && x.Position_y == objToCheck.Position_y)].IsViewable = true;
             }
             if (toDisplay_4.Any(x => x.Position_x == objToCheck.Position_x && x.Position_y == objToCheck.Position_y + 1))
             {
                 toDisplay_4[toDisplay_4.FindIndex(x => x.Position_x == objToCheck.Position_x && x.Position_y == objToCheck.Position_y + 1)].IsViewable = true;
             }
         }
     }
 }