Exemplo n.º 1
0
        public Planet(Vector2 position, Color col, float size, int id, Team team)
        {
            Position = position;
            color = col;
            ObjectSize = size;
            Radius = (0.5f * LevelSpawner.imageSize * size);
            productionRate = productionAccel *2* Radius + b;
            ID = id;
            this.team = team;
            this.invadingTeam = team;

            image = Art.Planet;
            Vector2 textSize = text.MeasureString(ID.ToString());
            centerTextOffset = (textSize) * ObjectSize / 2;

            if (team == null)
            {
                state = State.NEUTRAL;
                shipCount = 10;
            }
            else
            {
                state = State.OCCUPIED;
                shipCount = 200;
            }
        }
Exemplo n.º 2
0
        public static void sendShips(Team team, float percentageOfShips, Planet origin, Planet destination)
        {
            if (origin.ID != destination.ID)
            {
                int TotalShips = TeamManager.teamShipCount[0] + TeamManager.teamShipCount[1];
                float value = (float)Math.Pow((double)(.0001f * TotalShips), (double)2) + 1; // this should be a log/exponential function so we can cap how many ships go out... need help implementing.

                int numShips = (int)(origin.shipCount * percentageOfShips*(1/value));

                if (numShips <= 0)
                {
                    numShips = 1;
                }

                if (numShips >= origin.shipCount)
                {

                    numShips = (int)Math.Floor((double)origin.shipCount);
                    for (int i = 0; i < numShips; i++)
                    {

                        Ship ship = new Ship(team, origin, destination, 1);
                        EntityManager.Add(ship);

                    }

                }
                else
                {
                    if (value < origin.shipCount)
                    {
                        for (int i = 0; i < numShips; i++)
                        {
                            Ship ship = new Ship(team, origin, destination, value);
                            EntityManager.Add(ship);
                        }
                    }
                    else
                    {
                        for (int i = 0; i <origin.shipCount; i++)
                        {
                            Ship ship = new Ship(team, origin, destination, 1f);
                            EntityManager.Add(ship);
                        }
                    }

                }

            }
        }
Exemplo n.º 3
0
        //Texture2D markerImage;
        public Ship(Team team, Planet sourcePlanet, Planet destinationPlanet,float value)
        {
            image = Art.Ship;

            Radius = 8;
            Team = team;
            Direction = destinationPlanet.Position - sourcePlanet.Position;
            color = team.getColor();
            ObjectSize = 0.65f;
            Value = value;
            spawnRadius = sourcePlanet.Radius + Radius;
            Destination = destinationPlanet;
            Origin = sourcePlanet;
            //Colliding = true;
            GeneratePosition(sourcePlanet.Position, destinationPlanet.Position);
            //getDirection(Position, Destination.Position);
            //getDirection();
            Origin.shipCount -= Value;
            planetsNotCrossed = planetsNotCrossed.Where(planet => planet.ID != sourcePlanet.ID).ToList();
            GeneratePathPoints();
            //markerImage = Art.Marker;
            //pathPoints.ReconstructPath(sourcePlanet, destinationPlanet, 250);
        }
Exemplo n.º 4
0
 //we may want to implement a a team manager that can keep track of these things. but maybe here will be ok too.
 public static void addPlanet(Team t, Planet p)
 {
     t.planetsColonized.Add(p);
 }
Exemplo n.º 5
0
 public static void removePlanet(Team t, Planet p)
 {
     List<Planet> planet = t.planetsColonized.Where(x => x.ID == p.ID).ToList();
     t.planetsColonized.Remove(planet[0]);
 }
Exemplo n.º 6
0
        public void changeTeams()
        {
            if (team != null)
                TeamManager.removePlanet(team, this);
            if (invadingTeam != null)
            {
                this.team = invadingTeam;
                TeamManager.addPlanet(team, this);
            }
            color = team.getColor();
            Cue cue = GameRoot.soundBank.GetCue("Metal");
            cue.Play();

            float hue1 = rand.NextFloat(0, 6);
            float hue2 = (hue1 + rand.NextFloat(0, 2)) % 6f;
            Color color1 = ColorUtil.HSVToColor(hue1, 0.5f, 1);
            Color color2 = ColorUtil.HSVToColor(hue2, 0.5f, 1);

            for (int i = 0; i < (int)(60*(Math.Pow(ObjectSize,2))); i++)
            {
                float speed = (18f * (1f - 1 / rand.NextFloat(1, 10)))*(float)(Math.Pow(ObjectSize,2));
                var state = new ParticleState()
                {
                    Velocity = rand.NextVector2(speed, speed),
                    Type = ParticleType.Planet,
                    LengthMultiplier = 1
                };

                Color colorr = Color.Lerp(color1, color2, rand.NextFloat(0, 1));
                GameRoot.ParticleManager.CreateParticle(Art.LineParticle, Position, color, 190f, 1.5f, state);
            }
        }