Ejemplo n.º 1
0
        private void SpawnBeam(IGameObject target, bool absorbTarget)
        {
            this.ClearBeam();
            if (this.m_BeamWeapon == null || target == null)
            {
                return;
            }
            Turret turretWithWeaponTrait = this.m_VonNeumannChild.GetTurretWithWeaponTrait(WeaponEnums.WeaponTraits.Disintegrating);
            int    num  = turretWithWeaponTrait == null ? this.m_VonNeumannChild.ObjectID : turretWithWeaponTrait.ObjectID;
            int    val1 = this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildRUCarryCap;

            if (target is StellarBody)
            {
                PlanetInfo planetInfo = this.m_Game.GameDatabase.GetPlanetInfo((target as StellarBody).Parameters.OrbitalID);
                if (planetInfo != null)
                {
                    val1 = Math.Min(val1, planetInfo.Resources);
                }
            }
            this.m_Beam = this.m_Game.AddObject <VonNeumannDisintegrationBeam>(new List <object>()
            {
                (object)target.ObjectID,
                (object)this.m_BeamWeapon.GameObject.ObjectID,
                (object)this.m_VonNeumannChild.ObjectID,
                (object)this.m_VonNeumannChild.Player.ObjectID,
                (object)num,
                (object)absorbTarget,
                (object)val1,
                (object)this.m_Game.AssetDatabase.GlobalVonNeumannData.RUTransferRateShip,
                (object)this.m_Game.AssetDatabase.GlobalVonNeumannData.RUTransferRatePlanet,
                (object)this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildIntegrationTime
            }.ToArray());
        }
Ejemplo n.º 2
0
    public void SetNums(PlanetInfo info)
    {
        Vector3 playerPos = player.transform.position;
        float   dist      = Vector2.SqrMagnitude(playerPos - info.position);

        if (dist < turnOnDist)
        {
            Vector3 dest;
            if (!player.PlanetOn)
            {
                dest = info.position + (playerPos - info.position) / 2;
            }
            else
            {
                dest = info.position;
            }
            resourceCanvas.SetActive(true);
            float scale = 1 - dist / turnOnDist;
            scale = Mathf.Clamp(scale, 0, 1);
            resourceCanvas.transform.localScale = new Vector3(scale, scale, 1);
            resourceCanvas.transform.position   = Vector3.Lerp(resourceCanvas.transform.position, dest, 4 * Time.deltaTime);
            fuelNum.SetText(Mathf.Floor(info.fuelAmount).ToString());
            lavaNum.SetText(Mathf.Floor(info.lavaAmount).ToString());
            oresNum.SetText(Mathf.Floor(info.oresAmount).ToString());
            waterNum.SetText(Mathf.Floor(info.waterAmount).ToString());
            lifeCol.r      = 1 - info.lifeAmount;
            lifeCol.g      = info.lifeAmount;
            lifeBarR.color = lifeCol;
            lifeBarR.rectTransform.localScale = new Vector3(info.lifeAmount, 1, 1);
        }
        else
        {
            resourceCanvas.SetActive(false);
        }
    }
        private static IEnumerator World(SpawnerScript instance, int[] s, PlanetInfo planet)
        {
            if (GameScript.districtLevel == 0)
            {
                GameScript.districtLevel = 1;
            }
            MenuScript.player.GetComponent <NetworkView>().RPC("Invis", RPCMode.All, new object[0]);
            InstanceTracker.GameScript.fadeObj.SendMessage("fadeOut2");
            yield return(new WaitForSeconds(0.5f));

            MenuScript.player.SendMessage("Reset");
            GameScript.inInstance = false;
            instance.ship.SetActive(false);
            SpawnerScript.curBiome  = s[0];
            SpawnerScript.lastBiome = s[0];
            planet.InvokeOnGenerateWorld(instance, s);
            InstanceTracker.GameScript.TeleportPlayer(0);
            yield return(new WaitForSeconds(0.8f));

            instance.musicbox.SendMessage("PlayTune", SpawnerScript.curBiome);
            InstanceTracker.GameScript.fadeObj.SendMessage("fadeIn2");
            GameScript.wormBossCounter = 0;
            GameScript.hivemindCounter = 0;
            yield break;
        }
Ejemplo n.º 4
0
    void Awake()
    {
        plInfo = GetComponent <PlanetInfo> ();
        po     = GetComponent <PlanetaryOrbit> ();

        planetList.Add(this);
    }
Ejemplo n.º 5
0
        public static string PlanetName(PlanetInfo planet)
        {
            string starName = planet.HostStar.Name.ToText(LocalizationManifest.Get.CurrentLanguage);

            var context  = LocalizationManifest.Get.CurrentLanguage["FormMain"];
            var textVars = new TextVar(
                "bodyName",
                starName + " " + RomanFromatter.Fromat(planet.Position)
                ).Get;

            switch (planet.Type)
            {
            case PlanetType.Asteriod:
                return(context["AsteriodName"].Text(textVars));

            case PlanetType.GasGiant:
                return(context["GasGiantName"].Text(textVars));

            case PlanetType.Rock:
                return(context["RockName"].Text(textVars));

            default:
                throw new NotImplementedException("Unimplemented planet type: " + planet.Type);
            }
        }
Ejemplo n.º 6
0
        public IActionResult AddPlanet([FromBody] PlanetInfo planetToAdd)
        {
            // Error checking
            if (planetToAdd == null)
            {
                _logger.LogError("No planet information was received.");
                return(BadRequest("No planet information was received."));
            }

            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid PlanetInfo model.");
                return(BadRequest(ModelState));
            }

            // Create new planet
            // In a system backed by a database, the id increment would be handled by the db
            var lastId    = PlanetsDataStore.Current.Planets.Select(p => p.Id).Max();
            var newPlanet = new PlanetInfo()
            {
                Id          = ++lastId,
                Name        = planetToAdd.Name,
                Description = planetToAdd.Description
            };

            PlanetsDataStore.Current.Planets.Add(newPlanet);
            _logger.LogInformation($"Planet {planetToAdd.Name} sucessfully added.");

            return(CreatedAtRoute("GetPlanetById", new
                                  { planetId = newPlanet.Id }, newPlanet));
        }
