Example #1
0
        public Player(Project2Game game)
        {
            size = initSize;
            moveSpeed = mSpeed;
            spinSpeed = sSpeed;
            Random rand = new Random();
            color = rand.NextColor();

            pos = game.landscape.getStartPoint();
            pos.Y += size;
            oldPos = Vector3.Zero;
            rot = Matrix.Identity;

            generateSphere(size, color);

            vertices = Buffer.Vertex.New(
                game.GraphicsDevice,
                originalPoints);

            this.effect = game.Content.Load<Effect>("Phong");

            effect.Parameters["lightPntCol"].SetValue(game.sun.color.ToColor4());

            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game = game;
        }
Example #2
0
		/// <summary>
		/// /
		/// </summary>
		public override void Initialize ()
		{
			base.Initialize();

			paramsCB	=	new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );

			CreateTargets();
			LoadContent();

			Random	rand = new Random();

			randomDir	=	new Texture2D( Game.GraphicsDevice, 64,64, ColorFormat.Rgba8, false );
			randomDir.SetData( Enumerable.Range(0,4096).Select( i => rand.NextColor() ).ToArray() );

			Game.GraphicsDevice.DisplayBoundsChanged += (s,e) => CreateTargets();
			Game.Reloading += (s,e) => LoadContent();
		}
Example #3
0
        /// <summary>
        /// Occurs during the randomizing process
        /// </summary>
        /// <param name="generator"></param>
        protected override void OnRandomize(Random generator)
        {
            _color = generator.NextColor();
            Opacity = generator.NextFloat();
            _pointShape = generator.NextEnum<PointShape>();

            base.OnRandomize(generator);
        }
Example #4
0
        ///// <summary>
        ///// Adds SimpleStroke copy content
        ///// </summary>
        ///// <param name="copy"></param>
        //protected override void OnCopy(Descriptor copy)
        //{
        //    base.OnCopy(copy);
        //    ISimpleStroke ss = copy as ISimpleStroke;
        //    ss.Color = Color;
        //    ss.Width = Width;
        //    ss.DashStyle = this.DashStyle;
        //}

        /// <summary>
        /// Handles randomization of simple stroke content
        /// </summary>
        /// <param name="generator">The random generator to use for randomizing characteristics.</param>
        protected override void OnRandomize(Random generator)
        {
            _color = generator.NextColor();
            Opacity = generator.NextFloat();
            _width = generator.NextFloat(10);
            _dashStyle = generator.NextEnum<DashStyle>();
            base.OnRandomize(generator);
        }
Example #5
0
 /// <summary>
 /// Extends the randomize code to include the character aspects, creating a random character.
 /// However, since most fonts don't support full unicode values, a character from 0 to 255 is
 /// chosen.
 /// </summary>
 /// <param name="generator">The random class generator</param>
 protected override void OnRandomize(Random generator)
 {
     _color = generator.NextColor();
     Opacity = generator.NextFloat();
     _character = (char)generator.Next(0, 255);
     _fontFamilyName = FontFamily.Families[generator.Next(0, FontFamily.Families.Length - 1)].Name;
     _style = generator.NextEnum<FontStyle>();
     base.OnRandomize(generator);
 }
Example #6
0
        /// <summary>
        /// Calculates the unique colors as a scheme
        /// </summary>
        /// <param name="fs">The featureset with the data Table definition</param>
        /// <param name="uniqueField">The unique field</param>
        /// <param name="categoryFunc">Func for creating category</param>
        protected Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField, Func<Color, IFeatureCategory> categoryFunc)
        {
            if (categoryFunc == null) throw new ArgumentNullException("categoryFunc");

            var result = new Hashtable(); // a hashtable of colors
            var dt = fs.DataTable;
            var vals = new ArrayList();
            var i = 0;
            var rnd = new Random();
            foreach (DataRow row in dt.Rows)
            {
                var ind = -1;
                if (uniqueField != "FID")
                {
                    if (vals.Contains(row[uniqueField]) == false)
                    {
                        ind = vals.Add(row[uniqueField]);
                    }
                }
                else
                {
                    ind = vals.Add(i);
                    i++;
                }
                if (ind == -1) continue;

                var item = vals[ind];
                var c = rnd.NextColor();
                while (result.ContainsKey(c))
                {
                    c = rnd.NextColor();
                }
                var cat = categoryFunc(c);
                string flt = "[" + uniqueField + "] = ";
                if (uniqueField == "FID")
                {
                    flt += item;
                }
                else
                {
                    if (dt.Columns[uniqueField].DataType == typeof(string))
                    {
                        flt += "'" + item + "'";
                    }
                    else
                    {
                        flt += Convert.ToString(item, CultureInfo.InvariantCulture);
                    }
                }
                cat.FilterExpression = flt;
                AddCategory(cat);
                result.Add(c, item);
            }
       
            return result;
        }
