Пример #1
0
        static void OnPlanet(Vessel ship, int credits, Planet planet)
        {
            Program.GuiGenerate(ship, credits);

            Console.WriteLine("Вы находитесь на планете " + PlanetParameters.PlanetName(planet, "ru") + ". Куда бы вы хотели отправиться?");
            Console.WriteLine("[1] — Верфь");
            Console.WriteLine("[2] — Транспортная компания");
            Console.WriteLine("[3] — Биржа труда");
            Console.WriteLine("[4] — Космопорт (улететь отсюда)");
            Console.Write("\nВыберите один из вариантов: ");

            string answer = Console.ReadLine();

            switch (answer)
            {
            case "1":
                Console.Clear();
                Program.OnShipyard(ship, credits, planet);
                break;

            case "s":
                break;

            case "q":
                break;

            default:
                Console.Clear();
                Program.OnPlanet(ship, credits, planet);
                break;
            }
        }
Пример #2
0
 float CalcNoiseAtSpherePoint(Vector3 point, PlanetParameters planetParams)
 {
     return(Noise.Noise.GetOctaveNoise(planetParams.perlinSpaceSeed.x * planetParams.perlinScaler.x + point.x,
                                       planetParams.perlinSpaceSeed.y * planetParams.perlinScaler.y + point.y,
                                       planetParams.perlinSpaceSeed.z * planetParams.perlinScaler.z + point.z,
                                       planetParams.PERLIN_OCTAVES));
 }
Пример #3
0
 void GenerateTextures(PlanetParameters planetParams)
 {
     foreach (KeyValuePair <CubeSide, Material> entry in materialsBySide)
     {
         GenerateTextures(entry.Key, entry.Value, planetParams);
     }
 }
Пример #4
0
 public void Display(PlanetParameters planetParams)
 {
     this.planetParams = planetParams;
     planet.GeneratePlanet(planetParams);
     solarLight.GenerateStar(planetParams);
     ApplicationState.singleton.data.activePlanet = planetParams.planetSeed;
     hud.Draw(planetParams);
 }
Пример #5
0
        static void OnShipyard(Vessel ship, int credits, Planet planet)
        {
            Program.GuiGenerate(ship, credits);

            Console.WriteLine("Вы перегнали свой корабль на верфь планеты " + PlanetParameters.PlanetName(planet, "ru") + ".");
            Console.WriteLine("Работник вашего дока передал на ваш компьютер приветственное сообщение и запрос следующего действия.\n");
            Console.WriteLine("Что вы хотите сделать на верфи?");
            Console.WriteLine("[1] — Поменять корабль");
            Console.WriteLine("[2] — Установить новые орудия на корабль");
            Console.WriteLine("[3] — Ничего (покинуть верфь)");
            Console.Write("\nВыберите один из вариантов: ");

            string answer = Console.ReadLine();

            switch (answer)
            {
            case "1":
                Console.Clear();
                Program.OnShipyardGetNewShip(ship, credits, planet);
                break;

            case "2":
                Console.Clear();
                Program.OnShipyardChangeCannons(ship, credits, planet);
                break;

            case "3":
                Console.Clear();
                Program.OnPlanet(ship, credits, planet);
                break;

            case "s":
                break;

            case "q":
                break;

            default:
                Console.Clear();
                Program.OnShipyard(ship, credits, planet);
                break;
            }
        }
Пример #6
0
    void GenerateTextures(CubeSide side, Material material, PlanetParameters planetParams)
    {
        Texture2D diffuseMap = new Texture2D(textureWidth, textureHeight, TextureFormat.ARGB32, false); // alpha is specular

        diffuseMap.wrapMode = TextureWrapMode.Clamp;                                                    // prevent renderer from wrapping textures,  which can cause hairline seams to appear at edges of textures
        Color[] pix = new Color[textureWidth * textureHeight];
        material.mainTexture = diffuseMap;

        for (int y = 0; y < diffuseMap.height; y++)
        {
            for (int x = 0; x < diffuseMap.width; x++)
            {
                pix[y * textureWidth + x] = GenerateTextureAtPoint(x, y, side, diffuseMap, planetParams);
            }
        }

        diffuseMap.SetPixels(pix);
        diffuseMap.Apply();
    }
Пример #7
0
    Color GenerateTextureAtPoint(int x, int y, CubeSide side, Texture2D diffuseMap, PlanetParameters planetParams)
    {
        Vector3 spherePoint = FindSpherePointForTexturePoint(side, (float)x / diffuseMap.width, (float)y / diffuseMap.height);

        spherePoint.Normalize();
        float noise = CalcNoiseAtSpherePoint(spherePoint, planetParams);

        float distFromEquator = Mathf.Pow(Mathf.Abs(spherePoint.y), 1.5f);

        if (noise <= planetParams.seaLevel)          // water
        {
            return(AdjustColorForLongatitude(planetParams.waterColor, planetParams.waterIceColor, distFromEquator, planetParams));
        }
        else             // land
        {
            float   elevation     = noise - planetParams.seaLevel;
            float   gradientx     = elevation * planetParams.gradientMultiplier;
            Color32 gradientColor = planetParams.gradient.ColorAtX(Mathf.Clamp(gradientx, 0f, 1f), Mathf.Clamp(elevation, 0f, 1f));
            return(AdjustColorForLongatitude(gradientColor, planetParams.landIceColor, distFromEquator, planetParams));
        }
    }