Ejemplo n.º 7
0
 private void ShowInfomation()
 {
     // 何も当たらない場合は消す
     if (Input.GetButtonDown ("ShowInfomation") && dialog.activeSelf == false) {
         rayDirection = new Vector3 (transform.position.x, transform.position.y - parent.transform.position.y, transform.position.z);
         if (Physics.Raycast (mainCamera.transform.position, rayDirection, out hitInfo, 1000f)) {
             Debug.DrawLine (mainCamera.transform.position, hitInfo.point, Color.blue, 5);
             // 当たった場合パネルが非表示なら表示させる
             if (mainPanel.activeSelf == false) {
                 mainPanel.SetActive (true);
             }
             // あたったオブジェクトのStarInfo,PlanetInfoのコンポーネントを取得し、名前、説明を代入
             if (hitInfo.collider.tag == "Star") {
                 hitStarInfo = hitInfo.transform.gameObject.GetComponent<StarInfo> ();
                 nameText.text = hitStarInfo.name.ToString ();
                 descriptionText.text = hitStarInfo.description.ToString ();
             } else if (hitInfo.collider.tag == "Planet") {
                 hitPlanetInfo = hitInfo.transform.gameObject.GetComponent<PlanetInfo> ();
                 nameText.text = hitPlanetInfo.name.ToString ();
                 descriptionText.text = hitPlanetInfo.description.ToString ();
             }
         } else {
             if (mainPanel.activeSelf == true) {
                 mainPanel.SetActive (false);
             }
             rayDirection = new Vector3(transform.position.x*100, (transform.position.y - parent.transform.position.y)*100, transform.position.z*100);
             Debug.DrawRay (mainCamera.transform.position, rayDirection, Color.red, 5);
         }
     }
 }
Ejemplo n.º 8
0
 void getInfo(PlanetInfo info)
 {
     if (info.elementArray[0] != 0)
     {
         elementTextbox.text += "H " + info.elementArray[0] + "\n";
     }
     if (info.elementArray[1] != 0)
     {
         elementTextbox.text += "He " + info.elementArray[1] + "\n";
     }
     if (info.elementArray[2] != 0)
     {
         elementTextbox.text += "C " + info.elementArray[2] + "\n";
     }
     if (info.elementArray[3] != 0)
     {
         elementTextbox.text += "O " + info.elementArray[3] + "\n";
     }
     if (info.elementArray[4] != 0)
     {
         elementTextbox.text += "Ne " + info.elementArray[4] + "\n";
     }
     if (info.elementArray[5] != 0)
     {
         elementTextbox.text += "Si " + info.elementArray[5] + "\n";
     }
     if (info.elementArray[6] != 0)
     {
         elementTextbox.text += "Fe " + info.elementArray[6] + "\n";
     }
 }
    private void ShowMissionInfo()
    {
        int currentIndex = buttons.GetPosition();

        if (currentIndex == -1)
        {
            return;
        }

        currentDayText.text = "Day:  " + currentDay.value;

        MissionEntry mission = availableMaps[currentIndex];

        missionName.text = mission.entryName;
        missionDesc.text = mission.mapDescription;

        //Reward
        missionRewardMoney.text = "Money:  " + mission.reward.money;
        missionRewardMoney.gameObject.SetActive(mission.reward.money > 0);
        missionRewardScrap.text = "Scrap:  " + mission.reward.scrap;
        missionRewardScrap.gameObject.SetActive(mission.reward.scrap > 0);
        missionRewardItem.text = (mission.reward.items.Count > 0) ? "Item:  " + mission.reward.items[0].entryName : "";
        missionRewardItem.gameObject.SetActive(mission.reward.items.Count > 0);
        missionRewardItem2.text = (mission.reward.items.Count > 1) ? "Item2:  " + mission.reward.items[1].entryName : "";
        missionRewardItem2.gameObject.SetActive(mission.reward.items.Count > 1);

        //Planet info
        PlanetInfo info = planets[(int)mission.mapLocation];

        planetImage.color = info.planetColor;
        planetImage.transform.localScale = new Vector3(info.size, info.size, info.size);
        planetName.text = mission.mapLocation.ToString();
    }
Ejemplo n.º 10
0
        public static Entity CreatePlanetTemplate(uint planetIndex)
        {
            PlanetData data = PlanetInfo.GetData(planetIndex);

            float  initialAngle   = Random.Range(0f, 360f);          // TODO: calculate this from position
            double orbitRadius    = data.distanceFromSun() * Scales.au2km;
            float  orbitPeriod    = data.orbitalPeriod * 365.25f;
            float  rotationPeriod = data.rotationPeriod;
            double diameter       = data.diameter * Scales.earthDiameter;

            var position        = new Vector3d(0, 0, 0);
            var rotation        = Quaternion.identity;
            var scale           = new Vector3d(diameter, diameter, diameter);
            var spatialPosition = position / Scales.spatialFactor;

            var prefabName = (planetIndex == 5 || planetIndex == 6) ? SimulationSettings.RingedPlanetPrefabName : SimulationSettings.PlanetPrefabName;

            var planetTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent((Vector3)spatialPosition, CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: prefabName)
                                 .SetPersistence(true)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new TransformInfo.Data(position.ToImprobable(), rotation.ToImprobable(), scale.ToImprobable()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new OrbitInfo.Data(initialAngle, orbitRadius, orbitPeriod, rotationPeriod), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new PlanetIndex.Data(planetIndex), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(planetTemplate);
        }
Ejemplo n.º 11
0
        private PolygonData planetSpriteData(PlanetInfo planet)
        {
            var sprite = new TextureInfo();

            switch (planet.Type)
            {
            case PlanetType.Asteriod:
                sprite = GalaxyTextures.Get.Asteroids;
                break;

            case PlanetType.GasGiant:
                sprite = GalaxyTextures.Get.GasGiant;
                break;

            case PlanetType.Rock:
                sprite = GalaxyTextures.Get.RockPlanet;
                break;
            }

            return(new PolygonData(
                       PlanetZ,
                       new SpriteData(planetTransform(planet.Position), sprite.Id, Color.White, null, true),
                       SpriteHelpers.UnitRect(sprite).ToList()
                       ));
        }
Ejemplo n.º 12
0
        public IActionResult UpdatePlanet(int planetId,
                                          [FromBody] PlanetInfo planetToUpdate)
        {
            // Error checking
            if (planetToUpdate == null)
            {
                _logger.LogError("No planet information was received.");
                return(BadRequest("No planet information was received."));
            }

            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid PlanetInfo model.");
                return(BadRequest(ModelState));
            }

            // Update the specified planet
            var planet = PlanetsDataStore.Current.Planets.FirstOrDefault(p => p.Id == planetId);

            if (planet == null)
            {
                _logger.LogError($"Unable to locate planet with id {planetId}.");
                return(NotFound($"Unable to locate planet with id {planetId}."));
            }
            planet.Name        = planetToUpdate.Name;
            planet.Description = planetToUpdate.Description;
            _logger.LogInformation($"The star chart entry for {planet.Name} has been update.");

            return(NoContent());
        }
 protected virtual void Start()
 {
     //mainCamera = GameObject.Find("Main Camera");
     if (m_Target == null) return;
     m_OriginalRotation = transform.localRotation;
     info = canvas.GetComponent<PlanetInfo> ();
 }
