Esempio n. 1
0
        public Planet(int id, int seed, GraphicsDeviceManager graphics, PlanetTypes planetType, PlanetSizes planetSize)
        {
            Id           = id;
            PlanetType   = planetType;
            PlanetSize   = planetSize;
            ChunksWidth  = PlanetSizeDImensions[(int)planetSize][0];
            ChunksHeight = PlanetSizeDImensions[(int)planetSize][1];
            CellsWidth   = ChunksWidth * CHUNK_WIDTH;
            CellsHeight  = ChunksHeight * CHUNK_HEIGHT;

            noiseGenerator = new NoiseGenerator(planetType, seed, CellsWidth, CellsHeight);

            Map = new Map.Map(id, seed, ChunksWidth, ChunksHeight, noiseGenerator, graphics, planetType);

            List <Vector2> greens = PoissonSample.GeneratePoints(new Random(seed), 15, new Vector2(CellsWidth, CellsHeight));
            List <Vector2> blues  = PoissonSample.GeneratePoints(new Random(seed), 20, new Vector2(CellsWidth, CellsHeight));
            List <Vector2> reds   = PoissonSample.GeneratePoints(new Random(seed), 25, new Vector2(CellsWidth, CellsHeight));

            for (int i = 0; i < greens.Count; i++)
            {
                Structures.Add(new Ore(GetCellAtPosition(greens[i]), Ore.OreTypes.Green));
            }
            for (int i = 0; i < blues.Count; i++)
            {
                Structures.Add(new Ore(GetCellAtPosition(blues[i]), Ore.OreTypes.Blue));
            }
            for (int i = 0; i < reds.Count; i++)
            {
                Structures.Add(new Ore(GetCellAtPosition(reds[i]), Ore.OreTypes.Red));
            }
        }
Esempio n. 2
0
 public virtual void LoadPlanetLevel(
     PlanetTypes planetType,
     IEnumerable <IEnumerable <Vector2> > islands,
     int height,
     int width,
     bool[] layoutArray)
 {
     ViewModel.Level = new PlanetLevel(null, _wallWidth, _wallHeight, _physicsManager, planetType, islands, height, width, layoutArray);
 }
Esempio n. 3
0
 public override void LoadPlanetLevel(
     PlanetTypes planetType,
     IEnumerable <IEnumerable <Vector2> > islands,
     int height,
     int width,
     bool[] layoutArray)
 {
     ViewModel.Level = new PlanetLevel(_spriteBatch, _wallWidth, _wallHeight, _physicsManager, planetType, islands, height, width, layoutArray, _textureManager);
 }
 public void LoadPlanetLevel(
     PlanetTypes planetType,
     IEnumerable <IEnumerable <Vector2> > islands,
     int height,
     int width,
     bool[] layoutArray)
 {
     level = new PlanetLevel(_spriteBatch, _textureManager, _physicsManager, planetType, islands, height, width, layoutArray);
 }
Esempio n. 5
0
 public void UpdatePlanet(Thing thing)
 {
     PlanetType planetType;
     
     if (thing.type == (ushort) ThingType.Sun)
         planetType = PlanetTypes.GetPlanetType((byte) (Math.Abs(thing.seed % 2) + 4)); //suns!
     else
         planetType = PlanetTypes.GetPlanetType((byte) (Math.Abs(thing.seed % 4))); //planets!
     
     planet.UpdateSprite("Planets", planetType.planetSprite.Id);
 }
Esempio n. 6
0
 public ClientFullColonyStateDataResponse(ColonyModel cm, PlanetTypes planetType, IEnumerable <IStructureModel> structureModels)
 {
     Pages = new ClientColonyPages()
     {
         Overview = new ColonyOverviewPageData(cm, structureModels)
     };
     MetaData = new ColonyMetaData()
     {
         PlanetType = planetType, ColonyName = cm.Name
     };
 }
Esempio n. 7
0
 public void ViewTransition(string view, PlanetTypes type = PlanetTypes.BLUE)
 {
     if (!isGameOver)
     {
         if (view != "universe")
         {
             pType = type;
         }
         StartCoroutine(SetTransition(view));
     }
 }
