Beispiel #1
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);
                }
            }
        }
Beispiel #2
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;
        }
Beispiel #3
0
            public dSector(sector x, Planet_nature p, int number, int count)
            {
                int texIDb = 3;
                int texIDn = 3;

                if (x.building != null)
                    switch (x.building.type)
                    {

                    }

                if (x.natureBuilding != null)
                    switch (x.natureBuilding.type)
                    {
                        case buildingsEnum.grass: texIDn = 2; break;
                        case buildingsEnum.forest: texIDn = 0; break;
                    }

                if (p.type != PlanetType.sun)
                {
                    building = new objDrawer(sizes.standartSizeSmall, sizes.standartSizeSmall, texIDb);
                    nature = new objDrawer(sizes.standartSizeSmall, sizes.standartSizeSmall, texIDn);
                    ownerOverlay = new objDrawer(sizes.standartSizeSmall, sizes.standartSizeSmall, 4);
                }
                else
                {
                    building = new objDrawer(0, 0, 16);
                    nature = new objDrawer(0, 0, 16);
                    ownerOverlay = new objDrawer(0, 0, 16);
                }

                building.x = p.x;
                nature.x = p.x;
                building.y = p.y;
                nature.y = p.y;
                ownerOverlay.x = p.x;
                ownerOverlay.y = p.y;

                float secAngle = 360 / count * number;

                building.angle = secAngle;
                nature.angle = secAngle;
                ownerOverlay.angle = secAngle;

                Player owner = Render.players.Where(c => c.name == x.owner).FirstOrDefault();
                if (owner != null)
                {
                    building.colorMask = owner.color;
                    ownerOverlay.colorMask = owner.color;
                }

                secAngle = secAngle / 57.0f;

                float xCorr = (float)Math.Sin((double)secAngle) * p.radius;
                float yCorr = (float)Math.Cos((double)secAngle) * p.radius;

                nature.x += xCorr;
                nature.y -= yCorr;

                building.x += xCorr;
                building.y -= yCorr;

                ownerOverlay.x += xCorr / 2;
                ownerOverlay.y -= yCorr / 2;
            }