Ejemplo n.º 14
0
    public void UpdateBars(PlanetInfo info)
    {
        Vector3 playerPos = player.transform.position;
        float   dist      = Vector2.SqrMagnitude(playerPos - info.position);

        if (dist < turnOnDist)
        {
            Vector3 dest;
            if (!player.PlanetOn)
            {
                dest = info.position + (playerPos - info.position) / 2;
            }
            else
            {
                dest = info.position;
            }
            barrenCanvas.SetActive(true);
            float scale = 1 - dist / turnOnDist;
            scale = Mathf.Clamp(scale, 0, 1);
            barrenCanvas.transform.localScale = new Vector3(scale, scale, 1);
            barrenCanvas.transform.position   = Vector3.Lerp(barrenCanvas.transform.position, dest, 4 * Time.deltaTime);
            lavaBar.rectTransform.localScale  = new Vector3(info.lavaAmount / info.maxLava, 1, 1);
            waterBar.rectTransform.localScale = new Vector3(info.waterAmount / info.maxWater, 1, 1);
            lifeBarB.rectTransform.localScale = new Vector3(info.lifeAmount, 1, 1);
            lifeBarColor.r = 1 - (info.lifeAmount);
            lifeBarColor.g = (info.lifeAmount);
            lifeBarB.color = lifeBarColor;
        }
        else
        {
            barrenCanvas.SetActive(false);
        }
    }
Ejemplo n.º 15
0
    private void InitPlanetInfos()
    {
        LayoutRebuilder.ForceRebuildLayoutImmediate(smallPlanetsRectTransform);

        smallPlanets           = new GameObject[planetInfoList.planetInfos.Length];
        smallPlanetControllers = new SmallPlanetController[planetInfoList.planetInfos.Length];

        for (int i = 0; i < smallPlanetRectangles.Length; ++i)
        {
            Ray ray = mainCamera.ScreenPointToRay(smallPlanetRectangles[i].transform.GetChild(0).transform.position);

            Plane plane = new Plane(Vector3.back, Vector3.zero);

            if (plane.Raycast(ray, out float enter))
            {
                Vector3 intersectPoint = ray.GetPoint(enter);

                smallPlanets[i]           = Instantiate(smallPlanetPrefab, intersectPoint, Quaternion.identity);
                smallPlanetControllers[i] = smallPlanets[i].GetComponent <SmallPlanetController>();
                smallPlanetControllers[i].SetName(planetInfoList.planetInfos[i].name);
                smallPlanetControllers[i].SetMaterial(planetInfoList.planetInfos[i].smallPlanetMaterial);
                smallPlanetControllers[i].SetCamera(mainCamera);
            }
            else
            {
                Debug.LogWarning("Ray doesn't intersect with xOz plane");
            }
        }

        smallPlanetControllers[0].Select();

        currentPlanetInfo = planetInfoList.planetInfos[0];
    }
 public static bool Prefix(int b, ref int __result)
 {
     if (b < PlanetRegistry.VanillaWeightedExitPortalIDs.Length)
     {
         if (PlanetRegistry.Singleton.HasEntry(b))
         {
             PlanetInfo planet = PlanetRegistry.Singleton[b];
             int[]      weightedExitPortals = planet.WeightedExitPortalIDs.Union(PlanetRegistry.GetVanillaExitPortalWeights(b).Where(x => x.Item3 != -1).Select(x => Tuple.Create(x.Item1, x.Item2)), new ComparisonComparer <Tuple <int, int> >((p1, p2) => p1.Item1 - p2.Item1)).SelectMany(x => Enumerable.Repeat(x.Item1, x.Item2)).ToArray();
             __result = weightedExitPortals[Random.Range(0, weightedExitPortals.Length)];
         }
         else
         {
             int[] weightedExitPortals = PlanetRegistry.GetVanillaExitPortalWeights(b).SelectMany(x => Enumerable.Repeat(x.Item1, x.Item2)).ToArray();
             __result = weightedExitPortals[Random.Range(0, weightedExitPortals.Length)];
         }
         return(false);
     }
     else if (PlanetRegistry.Singleton.HasEntry(b))
     {
         PlanetInfo planet = PlanetRegistry.Singleton[b];
         int[]      weightedExitPortals = planet.WeightedExitPortalIDs.SelectMany(x => Enumerable.Repeat(x.Item1, x.Item2)).ToArray();
         __result = weightedExitPortals[Random.Range(0, weightedExitPortals.Length)];
         return(false);
     }
     return(true);
 }
Ejemplo n.º 17
0
	void Awake ()
	{
		plInfo = GetComponent<PlanetInfo> ();
		po = GetComponent<PlanetaryOrbit> ();

		planetList.Add (this);
	}
Ejemplo n.º 18
0
 private void OnPlanetState(PlanetState oldState, PlanetState newState, PlanetInfo planet)
 {
     if (newState == PlanetState.Opened)
     {
         UpdateViews();
     }
 }
Ejemplo n.º 19
0
    // Start is called before the first frame update
    void Start()
    {
        screenSize = PublicValueStorage.Instance.GetScreenSize();
        //Debug.Log("Size : " + screenSize);
        planetInfo = new PlanetInfo[planetSprites.Length];

        defaultPlanetPosition.y += screenSize.y;
        defaultPlanetPosition.z  = planetPrefab.transform.position.z;
        for (int i = 0; i < planetSprites.Length; i++)
        {
            Vector3 spawnPos = defaultPlanetPosition;
            spawnPos.x = Random.Range(screenSize.x * -0.5f, screenSize.x * 0.5f);
            spawnPos.z = planetPrefab.transform.position.z;

            planetInfo[i]             = new PlanetInfo(planetPrefab, planetSprites[i], spawnPos, this.transform);
            planetInfo[i].planetSpeed = Random.Range(moveSpeedMin, moveSpeedMax);
            planetInfo[i].spawnTimer  = Random.Range(10, spawnTimerMax);

            planetInfo[i].planetObject.SetActive(false);

            //Debug.Log(planetInfo[i].planetSpriteRenderer.sprite.name + " 's Timer : " + planetInfo[i].spawnTimer);
        }

        StartCoroutine(CoroutineMovePlanets());
    }
Ejemplo n.º 20
0
        public static void SetOutputRateNew(
            App game,
            int orbitalId,
            string panelName,
            string valueStr)
        {
            PlanetInfo planetInfo          = game.GameDatabase.GetPlanetInfo(orbitalId);
            ColonyInfo colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(orbitalId);

            Colony.OutputRate rate = Colony.OutputRate.Trade;
            if (panelName.Contains("partInfraSlider"))
            {
                rate = Colony.OutputRate.Infra;
            }
            else if (panelName.Contains("partTerraSlider"))
            {
                rate = Colony.OutputRate.Terra;
            }
            else if (panelName.Contains("partShipConSlider"))
            {
                rate = Colony.OutputRate.ShipCon;
            }
            else if (panelName.Contains("partOverDevelopment"))
            {
                rate = Colony.OutputRate.OverDev;
            }
            float outputRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(valueStr));

            Colony.SetOutputRate(game.GameDatabase, game.AssetDatabase, ref colonyInfoForPlanet, planetInfo, rate, outputRate);
            game.GameDatabase.UpdateColony(colonyInfoForPlanet);
        }