Esempio n. 8
0
        public List <Colours> getPlanetColours(PlanetTypes pt, ColourTypes ct)
        {
            var planetColoursRepo = new PlanetColoursRepository(_connection);
            var coloursRepo       = new ColourRepository(_connection);
            var planetColours     = planetColoursRepo.GetByPlanetTypeColourType(pt, ct);
            var listColours       = new List <Colours>();

            foreach (var pc in planetColours)
            {
                var col = coloursRepo.GetById(pc.ColourId);
                listColours.Add(col);
            }

            return(listColours);
        }
Esempio n. 9
0
        public SolarSystem(int seed, GraphicsDeviceManager graphics, Vector2 position, SolarSystem[] connections, int numbnerOfPlanets)
        {
            Position    = position;
            Connections = connections;

            Planets = new Planet[numbnerOfPlanets];
            Random random = new Random(seed);

            for (int i = 0; i < numbnerOfPlanets; i++)
            {
                PlanetTypes pt = (PlanetTypes)random.Next(0, 5);
                PlanetSizes ps = (PlanetSizes)random.Next(0, 2);
                Planets[i] = new Planet(i, random.Next(), graphics, pt, ps);
            }
        }
        public void LoadTestPlanet(PlanetTypes planetType)
        {
            bool[] layoutArray = new bool[] { false, false, false, false, false, false,
                                              false, true, true, true, true, false,
                                              false, true, false, false, true, false,
                                              false, true, false, false, true, false,
                                              false, true, true, true, true, false,
                                              false, false, false, false, false, false };



            // No walls
            //bool[] layoutArray = new bool[] {
            //                           false, false, false, false, false, false,
            //                           false, false , false, false, false, false,
            //                           false, false , false, false, false, false,
            //                           false, false , false, false, false, false,
            //                           false, false , false , false,false, false,
            //                           false, false, false, false, false, false };

            // Random islands, not currently implemented anyway
            List <List <Vector2> > islands = new List <List <Vector2> >();

            int height = 6;
            int width  = 6;

            LoadPlanetLevel(planetType, islands, height, width, layoutArray);

            //_gravityObjects.Add(new GravityObject(new Vector2(-5, -5), 1));
            //_gravityObjects.Add(new GravityObject(new Vector2(-5, 5), 1));
            //_gravityObjects.Add(new GravityObject(new Vector2(5, 5), 1));
            //_gravityObjects.Add(new GravityObject(new Vector2(5, -5), 1));
            _gravityObjects.Add(new GravityObject(new Vector2(0, 0), 1));

            CreateStructure(3, 3, StructureTypes.LaserTurret, 10000, 100, 546345, new HashSet <int>());
            _turrets[0].IsLocalSim = true;
#if DEBUG
            Debugging.SimulationManager.StartSimulating(_turrets[0]);
#endif
            //Ship npc = _shipManager.CreateShip(new Vector2(-1, -1), 7, 0, Vector2.Zero, "NPC", ShieldTypes.halo, ShipTypes.NPC_Penguin, WeaponTypes.Laser, WeaponTypes.Laser, _shipManager.PlayerShip.Teams, false);

            //npc.IsLocalSim = true;
            //Debugging.SimulationManager.StartSimulating(npc);



            _shipManager.PlayerShip.Cargo.AddStatelessCargo(StatelessCargoTypes.AmbassadorMissile, 999, true);
        }
        public void Insert(PlanetTypes entity)
        {
            var sql = $@"Insert Into PlanetTypes(@Type,@WaterVolume,@LandMass,@RotationSpeed,@PlanetScale,@PlanetDistance,@MinTemp,@MaxTemp)";

            _connection.Execute(sql,
                                new
            {
                entity.Type,
                entity.WaterVolume,
                entity.LandMass,
                entity.RotationSpeed,
                entity.PlanetScale,
                entity.PlanetDistance,
                entity.MinTemp,
                entity.MaxTemp
            });
        }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlanetLevel"/> class based on specified layout array.
        /// </summary>
        /// <param name="spriteBatch">The sprite batch. Set to null if the planet won't be drawn.</param>
        /// <param name="wallTexWidth">width of the wall texture, in pixels</param>
        /// <param name="wallTexHeight">height of the wall texture, in pixels</param>
        /// <param name="physicsManager">The physics manager.</param>
        /// <param name="planetType">Type of the planet.</param>
        /// <param name="islands">The islands.</param>
        /// <param name="height">The height.</param>
        /// <param name="width">The width.</param>
        /// <param name="layoutArray">The layout array.</param>
        /// <param name="textureManager">Set to null if the planet will not be drawn.</param>
        public PlanetLevel(SpriteBatch spriteBatch,
                           int wallTexWidth, int wallTexHeight,
                           PhysicsManager physicsManager,
                           PlanetTypes planetType,
                           IEnumerable <IEnumerable <Vector2> > islands,
                           int height, int width, bool[] layoutArray, TextureManager textureManager = null)
        {
            _wallWidth  = wallTexWidth;
            _wallHeight = wallTexHeight;

            _spriteBatch    = spriteBatch;
            _physicsManager = physicsManager;

            PlanetType = planetType;
            SetPlanetSize(width, height);//Creates PlanetMap
            int counter = 0;

            // Convert layoutArray to 2D array for easier processing
            bool[,] layout2D = new bool[width, height];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    layout2D[j, i] = layoutArray[counter];
                    counter++;
                }
            }

            SetOutsideWallToTile(ref PlanetMap, TileTypes.Wall);

            FindAndSetWalls(ref PlanetMap, layout2D);

            //CreateWallBodies(layout2D);
            BuildEdges(ref PlanetMap);
            //GenerateWallPolygon(layout2D);

            foreach (var points in islands)
            {
                //var verts = CreateCollisionObject(points);
            }

            if (textureManager != null)
            {
                renderLevel = new RenderLevel(textureManager);
            }
        }