Example #7
0
        /// <summary>
        /// Calculates the unique colors as a scheme 
        /// </summary>
        /// <param name="fs">The featureset with the data Table definition</param>
        /// <param name="uniqueField">The unique field</param>
        public Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField)
        {
            Hashtable result = new Hashtable(); // a hashtable of colors
            DataTable dt = fs.DataTable;
            ArrayList vals = new ArrayList();
            int i = 0;
            foreach (DataRow row in dt.Rows)
            {
                if (uniqueField != "FID")
                {

                    if (vals.Contains(row[uniqueField]) == false)
                    {
                        vals.Add(row[uniqueField]);
                    }
                }
                else
                {
                    vals.Add(i);
                    i++;
                }
            }
            Random rnd = new Random();
            foreach (object item in vals)
            {
                Color c = rnd.NextColor();
                while (result.ContainsKey(c))
                {
                    c = rnd.NextColor();
                }
                LineCategory cat = new LineCategory(c, 1);
                string flt = "[" + uniqueField + "] = ";
                if(uniqueField == "FID")
                {
                    flt += item;
                }
                else
                {
                    if (dt.Columns[uniqueField].DataType == typeof(string))
                    {
                        flt += "'" + item + "'";
                    }
                    else
                    {
                        flt += item.ToString();
                    } 
                }
                
                cat.FilterExpression = flt;
                Categories.Add(cat);
                result.Add(c, item);
            }
            return result;
        }