Ejemplo n.º 21
0
        public static Matrix GetSpawnTransform(App app, int systemId)
        {
            bool              flag = false;
            float             num1 = 0.0f;
            float             num2 = 0.0f;
            OrbitalObjectInfo orbitalObjectInfo1 = (OrbitalObjectInfo)null;
            Vector3           vector3_1          = Vector3.Zero;
            Vector3?          nullable           = new Vector3?();

            foreach (OrbitalObjectInfo orbitalObjectInfo2 in app.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId))
            {
                ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo2.ID);
                if (!flag || colonyInfoForPlanet != null)
                {
                    PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo2.ID);
                    float      num3       = 1000f;
                    if (planetInfo != null)
                    {
                        num3 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
                    }
                    Vector3 position = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position;
                    float   num4     = position.Length + num3;
                    if ((double)num4 > (double)num1 || !flag && colonyInfoForPlanet != null)
                    {
                        orbitalObjectInfo1 = orbitalObjectInfo2;
                        num1      = num4;
                        flag      = colonyInfoForPlanet != null;
                        vector3_1 = position;
                        num2      = num3 + 10000f;
                        nullable  = !orbitalObjectInfo2.ParentID.HasValue || orbitalObjectInfo2.ParentID.Value == 0 ? new Vector3?() : new Vector3?(app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position);
                        if (flag)
                        {
                            break;
                        }
                    }
                }
            }
            if (orbitalObjectInfo1 == null)
            {
                return(Matrix.Identity);
            }
            Vector3 vector3_2 = Vector3.Zero;

            if (nullable.HasValue)
            {
                Matrix  world = Matrix.CreateWorld(Vector3.Zero, Vector3.Normalize(nullable.Value), Vector3.UnitY);
                Vector3 v1    = Vector3.Normalize(vector3_1 - nullable.Value);
                vector3_2 = world.Right * num2;
                if ((double)Vector3.Dot(world.Right, v1) < 0.0)
                {
                    vector3_2 *= -1f;
                }
            }
            Vector3 vector3_3 = -vector3_1;
            double  num5      = (double)vector3_3.Normalize();
            Vector3 position1 = vector3_1 - vector3_3 * num2 + vector3_2;

            return(Matrix.CreateWorld(position1, Vector3.Normalize(vector3_1 - position1), Vector3.UnitY));
        }
Ejemplo n.º 22
0
 public static bool AreSame(PlanetInfo s1, PlanetInfo s2)
 {
     if (s1.ID == s2.ID && s1.Type == s2.Type && !s1.RingID.HasValue == !s2.RingID.HasValue && ((!s1.RingID.HasValue || s1.RingID.Value == s2.RingID.Value) && ((double)s1.Suitability == (double)s2.Suitability && s1.Biosphere == s2.Biosphere)) && (s1.Resources == s2.Resources && (double)s1.Infrastructure == (double)s2.Infrastructure))
     {
         return((double)s1.Size == (double)s2.Size);
     }
     return(false);
 }
Ejemplo n.º 23
0
    //private void AddOres(PlayerResources playerResources,float collected) {
    //	if(playerResources.HasOres && !FullOres) {
    //		// float collected = Mathf.SmoothStep(0, playerResources.Ores, curve.Evaluate(curveTime));
    //		playerResources.Ores -= collected;
    //		ores += collected;
    //		if(playerResources.Ores < 0.5f) {
    //			playerResources.Ores = 0f;
    //			ores = Mathf.Clamp(Mathf.Ceil(ores), 0, maxOres);
    //		}
    //	}
    //	else {//FULL
    //		ores = Mathf.Clamp(ores, 0, maxOres);
    //		playerResources.Ores = Mathf.Ceil(playerResources.Ores);
    //	}
    //}

    public void Setup(PlanetInfo info)
    {
        this.info = info;
        maxLava   = info.maxLava;
        //maxOres = info.maxOres;
        maxWater = info.maxWater;
        mat.SetFloat(Name, life);
    }
Ejemplo n.º 24
0
 public void GeneratePlanet(int width, int height, PlanetInfo planetInfo, bool setSkybox = true)
 {
     this.planetInfo = planetInfo;
             GeneratePlanet (width, height);
             if (setSkybox)
                     SetSkyBox (planetInfo.skybox);
             SetNormals (planetInfo.normals);
 }
Ejemplo n.º 25
0
 void changePlanetType(Dropdown change)
 {
     PlanetInfo.setInfo(PlanetModifiers.Planets[change.options[change.value].text]);
     scaleSlider.value = PlanetInfo.info.planetScale;
     speedSlider.value = PlanetInfo.info.rotationSpeed;
     pt.Regen();
     pb.resetBehaviour();
 }
Ejemplo n.º 26
0
 public ColonySelfSufficientDialog(App game, int planetId, int missionId)
     : base(game, "dialogColonySelfSufficientEvent")
 {
     this.orbitalObject = game.GameDatabase.GetOrbitalObjectInfo(planetId);
     this.planet        = game.GameDatabase.GetPlanetInfo(planetId);
     this.colony        = game.GameDatabase.GetColonyInfoForPlanet(planetId);
     this.mission       = game.GameDatabase.GetMissionInfo(missionId);
 }