Esempio n. 13
0
    public void Awake()
    {
        rend  = renderer;
        trans = transform;

        trans.localPosition = Vector3.zero;
        trans.localScale    = Vector3.one;
        trans.localRotation = Quaternion.identity;

        renderer.sharedMaterial.mainTexture = SpriteMeshEngine.SpriteSheetManager.GetSpriteSheet("Planets").Texture;

        planetTypes = PlanetTypes.GetPlanetTypes();

        meshFilter = GetComponent <MeshFilter>();

        mesh1 = new Mesh();

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

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

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

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

        if (this.owner != Owners.NONE)
        {
            isExplored[this.owner] = true;
        }
    }
Esempio n. 15
0
 private void UpdateMouseOverPlanetState()
 {
     isMouseOnAnyPlanet = false;
     foreach (GameObject planet in MapGeneration.GetRefrence().visiblePlanets)
     {
         if (Vector2.Distance(planet.transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition)) < PlanetTypes.GetPlanetRadius())
         {
             lastHoveredPlanet  = planet;
             isMouseOnAnyPlanet = true;
         }
     }
 }
    private static void CreatePlanetType(PlanetTypes type, StarProperties starProperties)
    {
        RandomWeight <int> popGenerator = new RandomWeight <int>();

        switch (type)
        {
        case PlanetTypes.TERRAN:
            popGenerator.AddWeight(100, 4);
            popGenerator.AddWeight(90, 2);
            popGenerator.AddWeight(80, 2);
            popGenerator.AddWeight(70, 1);
            break;

        case PlanetTypes.DESERT:
            popGenerator.AddWeight(60, 2);
            popGenerator.AddWeight(50, 2);
            popGenerator.AddWeight(40, 2);
            popGenerator.AddWeight(30, 1);
            break;

        case PlanetTypes.OCEAN:
            popGenerator.AddWeight(100, 1);
            popGenerator.AddWeight(90, 2);
            popGenerator.AddWeight(80, 3);
            popGenerator.AddWeight(70, 3);
            break;

        case PlanetTypes.ARID:
            popGenerator.AddWeight(90, 1);
            popGenerator.AddWeight(80, 2);
            popGenerator.AddWeight(70, 3);
            popGenerator.AddWeight(60, 2);
            popGenerator.AddWeight(50, 1);
            break;

        case PlanetTypes.STEPPE:
            popGenerator.AddWeight(60, 2);
            popGenerator.AddWeight(50, 3);
            popGenerator.AddWeight(40, 2);
            popGenerator.AddWeight(30, 1);
            break;

        case PlanetTypes.JUNGLE:
            popGenerator.AddWeight(100, 1);
            popGenerator.AddWeight(90, 3);
            popGenerator.AddWeight(80, 3);
            popGenerator.AddWeight(70, 2);
            break;

        case PlanetTypes.BARREN:
            popGenerator.AddWeight(50, 3);
            popGenerator.AddWeight(40, 3);
            popGenerator.AddWeight(30, 2);
            popGenerator.AddWeight(20, 1);
            break;

        case PlanetTypes.TUNDRA:
            popGenerator.AddWeight(50, 1);
            popGenerator.AddWeight(40, 2);
            popGenerator.AddWeight(30, 3);
            popGenerator.AddWeight(20, 1);
            break;

        case PlanetTypes.INFERNO:
            popGenerator.AddWeight(50, 1);
            popGenerator.AddWeight(40, 1);
            popGenerator.AddWeight(30, 2);
            popGenerator.AddWeight(20, 2);
            break;

        case PlanetTypes.DEAD:
            popGenerator.AddWeight(50, 1);
            popGenerator.AddWeight(40, 3);
            popGenerator.AddWeight(30, 2);
            popGenerator.AddWeight(20, 1);
            break;

        case PlanetTypes.RADIATED:
            popGenerator.AddWeight(40, 2);
            popGenerator.AddWeight(30, 1);
            popGenerator.AddWeight(20, 2);
            popGenerator.AddWeight(10, 2);
            break;

        case PlanetTypes.TOXIC:
            popGenerator.AddWeight(40, 2);
            popGenerator.AddWeight(30, 2);
            popGenerator.AddWeight(20, 2);
            popGenerator.AddWeight(10, 1);
            break;
        }

        starProperties.maxPopulation = popGenerator.GetRandomKey();
    }
