Ejemplo n.º 1
0
        public static Tuple<int, int> randomXY(int width, int height) {
            Random random = new Random();
            int x = random.Next(width);
            random = new Random(random.GetHashCode());
            int y = random.Next(height);

            return new Tuple<int, int>(x, y);
        }
Ejemplo n.º 2
0
 public void setIron(int i, int j)
 {
     System.Random seed = new System.Random();
     System.Random rnd  = new System.Random(seed.GetHashCode());
     mine = rnd.Next(0, 30);
     mapGen.tiles[i, j].iron = mine;
     //  ironList[i, j] = mine;
 }
Ejemplo n.º 3
0
 public void setWater(int i, int j)
 {
     System.Random seed = new System.Random();
     System.Random rnd  = new System.Random(seed.GetHashCode());
     mine = rnd.Next(0, 5);
     mapGen.tiles[i, j].water = mine;
     //  waterList[i, j] = mine;
 }
Ejemplo n.º 4
0
 public Particle(double _x, double _y, IDrawer _drawer)
 {
     Drawer = _drawer;
     m_CoordinatesNew = m_Coordinates = new PairDouble(_x, _y);
     
     Random k = new Random((int) DateTime.Now.ToBinary());
     Random r = new Random(k.GetHashCode());
     m_Speed = new PairDouble(Miscelaneous.ParticleSpeed * (0.5 - r.NextDouble()), Miscelaneous.ParticleSpeed * (0.5 - r.NextDouble()));
     m_Speed.Normalize();
 }
Ejemplo n.º 5
0
        public int AddPlayer(string name, string databaseId)
        {
            if (IsRoomFull())
            {
                throw new InvalidOperationException("Room is full");
            }

            PlayersNames.Add(name);
            PlayerDatabaseId.Add(databaseId);

            Random random          = new System.Random();
            int    playerSecretKey = random.GetHashCode();

            RoomPlayersKeys.Add(playerSecretKey);

            return(playerSecretKey);
        }
Ejemplo n.º 6
0
        public int GenerateRoomId()
        {
            int  newId;
            bool sameId;

            do
            {
                sameId = false;
                Random random = new System.Random();
                newId = random.GetHashCode();

                GameRoomsList.ForEach((gr) => {
                    if (gr.RoomID == newId)
                    {
                        sameId = true;
                    }
                });
            } while (sameId);
            return(newId);
        }
Ejemplo n.º 7
0
 public override Int32 GetHashCode()
 {
     return(_random.GetHashCode());
 }
Ejemplo n.º 8
0
        public static string Randomnum(int size)
        {
            try
            {
                System.Random ran = new System.Random();
                string v_return = ran.GetHashCode().ToString() + ran.Next(99).ToString();

                return v_return;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 9
0
 public void SaveToFile()
 {
     using (StreamWriter writer = new StreamWriter(File.Create(string.Format("{0}.txt", _rnd.GetHashCode()))))
     {
         string str = "";
         for (int x = 0; x < _mapWidth; x++)
         {
             str = "";
             for (int y = _mapHeight - 1; y != 0; y--)
             {
                 if (_map[x + y * _mapHeight].BasicValue != 1)
                 {
                     str += _map[x + y * _mapHeight].FloodValue;
                 }
                 else
                 {
                     if (_floodValue >= 10)
                     {
                         str += "##";
                     }
                     else
                     {
                         str += "#";
                     }
                 }
             }
             writer.WriteLine(str);
         }
     }
 }