Beispiel #1
0
 public void Initialize(StarColor myColor, float myScale, Vector3 mySpeed, float minX, float maxX, float minY, float maxY)
 {
     color = myColor;
     scale = myScale;
     speed = mySpeed;
     xMin  = minX;
     xMax  = maxX;
     yMin  = minY;
     yMax  = maxY;
 }
Beispiel #2
0
    /**
     * load map star prefabs
     */
    void LoadMapStars()
    {
        mapStarPrefabs = new Dictionary <StarColor, MapStar>();
        var objects = Resources.LoadAll("Stars/Map", typeof(GameObject));

        foreach (GameObject obj in objects)
        {
            MapStar star = obj.GetComponent <MapStar>();
            if (star != null)
            {
                StarColor color = (StarColor)star.GetType().GetField("color").GetRawConstantValue();
                mapStarPrefabs.Add(color, star);
                continue;
            }
        }
    }
Beispiel #3
0
    public void InitAndGenerate(InfoPaneManager infoPane, StarColor color, bool isHomeworld, uint id, Owners owner = Owners.NONE)
    {
        starProperties = new StarProperties(color, isHomeworld, owner);
        spendingInfo   = new StarSpending();

        // Init spending info.
        spendingInfo.population             = starProperties.population;
        spendingInfo.factories              = starProperties.factories;
        spendingInfo.waste                  = starProperties.waste;
        spendingInfo.reserves               = starProperties.reserves;
        spendingInfo.maxPopulation          = starProperties.maxPopulation;
        spendingInfo.effectiveMaxPopulation = starProperties.effectiveMaxPopulation;
        spendingInfo.reserves               = starProperties.reserves;
        spendingInfo.Init();

        ButtonManager.NextTurn += Turn;

        InfoPane = infoPane;
    }
    public StarProperties(StarColor color, bool isHomeworld, Owners owner = Owners.NONE)
    {
        this.color      = color;
        planetModifiers = new List <PlanetModifiers>();

        // Generate a new planet based on the star color and if it's a homeworld or not.
        if (isHomeworld)
        {
            // TODO: These need to vary based on race and difficulty
            population    = 50;
            factories     = 30;
            maxPopulation = 100;
            planetType    = PlanetTypes.TERRAN;
            planetModifiers.Add(PlanetModifiers.NORMAL);
        }
        else
        {
            population    = 0;
            factories     = 0;
            maxPopulation = 0;
            planetType    = PlanetTypes.NONE;
            planetModifiers.Add(PlanetModifiers.NORMAL);
            PlanetTypeGenerator.GenerateRandomPlanet(this);
        }

        this.owner             = owner;
        bases                  = 0;
        waste                  = 0;
        reserves               = 0;
        effectiveMaxPopulation = maxPopulation;

        isExplored = new Dictionary <Owners, bool>();
        foreach (var player in System.Enum.GetValues(typeof(Owners)).Cast <Owners>())
        {
            isExplored[player] = false;
        }

        if (this.owner != Owners.NONE)
        {
            isExplored[this.owner] = true;
        }
    }
Beispiel #5
0
            /// <summary>
            /// Returns the color of the provided star.
            /// </summary>
            public static Color LookupColor(Star star)
            {
                if (m_oStarColor == null)
                {
                    m_oStarColor = new StarColor();
                }

                if (star != null)
                {
                    string sClass = star.SpectralType.ToString() + star.SpectralSubDivision.ToString();
                    if (m_oStarColor.m_dicStarColors.ContainsKey(sClass))
                    {
                        return(m_oStarColor.m_dicStarColors[sClass]);
                    }
                    else
                    {
                        return(Color.White);
                    }
                }

                return(Color.White);
            }
        public static string To3JS(this Galaxy g)
        {
            StringBuilder b = new StringBuilder();

            b.AppendLine("var stars = [");
            foreach (var star in g.Stars)
            {
                var c = StarColor.ConvertTemperature(star.Temperature);
                b.AppendLine($"  {{name:\"{star.Name}\",x:{star.Position.X},y:{star.Position.Y},z:{star.Position.Z},r:{c.X},g:{c.Y},b:{c.Z}}},");
            }
            b.AppendLine("];");

            b.AppendLine();

            var n = Assembly.GetExecutingAssembly().GetManifestResourceNames();

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CasualGodComplex.Test.ThreeJs.js"))
                using (StreamReader reader = new StreamReader(stream))
                {
                    b.Append(reader.ReadToEnd());
                }

            return(b.ToString());
        }