Ejemplo n.º 27
0
        public void Sync(int planetID, bool PopulationSliders = false, bool ShowColonizebuttons = false)
        {
            StarSystemUI.ClearColonyDetailsControl(this.App.Game, this._rootPanel);
            PlanetInfo planetInfo = this.App.GameDatabase.GetPlanetInfo(planetID);

            if (planetInfo == null)
            {
                return;
            }
            this._planetID = planetID;
            this.CachePlanet(planetInfo);
            StarSystemUI.SyncPlanetDetailsControlNew(this.App.Game, this._rootPanel, planetID);
            this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "systemName"), "text", this.App.GameDatabase.GetStarSystemInfo(this.App.GameDatabase.GetOrbitalObjectInfo(planetInfo.ID).StarSystemID).Name);
            ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(planetID);

            this.App.UI.SetVisible(this.App.UI.Path(this._rootPanel, "rebellionActive"), (colonyInfoForPlanet != null ? (colonyInfoForPlanet.PlayerID != this.App.LocalPlayer.ID ? 0 : (colonyInfoForPlanet.RebellionType != RebellionType.None ? 1 : 0)) : 0) != 0);
            int num1 = 0;

            if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID)
            {
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partOverharvestSlider"), "id", "__partOverharvestSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString());
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partTradeSlider"), "id", "__partTradeSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString());
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partTerraSlider"), "id", "__partTerraSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString());
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partInfraSlider"), "id", "__partInfraSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString());
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partShipConSlider"), "id", "__partShipConSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString());
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "partCivSlider"), "id", "__partCivSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString());
                StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfoForPlanet.ID, this._widgetID, "");
                this.App.UI.SetPropertyBool(this._rootPanel, "expanded", true);
                if (!PopulationSliders)
                {
                    return;
                }
                foreach (ColonyFactionInfo faction1 in colonyInfoForPlanet.Factions)
                {
                    this.App.UI.AddItem(this.App.UI.Path(this._rootPanel, "MoraleRow"), "", faction1.FactionID, "", "popItem");
                    string itemGlobalId = this.App.UI.GetItemGlobalID(this.App.UI.Path(this._rootPanel, "MoraleRow"), "", faction1.FactionID, "");
                    this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "partPopSlider"), "id", "__partPopSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString() + "|" + (object)faction1.FactionID);
                    Faction faction2 = this.App.AssetDatabase.GetFaction(faction1.FactionID);
                    this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "factionicon"), "sprite", "logo_" + faction2.Name.ToLower());
                    this.App.UI.SetSliderValue(this.App.UI.Path(itemGlobalId, "__partPopSlider|" + this._widgetID.ToString() + "|" + colonyInfoForPlanet.ID.ToString() + "|" + (object)faction1.FactionID), (int)((double)faction1.CivPopWeight * 100.0));
                    this.App.UI.SetText(this.App.UI.Path(itemGlobalId, "gameMorale_human"), faction1.Morale.ToString());
                    double num2 = (colonyInfoForPlanet.CurrentStage == Kerberos.Sots.Data.ColonyStage.GemWorld ? Colony.GetMaxCivilianPop(this.App.GameDatabase, planetInfo) * (double)this.App.AssetDatabase.GemWorldCivMaxBonus : Colony.GetMaxCivilianPop(this.App.GameDatabase, planetInfo)) * (double)colonyInfoForPlanet.CivilianWeight * (double)faction1.CivPopWeight * (double)this.App.AssetDatabase.GetFaction(this.App.GameDatabase.GetPlayerFactionID(colonyInfoForPlanet.PlayerID)).GetImmigrationPopBonusValueForFaction(this.App.AssetDatabase.GetFaction(faction1.FactionID));
                    this.App.UI.SetText(this.App.UI.Path(itemGlobalId, "popRatio"), (faction1.CivilianPop / 1000000.0).ToString("0.0") + "M / " + (num2 / 1000000.0).ToString("0.0") + "M");
                    ++num1;
                }
                this.App.UI.SetShape(this._rootPanel, 0, 0, 360, 90 + 22 * (((IEnumerable <ColonyFactionInfo>)colonyInfoForPlanet.Factions).Count <ColonyFactionInfo>() > 1 ? ((IEnumerable <ColonyFactionInfo>)colonyInfoForPlanet.Factions).Count <ColonyFactionInfo>() : 0));
            }
            else
            {
                if (colonyInfoForPlanet != null || !ShowColonizebuttons || !(this.App.CurrentState.GetType() == typeof(StarMapState)))
                {
                    return;
                }
                StarSystemInfo starSystemInfo = this.App.GameDatabase.GetStarSystemInfo(this.App.GameDatabase.GetOrbitalObjectInfo(planetInfo.ID).StarSystemID);
                this.App.UI.SetVisible(this.App.UI.Path(this._rootPanel, "btnColoninzePlanet"), (Kerberos.Sots.StarFleet.StarFleet.CollectAvailableFleets(this.App.Game, this.App.LocalPlayer.ID, starSystemInfo.ID, MissionType.COLONIZATION, false).Any <FleetInfo>() && StarSystemDetailsUI.CollectPlanetListItemsForColonizeMission(this.App, starSystemInfo.ID, this.App.LocalPlayer.ID).Contains <int>(planetID) ? 1 : 0) != 0);
                this.App.UI.SetPropertyString(this.App.UI.Path(this._rootPanel, "btnColoninzePlanet"), "id", "btnColoninzePlanet|" + starSystemInfo.ID.ToString() + "|" + planetInfo.ID.ToString());
            }
        }
Ejemplo n.º 28
0
        protected void SetSyncedSystem(StarSystemInfo system)
        {
            this.App.UI.ClearItems("system_list");
            this.App.UI.ClearDisabledItems("system_list");
            foreach (SystemWidget systemWidget in this._systemWidgets)
            {
                systemWidget.Terminate();
            }
            foreach (PlanetWidget planetWidget in this._planetWidgets)
            {
                planetWidget.Terminate();
            }
            this._planetWidgets.Clear();
            List <PlanetInfo> planetInfoList = this.FilteredPlanetList(system);

            this.App.UI.AddItem("system_list", "", system.ID, "", "systemTitleCard");
            this._systemWidgets.Add(new SystemWidget(this.App, this.App.UI.GetItemGlobalID("system_list", "", system.ID, "")));
            this._systemWidgets.Last <SystemWidget>().Sync(system.ID);
            PlayerInfo playerInfo = this.App.GameDatabase.GetPlayerInfo(this.App.LocalPlayer.ID);

            foreach (PlanetInfo planetInfo in planetInfoList)
            {
                PlanetInfo planet = planetInfo;
                if (this.App.AssetDatabase.IsPotentialyHabitable(planet.Type))
                {
                    this.App.UI.AddItem("system_list", "", planet.ID + 999999, "", "planetDetailsM_Card");
                    this._planetWidgets.Add(new PlanetWidget(this.App, this.App.UI.GetItemGlobalID("system_list", "", planet.ID + 999999, "")));
                    this._planetWidgets.Last <PlanetWidget>().Sync(planet.ID, false, false);
                    string itemGlobalId = this.App.UI.GetItemGlobalID("system_list", "", planet.ID + 999999, "");
                    this.App.UI.SetPropertyString(this.UI.Path(itemGlobalId, "applyTrap"), "id", "applyTrap|" + planet.ID.ToString());
                    if (this._existingTraps.Any <ColonyTrapInfo>((Func <ColonyTrapInfo, bool>)(x => x.PlanetID == planet.ID)))
                    {
                        this.App.UI.SetChecked("applyTrap|" + planet.ID.ToString(), true);
                        this.App.UI.SetPropertyBool("applyTrap|" + planet.ID.ToString(), "input_enabled", false);
                    }
                    else
                    {
                        this.App.UI.SetChecked("applyTrap|" + planet.ID.ToString(), false);
                    }
                    if (this.App.GameDatabase.GetColonyInfoForPlanet(planet.ID) == null && this.App.AssetDatabase.GetFaction(playerInfo.FactionID).Name.ToLower() == "morrigi")
                    {
                        this.App.UI.SetVisible(this.UI.Path(itemGlobalId, "applyTrap|" + planet.ID.ToString()), true);
                    }
                }
                else if (this.App.AssetDatabase.IsGasGiant(planet.Type))
                {
                    this.App.UI.AddItem("system_list", "", planet.ID + 999999, "", "gasgiantDetailsM_Card");
                    this._planetWidgets.Add(new PlanetWidget(this.App, this.App.UI.GetItemGlobalID("system_list", "", planet.ID + 999999, "")));
                    this._planetWidgets.Last <PlanetWidget>().Sync(planet.ID, false, false);
                }
                else if (this.App.AssetDatabase.IsMoon(planet.Type))
                {
                    this.App.UI.AddItem("system_list", "", planet.ID + 999999, "", "moonDetailsM_Card");
                    this._planetWidgets.Add(new PlanetWidget(this.App, this.App.UI.GetItemGlobalID("system_list", "", planet.ID + 999999, "")));
                    this._planetWidgets.Last <PlanetWidget>().Sync(planet.ID, false, false);
                }
            }
        }
    private void SetPlanet(PlanetInfo info)
    {
        _currentPlanet = info;

        Physics2D.gravity           = info.Gravity;
        Camera.main.backgroundColor = info.BackgroundColor;

        _uiController.SetActiveSwitchPlanetWindow();
    }
