Ejemplo n.º 1
0
    void GetMaterial(Material material)
    {
        // Assign material
        gameObject.GetComponent <Renderer>().material = material;

        string planetName = material.ToString();

        planetName = planetName.Substring(0, material.ToString().IndexOf(' '));

        // Assign type
        switch (planetName)
        {
        case "Venus":
            type = PlanetType.VENUS;
            break;

        case "Earth":
            type = PlanetType.EARTH;
            break;

        case "Moon":
            type = PlanetType.MOON;
            break;

        case "Mars":
            type = PlanetType.MARS;
            break;

        case "Jupiter":
            type = PlanetType.JUPITER;
            break;
        }
    }
Ejemplo n.º 2
0
        public dPlanet(Planet_nature x)
        {
            int texID=-1;

            this.radius = x.radius;
            this.type = x.type;

            switch (x.type)
            {
                case PlanetType.flat: texID = 1; break;
                case PlanetType.sun: texID = 15; break;
            }

            ground = new objDrawer(x.radius * 2, x.radius * 2, texID);
            this.name = x.name;

            ground.x = x.x;
            ground.y = x.y;

            if (x.sectors != null && x.sectors.Length > 0)
            {
                sectors = new dSector[x.sectors.Length];
                for (int i = 0; i < x.sectors.Length; i++)
                {
                    if(x.sectors[i]!=null)
                    sectors[i] = new dSector(x.sectors[i], x, i, x.sectors.Length);
                }
            }
        }
Ejemplo n.º 3
0
    private void Initialize()
    {
        if (Spawner != null)
        {
            Spawner.UnitCount = Spawner.UnitCountInitial;
            Spawner.UpdateLabel();
        }
        if (GameManager.Instance.PlayersWithUnassignedPlanets.Count > 0 && UseAsStartPosition)
        {
            int player = GameManager.Instance.PlayersWithUnassignedPlanets.Dequeue();
            PlayerController playerController = GameManager.Instance.PlayerController[player + 1];
            SetOwner(player, playerController);
            Type = PlanetType.Main;

            playerController.Trans.position = Trans.position;
            Vector3 pos = Trans.position;
            pos.z += 0.1f;
            MothershipOrbit newMothershipOrbit =
                Instantiate(mothershipOrbitPrefab, Trans.position, Trans.rotation, Trans).GetComponent <MothershipOrbit>();
            newMothershipOrbit.transform.position     = pos;
            newMothershipOrbit.Owner.PlayerController = Owner.PlayerController;
            newMothershipOrbit.Owner.PlayerNumber     = Owner.PlayerNumber;
            newMothershipOrbit.DelayedStart();
            newMothershipOrbit.Planet = this;
        }
        else
        {
            int player = -1;
            PlayerController playerController = GameManager.Instance.PlayerController[player + 1];
            SetOwner(player, playerController);
        }
        explosionPrefab = Resources.Load <GameObject>("Explosion");
    }
Ejemplo n.º 4
0
 public Planet(string name, float seed, int galaxy, int stellarSystem, int planetID, PlanetType planetType, int horizontalSize, int verticalSize, float smoothness, int heightMultiplier, float seedCave, float caveWidth, float caveQuantity, float gravity, float daySpeedMultiplier, string atmosphere, Color filter, int numberOfChest, List <Ore> oreList, int[,] savedMapMatrix, int[] savedMapHeight, List <TileBase> tilesType, Vector3 playerLastPosition, Material planetMaterial)
 {
     this.name               = name;
     this.seed               = seed;
     this.galaxy             = galaxy;
     this.stellarSystem      = stellarSystem;
     this.planetID           = planetID;
     this.planetType         = planetType;
     this.horizontalSize     = horizontalSize;
     this.verticalSize       = verticalSize;
     this.smoothness         = smoothness;
     this.heightMultiplier   = heightMultiplier;
     this.seedCave           = seedCave;
     this.caveWidth          = caveWidth;
     this.caveQuantity       = caveQuantity;
     this.gravity            = gravity;
     this.daySpeedMultiplier = daySpeedMultiplier;
     this.atmosphere         = atmosphere;
     this.filter             = filter;
     this.numberOfChest      = numberOfChest;
     this.oreList            = oreList;
     this.savedMapMatrix     = savedMapMatrix;
     this.savedMapHeight     = savedMapHeight;
     this.tilesType          = tilesType;
     this.playerLastPosition = playerLastPosition;
     this.planetMaterial     = planetMaterial;
 }
Ejemplo n.º 5
0
    public void Initialize(GameController controller, PlanetType type)
    {
        m_controller = controller;
        GameSettings.GameMode gameMode = m_controller.GetGameMode();
        switch (gameMode)
        {
        case GameSettings.GameMode.Easy:
            m_increaseRate = m_increaseRateEasy;
            break;

        case GameSettings.GameMode.Normal:
            m_increaseRate = m_increaseRateNormal;
            break;

        case GameSettings.GameMode.Hard:
            if (type == Planet.PlanetType.Enemy)
            {
                m_increaseRate = m_increaseRateHard;
            }
            else
            {
                m_increaseRate = m_increaseRateNormal;
            }
            break;
        }

        SetType(type);
    }