Beispiel #7
0
 public LocalStar GetLocalStarPrefab(StarColor color)
 {
     return(localStarPrefabs[color]);
 }
Beispiel #8
0
 public MapStar GetMapStarPrefab(StarColor color)
 {
     return(mapStarPrefabs[color]);
 }
Beispiel #9
0
            /// <summary>
            /// Returns the color of the provided star.
            /// </summary>
            public static Color LookupColor(Star star)
            {
                if (m_oStarColor == null)
                {
                    m_oStarColor = new StarColor();
                }

                if (star != null)
                {
                    string sClass = star.SpectralType.ToString() + star.SpectralSubDivision.ToString();
                    if (m_oStarColor.m_dicStarColors.ContainsKey(sClass))
                    {
                        return m_oStarColor.m_dicStarColors[sClass];
                    }
                    else
                    {
                        return Color.White; 
                    }
                }

                return Color.White;
            }
Beispiel #10
0
 public void AddStar(CelestialBody StarCB, StarColor StarColor)
 {
     StarDistance[StarCB] = StarColor;
 }
Beispiel #11
0
 public MapStar GetMapStarPrefab(StarColor color)
 {
     return mapStarPrefabs[color];
 }
Beispiel #12
0
 public LocalStar GetLocalStarPrefab(StarColor color)
 {
     return localStarPrefabs[color];
 }
