LifeSimulation.Core.World.World C# (CSharp) 메소드

World() 공개 메소드

public World ( ArrayList races, int initialLifelets, SpawnMethod spawnMethod ) : System
races System.Collections.ArrayList
initialLifelets int
spawnMethod SpawnMethod
리턴 System
        public World(ArrayList races, int initialLifelets, SpawnMethod spawnMethod)
        {
            // Init
            _stats = new Hashtable();
            _randomGen = new Random((int)DateTime.Now.Ticks);
            _initialLifelets = initialLifelets;
            _races = races;
            _spawnMethod = spawnMethod;
            _age = 0;

            // Assign a color for each race
            ArrayList colors = new ArrayList(new Color[]{Color.Red,Color.Blue,Color.Green,Color.Aqua,Color.Lime,Color.Orange});
            foreach(Type t in races) {
                Color c = Color.FromArgb(_randomGen.Next(256),_randomGen.Next(256),_randomGen.Next(256)); // Random color, if we run out
                if(colors.Count > 0) {
                    int i = _randomGen.Next(colors.Count);
                    c = (Color)colors[i];
                    colors.RemoveAt(i);
                }
                _stats[t.FullName + "_Color"] = c;
            }

            // Reset
            this.Reset();
        }