Пример #8
0
    void ApplyPlanetSizeAndElevationToMesh(PlanetParameters planetParams)
    {
        // apply planet size and elevation
        Vector3[] vertices = mesh.vertices;
        for (int i = 0; i < vertices.Length; i++)
        {
            Vector3 vertex = vertices[i];
            vertex.Normalize();
            float noiseAtVertex = CalcNoiseAtSpherePoint(vertex, planetParams);

            float scaleMultiplier = planetParams.planetSize;
            if (noiseAtVertex > planetParams.seaLevel)
            {
                scaleMultiplier += (noiseAtVertex - planetParams.seaLevel) * planetParams.terrainHeight;
            }
            vertex = Vector3.Scale(vertex, new Vector3(scaleMultiplier, scaleMultiplier, scaleMultiplier));

            vertices[i] = vertex;
        }
        mesh.vertices = vertices;
        mesh.RecalculateBounds();
    }
Пример #9
0
        public override void Update(GameTime gameTime)
        {
            SystemCore.ActiveScene.SetDiffuseLightDir(0, Vector3.Normalize(Vector3.Zero - earth.CurrentCenterPosition));

            foreach (MiniPlanet miniPlanet in planets)
            {
                float distanceFromSurface =
                    (cameraGameObject.Transform.WorldMatrix.Translation - miniPlanet.CurrentCenterPosition).Length();

                miniPlanet.Update(gameTime, distanceFromSurface, cameraGameObject.Transform.WorldMatrix.Translation);
            }



            if (SystemCore.Input.KeyPress(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                GenerateSystem();
            }

            int currentIndex = 0;
            PlanetParameters currentParameter = null;

            foreach (KeyValuePair <string, PlanetParameters> pair in NoiseGenerator.miniPlanetParameters)
            {
                if (currentIndex == currentParameterIndex)
                {
                    currentParameter = pair.Value;
                    break;
                }
                currentIndex++;
            }

            DebugText.Write(currentParameter.Name + " : " + currentParameter.Value.ToString());

            if (SystemCore.Input.KeyPress(Keys.OemPlus))
            {
                currentParameterIndex++;
                if (currentParameterIndex >= NoiseGenerator.miniPlanetParameters.Count)
                {
                    currentParameterIndex = 0;
                }
            }
            if (SystemCore.Input.KeyPress(Keys.OemMinus))
            {
                currentParameterIndex--;
                if (currentParameterIndex < 0)
                {
                    currentParameterIndex = NoiseGenerator.miniPlanetParameters.Count - 1;
                }
            }

            //double
            if (SystemCore.Input.KeyPress(Keys.NumPad1))
            {
                currentParameter.Value *= 2;
                GenerateSystem();
            }
            //half
            if (SystemCore.Input.KeyPress(Keys.NumPad2))
            {
                currentParameter.Value /= 2f;
                GenerateSystem();
            }

            //
            if (SystemCore.Input.KeyPress(Keys.NumPad3))
            {
                currentTestLod--;
                planets[0].SetLOD(currentTestLod);
            }
            if (SystemCore.Input.KeyPress(Keys.NumPad4))
            {
                currentTestLod++;
                planets[0].SetLOD(currentTestLod);
            }



            base.Update(gameTime);
        }
Пример #10
0
 public void GenerateStar(PlanetParameters planetParams)
 {
     light.color     = planetParams.starLight;
     light.intensity = planetParams.starIntensity;
 }
Пример #11
0
 public void GeneratePlanet(PlanetParameters planetParams)
 {
     InitMesh();
     GenerateTextures(planetParams);
     ApplyPlanetSizeAndElevationToMesh(planetParams);
 }
Пример #12
0
    Color32 AdjustColorForLongatitude(Color color, Color iceColor, float distFromEquator, PlanetParameters planetParams)
    {
        Color32 polarCapsColor = Color.Lerp(color, iceColor, Mathf.Clamp(planetParams.icyness, 0f, 1f));
        Color32 equatorColor   = Color.Lerp(color, iceColor, Mathf.Clamp(planetParams.icyness - 1f, 0f, 1f));

        return(Color32.Lerp(equatorColor, polarCapsColor, Mathf.Clamp(distFromEquator, 0f, 1f)));
    }
Пример #13
0
 public void Draw(PlanetParameters planetParams)
 {
     planetName.text = planetParams.name;
 }
Пример #14
0
 public void GenerateStar(PlanetParameters planetParams)
 {
     light.color = planetParams.starLight;
     light.intensity = planetParams.starIntensity;
 }