Advertisement
Alexqq11

Untitled

May 14th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. public class Pipe {
  2.         //{ TopWidth = value; Propities[0] = value; }
  3.         private bool exist = false;
  4.        
  5.         private int _TopWidth;
  6.         private int _TopLength;
  7.         private int _BottomWidth;
  8.         private int _BottomLength;
  9.  
  10.         public int TopWidth { get { return _TopWidth; } set { _TopWidth = value; PropitiesInit(); Propities[0] = value; } }
  11.         public int TopLength { get { return _TopLength; } set { _TopLength = value; PropitiesInit(); Propities[1] = value; } }
  12.         public int BottomWidth { get { return _BottomWidth; } set { _BottomWidth = value; PropitiesInit(); Propities[2] = value; } }
  13.         public int BottomLength { get { return _BottomLength; } set { _BottomLength = value; PropitiesInit(); Propities[3] = value; } }
  14.         private List<int> Propities;// /{ get; set;}
  15.         // сильно зависим от параметров окна //
  16.         private void PropitiesInit() {
  17.             if (!exist)
  18.                 Propities = new List<int>();
  19.             for (var i = 0; i < 4; i++)
  20.                 Propities.Add(0);
  21.             exist = true;
  22.         }
  23.         public Pipe (int windowHeight , int windowWidth, int distanceBetweenPipes) // To do make normal params to generate pipe
  24.         {
  25.             PropitiesInit();
  26.             Random random = new Random();
  27.             TopWidth = windowWidth;
  28.             TopLength = random.Next(40, (windowHeight - distanceBetweenPipes)); // refact 40 to pipe length min
  29.             BottomWidth = windowWidth;
  30.             BottomLength = TopLength + distanceBetweenPipes;
  31.             Propities[0] = TopWidth;
  32.             Propities[1] = TopLength;
  33.             Propities[2] = BottomWidth;
  34.             Propities[3] = BottomLength;
  35.         }
  36.         public bool Any()
  37.         {
  38.             return Propities.Any();
  39.         }
  40.         public int this[int i]
  41.         {
  42.             get{return Propities[i];}
  43.             set
  44.             {
  45.                 Propities[i] = value;
  46.                 switch (i)
  47.                 {
  48.                     case 0 :
  49.                         _TopWidth = value;
  50.                         break;
  51.                     case 1 :
  52.                         _TopLength = value;
  53.                         break;
  54.                     case 2 :
  55.                         _BottomWidth = value;
  56.                         break;
  57.                     case 3 :
  58.                         _BottomLength = value;
  59.                         break;
  60.  
  61.                 }
  62.             }
  63.         }
  64.        
  65.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement