Пример #1
0
        public ParticleTestScreen(ScreenContainer container)
            : base(container)
        {
            am = FSGGame.achievementManager;
            pm = new MAOParticleManager(new Rectangle(0, 0, 800, 400), Constants.MaxParticles, Constants.ParticleSize, am.processParticle);

            brushSize = 3;
            rand = new Random(Environment.TickCount);
            //pm.addSource(new Vector2(400, 0), 1, Particle_Type.Sand,true);
            //pm.addSource(new Vector2(450, 0), 2, Particle_Type.Sand,true);
            //pm.addSource(new Vector2(500, 0), 3, Particle_Type.Sand,true);
            pm.addSource(new Vector2(550, 0), 1, Particle_Type.Water, true);
            //pm.addSource(new Vector2(5, 360), 1, Particle_Type.Fire, true);
            //pm.addSource(new Vector2(600, 0), 5, Particle_Type.Sand);
            currentParticle = Particle_Type.Sand;

            selectPositions = new int [7];
            selectPositions[0] = 17;
            selectPositions[1] = 117;
            selectPositions[2] = 217;
            selectPositions[3] = 317;
            selectPositions[4] = 417;
            selectPositions[5] = 517;
            selectPositions[6] = 617;
        }
Пример #2
0
 public Source(Vector2 pos, int cyclesBetween, Particle_Type outputType)
 {
     position = pos;
     period = cyclesBetween;
     type = outputType;
     counter = 0;
 }
Пример #3
0
 public TotalOfTypeAchievement(int numRequired, Particle_Type type, string name, string message)
     : base()
 {
     this.name = name;
     this.message = message;
     this.numReq = numRequired;
     this.type = type;
     count = 0;
 }
Пример #4
0
 public TypeOnScreenAchievement(int numRequired, Particle_Type type, string name, string message)
     : base()
 {
     counter = 0;
     numReq = numRequired;
     this.name = name;
     this.message = message;
     this.type = type;
 }
Пример #5
0
 public Particle(Vector2 pos, Vector2 vel, Particle_Type ptype, Color partColor)
 {
     Dead = false;
     position = pos;
     velocity = vel;
     type = ptype;
     pColor = partColor;
     dontMove = false;
     remove = false;
 }
Пример #6
0
 public void addParticle(Vector2 position, Vector2 velocity, Particle_Type type)
 {
     Particle p;
     if (type.Equals(Particle_Type.Sand))
         p = new Particle_Sand(position, velocity);
     else if (type.Equals(Particle_Type.Wall))
         p = new Particle_Wall(position, velocity);
     else
         p = new Particle_Sand(position, velocity);
     //Check if p is in the viewing box
     Rectangle surround = new Rectangle((int)p.position.X - boundryBuffer, (int)p.position.Y - boundryBuffer, 2 * boundryBuffer, 2 * boundryBuffer);
     if (boundry.Intersects(surround))
         particles.Add(p);
 }
Пример #7
0
        public bool addParticle(Vector2 position, Vector2 velocity, Particle_Type type, bool screenCoord, bool overlay)
        {
            if(screenCoord)
                position = (position + new Vector2(boundry.X, boundry.Y)) / particleSize;
            position.X = (int)position.X;
            position.Y = (int)position.Y;
            Particle p;
            if(type.Equals(Particle_Type.Sand))
                p = new Particle_Sand(position, velocity);
            else if (type.Equals(Particle_Type.Wall))
                p = new Particle_Wall(position, velocity);
            else if (type.Equals(Particle_Type.Water))
                p = new Particle_Water(position, velocity);
            else if (type.Equals(Particle_Type.Plant))
                p = new Particle_Plant(position, velocity);
            else if (type.Equals(Particle_Type.Fire))
                p = new Particle_Fire(position, velocity);
            else
                p = new Particle_Sand(position, velocity);
            //Check if p is in the viewing box
            Rectangle surround = new Rectangle((int)p.position.X - boundryBuffer, (int)p.position.Y - boundryBuffer, 2 * boundryBuffer, 2 * boundryBuffer);
            if (boundry.Intersects(surround))
            {
                //particles.Add(p);
                //particleField[(int)p.position.X, (int)p.position.Y] = p;//todo fix
                //return true;
                if (!overlay)
                {
                    if (particleStorage.particleAt((int)p.position.X, (int)p.position.Y) != null && particleStorage.particleAt((int)p.position.X, (int)p.position.Y).type == p.type)
                        return true;
                    else
                    {
                        particleStorage.deleteParticle(particleStorage.particleAt((int)p.position.X, (int)p.position.Y));
                        particleStorage.newParticle(p);
                        return true;
                    }
                }
                if (particleStorage.newParticle(p))
                    return true;
                //particles.Add(p);
                //particleField[(int)p.position.X, (int)p.position.Y] = p;//todo fix

            }
            return false;
        }