Esempio n. 17
0
 public void CreatePort(int distance, int maxTrip, PlanetTypes type, float currentTrip, float scale, int ID,
                        int parentID, bool isMoon)
 {
     _spaceManager.CreatePort(distance, maxTrip, type, currentTrip, scale, ID, parentID, isMoon);
 }
Esempio n. 18
0
 public Planet(int id, Vector2 position, int diameter, PlanetTypes type)
 {
     ID = id;
       Dst = new Rectangle((int)position.X, (int)position.Y, diameter, diameter);
       PlanetType = type;
 }
 private static void AddRandomModifiers(PlanetTypes type, StarProperties starProperties)
 {
 }
Esempio n. 20
0
        public MapHex(BinaryReader r)
        {
            Contract.Requires(r != null);

            // data

            Id = r.ReadInt32();

            X = r.ReadInt32();
            Y = r.ReadInt32();

            EmpireControl = (Races)r.ReadInt32();
            CartelControl = (Races)r.ReadInt32();

            Terrain = r.ReadInt32();
            Planet  = r.ReadInt32();
            Base    = r.ReadInt32();

            TerrainType = (TerrainTypes)r.ReadInt32();
            PlanetType  = (PlanetTypes)r.ReadInt32();
            BaseType    = (BaseTypes)r.ReadInt32();

            BaseEconomicPoints    = r.ReadInt32();
            CurrentEconomicPoints = r.ReadInt32();

            EmpireBaseVictoryPoints    = r.ReadInt32();
            EmpireCurrentVictoryPoints = r.ReadInt32();

            CartelBaseVictoryPoints    = r.ReadInt32();
            CartelCurrentVictoryPoints = r.ReadInt32();

            BaseSpeedPoints    = r.ReadDouble();
            CurrentSpeedPoints = r.ReadDouble();

            // helpers

            ControlPoints = new double[(int)Races.kNumberOfRaces];

            for (int i = 0; i < (int)Races.kNumberOfRaces; i++)
            {
                ControlPoints[i] = r.ReadDouble();
            }

            Mission    = r.ReadInt64();
            Population = new Dictionary <int, object>();

            while (true)
            {
                int characterId = r.ReadInt32();

                if (characterId == 0)
                {
                    break;
                }

                Population.Add(characterId, null);
            }

            PopulationCount = new int[(int)Races.kNumberOfRaces];

            for (int i = 0; i < (int)Races.kNumberOfRaces; i++)
            {
                PopulationCount[i] = r.ReadInt32();
            }
        }
Esempio n. 21
0
 public void SetPlanetDifficulty(PlanetTypes pType)
 {
     PlanetType = pType;
 }
Esempio n. 22
0
        public Map(int id, int seed, int width, int height, NoiseGenerator noiseGenerator, GraphicsDeviceManager graphics, PlanetTypes planetType)
        {
            Width  = width;
            Height = height;
            Chunks = new Chunk[height, width];
            int i = 0;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Chunks[y, x] = new Chunk(x, y, ChunkWidth, ChunkHeight, width, height, noiseGenerator, graphics, planetType);
                    i++;
                }
            }
        }
Esempio n. 23
0
        public Chunk(int chunkX, int chunkY, int width, int height, int mapWidth, int mapHeight, NoiseGenerator noiseGenerator, GraphicsDeviceManager graphics, PlanetTypes planetType)
        {
            Width           = width;
            Height          = height;
            this.planetType = planetType;

            Cells = new Cell[height, width];

            ChunkX = chunkX;
            ChunkY = chunkY;

            List <List <Vector3> > positions        = new List <List <Vector3> >();
            List <List <Vector2> > texturePositions = new List <List <Vector2> >();
            List <List <Color> >   colors           = new List <List <Color> >();

            Biomes = new List <BiomeType>();

            int biomesTotal = 0;
            Dictionary <int, int> biomesToPos = new Dictionary <int, int>();

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Cells[y, x] = new Cell();

                    int _cellGlobalIndex = (y + chunkY * height) * width * mapWidth + x + chunkX * width;

                    BiomeType biome = noiseGenerator.BiomeAtIndex(_cellGlobalIndex);

                    int pushIndex = -1;
                    if (!biomesToPos.TryGetValue((int)biome, out pushIndex))
                    {
                        positions.Add(new List <Vector3>());
                        texturePositions.Add(new List <Vector2>());
                        colors.Add(new List <Color>());
                        biomesToPos.Add((int)biome, biomesTotal);
                        pushIndex = biomesTotal;
                        biomesTotal++;
                        Biomes.Add(biome);
                    }

                    (List <Vector3> __positions, List <Vector2> __texturePositions, List <Color> __colors, List <int> __indicies) = Cells[y, x].GenerateMesh(chunkX, chunkY, width, height, mapWidth, mapHeight, x, y, noiseGenerator);

                    positions[pushIndex].AddRange(__positions);
                    texturePositions[pushIndex].AddRange(__texturePositions);
                    colors[pushIndex].AddRange(__colors);
                }
            }

            //positions.Reverse();
            //colors.Reverse();
            //vertices = new VertexPositionColor[positions.Count];
            Indicies = new IndexBuffer(graphics.GraphicsDevice, IndexElementSize.ThirtyTwoBits, positions.Count, BufferUsage.WriteOnly);

            Vertices = new VertexPositionColorTexture[biomesTotal][];

            int[] indicies = new int[positions.Count];

            for (int i = 0; i < positions.Count; i++)
            {
                var _vertices = new VertexPositionColorTexture[positions[i].Count];
                for (int j = 0; j < positions[i].Count; j++)
                {
                    _vertices[j] = new VertexPositionColorTexture(positions[i][j], colors[i][j], texturePositions[i][j]);
                }

                Vertices[i] = _vertices;

                //vertices[i] = new VertexPositionColor(positions[i], colors[i]);
                //indicies[i] = i;
            }

            Indicies.SetData(indicies);

            BoundingBox = new BoundingBox(new Vector3(chunkX * width * Cell.innerRadius * 2, chunkY * height * Cell.outerRadius * 3 / 2, 0), new Vector3((chunkX + 1) * width * Cell.innerRadius * 2, (chunkY + 1) * height * Cell.outerRadius * 3 / 2, 0));

            testEffect = new BasicEffect(graphics.GraphicsDevice);
        }
Esempio n. 24
0
        public List <PlanetColours> GetByPlanetTypeColourType(PlanetTypes pt, ColourTypes ct)
        {
            var sql = $@"Select * from PlanetColours where PlanetColours.PlanetTypeId = {pt.Id} and PlanetColours.ColourTypeId = {ct.Id}";

            return(_connection.Query <PlanetColours>(sql).ToList());
        }
Esempio n. 25
0
        public Controller()
            : base()
        {
            int currentPlanet = DB.CurrentPlanet;

              Player = new Player(new Vector2(World.WORLD_WIDTH / 2, 100));
              Type = (PlanetTypes)DB.Planets[currentPlanet].PlanetType;
              Camera = new Camera();

              WhaleButton = new UI.Button(Player.Position.X, 100, "Planet/WhaleButton", Events.GoToSystemView);

              if (currentPlanet != 7)
              {
            Generators.Add(new Generator(new Vector2(0, 250)));
            Generators.Add(new Generator(new Vector2(World.WORLD_WIDTH - Generator.WIDTH, 250)));
              }
              else
              {
            AncientMachines.Add(new AncientMachine(new Vector2(0, 250)));
            AncientMachines.Add(new AncientMachine(new Vector2(
              World.WORLD_WIDTH - Generator.WIDTH, 250)));
              }

              if (Generators.Count > 0)
              {
            ActiveObjects.Add(Generators[0]);
            ActiveObjects.Add(Generators[1]);
              }

              foreach (var item in DB.Planets[currentPlanet].Hostiles)
              {
            switch ((HostilesTypes)item.Type)
            {
              case HostilesTypes.Boomba: ActiveObjects.Add(new Boomba(item.Position)); break;
              case HostilesTypes.Buffalo: ActiveObjects.Add(new Buffalo(item.Position)); break;
              case HostilesTypes.Bullfrog: ActiveObjects.Add(new Bullfrog(item.Position)); break;
              case HostilesTypes.CrushingMachine: ActiveObjects.Add(new CrushingMachine(item.Position)); break;
              case HostilesTypes.FireColumn: ActiveObjects.Add(new FireColumn(item.Position)); break;
              case HostilesTypes.FlamingBoulderSpawner: ActiveObjects.Add(new FlamingBoulder(item.Position)); break;
              case HostilesTypes.IceCloud: ActiveObjects.Add(new IceCloud(item.Position)); break;
              case HostilesTypes.IceColumn: ActiveObjects.Add(new IceColumn(item.Position)); break;
              case HostilesTypes.Icydactyl: ActiveObjects.Add(new Icydactyl(item.Position)); break;
              case HostilesTypes.Leech: ActiveObjects.Add(new Leech(item.Position)); break;
              case HostilesTypes.RobotSender: ActiveObjects.Add(new RobotSender(item.Position)); break;
              case HostilesTypes.RobotSentinel: ActiveObjects.Add(new RobotSentinel(item.Position)); break;
              case HostilesTypes.Rockguy: ActiveObjects.Add(new Rockguy(item.Position)); break;
              case HostilesTypes.SnappingPlant: ActiveObjects.Add(new SnappingPlant(item.Position)); break;
              case HostilesTypes.SpikeWall: ActiveObjects.Add(new SpikeWall(item.Position)); break;
              case HostilesTypes.StoneRobot: ActiveObjects.Add(new StoneRobot(item.Position)); break;
              case HostilesTypes.StormCloud: ActiveObjects.Add(new StormCloud(item.Position)); break;
              case HostilesTypes.Swarm: ActiveObjects.Add(new Swarm(item.Position)); break;
              case HostilesTypes.Yeti: ActiveObjects.Add(new Yeti(item.Position)); break;
            }
              }

              foreach (var item in DB.Planets[currentPlanet].Foods)
            Foods.Add(new Food(item.Position));

              foreach (var item in DB.Planets[currentPlanet].Cubes)
            Cubes.Add(new Cube(item.Position));

              foreach (var item in DB.Planets[currentPlanet].Critters)
            Critters.Add(new Critter(item.Position, item.Type));

              foreach (var item in DB.Planets[currentPlanet].Peoples)
            Persons.Add(new Person((CharacterTypes)item.Type, item.Position));

              Game1.EventMan.Register(Events.MouseMove, MouseMove);
              Game1.EventMan.Register(Events.MouseClick, MouseClick);
              Game1.EventMan.Register(Events.GoToSystemView, GoToSystemView);
              Game1.EventMan.Register(Events.PlayerHitByFeedback, PlayerHitByFeedback);
              Game1.EventMan.Register(Events.TeleportedFood, TeleportedFood);
              Game1.EventMan.Register(Events.PersonTeleported, PersonTeleported);

              WhaleButton.DeregisterEvents();

              switch (Type)
              {
            case PlanetTypes.Green:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Jungle:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Ice:
              Audio.Play(Music.Ice);
              break;
            case PlanetTypes.Desert:
              Audio.Play(Music.Jungle);
              break;
            case PlanetTypes.Volcano:
              Audio.Play(Music.Volcano);
              break;
            case PlanetTypes.Machine:
              Audio.Play(Music.Machine);
              break;
              }
        }