Example #8
0
		/// <summary>
		/// Draw stuff here
		/// </summary>
		/// <param name="gameTime"></param>
		/// <param name="stereoEye"></param>
		protected override void Draw ( GameTime gameTime, StereoEye stereoEye )
		{
			var sb = GetService<SpriteBatch>();
			var rand = new Random();

			var data = Enumerable.Range(0,64*64)
						.Select( i => rand.NextColor() )
						.ToArray();

			dynamicTexture.SetData(0, null, data, 0, 64*64 );


			GraphicsDevice.SetTargets( dsMS.Surface, rtMS.Surface );
			GraphicsDevice.Clear( dsMS.Surface );
			GraphicsDevice.Clear( rtMS.Surface, Color4.Black );
			

			sb.Begin(SpriteBlend.AlphaBlend,null,null, Matrix.OrthoRH(256,256,-1,1));
				sb.DrawSprite( texture, 0,0,256, angle, Color.White );
			sb.End();

			GraphicsDevice.Resolve( rtMS, rt );


			GraphicsDevice.RestoreBackbuffer();


			int w  = GraphicsDevice.DisplayBounds.Width;
			int h  = GraphicsDevice.DisplayBounds.Height;

			//	begin sprite gathering/accumulation :
			sb.Begin();

				if (InputDevice.IsKeyDown(Keys.T)) {
					sb.Draw( texture2, 0,          0, 256, 256, Color.White	);
					sb.Draw( texture , 256+128*0,  0, 128, 128, Color.Red	);
					sb.Draw( texture2, 256+128*1,  0, 128, 128, Color.Lime	);
					sb.Draw( texture , 256+128*2,  0, 128, 128, Color.Blue	);
				} else {
					sb.Draw( rt, 0,          0, 256, 256, Color.White	);
					sb.Draw( rt, 256+128*0,  0, 128, 128, Color.Red	);
					sb.Draw( rt, 256+128*1,  0, 128, 128, Color.Lime	);
					sb.Draw( rt, 256+128*2,  0, 128, 128, Color.Blue	);
				}

			sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
				sb.DrawSprite( texture, 576,192,128, angle, Color.White );


			sb.Restart(SpriteBlend.AlphaBlend, SamplerState.LinearClamp);
				sb.DrawSprite( texture, 704,192,128, angle, Color.White );


			sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
				sb.DrawSprite( texture2, 576,192+128,128, angle, Color.White );


			sb.Restart(SpriteBlend.AlphaBlend, SamplerState.LinearClamp);
				sb.DrawSprite( texture2, 704,192+128,128, angle, Color.White );


			sb.Restart();

				for (int i=0; i<numSprites; i++) {
					//sb.DrawSprite( sb.TextureWhite, r.Next(w), r.Next(h), 7, r.NextFloat(0,360), r.NextColor() ); 
					sb.Draw( sb.TextureWhite, r.Next(w), r.Next(h), 7, 7, r.NextColor() ); 
				}

				var h1 = font1.LineHeight;
				var h2 = font2.LineHeight;

				font1.DrawString( sb, "Lenna Soderberg",      64, 256 + h1,      Color.White  );
				font2.DrawString( sb, "Text (tracking = 0)",  64, 256 + h1+h2,   Color.Red );
				font2.DrawString( sb, "Text (tracking = 2)",  64, 256 + h1+h2*2, Color.Lime, 2 );
				font2.DrawString( sb, "Text (tracking = 4)", 64, 256 + h1+h2*3, Color.Lime, 4 );

				font2.DrawString( sb, string.Format("{1} sprites -> FPS = {0}", gameTime.Fps, numSprites), 64, 256 + h1+h2*4, Color.White );


			sb.Restart( SpriteBlend.Additive );
				sb.Draw( sb.TextureWhite,   256, 128, 128, 128, Color.Gray	);
				sb.Draw( texture, 256, 128, 128, 128, Color.Gray	);


			sb.Restart( SpriteBlend.AlphaBlend );
				sb.Draw( sb.TextureWhite, 256+128, 128, 128, 128, new Color(240,225,160,255)	);


			sb.Restart( SpriteBlend.NegMultiply );
				sb.Draw( texture, 256+128, 128, 128, 128, Color.White	);


			sb.Restart(SpriteBlend.AlphaBlend, SamplerState.AnisotropicWrap);
				sb.DrawBeam( texture2, new Vector2(350,540), new Vector2(750,415), Color.Yellow, Color.LightYellow, 80, 5.5f, offset );

			sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
				sb.Draw( dynamicTexture, 0,0,256,256,new Color(255,255,255,64) );

				sb.Draw( sb.TextureBlack,	0,0,8,8, Color.White);
				sb.Draw( sb.TextureBlue,	8,0,8,8, Color.White);
				sb.Draw( sb.TextureGreen, 	16,0,8,8, Color.White);
				sb.Draw( sb.TextureRed,		24,0,8,8, Color.White);
				sb.Draw( sb.TextureWhite,	32,0,8,8, Color.White);

			sb.Restart();

				/*var name = atlas.SubImageNames[ ((int)atlasId) % atlas.SubImageNames.Length ];
				var ar = atlas.GetSubImageRectangle( name );

				sb.Draw( atlas.Texture, new Rectangle(10,400, ar.Width, ar.Height), ar, Color.White );
				sb.DrawDebugString( 10, 392, name, Color.White );

				atlasId += gameTime.ElapsedSec * 2;*/

			sb.End();

			base.Draw( gameTime, stereoEye );
		}
Example #9
0
 private static List<Color> CreateUnboundedRandomColors(int numColors)
 {
     Random rnd = new Random(DateTime.Now.Millisecond);
     List<Color> result = new List<Color>(numColors);
     for (int i = 0; i < numColors; i++)
     {
         result.Add(rnd.NextColor());
     }
     return result;
 }