コード例 #1
0
ファイル: Unit.cs プロジェクト: Kieboom-Aaron/eendenjacht
        protected void generateStartPos(Canvas c)
        {
            SingletonRandom r    = SingletonRandom.getInstance();
            int             side = r.Next(0, 2);
            int             dir  = r.Next(0, 3);
            int             x    = r.Next(1, (int)(c.Width - _currentImage.Width));
            int             y    = r.Next(1, (int)(c.Height - _currentImage.Height));

            switch (side)
            {
            case 0:
            {
                _direction = Directions.RIGHT_DIRECTIONS[dir];
                _x         = 0;
                _y         = y;
                break;
            }

            case 1:
            {
                _direction = Directions.LEFT_DIRECTIONS[dir];
                _x         = (int)(c.Width - _currentImage.Width);;
                _y         = y;
                break;
            }
            }
        }
コード例 #2
0
 public static SingletonRandom getInstance()
 {
     if (instance == null)
     {
         instance = new SingletonRandom();
     }
     return instance;
 }
コード例 #3
0
 public static SingletonRandom getInstance()
 {
     if (instance == null)
     {
         instance = new SingletonRandom();
     }
     return(instance);
 }