コード例 #1
0
    void Start()
    {
        StarSystem a = SystemGenerator.Generate();

        mat = new Material[a.Planets.Count];

        for (int i = 0; i < a.Planets.Count; i++)
        {
            GameObject temp = Instantiate(QuadRef, new Vector3(i * 6, 0, 0), Quaternion.Euler(90, 0, 0)) as GameObject;
            mat[i]             = temp.GetComponent <MeshRenderer>().material;
            mat[i].mainTexture = a.Planets[i].textureDiffuse;

            if (a.Planets[i].textureIllumination != null)
            {
                mat[i].SetTexture("_EmissionMap", a.Planets[i].textureIllumination);
                mat[i].SetColor("_EmissionColor", new Color(1, 1, 1, 1));
                mat[i].EnableKeyword("_EMISSION");
            }

            if (a.Planets[i].textureNormal != null)
            {
                mat[i].SetTexture("_BumpMap", a.Planets[i].textureNormal);
                mat[i].SetFloat("_BumpScale", a.Planets[i].Blueprint.NormalMult);
                mat[i].EnableKeyword("_NORMALMAP");
            }
        }
    }
コード例 #2
0
        public static ushort[] GetCoefficients(uint[,,] points)
        {
            var polynomsCount = points.GetLength(0);
            var pointsCount   = points.GetLength(1);
            var coefficients  = new ushort[polynomsCount];

            var currentPoints = new uint[pointsCount, 2];

            var systemMatrix = new ulong[polynomsCount, polynomsCount + 1];
            var solved       = new ulong[polynomsCount];

            for (var i = 0; i < polynomsCount; i++)
            {
                for (var j = 0; j < pointsCount; j++)
                {
                    currentPoints[j, 0] = points[i, j, 0];
                    currentPoints[j, 1] = points[i, j, 1];
                }

                systemMatrix = SystemGenerator.GenerateSystemMatrixWithFiniteField(currentPoints);
                solved       = LinearEquationsSystemSolver.SolveWithFiniteField(systemMatrix);

                coefficients[i] = (ushort)solved[0];
            }

            return(coefficients);
        }
コード例 #3
0
 public void AddGenerator(SystemGenerator gen)
 {
     if (this.generator != null)
     {
         Debug.LogError("there is already registered generator");
         return;
     }
     this.generator = gen;
 }
コード例 #4
0
        public void NewGame()
        {
            var gen = new SystemGenerator();
            var systems = gen.GenerateSystems();

            _ctx = new GameContext(systems, context => Debug.WriteLine("State changed"));

            _ctx.StartTurn();
        }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        sysGenInstance = SystemGenerator.Instance;

        for (int i = 0; i < sysGenInstance.StarConnectionList.Count; i++)
        {
            RenderStarConnections(sysGenInstance.StarConnectionList[i]);
        }
    }
コード例 #6
0
        private void GenerateSystem()
        {
            Extensions.InitRandomSeed((int)_seedSelector.Value);
            var curIdx    = _systemListBox.SelectedIndex;
            var newSystem = SystemGenerator.GenerateStellarSystem(_system.Name, GetSelectedOptions());

            _group.Systems[curIdx]       = newSystem;
            _systemListBox.Items[curIdx] = newSystem;
            SetSystem(newSystem);
        }
コード例 #7
0
 void Generate()
 {
     Random.seed = randomSeed;
     System      = new GameObject("Test GameObject");
     systems     = new SystemGenerator[5];
     for (int i = 0; i < systems.Length; i++)
     {
         systems[i]            = new SystemGenerator();
         systems[i].randomSeed = (int)Random.Range(int.MinValue, int.MaxValue);
     }
     systems[0].Generate(System);
 }
コード例 #8
0
        private void GenerateGroup()
        {
            _systemListBox.Items.Clear();
            var options = GetSelectedOptions();

            _group = SystemGenerator.GenerateStellarGroup((int)_seedSelector.Value, (int)_countSelector.Value, options);
            foreach (var system in _group.Systems)
            {
                _systemListBox.Items.Add(system);
            }

            _systemListBox.SelectedIndex = 0;
        }
コード例 #9
0
        public async void SystemGenerator_Test(string id, string lang, string output = null)
        {
            var goodId = Guid.Parse(id);

            var result = await SystemGenerator.CreateSystem(Helper.CreateSystemInfo(goodId, lang, output));

            if (!Helper.LanguageExists(lang).HasValue || output != null && output.Equals("."))
            {
                Assert.True(result.HasError);
            }
            else
            {
                Assert.False(result.HasError);
            }
        }
コード例 #10
0
        public static Galaxy Generate()
        {
            Galaxy Galaxy = new Galaxy();

            Galaxy.Name = "Milky Way";

            Galaxy.Systems = new ISystem[MaxSystems];

            for (int i = 0; i < MaxSystems; i++)
            {
                Galaxy.Systems[i] = SystemGenerator.GeneratePlanetarySystem();
            }

            return(Galaxy);
        }