Ejemplo n.º 30
0
        public StellarBody.Params GetStellarBodyParams(GameSession game, int orbitalId)
        {
            OrbitalObjectInfo orbitalObjectInfo   = game.GameDatabase.GetOrbitalObjectInfo(orbitalId);
            ColonyInfo        colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(orbitalId);
            PlanetInfo        planetInfo          = game.GameDatabase.GetPlanetInfo(orbitalId);
            SystemColonyType  colonyType          = SystemColonyType.Normal;
            int        num;
            double     population;
            PlayerInfo povPlayerInfo;

            if (colonyInfoForPlanet != null)
            {
                num           = colonyInfoForPlanet.PlayerID;
                population    = colonyInfoForPlanet.ImperialPop;
                povPlayerInfo = game.GameDatabase.GetPlayerInfo(num);
                if (orbitalObjectInfo != null && povPlayerInfo != null)
                {
                    HomeworldInfo homeworldInfo = game.GameDatabase.GetHomeworlds().FirstOrDefault <HomeworldInfo>((Func <HomeworldInfo, bool>)(x => x.SystemID == orbitalObjectInfo.StarSystemID));

                    if (homeworldInfo != null && homeworldInfo.SystemID != 0 && homeworldInfo.PlayerID == povPlayerInfo.ID)
                    {
                        colonyType = SystemColonyType.Home;
                    }
                    else if (game.GameDatabase.GetProvinceInfos().Any <ProvinceInfo>((Func <ProvinceInfo, bool>)(x =>
                    {
                        if (x.CapitalSystemID != orbitalObjectInfo.StarSystemID || x.PlayerID != povPlayerInfo.ID)
                        {
                            return(false);
                        }
                        int capitalSystemId = x.CapitalSystemID;
                        int?homeworld = povPlayerInfo.Homeworld;
                        if (capitalSystemId == homeworld.GetValueOrDefault())
                        {
                            return(!homeworld.HasValue);
                        }
                        return(true);
                    })))
                    {
                        colonyType = SystemColonyType.Capital;
                    }
                }
            }
            else
            {
                num           = 0;
                population    = 0.0;
                povPlayerInfo = game.GameDatabase.GetPlayerInfo(game.LocalPlayer.ID);
            }
            FactionInfo factionInfo   = game.GameDatabase.GetFactionInfo(povPlayerInfo.FactionID);
            float       hazard        = Math.Abs(planetInfo.Suitability - factionInfo.IdealSuitability);
            float       stratModifier = (float)game.App.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, povPlayerInfo.ID);
            float       radius        = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
            Matrix      transform     = orbitalObjectInfo.OrbitalPath.GetTransform(0.0);

            return(this.GetStellarBodyParams(StarSystemMapUI.SelectIcon(planetInfo, game.GameDatabase.GetStarSystemOrbitalObjectInfos(orbitalObjectInfo.StarSystemID), (IEnumerable <PlanetInfo>)game.GameDatabase.GetStarSystemPlanetInfos(orbitalObjectInfo.StarSystemID)), transform.Position, radius, orbitalId, num, planetInfo.Type, hazard, stratModifier, factionInfo.Name, (float)planetInfo.Biosphere, population, new int?(), Colony.GetColonyStage(game.GameDatabase, num, (double)hazard), colonyType));
        }
Ejemplo n.º 31
0
 public void Load(string fileName)
 {
     if (!Utility.FileExists ("config", fileName, "userplanet")) {
                     print ("File does not exist");
             } else {
                     StreamReader reader = Utility.GetConfigFileReader ("config", fileName, "userplanet");
                     string line = reader.ReadLine ();
                     planetInfo = GameState.LoadPlanet (line);
             }
 }
Ejemplo n.º 32
0
 public void Initialize(PlanetInfo info)
 {
     this.info = info;
     position  = new Vector3(info.position[0], info.position[1], 0);
     gameObject.transform.position = position;
     health     = info.health;
     rarity     = info.rarity;
     discovered = 1;
     maxHealth  = info.maxHealth;
 }
Ejemplo n.º 33
0
    public Sprite RndPlanetSprite(PlanetInfo pi, Planet rp)
    {
        int             rnd       = Random.Range(0, spawnablePlanets.Length);
        SpawnablePlanet spawnable = spawnablePlanets[rnd];

        pi.spriteInfo          = spawnable;
        rp.planetSprite.sprite = spawnable.Planet;
        GenerateObstacles(pi, rp, spawnable);
        return(spawnable.Planet);
    }
Ejemplo n.º 34
0
    public void SetPlanet(int width, int height, Color[] colors, PlanetInfo planetInfo)
    {
        Texture2D planetTex = new Texture2D(width, height, TextureFormat.ARGB32, false);

        this.planetInfo = planetInfo;
        planetTex.SetPixels(colors);
        planetTex.Apply();
        renderer.material.mainTexture = planetTex;
        SetWater(planetInfo.colorRamp.gradient [0]);
    }
Ejemplo n.º 35
0
 public void GeneratePlanet(int width, int height, PlanetInfo planetInfo, bool setSkybox = true)
 {
     this.planetInfo = planetInfo;
     GeneratePlanet(width, height);
     if (setSkybox)
     {
         SetSkyBox(planetInfo.skybox);
     }
     SetNormals(planetInfo.normals);
 }
Ejemplo n.º 36
0
    public PlanetInfo CreateInfo()
    {
        PlanetInfo planetInfo = new PlanetInfo ();
                planetInfo.skybox = skyboxes [GameObject.Find ("SkyBoxDropdown").GetComponent<dfDropdown> ().SelectedIndex];
                planetInfo.normals = planetNormals [GameObject.Find ("NormalDropdown").GetComponent<dfDropdown> ().SelectedIndex];
                planetInfo.coalReserves = 10000 * GameObject.Find ("CoalSlider").GetComponentInChildren<dfSlider> ().Value;
                planetInfo.oilFactor = GameObject.Find ("OilSlider").GetComponentInChildren<dfSlider> ().Value;
                ;
                planetInfo.windFactor = GameObject.Find ("WindSlider").GetComponentInChildren<dfSlider> ().Value;
                ;
                planetInfo.sunFactor = GameObject.Find ("SunSlider").GetComponentInChildren<dfSlider> ().Value;
                ;
                planetInfo.pollutionClearance = 20;
                planetInfo.startPollution = 0;
                planetInfo.maxPollution = 5000;
                planetInfo.startEnergy = 20;
                planetInfo.population = 100;
                planetInfo.iq = 1;
                planetInfo.gameLength = 1000;
                planetInfo.planetSize = (int)GameObject.Find ("SizeSlider").GetComponentInChildren<dfSlider> ().Value;
                print (planetInfo.planetSize);
                planetInfo.rotationSpeed = 1;
                planetInfo.windZones = 3;
                planetInfo.octaves = (int)GameObject.Find ("OctavesSlider").GetComponentInChildren<dfSlider> ().Value;
                planetInfo.gain = GameObject.Find ("GainSlider").GetComponentInChildren<dfSlider> ().Value;
                planetInfo.lacunarity = GameObject.Find ("LacunaritySlider").GetComponentInChildren<dfSlider> ().Value;
                planetInfo.stretch = GameObject.Find ("StretchSlider").GetComponentInChildren<dfSlider> ().Value;

                Color[] colors = new Color[6];
                float[] ranges = new float[5];

                for (int i = 0; i < colors.Length; i++) {
                        Color c = GameObject.Find ("ColorDisplay" + (i + 1)).GetComponentInChildren<dfSlicedSprite> ().Color;
                        if (i == 0)
                                c.a = 0;
                        colors [i] = c;
                }

                for (int i = 0; i < ranges.Length; i++) {
                        ranges [i] = GameObject.Find ("Slider" + (i + 1)).GetComponentInChildren<dfSlider> ().Value / 100f;
                }

                ColorRamp r = new ColorRamp (colors, ranges);
                planetInfo.colorRamp = r;

                return planetInfo;
    }
Ejemplo n.º 37
0
    // Use this for initialization
    void Start()
    {
        //planet graphics
        SpriteCollection sc = GameObject.Find("Sprite Collection").GetComponent<SpriteCollection>();
        ssc = transform.parent.GetComponent<SolarSystemGen>();

        transform.position += new Vector3(orbitDistance, 0, 0);
        g = gameObject.AddComponent<SpriteRenderer>();
        c = gameObject.AddComponent<CircleCollider2D>();

        g.sprite = habitable ? sc.getHabitablePlanet() : sc.getHostilePlanet();

        float scale = habitable ? Random.Range(0.2f, 0.5f): Random.Range(0.4f, 0.75f);
        transform.localScale = new Vector3(scale, scale, scale);

        planetInfo = new PlanetInfo(GetComponentInParent<SolarSystemGen>().starInfo.name + orbitDistance, habitable, GetComponentInParent<SolarSystemGen>().starInfo.rank);
    }
    public void CreatePlanetRPC(int planetID, int moonID, int ptype, float inScale, int ndx)
    {
        GameObject planet = PhotonView.Find(planetID).gameObject;
        PlanetInfo planetInfoTemp = new PlanetInfo();
        int planetType = ptype;

        planet.name = "Planet " + ndx.ToString();
        Material mat = (Material)Resources.Load("Planets/Materials/" + seedArray[planetType].ToString(), typeof(Material));
        planet.renderer.material = mat;
        planet.GetComponent<PlanetUpdate>().enabled = true;
        planet.transform.localScale *= inScale; // will modify this based on planet type.
        if (moonID > -1)
        {
            GameObject moon = PhotonView.Find(moonID).gameObject;
            // Set up moon.
            moon.name = planet.name + " Moon";
            Material moonmat = (Material)Resources.Load("Planets/Materials/" + seedArray[2].ToString(), typeof(Material)); // MAKE THIS RANDOM BASED ON MOON MATERIALS
            moon.renderer.material = moonmat;
            moon.GetComponent<PlanetUpdate>().enabled = true;
            float moonScale = 200; // MAKE THIS RANDOM
            moon.transform.localScale *= moonScale;
            moon.transform.parent = planet.transform;
            moon.transform.position += new Vector3(planet.transform.localScale.x * 2, planet.transform.localScale.x * 2,0.0f);
            moon.AddComponent("rotatePlanet");
            planetInfoTemp.hasMoon = true;
            planetInfoTemp.moonScale = moonScale;
            planetInfoTemp.moonPosition = moon.transform.position;
            planetInfoTemp.moonMaterial = 3; // MAKE THIS RANDOM
        }

        // Add planet for saving.
        planetInfoTemp.material = planetType;
        planetInfoTemp.name = planet.name;
        planetInfoTemp.position = planet.transform.position;
        planetInfoTemp.scale = planet.transform.localScale;
        planetInfoTemp.planet = planet;
        systemPlanets.Add(planetInfoTemp);
    }
Ejemplo n.º 39
0
 public void SetPlanet(int width, int height, Color[] colors, PlanetInfo planetInfo)
 {
     Texture2D planetTex = new Texture2D (width, height, TextureFormat.ARGB32, false);
             this.planetInfo = planetInfo;
             planetTex.SetPixels (colors);
             planetTex.Apply ();
             renderer.material.mainTexture = planetTex;
             SetWater (planetInfo.colorRamp.gradient [0]);
 }
Ejemplo n.º 40
0
 public void generatePlanet(PlanetInfo pi)
 {
     planetInfo = pi;
     Generate3DPerlinMap();
 }
    void CreatePlanets()
    {
        int planets = seedArray[1];

        for (int ndx = 0; ndx < planets; ++ndx)
        {
            PlanetInfo planetInfoTemp = new PlanetInfo();
            int planetType = Random.Range(0, 9);
            int hasMoon = SystemSeed.RandomSeed_Zero_to_OneHundred();

            GameObject planet = PhotonNetwork.Instantiate(("Planets/Planet"), PlanetPositionGenerator(), Quaternion.identity, 0) as GameObject;
            planet.name = "Planet " + ndx.ToString();
            Material mat = (Material)Resources.Load("Planets/Materials/" + seedArray[planetType].ToString(), typeof(Material));
            planet.renderer.material = mat;
            planet.GetComponent<PlanetUpdate>().enabled = true;
            float scaleUp = UnityEngine.Random.Range(1000,10000);
            planet.transform.localScale *= scaleUp; // will modify this based on planet type.

            int moonID = -1;
            // Checks if planet has a moon using Modulus.
            if (hasMoon % 2 != 0)
            {
                GameObject moon = PhotonNetwork.Instantiate(("Planets/Planet"), planet.transform.position, Quaternion.identity, 0) as GameObject;
                moon.name = planet.name + " Moon";
                Material moonmat = (Material)Resources.Load("Planets/Materials/" + seedArray[2].ToString(), typeof(Material)); // MAKE THIS RANDOM BASED ON MOON MATERIALS
                moon.renderer.material = moonmat;
                moon.GetComponent<PlanetUpdate>().enabled = true;
                float moonScale = 200; // MAKE THIS RANDOM
                moon.transform.localScale *= moonScale;
                moon.transform.parent = planet.transform;
                moon.transform.position += new Vector3(planet.transform.localScale.x * 2, planet.transform.localScale.x * 2,0.0f);
                moon.AddComponent("rotatePlanet");
                planetInfoTemp.hasMoon = true;
                planetInfoTemp.moonScale = moonScale;
                planetInfoTemp.moonPosition = moon.transform.position;
                planetInfoTemp.moonMaterial = 3; // MAKE THIS RANDOM
                moonID = moon.GetComponent<PhotonView>().viewID;
            }

            // Add planet for saving.
            planetInfoTemp.material = planetType;
            planetInfoTemp.name = planet.name;
            planetInfoTemp.position = planet.transform.position;
            planetInfoTemp.scale = planet.transform.localScale;
            planetInfoTemp.planet = planet;
            systemPlanets.Add(planetInfoTemp);

            photonView.RPC("CreatePlanetRPC", PhotonTargets.OthersBuffered, planet.GetComponent<PhotonView>().viewID, moonID, planetType, scaleUp, ndx);
        }
    }
