Ejemplo n.º 1
0
 public Enemy()
 {
     Random rand = new Random((int)DateTime.Now.Ticks);
     timeFromLastSearch = (float)rand.NextDouble() * MaxTimeFromLastSearch;
     particleManager = new ParticleSystem();
     number++;
     myNumber = number;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            averageCalcTime = new List<double>();
            averageDrawTime = new List<double>();
            particleSystems = new List<ParticleSystem>();
            DebugForm.Initialize();
            Manager = new ParticleManager();
            form = new InitializeForm(this);
            form.Show();
            this.IsMouseVisible = true;
            collisionrects = new List<Rectangle>();
            blank = Content.Load<Texture2D>("Blank");
            font = Content.Load<SpriteFont>("Arial");
            rects = new Rectangle[10, 10];
            rect2 = new Rectangle(-1000,0 , 1000, 800);
            rect3 = new Rectangle(800, 0, 1000, 800);
            rect4 = new Rectangle(0, -1000, 800, 1000);
            rect5 = new Rectangle(0, 600, 1000, 1000);
            testrect = new Rectangle(350,250, 100, 100);

            system1 = new XNAParticleSystem.ParticleSystem();
            system2 = new XNAParticleSystem.ParticleSystem();
            system1.debugPrefix = "System1";
            system2.debugPrefix = "System2";

            target = new RenderTarget2D(GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth,
                GraphicsDevice.PresentationParameters.BackBufferHeight,
                false,
                SurfaceFormat.Color,
                DepthFormat.None,
                GraphicsDevice.PresentationParameters.MultiSampleCount,
                RenderTargetUsage.PreserveContents);
            //InitializeNewParticleMangersTest();
            Manager.StartAllExplosions();
            //InitializeNewtonAtom();
            //InitializeSnow();
            InitializeMASSCollision();

            //InitializeBloodCollision();
            //if (system1 !=null)
            {
                Manager.Add(system1);
            } //if (system2!=null)
            {

                Manager.Add(system2);
            }
            //InitializeNewton();
            //InitializeExplosion();
            //InitializeBiene();

            //InitializeCircle();
            //InitializeWaterfall();

            //manager2.AddNewtonMass(new Vector2(400, 300), 5000);

            //manager2.AddCollisionRect(testrect);
            //manager2.AddCollisionRect(testrect);
            system1.AddCollisionRect(rect5);
            system1.AddCollisionRect(rect2);
            system1.AddCollisionRect(rect3);
            system2.AddCollisionRect(rect4);
            system1.AddCollisionRect(rect4);
            system2.AddCollisionRect(rect5);
            system2.AddCollisionRect(rect2);
            system2.AddCollisionRect(rect3);
            system1.AddCollisionRect(new Rectangle(-1000, 500, 50, 50));
            collisionrects.Add(new Rectangle(-1000, 500,50, 50));
            base.Initialize();
            //manager.UseTimedAlpha = false;
            //manager.Alpha = 0.1f;
        }
Ejemplo n.º 3
0
        public void InitializeNewParticleMangersTest()
        {
            for (int i = 0; i < 5; i++)
            {
                for (int k = 0; k < 5; k++)
                {
                    ParticleSystem system = new ParticleSystem();
                    system.Initialize(false,1000, 5, SpawnType.Explosion, 2, Content.Load<Texture2D>("blank"), new Vector2(i * 100 + 100, k * 100 + 100));
                    system.Gravity = new Vector2(0, 200);
                    system.MaxSpeed = new Vector2(100, 100);
                    system.Type = GravityType.OverallForce;
                    system.Spawndirections = SpawnDirections.AllWays;
                    system.debugPrefix = i.ToString() + "x" + k.ToString() + " System";
                    system.Collisiontype = CollisionType.Collision;
                    system.AddCollisionRect(rect2);
                    system.AddCollisionRect(rect3);
                    system.AddCollisionRect(rect4);
                    system.AddCollisionRect(rect5);

                    if (single)
                    {
                        Manager.Add(system);
                    }
                    else
                    {
                        //particleSystems.Add(system);
                    }

                }
            }
        }
Ejemplo n.º 4
0
 public void InitializeNEW(bool BetweenParticleCollision)
 {
     Manager.Stop();
     Manager.Clear();
     collisionrects.Clear();
     if (system1 != null)
         system1.Dispose();
     system1 = new XNAParticleSystem.ParticleSystem();
     if (system2 != null)
         system2.Dispose();
     system2 = new XNAParticleSystem.ParticleSystem();
     system1.BetweenParticleCollision1 = BetweenParticleCollision;
     system2.BetweenParticleCollision1 = BetweenParticleCollision;
 }