Ejemplo n.º 6
0
        private IEnumerable <PlanetTraitType> randomTraits(Random rng, PlanetType bodyType, double size)
        {
            var targetCount = rng.Next(this.planetTraitGroups[bodyType].Length + 1);
            var options     = new PickList <PlanetTraitType[]>(rng, this.planetTraitGroups[bodyType]);

            while (options.Count() > targetCount)
            {
                options.Take();
            }

            var vars = new Var("size", size).
                       And("asteroid", bodyType == PlanetType.Asteriod).
                       And("rock", bodyType == PlanetType.Rock).
                       And("gasGiant", bodyType == PlanetType.GasGiant).
                       Init(this.planetTraits.Keys, false);

            foreach (var group in this.planetTraitGroups[bodyType].Where(x => options.InnerList.Contains(x)))
            {
                var applicableTraits = new PickList <PlanetTraitType>(rng, group.
                                                                      Where(x => !this.traitConditions.ContainsKey(x.IdCode) || this.traitConditions[x.IdCode].Evaluate(vars.Get) >= 0)
                                                                      );
                if (applicableTraits.Count() > 0)
                {
                    var trait = applicableTraits.Pick();

                    yield return(trait);

                    vars.Set(trait.IdCode, 1);
                }
            }
        }
    public Planet(string loadString, int inID)
    {
        string[] argument = loadString.Split('|');
        galacticPosition.x = float.Parse(argument[0]);
        galacticPosition.y = float.Parse(argument[1]);
        galacticPosition.z = float.Parse(argument[2]);
        this.type          = (PlanetType)int.Parse(argument[3]);
        id        = inID;
        isVisited = (argument[4] == "1");
        isLocked  = (argument[5] == "1");
        seed      = int.Parse(argument[6]);
        name      = argument[7];

        switch (this.type)
        {
        case Planet.PlanetType.HOME: this.color = new Color(0, .8f, 0); break;

        case Planet.PlanetType.COLD: this.color = new Color(.4f, .7f, 1); break;

        case Planet.PlanetType.HOT: this.color = new Color(1, .6f, .3f); break;

        case Planet.PlanetType.NEON: this.color = new Color(.8f, .3f, .7f); break;

        default: this.color = new Color(0, .1f, .15f); break;
        }
    }
        public static PlanetGenerator getGenerator(PlanetType type, Vector2u size, int seed)
        {
            switch (type)
            {
            case PlanetType.GasGiant:
                throw new NotImplementedException();
                return(null);

                break;

            case PlanetType.Ice:
                return(new SnowGenerator(size, seed));

                break;

            case PlanetType.Terran:
                return(new TerraGenerator(size, seed));

                break;

            case PlanetType.Water:
                return(new BluePlanetGenerator(size, seed));

                break;

            case PlanetType.Red:
                return(new RedGenerator(size, seed));

                break;

            default:
                throw new NotSupportedException();
                break;
            }
        }
Ejemplo n.º 9
0
 public Planet()
 {
     name               = "";
     seed               = 0.0f;
     galaxy             = 0;
     stellarSystem      = 0;
     planetID           = 0;
     planetType         = new PlanetType();
     horizontalSize     = 0;
     verticalSize       = 0;
     smoothness         = 0.0f;
     heightMultiplier   = 0;
     seedCave           = 0.0f;
     caveWidth          = 0.0f;
     caveQuantity       = 0.0f;
     gravity            = 9.81f;
     daySpeedMultiplier = 1;
     atmosphere         = "";
     filter             = new Color();
     numberOfChest      = 0;
     oreList            = new List <Ore> ();
     savedMapMatrix     = null;
     savedMapHeight     = null;
     tilesType          = new List <TileBase> ();
     playerLastPosition = new Vector3(0, 0, 0);
     planetMaterial     = null;
 }
Ejemplo n.º 10
0
        // Создание префаба сферы планетарной планеты
        public static GameObject CreatePlanetSphere(PlanetType APlanetType, PlanetMode aMode)
        {
            string LPrefabPath = "PL/Planet/";
            int    LSkinID;
            string LPrefabPlanetSphereType = APlanetType.ToString();

            // Временное украшательство
            if (APlanetType == PlanetType.Earth && aMode == PlanetMode.Big)
            {
                LPrefabPlanetSphereType = "Big";
                LSkinID = Random.Range(1, 4);
            }
            else if (APlanetType == PlanetType.Earth && aMode == PlanetMode.Normal)
            {
                LPrefabPlanetSphereType = "Small";
                LSkinID = Random.Range(1, 4);
            }
            else
            if (APlanetType == PlanetType.Hydro)
            {
                LSkinID = Random.Range(1, 3);
            }
            else
            if (APlanetType == PlanetType.Sun)
            {
                LSkinID = 2;
            }
            else
            {
                LSkinID = 1;
            }
            string LPrefabPlanetSphere = LPrefabPlanetSphereType + "/pfPLPlanetSphere" + LPrefabPlanetSphereType + LSkinID.ToString();

            return(Create(LPrefabPath + LPrefabPlanetSphere, Vector3.zero));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Setup for Trail Mode
        /// </summary>
        /// <param name="menuNode">Menu node.</param>
        /// <param name = "planet"></param>
        /// <param name = "autoSelectDifficulty"></param>
        public void Setup(SurfaceMenuNode menuNode, PlanetType planet, bool autoSelectDifficulty = true)
        {
            currentSurfaceNode = menuNode;
            currentPlanet      = planet;
            currentBonusPlanet = null;
            currentMenuNode    = null;
            pillars            = menuNode.transform.GetComponentsInChildren <PillarMenuNode>(true);

            if (autoSelectDifficulty)
            {
                SetupDifficulty(menuNode.LaunchGame);
            }

            SetupMode(true);
            SetupGame(menuNode.LaunchGame);

            CurvedUIAnimator.gameObject.SetActive(true);
            CurvedUIAnimator.Play("bentScreen_hiddenToPrimary");

            TrailName.text        = Localizer.Get("PedestalView.Title.TrialName." + planet + "." + menuNode.LaunchGame);
            TrailDescription.text = Localizer.Get("PedestalView.Description.TrialObjective." + planet + "." + menuNode.LaunchGame);

            if (menuNode.LaunchGame == Game.Duel || menuNode.LaunchGame == Game.Assault)
            {
                Lesson.text = Localizer.Get("PedestalView.Prompt.TrialLesson." + planet + "." + menuNode.LaunchGame + "." + CurrentDifficulty.ToString());
                ChangeBackground(CurrentDifficulty);
            }
            else
            {
                Lesson.text = Localizer.Get("PedestalView.Prompt.TrialLesson." + planet + "." + menuNode.LaunchGame);
                ChangeBackground(CurrentDifficulty, true);
            }
        }
Ejemplo n.º 12
0
        public DBPlanet(DateTime inventingDate, byte[] photo, string name, Distance middleDistance, uint radius, bool hasAtmosphere, PlanetType type, string star, string galaxy, uint temperature = 0, HashSet <Moon> moons = null)
        //base(inventingDate, photo, name, middleDistance, radius, temperature)
        {
            HasAtmosphere = hasAtmosphere;
            Type          = type;
            Moons         = new Collection <DBMoon>();
            if (moons != null)
            {
                foreach (var moon in moons)
                {
                    Moons.Add(new DBMoon(moon, Id));
                }
            }
            //else Moons = new HashSet<DBMoon>();

            Photo = photo;

            Name = name;
            MiddleDistanceValue = middleDistance.Value;
            MiddleDistanceUnit  = middleDistance.Unit;

            Radius      = radius;
            Temperature = temperature;
            //Galaxy = galaxy;
            InventingDate = inventingDate;

            //Database.EnsureCreated();
            Type   = type;
            Star   = star;
            Galaxy = galaxy;
        }
Ejemplo n.º 13
0
 public Server(PlanetType thePlanetType, ServerInfo theServerInfo)
 {
     InitializeComponent();
     aPlanet            = thePlanetType;
     this.Loaded       += new RoutedEventHandler(Server_Loaded);
     lblServerName.Text = theServerInfo.ServerName;
 }
Ejemplo n.º 14
0
    public PlanetData(PlanetTypeEnum type)
    {
        switch (type)
        {
        case PlanetTypeEnum.Desert:
            data = new PlanetTypeEgypt();
            break;

        case PlanetTypeEnum.Forest:
            data = new PlanetTypeForest();
            break;

        case PlanetTypeEnum.Water:
            data = new PlanetTypeHawaii();
            break;

        case PlanetTypeEnum.Icy:
            data = new PlanetTypeIce();
            break;

        case PlanetTypeEnum.Plain:
            data = new PlanetTypeIceGrey();
            break;

        case PlanetTypeEnum.Clay:
            data = new PlanetTypeOrange();
            break;

        case PlanetTypeEnum.Tundra:
            data = new PlanetTypePine();
            break;
        }
    }
Ejemplo n.º 15
0
        public static bool IsPlanetLocked(PlanetType planet)
        {
            if (AllProgressionUnlocked)
            {
                return(false);
            }

            SG.Lonestar.Inventory.BattleProgress progress = GetDuelApi().Progress;

            // TODO: I don't like having this is code, but we don't have a better way just yet.
            switch (planet)
            {
            case PlanetType.Naboo:
                return(false);

            case PlanetType.Garel:
                return(!progress.HasCompleted(DuelAPI.Duelist.DarthMaul, 1));

            case PlanetType.Lothal:
                return(!progress.HasCompleted(DuelAPI.Duelist.SeventhSister, 1));

            case PlanetType.Hoth:
                return(!progress.HasCompleted(DuelAPI.Duelist.GrandInquisitor, 1));

            case PlanetType.Takodana:
                return(!progress.HasCompleted(DuelAPI.Duelist.DarthVader, 1));

            case PlanetType.Core:
                return(!progress.HasCompleted(DuelAPI.Duelist.KyloRen, 2));
            }

            return(false);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Gets the planet animator.
        /// </summary>
        /// <returns>The planet animator.</returns>
        /// <param name="planet">Planet.</param>
        public Animator GetPlanetAnimator(PlanetType planet)
        {
            Animator animator = PlanetAnimators[(int)planet];

            animator.gameObject.SetActive(true);
            return(animator);
        }
Ejemplo n.º 17
0
    private void ChangePlanetType(PlanetType type)
    {
        var planetSettings = planets.First(p => p.type == type);

        _camera.backgroundColor = planetSettings.color;
        Physics2D.gravity       = new Vector2(0f, -planetSettings.gravity);
    }
Ejemplo n.º 18
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] PlanetType planetType)
        {
            if (id != planetType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(planetType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlanetTypeExists(planetType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(planetType));
        }
Ejemplo n.º 19
0
    //Allows for simple planet addition.
    static PlanetTypes()
    {
        typeRock = new PlanetType
        {
            typename = "Rock",

            life = false,

            genblocks = new List<BlockType>()
            {
                BlockTypes.typeCore,
                BlockTypes.typeStone,
                BlockTypes.typeEmpty,
                BlockTypes.typeBedrock
            },

            genores = new List<BlockType>()
            {
                BlockTypes.typeOreIron,
                BlockTypes.typeOreUranium
            }

        };

        typeLava = new PlanetType
        {

        };

        typeIce = new PlanetType
        {

        };
    }
Ejemplo n.º 20
0
    void SetPlanetMaterial(PlanetType type)
    {
        if (type == PlanetType.Cold)
        {
            PlanetModel.GetComponent <MeshRenderer>().material = ColdPlanetMat;
        }
        else if (type == PlanetType.Hot)
        {
            PlanetModel.GetComponent <MeshRenderer>().material = HotPlanetMat;
        }
        else if (type == PlanetType.Gas)
        {
            PlanetModel.GetComponent <MeshRenderer>().material = GasPlanetMat;
            //set random color
            Color c = Color.Lerp(GasPlanetColor1, GasPlanetColor2, Random.value);

            float intensity = Random.Range(1f, 1.5f);

            PlanetModel.GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", c);
            PlanetModel.GetComponent <MeshRenderer>().material.SetFloat("_Intensity", intensity);
        }
        else
        {
            PlanetModel.GetComponent <MeshRenderer>().material = DefaultPlanetMat;
        }
    }
Ejemplo n.º 21
0
        public static void init(

            )
        {
            var        icon          = AbstractResourceTest.GetTestAbstractImage();
            PlanetType t1            = null;
            var        yieldResource =
                SingularGameResourceYieldTest.getTestSingularGameResourceYield(
                    type: GameResourceTest.getTestGameResourceType(),
                    value: 500
                    );
            var fullYield =
                GameResourceYieldTest.GetTestFinishedGameResourceYield(yieldResource);

            Assert.DoesNotThrow(() => t1 = getTestPlanetType(
                                    id: 0,
                                    image: icon,
                                    name: "Test1",
                                    desc: "TestD1",
                                    calc: count => fullYield
                                    ));

            var calcYield = t1.getYield(123);

            Assert.Multiple(() => {
                Assert.AreEqual(0, t1.id);
                Assert.AreEqual("Test1", t1.name);
                Assert.AreEqual("TestD1", t1.description);
                Assert.AreEqual(icon, t1.icon);
                Assert.AreEqual(fullYield, calcYield);
            });
        }
Ejemplo n.º 22
0
        public virtual void SaveToXML(XmlElement objOrbit)
        {
            var nfi = System.Globalization.NumberFormatInfo.InvariantInfo;

            var xePlanet = objOrbit.OwnerDocument.CreateElement("Planet");

            objOrbit.AppendChild(xePlanet);
            Common.CreateTextNode(xePlanet, "Type", PlanetType.ToString());
            Common.CreateTextNode(xePlanet, "Dense", Dense.ToString());
            Common.CreateTextNode(xePlanet, "Mass", Mass.ToString());
            Common.CreateTextNode(xePlanet, "Gravity", Grav.ToString());
            Common.CreateTextNode(xePlanet, "Pressure", Pressure.ToString());
            Common.CreateTextNode(xePlanet, "MaxPop", Maxpop.ToString());
            Common.CreateTextNode(xePlanet, "OrbitRange", OrbitRange.ToString());
            Common.CreateTextNode(xePlanet, "OrbitNumber", OrbitNumber.ToString());
            Common.CreateTextNode(xePlanet, "Tilt", Tilt.ToString());
            Common.CreateTextNode(xePlanet, "Ecc", Ecc.ToString());
            Common.CreateTextNode(xePlanet, "Rotation", Rotation.ToString());
            Common.CreateTextNode(xePlanet, "TidallyLocked", TidallyLocked.ToString());
            Common.CreateTextNode(xePlanet, "Temp", Temp.ToString());
            Common.CreateTextNode(xePlanet, "Diameter", Diameter.ToString());
            Common.CreateTextNode(xePlanet, "NumSats", Satellites.Count.ToString());
            Common.CreateTextNode(xePlanet, "Mainworld", MainWorld.ToString());
            Common.CreateTextNode(xePlanet, "NormalUWP", Normal.DisplayString(PlanetType, Diameter));
            Common.CreateTextNode(xePlanet, "CollapseUWP", Collapse.DisplayString(PlanetType, Diameter));
            Common.CreateTextNode(xePlanet, "Life", Life.ToString());
            Common.CreateTextNode(xePlanet, "LifeFactor", LifeFactor.ToString());
            Common.CreateTextNode(xePlanet, "Name", Name);

            var xeChild = objOrbit.OwnerDocument.CreateElement("Temperature");

            for (var i = 0; i < (Constants.NUM_HEX_ROWS * 2) - 1; i += 2)
            {
                var xeTemp = objOrbit.OwnerDocument.CreateElement("Row" + (i / 2 + 1).ToString());

                Common.CreateTextNode(xeTemp, "Summer", Summer[i].ToString("N", nfi) + "/" + Summer[i + 1].ToString("N", nfi));
                Common.CreateTextNode(xeTemp, "Fall", Fall[i].ToString("N", nfi) + "/" + Fall[i + 1].ToString("N", nfi));
                Common.CreateTextNode(xeTemp, "Winter", Winter[i].ToString("N", nfi) + "/" + Winter[i + 1].ToString("N", nfi));

                xeChild.AppendChild(xeTemp);
            }

            xePlanet.AppendChild(xeChild);

            if (Life)
            {
                xeChild = objOrbit.OwnerDocument.CreateElement("AnimalEncounters");
                TableGenerator.WriteToXML(xeChild);
                xePlanet.AppendChild(xeChild);
            }

            Normal.SaveToXML(xePlanet);
            Collapse.SaveToXML(xePlanet);

            foreach (var satellite in Satellites)
            {
                satellite.SaveToXML(xePlanet);
            }
        }
Ejemplo n.º 23
0
 public Planet(PlanetType planetType, Factions owningFaction, Factions originalFaction, int captureTurn, int devestationTurn)
 {
     PlanetType      = planetType;
     OwningFaction   = owningFaction;
     OriginalFaction = originalFaction;
     CaptureTurn     = captureTurn;
     DevestationTurn = devestationTurn;
 }
Ejemplo n.º 24
0
 public Planet(StarData star, int position, PlanetType type, double size, List <BodyTraitType> traits)
 {
     this.Star     = star;
     this.Position = position;
     this.Type     = type;
     this.Size     = size;
     this.Traits   = new PendableSet <BodyTrait>(traits.Select(x => x.Instantiate(this)));
 }
Ejemplo n.º 25
0
 public Planet(string name, PlanetType type, RLColor color, IBody parent, float distanceFromParent = 0f)
 {
     this.Name               = name;
     this.PlanetType         = type;
     this.Color              = color;
     this.Parent             = parent;
     this.distanceFromParent = distanceFromParent;
 }
Ejemplo n.º 26
0
 public Planet(int x, int y, int z, PlanetType type, int size)
 {
     X    = x;
     Y    = y;
     Z    = z;
     Type = type;
     Size = size;
 }
Ejemplo n.º 27
0
 public Planet(int id, [CanBeNull] Player owner, Vector2 position, PlanetType type, int unitsCount)
 {
     Position   = position;
     Type       = type;
     UnitsCount = unitsCount;
     Id         = id;
     Owner      = owner;
 }
Ejemplo n.º 28
0
 public Planet(StarData star, int position, PlanetType type, double size, IEnumerable <PlanetTraitType> traits)
 {
     this.Star     = star;
     this.Position = position;
     this.Type     = type;
     this.Size     = size;
     this.Traits   = new PendableSet <PlanetTraitType>(traits);
 }
Ejemplo n.º 29
0
    public Planet(string name, Vector3 location, Random random, PlanetType planetType) : base(name, location, random)
    {
        base.type  = PointOfInterestType.Planet;
        base.model = ModelDB.GetPlanet(planetType, random);

        _waterLevel = random.Next(0, 100) * .01f;
        _planetType = planetType;
        _palette    = PaletteDB.Get(_planetType).Instantiate();
    }
Ejemplo n.º 30
0
        double vitesseDesastre; // Influe sur la vitesse d'apparition des desastres

        // Constructeur
        public MyPlanet()
        {
            this.planetType      = new PlanetType();
            this.name            = "default";
            this.temperature     = this.planetType.getDepartTemperature();
            this.radiation       = this.planetType.getDepartRadiation();
            this.coeficienEau    = this.planetType.getCoefEau();
            this.vitesseDesastre = this.planetType.getVitesseDesastre();
        }
Ejemplo n.º 31
0
 public Planet(string name, string sprite, PlanetType type, float radius, float orbitRadius=1, float orbitPeriod=365, params SpaceObject[] children)
     : base(children)
 {
     Name = name;
     TextureId = sprite;
     Type = type;
     OrbitRadius = orbitRadius;
     OrbitPeriod = orbitPeriod;
     Radius = radius;
 }
Ejemplo n.º 32
0
    public Planet(string name, int size, PlanetType planetType, Game game, StarOrbit orbit, int nthOrbit, bool isSatellite) : base(CelestialBodyType.Planet, orbit, game) // for making special named planets, such as Mercury, Mars.
    {
        this.nthOrbit    = nthOrbit;
        this.name        = name;
        this.size        = size;
        this.planetType  = planetType;
        this.isSatellite = isSatellite;

        _SetRadiusAndPosition();
    }
Ejemplo n.º 33
0
        public Sprite GetSprite(PlanetType type)
        {
            var planetNum = Utilities.RandomInt(0, _planetTypes - 1);
            var planetRow = PlanetMapping[type];
            var x         = _upperLeft.X + (planetNum * SpriteSize.Width) + (planetNum * _hPadding);
            var y         = _upperLeft.Y + (planetRow * SpriteSize.Height) + (planetRow * _vPadding);
            var rect      = new Rectangle(x, y, SpriteSize.Width, SpriteSize.Height);

            return(new Sprite(_image, rect));
        }
Ejemplo n.º 34
0
        static Planet_nature getNewPlanet(PlanetType type, float[] xy)
        {
            Planet_nature natPlanet = new Planet_nature();
            natPlanet.x=xy[0];
            natPlanet.y=xy[1];

            natPlanet.name=getPlanetName();

            natPlanet.resources = new Resource[3];
            for (int i = 0; i < natPlanet.resources.Length; i++ )
            {
                natPlanet.resources[i] = new Resource();
            }

            natPlanet.resources[0].type = ResouresType.garbage;
            natPlanet.resources[1].type=ResouresType.air;
            natPlanet.resources[2].type=ResouresType.water;

            int sectorsCount = 10;
            if (type == PlanetType.sun) sectorsCount = 1;

            natPlanet.sectors = new sector[sectorsCount];

            natPlanet.type = type;

            switch(type)
            {
                case PlanetType.flat:
                    natPlanet.radius = manager.rand.Next(10, 20);
                    for (int i = 0; i < sectorsCount; i++ )
                    {
                        natPlanet.sectors[i] = new sector();
                        if (manager.rand.Next(0, 2) == 1)
                        {
                            natPlanet.sectors[i].natureBuilding = new Building(buildingsEnum.grass);
                        }
                        else
                        {
                            natPlanet.sectors[i].natureBuilding = new Building(buildingsEnum.forest);
                        }
                    }
                    break;

                case PlanetType.sun:
                    natPlanet.name = "Helios";
                    natPlanet.radius = 50;
                    for (int i = 0; i < sectorsCount; i++)
                    {
                        natPlanet.sectors[i] = new sector();
                    }
                    break;
            }

            return natPlanet;
        }
Ejemplo n.º 35
0
    public static GameObject CreatePlanet(GameObject obj, string name, PlanetType type, Star host, int orbit, Vector3 pos, Quaternion quat)
    {
        obj = (GameObject)Instantiate(obj, pos, quat);
        host.AssignPlanet(obj.GetComponent<Planet>(), orbit);

        obj.AddComponent<Planet>();
        obj.GetComponent<Planet>().nickname = name;
        obj.GetComponent<Planet>().type = type;

        return obj;
    }
Ejemplo n.º 36
0
 public Archetype()
 {
     Type = PlanetType.BASE;
     TemperatureRange = new Vector2(0, 0); // kelvin
     AtmospherePressureRange = new Vector2(0, 2.5f); // bars
     DayLengthRange = new Vector2(5, 90); // minutes
     MassRange = new Vector2(0.2f, 2.5f);
     ColorPalette = new Color[] {
         new Color(0,0,0,1),
         new Color(1,1,1,1)
     };
 }
Ejemplo n.º 37
0
	public void SpawnPlanet (Vector3 pos, PlanetType pt) {

		GameObject plan = pt.GetInstance ();

		plan.transform.parent = stuffHolder.transform;

		plan.transform.position = pos;

		//Debug.Log ("Loading " + pt.assetLoc + " " + Resources.Load ("PlanetImages/" + pt.assetLoc, typeof(Sprite)) as Sprite);
		//plan.GetComponent <SpriteRenderer> ().sprite = Resources.Load ("PlanetImages/" + pt.assetLoc, typeof(Sprite)) as Sprite;

		planets.Add (plan);
	}
Ejemplo n.º 38
0
    private void OnValidate()
    {
        if (Application.isPlaying) { return; }
        if (Type != _type)
        {
            Debug.Log("Type Changed from " + _type + " to " + Type);
            _type = Type;
            SetSprite();
        }

        if (PlanetRadius != _planet) { _planet = PlanetRadius; SetScale(); }
        if (GravityDepth != _gravity) { _gravity = GravityDepth; SetScale(); }
    }
Ejemplo n.º 39
0
    public static PlanetTypeData GetPlanetTypeData(PlanetType type)
    {
        // Load the Data if it does not yet exist
        if(_planetTypeData == null)
        {
            _planetTypeData = new Dictionary<PlanetType, PlanetTypeData>();
            _planetTypeData.Add(PlanetType.Chomper, new PlanetTypeData(PlanetType.Chomper, "big_guy"));
            _planetTypeData.Add(PlanetType.Bouncer, new PlanetTypeData(PlanetType.Bouncer, "flapper"));
            _planetTypeData.Add(PlanetType.Popper, new PlanetTypeData(PlanetType.Popper, "lil_guy"));
        }

        // Return the data type or popper Type if not found.
        if(_planetTypeData.ContainsKey(type))
        {
            return _planetTypeData[type];
        }
        return _planetTypeData[PlanetType.Popper];
    }
Ejemplo n.º 40
0
 public PlanetTypeData(PlanetType type, string sprite)
 {
     Type = type;
     Sprite = sprite;
 }
Ejemplo n.º 41
0
 public PlanetData(PlanetType type, Vector2 pos, float gap, float gravity, float body)
 {
     Type = type;
     Gap = gap;
     Gravity = gravity;
     Body = body;
     Pos = pos;
 }
Ejemplo n.º 42
0
	public override void Initialize(bool bRandomize)
	{
		if (bRandomize)
		{
			int seed = UnityEngine.Random.Range (0, 8);
			Type = (PlanetType)seed;
			seed = UnityEngine.Random.Range (0, 5);
			Size = (PlanetSize)seed;

			Coordinates.Set (UnityEngine.Random.Range(-50f, 50f), UnityEngine.Random.Range(-50f, 50f));
		}
		base.Initialize (bRandomize);
		
		switch (Type)
		{
			case PlanetType.Asteroid:
			{
				_baseModifiers.Fuel = 0f;
				_baseModifiers.Metal = UnityEngine.Random.Range (1.25f, 1.4f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.25f, .4f);
				_baseModifiers.Organic = 0;

				_initialRates = new GainRate (0f, 0f, 0f, 0f);
				break;
			}
			case PlanetType.Aquatic:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (.8f, 1.1f);
				_baseModifiers.Metal = UnityEngine.Random.Range (.1f, .2f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.5f, .75f);
				_baseModifiers.Organic = UnityEngine.Random.Range (.5f, .75f);

				_initialRates = new GainRate (0f, 0f, .5f, 2f);
				break;
			}
			case PlanetType.Barren:
			{
				_baseModifiers.Fuel = 0f;
				_baseModifiers.Metal = UnityEngine.Random.Range (.5f, .75f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.1f, .2f);
				_baseModifiers.Organic = 0f;

				_initialRates = new GainRate (0f, 0f, 0f, 0f);
				break;
			}
			case PlanetType.Desert:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (.8f, 1.1f);
				_baseModifiers.Metal = UnityEngine.Random.Range (.8f, 1.1f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.5f, .75f);
				_baseModifiers.Organic = UnityEngine.Random.Range (.1f, .2f);

				_initialRates = new GainRate (0f, 0f, 0f, 0f);
				break;
			}
			case PlanetType.Frozen:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (.1f, .2f);
				_baseModifiers.Metal = UnityEngine.Random.Range (.1f, .2f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (1.1f, 1.2f);
				_baseModifiers.Organic = 0f;

				_initialRates = new GainRate (0f, 0f, 0f, 0f);
				break;
			}
			case PlanetType.Gas:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (1.4f, 1.6f);
				_baseModifiers.Metal = 0f;
				_baseModifiers.Crystal = 0f;
				_baseModifiers.Organic = 0f;

				_initialRates = new GainRate (.5f, 0f, 0f, 0f);
				break;
			}
			case PlanetType.Jungle:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (1.1f, 1.2f);
				_baseModifiers.Metal = UnityEngine.Random.Range (.25f, .4f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.25f, .4f);
				_baseModifiers.Organic = UnityEngine.Random.Range (1.4f, 1.6f);

				_initialRates = new GainRate (2f, 0f, 1f, 5f);
				break;
			}
			case PlanetType.Terran:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (.8f, 1.1f);
				_baseModifiers.Metal = UnityEngine.Random.Range (.8f, 1.1f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.8f, 1.1f);
				_baseModifiers.Organic = UnityEngine.Random.Range (.8f, 1.1f);

				_initialRates = new GainRate (4f, 4f, 4f, 4f);
				break;
			}
			case PlanetType.Volcanic:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (1.1f, 1.2f);
				_baseModifiers.Metal = UnityEngine.Random.Range (1.25f, 1.4f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (.25f, .4f);
				_baseModifiers.Organic = 0f;

				_initialRates = new GainRate (0f, 2f, 0f, 0f);
				break;
			}
			default:
			{
				_baseModifiers.Fuel = UnityEngine.Random.Range (0f, .1f);
				_baseModifiers.Metal = UnityEngine.Random.Range (0f, .1f);
				_baseModifiers.Crystal = UnityEngine.Random.Range (0f, .1f);
				_baseModifiers.Organic = UnityEngine.Random.Range (0f, .1f);

				_initialRates = new GainRate (0f, 0f, 0f, 0f);
				break;
			}
		}

		int _randomNum = -1;

		do 
		{
			_randomNum = UnityEngine.Random.Range (0, Database.PlanetNames.Length - 1);
		} 
		while (_selectedNames.Contains(_randomNum));

		Name = Database.PlanetNames[_randomNum];
		InteractRadius = ((int)Size + 1) * 2f;
		UpdateState += OnUpdateStateEvent;
		UpdateSecond += OnUpdateSecondEvent;

		CalcRates ();
	}
Ejemplo n.º 43
0
	public Planet(PlanetType PType)
	{
		Type = PType;
	}
Ejemplo n.º 44
0
 public static void AddBackgroundPlanet(this EntityWorld world, PlanetType planetType)
 {
 }
Ejemplo n.º 45
0
 private PlanetBase AttachPlanetBehavior(GameObject go, PlanetType type)
 {
     PlanetBase behavior;
     switch(type)
     {
         case PlanetType.Popper:
         {
             behavior = go.AddComponent<PlanetPopper>();
             break;
         }
         case PlanetType.Bouncer:
         {
             behavior = go.AddComponent<PlanetBouncer>();
             break;
         }
         case PlanetType.Chomper:
         {
             behavior = go.AddComponent<PlanetChomper>();
             break;
         }
         default:
         {
             behavior = go.AddComponent<PlanetBase>();
             break;
         }
     }
     return behavior;
 }
Ejemplo n.º 46
0
    public virtual void Initialize(PlanetData data)
    {
        PlanetObject = gameObject.transform.GetChild(0).gameObject;
        GravityObject = gameObject.transform.GetChild(1).gameObject;
        if(PlanetObject == null || GravityObject == null)
        {Logger.Log("Error Initializing Planet " + data.Type, 4);return;}

        _data = data;
        _active = true;
        _orbitActive = false;
        Type = data.Type;
        BodyRadius = data.Body;
        GravityDepth = data.Gravity;
    }
Ejemplo n.º 47
0
	void End () {
		state = editingState.none;
		currentlyPlacing = null;
		currentlyTyped = null;
		underCursor = null;
		vineEnd1 = null;
		vineEnd2 = null;
		vine = null;
		currentDemand = "";
	}
Ejemplo n.º 48
0
	public static void StartPlacingPlanet (string name) {
		PlanetType pt = new PlanetType (name);

		currentlyPlacing = pt.GetInstance ();
		currentlyTyped = pt;
		underCursor = currentlyPlacing;
		currentlyPlacing.AddComponent <HasDemands> ().startWithNoDemands = true;

		state = editingState.planets;
	}
Ejemplo n.º 49
0
	public PlacementDetails (PlanetType pt, Vector3 p) {
		planetType = pt;
		pos = p;

		id = idCount;
		idCount ++;
	}
Ejemplo n.º 50
0
 public override void SetType(PlanetType type)
 {
     base.SetType(type);
 }
Ejemplo n.º 51
0
    public virtual void SetType(PlanetType type)
    {
        SpriteRenderer sr = PlanetObject.GetComponent<SpriteRenderer>();
        sr.sprite = Resources.Load<Sprite>("Sprites/" + Global.GetPlanetTypeData(_data.Type).Sprite);

        // TODO: Modify the behavior and skin to match the type
    }
Ejemplo n.º 52
0
	// Update is called once per frame
	void Update () {
		//mouse
		Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition);
		pz.z = 0;
		if (useGrid && state == editingState.planets) {
			pz.x = (int)pz.x;
			pz.y = (int)pz.y;
		}
		if (underCursor != null) {
			underCursor.transform.position = pz;
		}

		//right click escapes
		if (Input.GetMouseButton (1)) {
			GameObject.Destroy (currentlyPlacing);
			GameObject.Destroy (underCursor);
			End ();
		}

		switch (state) {
		case editingState.planets:
			if (Input.GetMouseButton (0)) {
				if (currentlyTyped != null) {
					var pd = new PlacementDetails (currentlyTyped, currentlyPlacing.transform.position);
					pd.thePlanetGob = currentlyPlacing;
					record.Add (pd);
				}
				currentlyPlacing = null;
				currentlyTyped = null;
				underCursor = null;
				state = editingState.none;
			}
			break;
		case editingState.vine:
			//TODO stretch
			if (vineEnd1 != null) {
				Vector3 end2 = Vector3.zero;
				if (vineEnd2 != null)
					end2 = vineEnd2.transform.position;
				else 
					end2 = pz;
				FlowerDragManager.PlaceVine (vineEnd1.transform.position, end2, vine);
			}

			if (Input.GetMouseButtonDown (0) && currentPlanetByMouse != null) {
				if (vineEnd1 == null) {
					//Debug.Log ("Vine1");
					vineEnd1 = currentPlanetByMouse;
					
					vine.gameObject.transform.SetAsFirstSibling ();
					//startPos = flo.gameObject.transform.parent.position;
				} else if (currentPlanetByMouse != vineEnd1) {
					//Debug.Log ("Vine2");
					vineEnd2 = currentPlanetByMouse;
					
					//record vine
					PlacementDetails p1 = null;
					PlacementDetails p2 = null;
					foreach (var p in record) {
						if (p.thePlanetGob == currentPlanetByMouse.gameObject)
							p1 = p;
						if (p.thePlanetGob == vineEnd1.gameObject)
							p2 = p;
					}
					if (p1 != null && p2 != null)
						p1.AddVineNeighbor (p2);
					else
						Debug.Log ("Vine recording problem: " + p1 + "-" + p2);

					//straighten out the end
					Vector3 end2 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
					FlowerDragManager.PlaceVine (vineEnd1.transform.position, end2, vine);

					//end
					vineEnd1 = null;
					vineEnd2 = null;
					vine = null;
					state = editingState.none;
					currentlyPlacing = null;
					underCursor = null;
				}
			}
			break;
		case editingState.flower:
			if (Input.GetMouseButtonDown (0) && currentPlanetByMouse != null) {
				//give the planet a flower
				//record flower
				foreach (var p in record) {
					if (p.thePlanetGob == currentPlanetByMouse.gameObject)
						p.hasFlower = true;
				}

				End ();
			}
			break;
		case editingState.demands:
			if (Input.GetMouseButtonDown (0) && currentPlanetByMouse != null && currentDemand != "") {
				//TODO record demand
				//Debug.Log ("Adding demand: "+ currentDemand);
				currentPlanetByMouse.hasDemands.AddDemand (currentDemand, false, false);
			}
			break;
		}
	}
Ejemplo n.º 53
0
 public void SetCurrentPlanetType(PlanetType type)
 {
     _planetType = type;
 }
Ejemplo n.º 54
0
	// Use this for initialization
	void Start ()
	{
		//gameObject.name = GetPlanetName ();

		foreach (var s in startConnected)
		{
			AddConnectedPlanet (s.ends [0], s);//so yeah, this is the behavior of startconnected
		}

		//planets have needs
		hasDemands = gameObject.GetComponent <HasDemands> ();
		if (hasDemands == null)
			hasDemands = gameObject.AddComponent <HasDemands> ();

		if (planetType == null)
		{
			planetType = new PlanetType ("starting planet");
			planetType.hasDemands = false;
			planetType.growsFlower = true;
		}
	}
Ejemplo n.º 55
0
 public PlanetCreationRequest(IGameTime timeSent, PlanetType planetType, int size)
     : base(timeSent)
 {
     this.PlanetType = planetType;
     this.PlanetSize = size;
 }
Ejemplo n.º 56
0
        public SystemBody(OrbitingEntity parent, PlanetType type)
            : base()
        {
            /// <summary>
            /// create these or else anything that relies on a unique global id will break.
            /// </summary>
            Id = Guid.NewGuid();

            Type = type; // set the type ASAP in case anthing needs to know it.

            Moons = new BindingList<SystemBody>();
            Populations = new BindingList<Population>();

            SSEntity = StarSystemEntityType.Body;

            Parent = parent;
            Position = parent.Position;

            TaskGroupsInOrbit = new BindingList<TaskGroupTN>();

            GeoSurveyList = new Dictionary<Faction, bool>();

            /// <summary>
            /// Default mineral amount is zero.
            /// do mineral generation elsewhere.
            /// </summary>
            m_aiMinerialReserves = new float[Constants.Minerals.NO_OF_MINERIALS];
            m_aiMinerialAccessibility = new float[Constants.Minerals.NO_OF_MINERIALS];
            for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
            {
                m_aiMinerialReserves[mineralIterator] = 0.0f;
                m_aiMinerialAccessibility[mineralIterator] = 0.0f;
            }

#warning planet generation needs minerals, anomalies, and ruins generation.
            PlanetaryRuins = new Ruins();


            Atmosphere = new Atmosphere(this);
        }
	// Use this for initialization
	void Start () {
		var pt = new PlanetType ("victory");
		gameObject.GetComponent <PlanetComponent> ().planetType = pt;
	}
Ejemplo n.º 58
0
 public Planet GetPlanetPrefab(PlanetType type)
 {
     return planetPrefabs[type];
 }