Ejemplo n.º 42
0
    public static void GenerateGalaxie()
    {
        ArrayList scenes = new ArrayList ();
        scenes.Add ("BPlaneteBCyan");
        scenes.Add ("BPlaneteSable1");
        scenes.Add ("BPlaneteSable2");

        //ArrayList alreadyTaken = new ArrayList();

        if (planets == null) {
            Bounds cameraBounds = PixelPerfectCamera.OrthographicBounds (Camera.main);
            float xMax = (cameraBounds.extents.x - cameraBounds.extents.x * 0.1f) / 2;
            Globals.planets = new PlanetInfo[planetsCount];

            for (int i = 0; i < planetsCount; i++) {

                float x = Random.Range (- xMax, xMax);
                float y = Random.Range (- xMax, xMax);
                if (y < 0 && y < -4.5f)
                    y = -4.5f;

                if (!CheckPosition (x, y)) {
                    i--;
                    continue;
                }

                //int size = Random.Range (1, 3);
                //float scale = planet.transform.localScale.x / (size * 2);

                // Choix random de la scene

                bool sceneOk = false;
                string scene = "";

                while(!sceneOk){
                    int sceneRand = Random.Range(0, scenes.Count);

                    scene = (string)scenes[sceneRand];
                    sceneOk = true;
                }

                PlanetInfo p = new PlanetInfo ();
                p.x = x;
                p.y = y;
                p.scene = scene;
                //p.scale = scale;

                Globals.planets [i] = p;
            }

            PlanetInfo p2 = Globals.planets [1];
            p2.scene = "BPlaneteRouge1";
            p2.tribuId = 2;

            System.Array.Sort (Globals.planets, SortPlanets);

            PlanetInfo p1 = Globals.planets [0];
            p1.scene = "BPlaneteBleue";
            p1.tribuId = 1;

            Globals.currentPlanet = p1;
            Globals.currentPlanetId = 0;
        }
    }
Ejemplo n.º 43
0
 static int SortPlanets(PlanetInfo a, PlanetInfo b)
 {
     if (a.y > b.y) {
         return -1;
     } else if (a.y < b.y) {
         return 1;
     }
     return 0;
 }
Ejemplo n.º 44
0
    private void SharedConstructor(int width, int height)
    {
        skyboxes = Utility.GetSkyboxes();
        planetNormals = Utility.GetPlanetNormals();

        planetInfo = new PlanetInfo();
        rand = new System.Random();
        floatColors = new float[width * height];
        noise = new Noise();
        this.width = width;
        this.height = height;
    }
Ejemplo n.º 45
0
 /// <summary>
 /// After object has been created, it should have initialized
 /// through this method.
 /// </summary>
 /// <param name="planetToken">JSON token of planet information.</param>
 public void GetPlanet(JToken planetToken)
 {
     planetInfo = new PlanetInfo(planetToken);
     initTiles();      
 }
Ejemplo n.º 46
0
    public static PlanetInfo LoadPlanet(string line)
    {
        string[] splitLine = line.Split (',');
                if (splitLine.Length < numCol) {
                        print ("invalid line in planets file");
                }

                PlanetInfo planetInfo = new PlanetInfo ();

                int i = 0;
                planetInfo.planetName = splitLine [i].Trim ();
                i++;
                planetInfo.skybox = splitLine [i].Trim ();
                i++;
                planetInfo.normals = splitLine [i].Trim ();
                i++;
                planetInfo.coalReserves = int.Parse (splitLine [i]);
                i++;
                planetInfo.oilFactor = float.Parse (splitLine [i]);
                i++;
                planetInfo.windFactor = float.Parse (splitLine [i]);
                i++;
                planetInfo.sunFactor = float.Parse (splitLine [i]);
                i++;
                planetInfo.rotationSpeed = float.Parse (splitLine [i]);
                i++;
                planetInfo.gameLength = int.Parse (splitLine [i]);
                i++;
                planetInfo.planetSize = int.Parse (splitLine [i]);
                i++;
                planetInfo.population = int.Parse (splitLine [i]);
                i++;
                planetInfo.iq = float.Parse (splitLine [i]);
                i++;
                planetInfo.startEnergy = int.Parse (splitLine [i]);
                i++;
                planetInfo.startPollution = int.Parse (splitLine [i]);
                i++;
                planetInfo.pollutionClearance = int.Parse (splitLine [i]);
                i++;
                planetInfo.maxPollution = int.Parse (splitLine [i]);
                i++;
                planetInfo.windZones = int.Parse (splitLine [i]);
                i++;
                planetInfo.octaves = int.Parse (splitLine [i]);
                i++;
                planetInfo.gain = float.Parse (splitLine [i]);
                i++;
                planetInfo.lacunarity = float.Parse (splitLine [i]);
                i++;
                planetInfo.stretch = float.Parse (splitLine [i]);

                List<Color> colors = new List<Color> ();
                List<float> ranges = new List<float> ();
                for (i = 0; i < splitLine.Length - numCol; i++) {
                        string colorString = splitLine [i + numCol].Trim ();
                        if (colorString == "") {
                                break;
                        }
                        string[] colorArray = colorString.Split ('|');
                        float r = float.Parse (colorArray [0]);
                        float g = float.Parse (colorArray [1]);
                        float b = float.Parse (colorArray [2]);
                        float a = 1;
                        if (colorArray.Length > 3) {
                                a = float.Parse (colorArray [3]);
                        }
                        colors.Add (new Color (r, g, b, a));
                        i++;

                        if (i + numCol < splitLine.Length) {
                                string range = (string)(splitLine [i + numCol]).Trim ();
                                if (!string.IsNullOrEmpty (range)) {
                                        ranges.Add (float.Parse (range));
                                }
                        }
                }
                planetInfo.colorRamp = new ColorRamp (colors.ToArray (), ranges.ToArray ());
                return planetInfo;
    }