Пример #8
0
 public void addSource(Vector2 position, int period, Particle_Type type)
 {
     Source source = new Source(position, period, type);
     sources.Add(source);
 }
Пример #9
0
 public void addSource(Vector2 position, int period, Particle_Type type, bool screenCoord)
 {
     if(screenCoord)
         position = (position + new Vector2(boundry.X, boundry.Y)) / particleSize;
     Source source = new Source(position, period, type);
     sources.Add(source);
 }
Пример #10
0
        private void getInput()
        {
            if (FSGGame.controller.ContainsBool(Inputs.ActionType.AButton))//mouseState.LeftButton == ButtonState.Pressed)//FSGGame.controller.ContainsBool(Inputs.ActionType.Select))
            {
                Vector2 temp = FSGGame.controller.CursorPosition();

                //mouse selection of particle type
                if (temp.Y >= 415)
                {
                    if (temp.X > 25 && temp.X < 115)
                        currentParticle = Particle_Type.Sand;
                    else if (temp.X > 125 && temp.X < 215)
                        currentParticle = Particle_Type.Water;
                    else if (temp.X > 225 && temp.X < 315)
                        currentParticle = Particle_Type.Wall;
                    else if (temp.X > 325 && temp.X < 415)
                        currentParticle = Particle_Type.Plant;
                    else if (temp.X > 425 && temp.X < 515)
                        currentParticle = Particle_Type.Fire;
                    else if (temp.X > 525 && temp.X < 615)
                        currentParticle = Particle_Type.Remove;
                    else if (temp.X > 625 && temp.X < 635)
                    {
                        if (temp.Y > 440 && temp.Y < 460 && brushSize >= 3)
                            brushSize--;
                        else if (temp.Y < 435 && temp.Y > 415 && brushSize <= 20)
                            brushSize++;
                    }
                    else if (temp.X > 760 && temp.X < 779)
                    {
                        this.Disposed = true;
                        FSGGame.screens.Play(new TitleScreen(FSGGame.screens));
                    }
                }

                else
                {
                    temp.X -= brushSize;
                    temp.Y -= brushSize;
                    Vector2 temp2;
                    if (currentParticle == Particle_Type.Remove)
                        for (int x = 0; x < 2 * brushSize; x++)
                        {
                            for (int y = 0; y < 2 * brushSize; y++)
                            {
                                temp2.X = temp.X + x;
                                temp2.Y = temp.Y + y;
                                pm.removeParticleScreenCoord(temp2);
                            }
                        }
                    else if (currentParticle != Particle_Type.Wall && currentParticle != Particle_Type.Plant)
                    {
                        temp.X += brushSize;
                        temp.Y += brushSize;
                        for (int i = 0; i < brushSize; i++)
                        {
                            temp2 = new Vector2(temp.X + 10 * ((float)rand.NextDouble() - .5f), temp.Y + 10 * ((float)rand.NextDouble()) - .5f); //random location for spawning
                            pm.addParticle(temp2, Vector2.Zero, currentParticle, true, true);
                        }
                    }
                    else
                    {
                        for (int x = 0; x < 2 * brushSize; x++)
                        {
                            for (int y = 0; y < 2 * brushSize; y++)
                            {
                                temp2.X = temp.X + x;
                                temp2.Y = temp.Y + y;
                                pm.addParticle(temp2, Vector2.Zero, currentParticle, true, false);
                            }
                        }
                    }
                }

            }

            if (FSGGame.controller.ContainsBool(Inputs.ActionType.SelectionRight))   //if right arrow is pressed
            {
                if (currentParticle != Particle_Type.Remove)
                    currentParticle++;
                else
                    currentParticle = Particle_Type.Sand;
            }
            else if (FSGGame.controller.ContainsBool(Inputs.ActionType.SelectionLeft))   //if left arrow is pressed
            {
                if (currentParticle > 0)
                    currentParticle--;
                else
                    currentParticle = Particle_Type.Remove;
            }

            if (FSGGame.controller.ContainsBool(Inputs.ActionType.SelectionUp) && brushSize <= 20)
                brushSize++;
            else if (FSGGame.controller.ContainsBool(Inputs.ActionType.SelectionDown) && brushSize >= 3)
                brushSize--;
        }