Esempio n. 26
0
        public List <PlanetColours> GetByPlanetType(PlanetTypes entity)
        {
            var sql = $@"Select * from PlanetColours where PlanetColours.PlanetTypeId = {entity.Id}";

            return(_connection.Query <PlanetColours>(sql).ToList());
        }
Esempio n. 27
0
        public void CreatePort(int distance, int maxTrip, PlanetTypes type, float currentTrip, float scale, int ID,
                               int parentID, bool isMoon)
        {
            var port = new Port(_messageService);

            // Take values we know and create a planet.
            port.distance     = distance;
            port.currentTrip  = currentTrip;
            port.maxTrip      = maxTrip;
            port.planetType   = type;
            port.Id           = ID;
            port.OrbitID      = parentID;
            port.scale        = scale;
            port.scale       *= .1f; // Make the scale below 1
            port.moonList     = new List <Planet>();
            port.minimapColor = Color.Fuchsia;
            //Console.WriteLine(distance);

            // Set information depending on if moon or not.
            if (isMoon)
            {
                // Search for planet to tell it has moons.
                for (int i = 0; i < planetList.Count; i++)
                {
                    if (planetList[i].Id == parentID)
                    {
                        planetList[i].hasMoons = true;
                    }
                }
                port.planet    = false;
                port.moon      = true;
                port.increment = 1;
                port.angle     = 1;
            }
            else
            {
                port.planet    = true;
                port.moon      = false;
                port.increment = 1;
                port.angle     = 1;
            }


            // Set the texture
            if (_textureManager != null)
            {
                port.baseTexture   = _textureManager.Port;
                port.shadowTexture = _textureManager.Port;
            }
            port.body = CreatePortBody(360 / 4f, 1f, BaseDensity, port.Id);

            port.body.SleepingAllowed = true;
            port.body.Restitution     = 0.8f;
            port.body.OnCollision    += (port.body_OnCollision);
            port.body.UserData        = new CollisionDataObject(port, BodyTypes.Port);

            if (isMoon)
            {
                // Search for planet to give it a moon.
                for (int i = 0; i < planetList.Count; i++)
                {
                    if (planetList[i].Id == parentID)
                    {
                        port.increment = port.currentTrip / port.maxTrip;
                        if (maxTrip == 0)
                        {
                            port.increment = 0;
                        }

                        // Increment the angle
                        port.angle = (float)(Math.PI * 2) * port.increment;


                        port.pos.X = ConvertUnits.ToSimUnits((float)Math.Cos(port.angle) * port.distance) +
                                     planetList[i].pos.X;
                        port.pos.Y = ConvertUnits.ToSimUnits((float)Math.Sin(port.angle) * port.distance) +
                                     planetList[i].pos.Y;

                        port.body.Position = port.pos;

                        planetList[i].moonList.Add(port);
                    }
                }
            }
            else
            {
                // Set position
                port.increment = port.currentTrip / port.maxTrip;

                // Increment the angle
                port.angle = MathHelper.ToRadians(360) * port.increment;

                port.pos.X = ConvertUnits.ToSimUnits((float)Math.Cos(port.angle) * port.distance);
                port.pos.Y = ConvertUnits.ToSimUnits((float)Math.Sin(port.angle) * port.distance);

                //TODO: remove this, it's a temporary fix for a likely temporary problem
                if (port.pos.X != port.pos.X)//NaN test
                {
                    port.body.Position = new Vector2(15, 15);
                }
                else
                {
                    port.body.Position = port.pos;
                }

                planetList.Add(port);
            }

            if (planetAmountToUpdate <= 5)
            {
                planetAmountToUpdate++;
            }
            port.moon  = false;
            port.scale = .5f;
            // Solves a world of issues to step the physics here.
            _physicsManager.ResyncWorldObjects();
        }
        public void Delete(PlanetTypes entity)
        {
            var sql = $@"Delete from PlanetTypes where PlanetTypes.Id = {entity.Id}";

            _connection.Execute(sql);
        }