コード例 #11
0
 public Snowflake(float controlHeight)
 {
     Axiom           = "F";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("F", "F-F+F+F-F")
     });
     LineLength        = 11;
     InitialLineLength = LineLength;
     X        = 80;
     InitialX = X;
     Y        = controlHeight / 2 + 250;
     InitialY = Y;
     MaximumNumberOfIterations = 3;
     RotationAngle             = (float)Math.PI / 2;
     Angle             = 0;
     UseAutoLineLength = false;
 }
コード例 #12
0
 public Bush(float controlWidth, float controlHeight)
 {
     Axiom           = "F";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("F", "F[+FF][-FF]F[-F][+F]F")
     });
     LineLength        = 8;
     InitialLineLength = LineLength;
     X        = (float)controlWidth / 2;
     InitialX = X;
     Y        = (float)controlHeight - 30;
     InitialY = Y;
     MaximumNumberOfIterations = 3;
     RotationAngle             = (float)Math.PI / 5;
     Angle             = 3 * (float)Math.PI / 2;
     UseAutoLineLength = false;
 }
コード例 #13
0
 public LeviCurve(float controlWidth, float controlHeight)
 {
     Axiom           = "F++F++F++F";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("F", "-F++F-")
     });
     LineLength        = 10;
     InitialLineLength = LineLength;
     X        = (float)controlWidth / 2 - 100;
     InitialX = X;
     Y        = (float)controlHeight / 2 - 125;
     InitialY = Y;
     MaximumNumberOfIterations = 8;
     RotationAngle             = (float)Math.PI / 4;
     Angle             = 0;
     UseAutoLineLength = false;
 }
コード例 #14
0
 public Tree(float controlWidth, float controlHeight)
 {
     Axiom           = "F";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("F", "FF+[+F-F-F]-[-F+F+F]")
     });
     LineLength        = 50;
     InitialLineLength = LineLength;
     X        = (float)controlWidth / 2;
     InitialX = X;
     Y        = (float)controlHeight - 30;
     InitialY = Y;
     MaximumNumberOfIterations = 4;
     RotationAngle             = (float)Math.PI / 8;
     Angle             = 3 * (float)Math.PI / 2;
     UseAutoLineLength = true;
 }
コード例 #15
0
 public GosperCurve(float controlWidth)
 {
     Axiom           = "XF";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("X", "X+YF++YF-FX--FXFX-YF+"),
         new Rule("Y", "-FX+YFYF++YF+FX--FX-Y")
     });
     LineLength        = 3;
     InitialLineLength = LineLength;
     X        = (float)controlWidth / 2 + 110;
     InitialX = X;
     Y        = 150;
     InitialY = Y;
     MaximumNumberOfIterations = 4;
     RotationAngle             = (float)Math.PI / 3;
     Angle             = 0;
     UseAutoLineLength = false;
 }
コード例 #16
0
 public Ancient(int controlWidth)
 {
     Axiom           = "F";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("F", "FXF"),
         new Rule("X", "[-F+F+F]+F-F-F+"),
     });
     LineLength        = 10;
     InitialLineLength = LineLength;
     X        = controlWidth - 50;
     InitialX = X;
     Y        = 50;
     InitialY = Y;
     MaximumNumberOfIterations = 8;
     RotationAngle             = 2 * (float)Math.PI / 3;
     Angle             = 4 * (float)Math.PI / 4.85f;
     UseAutoLineLength = true;
 }
コード例 #17
0
 public Reed(float controlHeight)
 {
     Axiom           = "Y";
     InitialAxiom    = Axiom;
     SystemGenerator = new SystemGenerator(new[]
     {
         new Rule("X", "X[-FFF][+FFF]FX"),
         new Rule("Y", "YFX[+Y][-Y]")
     });
     LineLength        = 10;
     InitialLineLength = LineLength;
     X        = 0;
     InitialX = X;
     Y        = controlHeight - 30;
     InitialY = Y;
     MaximumNumberOfIterations = 6;
     RotationAngle             = (float)Math.PI / 7;
     Angle             = 7 * (float)Math.PI / 3.75f;
     UseAutoLineLength = true;
 }
コード例 #18
0
        public static async Task Main(string[] args)
        {
            var info = GetInfoFromArgs(args);

            var result = await SystemGenerator.CreateSystem(info);

            WriteLine($"Details:\n\tId:\t\t{info.Id}\n\tLanguage:\t{info.TargetLanguage}\n\tOutput:\t\t{info.Output}");

            WriteLine();

            if (result.HasError)
            {
                GotError(result.Error);
            }
            else
            {
                var color = ForegroundColor;
                ForegroundColor = ConsoleColor.Green;

                WriteLine("Your system has been created");

                ForegroundColor = color;
            }
        }
コード例 #19
0
 public LobbyController(IDb db, SystemGenerator generator, Storage storage)
 {
     _db = db;
     _generator = generator;
     _storage = storage;
 }
コード例 #20
0
 public void TestInitialize()
 {
     generator = new SystemGenerator();
 }