Beispiel #13
0
        public KspSystemDefinition GetConfigData()
        {
            KspSystemDefinition kspSystemDefinition;

            if (system_config == null)
            {
                return(null);
            }
            else
            {
                if (!system_config.HasData && !system_config_valid)
                {
                    return(null);
                }
                else
                {
                    UrlDir.UrlConfig[] kspNodes = GameDatabase.Instance.GetConfigs("KSPSystem");
                    if (kspNodes.Count() > 1)//TODO: Do something about this...
                    {
                        Debug.Log("There shouldn't be more than 1 KSPSystem config! Use ModuleManager to patch the existing config!");
                        return(null);
                    }
                    ConfigNode kspNode = kspNodes[0].config;
                    try
                    {
                        foreach (ConfigNode color in kspNode.GetNode("StarColors").GetNodes("StarColor"))
                        {
                            if (color.GetValue("name") != null)
                            {
                                StarColor sc = new StarColor();
                                sc.givesOffLight = (color.GetValue("GivesOffLight") ?? "true") == "true";
                                Vector4 lightColor = ConfigNode.ParseVector4(color.GetValue("LightColor") ?? "0,0,0,0");
                                sc.lightColor = new Color(lightColor.x, lightColor.y, lightColor.z, lightColor.w);
                                Vector4 emitColor0 = ConfigNode.ParseVector4(color.GetValue("EmitColor0") ?? "0,0,0,0");
                                sc.emitColor0 = new Color(emitColor0.x, emitColor0.y, emitColor0.z, emitColor0.w);
                                Vector4 emitColor1 = ConfigNode.ParseVector4(color.GetValue("EmitColor1") ?? "0,0,0,0");
                                sc.emitColor1 = new Color(emitColor1.x, emitColor1.y, emitColor1.z, emitColor1.w);
                                Vector4 sunspotColor = ConfigNode.ParseVector4(color.GetValue("SunspotColor") ?? "0,0,0,0");
                                sc.sunSpotColor = new Color(sunspotColor.x, sunspotColor.y, sunspotColor.z, sunspotColor.w);
                                Vector4 rimColor = ConfigNode.ParseVector4(color.GetValue("RimColor") ?? "0,0,0,0");
                                sc.rimColor      = new Color(rimColor.x, rimColor.y, rimColor.z, rimColor.w);
                                sc.coronaTexture = GameDatabase.Instance.GetTexture(color.GetValue("CoronaTexture") ?? "", false);
                                StarSystem.StarColors.Add(color.GetValue("name"), sc);
                                Debug.Log("Added star color " + color.GetValue("name"));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Log("Error loading star colors: " + e);
                    }
                    RootDefinition rootDefinition;
                    double         sun_solar_mass;
                    try
                    {
                        sun_solar_mass = double.Parse(kspNode.GetNode("Root").GetValue("SolarMasses"));
                    }
                    catch
                    {
                        sun_solar_mass = 7700;
                    }
                    string rootName        = kspNode.GetNode("Root").GetValue("name") ?? "Root";
                    string rootDescription = kspNode.GetNode("Root").GetValue("BodyDescription") ?? "";
                    string rootColor       = kspNode.GetNode("Root").GetValue("StarColor") ?? "";
                    Debug.Log("Setting the root's color to " + rootColor);
                    StarColor blackHoleColor = (StarSystem.StarColors.ContainsKey(rootColor)) ? StarSystem.StarColors[rootColor] : null;
                    rootDefinition            = new RootDefinition(sun_solar_mass, blackHoleColor, rootName, rootDescription);
                    kspSystemDefinition       = new KspSystemDefinition(rootDefinition);
                    kspSystemDefinition.Stars = getStars(kspNode.GetNode("StarSystems").GetNodes("StarSystem"));
                }
            }
            return(kspSystemDefinition);
        }
    private static PlanetTypes GetRandomPlanetType(StarColor color)
    {
        RandomWeight <PlanetTypes> typeGenerator = new RandomWeight <PlanetTypes>();

        switch (color)
        {
        case StarColor.BLUE:
            typeGenerator.AddWeight(PlanetTypes.BARREN, 3);
            typeGenerator.AddWeight(PlanetTypes.DEAD, 2);
            typeGenerator.AddWeight(PlanetTypes.INFERNO, 2);
            typeGenerator.AddWeight(PlanetTypes.RADIATED, 1);
            typeGenerator.AddWeight(PlanetTypes.TOXIC, 1);
            break;

        case StarColor.GREEN:
            typeGenerator.AddWeight(PlanetTypes.ARID, 2);
            typeGenerator.AddWeight(PlanetTypes.BARREN, 1);
            typeGenerator.AddWeight(PlanetTypes.DESERT, 2);
            typeGenerator.AddWeight(PlanetTypes.JUNGLE, 1);
            typeGenerator.AddWeight(PlanetTypes.OCEAN, 1);
            typeGenerator.AddWeight(PlanetTypes.STEPPE, 2);
            typeGenerator.AddWeight(PlanetTypes.TERRAN, 1);
            typeGenerator.AddWeight(PlanetTypes.TUNDRA, 1);
            break;

        case StarColor.PURPLE:
            typeGenerator.AddWeight(PlanetTypes.BARREN, 1);
            typeGenerator.AddWeight(PlanetTypes.DEAD, 1);
            typeGenerator.AddWeight(PlanetTypes.INFERNO, 1);
            typeGenerator.AddWeight(PlanetTypes.RADIATED, 3);
            typeGenerator.AddWeight(PlanetTypes.TOXIC, 2);
            break;

        case StarColor.RED:
            typeGenerator.AddWeight(PlanetTypes.ARID, 1);
            typeGenerator.AddWeight(PlanetTypes.BARREN, 2);
            typeGenerator.AddWeight(PlanetTypes.DESERT, 3);
            typeGenerator.AddWeight(PlanetTypes.OCEAN, 1);
            typeGenerator.AddWeight(PlanetTypes.STEPPE, 3);
            typeGenerator.AddWeight(PlanetTypes.TUNDRA, 2);
            break;

        case StarColor.WHITE:
            typeGenerator.AddWeight(PlanetTypes.BARREN, 3);
            typeGenerator.AddWeight(PlanetTypes.DEAD, 2);
            typeGenerator.AddWeight(PlanetTypes.DESERT, 2);
            typeGenerator.AddWeight(PlanetTypes.INFERNO, 2);
            typeGenerator.AddWeight(PlanetTypes.RADIATED, 1);
            typeGenerator.AddWeight(PlanetTypes.TOXIC, 1);
            break;

        case StarColor.YELLOW:
            typeGenerator.AddWeight(PlanetTypes.ARID, 2);
            typeGenerator.AddWeight(PlanetTypes.DESERT, 1);
            typeGenerator.AddWeight(PlanetTypes.JUNGLE, 3);
            typeGenerator.AddWeight(PlanetTypes.OCEAN, 3);
            typeGenerator.AddWeight(PlanetTypes.STEPPE, 2);
            typeGenerator.AddWeight(PlanetTypes.TERRAN, 3);
            break;
        }

        return(typeGenerator.GetRandomKey());
    }