Esempio n. 29
0
 public void GoToRunner(PlanetTypes pType)
 {
     gameManager.ViewTransition("runner", pType);
 }
Esempio n. 30
0
        public void CreateSinglePlanet(int distance, int maxTrip, PlanetTypes type, float currentTrip, float scale, int ID,
                                       int orbitID, bool isMoon)
        {
            var p = new Planet(_messageService);

            // Take values we know and create a planet.
            p.distance    = distance;
            p.maxTrip     = maxTrip;
            p.planetType  = type;
            p.currentTrip = currentTrip;
            p.Id          = ID;
            p.OrbitID     = orbitID;
            p.scale       = scale;
            p.scale      *= .1f; // Make the scale below 1


            // Set information depending on if moon or not.
            if (isMoon)
            {
                // Search for planet to tell it has moons.
                for (int i = 0; i < planetList.Count; i++)
                {
                    if (planetList[i].Id == orbitID)
                    {
                        planetList[i].hasMoons = true;
                    }
                }
                p.planet    = false;
                p.moon      = true;
                p.increment = 1;
                p.angle     = 1;
            }
            else
            {
                p.planet    = true;
                p.moon      = false;
                p.increment = 1;
                p.angle     = 1;
                p.moonList  = new List <Planet>();
            }


            // Set the texture
            if (_textureManager != null)
            {
                AssignPlanetTexture(p);
            }

            //TODO: Put size in a config file for f**k's sake
            p.body = CreatePlanetBody(150, p.scale, BaseDensity, p.Id);

            p.body.SleepingAllowed = false;
            p.body.Restitution     = 0.8f;
            p.body.OnCollision    += new OnCollisionEventHandler(p.body_OnCollision);

            if (isMoon)
            {
                p.body.UserData = new CollisionDataObject(p, BodyTypes.Moon);
                // Search for planet to give it a moon.
                for (int i = 0; i < planetList.Count; i++)
                {
                    if (planetList[i].Id == orbitID)
                    {
                        p.increment = p.currentTrip / p.maxTrip;
                        if (p.maxTrip == 0)
                        {
                            p.increment = 0;
                        }

                        // Increment the angle
                        p.angle = MathHelper.ToRadians(360) * p.increment;


                        p.pos.X = ConvertUnits.ToSimUnits((float)Math.Cos(p.angle) * p.distance) + planetList[i].pos.X;
                        p.pos.Y = ConvertUnits.ToSimUnits((float)Math.Sin(p.angle) * p.distance) + planetList[i].pos.Y;

                        p.body.Position = p.pos;

                        planetList[i].moonList.Add(p);
                    }
                }
            }
            else
            {
                p.body.UserData = new CollisionDataObject(p, BodyTypes.Planet);
                // Set position
                p.increment = p.currentTrip / p.maxTrip;
                if (p.maxTrip == 0)
                {
                    p.increment = 0;
                }

                // Increment the angle
                p.angle = MathHelper.ToRadians(360) * p.increment;


                p.pos.X = ConvertUnits.ToSimUnits((float)Math.Cos(p.angle) * p.distance);
                p.pos.Y = ConvertUnits.ToSimUnits((float)Math.Sin(p.angle) * p.distance);


                p.body.Position = p.pos;

                planetList.Add(p);
            }

            if (planetAmountToUpdate <= 5)
            {
                planetAmountToUpdate++;
            }


            // Solves a world of issues to step the physics here.
            _physicsManager.ResyncWorldObjects();
        }