Ejemplo n.º 5
0
        protected override void InitializeObject(string data)
        {
            string[] temp = data.Split(',');
            values = new float[Enum.GetValues(typeof(JumpPadValues)).Length];
            for(int i = 0; i< temp.Length;i++)
            {
                try
                {
                    values[i] = float.Parse(temp[i], CultureInfo.CreateSpecificCulture("en-us"));
                }
                catch (Exception e)
                {
                    DebugManager.AddItem(e.Message, this.ToString(), new StackTrace(e), System.Drawing.Color.Red);
                    FileManager.WriteInErrorLog(this, "Failed to load Data of "+ Type +": \n" + e.Message, e.GetType());
                }
            }
            timeThreshold = values[(int)JumpPadValues.Fallof];
            blank = Content.Load<Texture2D>("Stuff\\Blank");
            jumpPadTex = Content.Load<Texture2D>(GameParameters.CurrentGraphXPackPath + "Level/InteractiveObjects/JumpPad");
            drawRects = new ExtendedRectangle[5];
            drawRectsAlpha = new byte[5];
            drawRectsTime = new float[5];
            ActionRectangle = new Rectangle(
                (int)values[(int)JumpPadValues.RectangleX],
                (int)values[(int)JumpPadValues.RectangleY],
                (int)values[(int)JumpPadValues.RectangleWidth],
                (int)values[(int)JumpPadValues.RectangleHeight]);

            force = new Vector2(values[(int)JumpPadValues.SpeedX],values[(int)JumpPadValues.SpeedY]);
            float rotation = force.GetRotation();
            for (int i = 0; i < drawRects.Length; i++)
            {
                drawRectsTime[i] = (float)i / drawRects.Length * AnimationTimeThreshold;
                Vector2 offset = (force / MaxForceLength) * (((float)i / drawRects.Length) * MaxLengthDrawRects);
                drawRects[i] = ExtendedRectangle.Transform(new Rectangle(
                    (int)values[(int)JumpPadValues.RectangleX], (int)values[(int)JumpPadValues.RectangleY],
                    32,
                    2),
                    new Vector2(blank.Width,blank.Height),
                    new Vector2((int)values[(int)JumpPadValues.RectangleWidth] / 2,
                    (int)values[(int)JumpPadValues.RectangleHeight] / 2),
                    offset,
                    force.GetRotation() - (float)Math.PI/2);

            }
            particles = new ParticleSystem();
            particles.Initialize(false, SpawnType.Fontaine,
                50,
                100,
                3,
                Color.White,
                new Vector2(values[(int)JumpPadValues.RectangleX] , values[(int)JumpPadValues.RectangleY]),
                new Vector2(values[(int)JumpPadValues.RectangleX] + values[(int)JumpPadValues.RectangleWidth], values[(int)JumpPadValues.RectangleY] + values[(int)JumpPadValues.RectangleHeight]),
                 SpawnDirections.Angle, force /MaxForceLength * 1000, blank, GravityType.OverallForce, Vector2.Zero, 1, XNAParticleSystem.CollisionType.None);
            Options.InitObjectHolder.particleManagers[EGameState.Game].Add(particles);
            particles.Reset();
            particles.UseMinSpeed = true;
            particles.MinSpeed = force / MaxForceLength * 500;
            particles.SpawnAngle = 0.0f;
            particles.AirFriction = 0.95f;
            //particles.UseCuda(true);
        }
Ejemplo n.º 6
0
 protected override DrawPosition InitializeEvent(IServiceProvider serviceProvider,GraphicsDevice device,LevelVariables levelVariables, Options options)
 {
     this.options = options;
     blank = Content.Load<Texture2D>("Stuff/Blank");
     killeffect = new KillEffect();
     killeffect.Initialize(serviceProvider, device, options);
     traceEffect = new Trace();
     traceEffect.Initialize(serviceProvider, device, options);
     rect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);
     screenwidth = options.ScreenWidth;
     coord = new Vector2(options.ScreenWidth / 2, options.ScreenHeight / 2 + options.ScreenHeight * 0.35f);
     frontrect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);
     shakeDivider = 10;
     manager = new ParticleSystem();
     gameOverText.font = Content.Load<SpriteFont>("Stuff\\Font");
     gameOverText.Text = gameOver;
     gameOverText.color = new Color(1f,1f,1f, 0);
     blackScreenColor = new Color(0f,0f,0f, 0);
     toonShader = new ToonShader();
     toonShader.Initialize(serviceProvider, device, options);
     toonShader.CurrentTechnique = ToonShaderEffects.BrightEdgesColored;
     return DrawPosition.Post;
 }