public WheelMenu( MenuScreen screen, Camera camera, float wheelScale, float screenScale, float startX, float activeX, float finishX, float y) : base(screen, Vector2.Zero) { this.wheelScale = wheelScale; scaleMatrix = Matrix.CreateScale( wheelScale ); this.camera = camera; angle = MathHelper.PiOver4; TransitionOnPosition = new Vector2( startX, y ); Position = new Vector2( activeX, y ); TransitionOffPosition = new Vector2( finishX, y ); rotateSpring = new SpringInterpolater( 1, 50, SpringInterpolater.GetCriticalDamping( 50 ) ); lastX = startX; ContentManager content = screen.ScreenManager.Game.Content; entryEffect = content.Load<Effect>( "Effects/basic" ).Clone( Screen.ScreenManager.GraphicsDevice ); entryEffect.CurrentTechnique = entryEffect.Techniques["DiffuseColor"]; entryEffect.Parameters["LightingEnabled"].SetValue( false ); entryWorldEffectParameter = entryEffect.Parameters["World"]; entryViewEffectParameter = entryEffect.Parameters["View"]; entryProjectionEffectParameter = entryEffect.Parameters["Projection"]; entryDiffuseEffectParameter = entryEffect.Parameters["DiffuseMap"]; wheelModel = content.Load<CustomModel>( "Models/hamsterWheel" ); foreach ( CustomModel.ModelPart part in wheelModel.ModelParts ) { part.Effect.CurrentTechnique = part.Effect.Techniques["Color"]; part.Effect.Parameters["Color"].SetValue( new Color( Color.LightGray, 0 ).ToVector4() ); } }
public PlayerTag( Player player, SpriteFont font ) { this.player = player; this.font = font; ss = GameCore.Instance.GraphicsDevice.Viewport.Height / 1080f; color = GameCore.Instance.PlayerColors[player.PlayerNumber]; device = player.Screen.ScreenManager.GraphicsDevice; camera = player.Screen.Camera; spriteBatch = player.Screen.ScreenManager.SpriteBatch; tagOffset *= device.Viewport.Height / 1080f; nearHeightOver2 = camera.Near * (float)Math.Tan( camera.Fov / 2 ); nearWidthOver2 = camera.Aspect * nearHeightOver2; screenPos = Vector2.Zero; origin = font.MeasureString( player.HUD.Name ) / 2; spring = new SpringInterpolater( 1, 700, .3f * SpringInterpolater.GetCriticalDamping( 700 ) ); spring.SetSource( 0 ); spring.SetDest( 1 ); }
public MainPage() { //don't touch this method. microsoft created InitializeComponent(); //this method initializes the Device DeviceManager.CreateDevice(panel1.Handle, panel1.Width, panel1.Height); _camera = new Camera(); _renderer = new Renderer(); Init(); DeviceManager.LocalDevice.SetRenderState(RenderState.Lighting, _renderer.IsGlobalLightOn); DeviceManager.LocalDevice.SetRenderState(RenderState.CullMode, Cull.Counterclockwise); DeviceManager.LocalDevice.SetRenderState(RenderState.ZEnable, ZBufferType.UseZBuffer); DeviceManager.LocalDevice.SetRenderState(RenderState.NormalizeNormals, true); DeviceManager.LocalDevice.SetRenderState(RenderState.Ambient, Color.Gray.ToArgb()); DeviceManager.LocalDevice.SetRenderState(RenderState.SpecularEnable, false); //set GUI control attributes SetGui(); panel1.MouseWheel += panel1_MouseWheel; }
public void Begin(Camera camera) { this.camera = camera; StateManager.SetRenderState(RenderState.Lighting, false); StateManager.SetRenderState(RenderState.AlphaTestEnable, true); StateManager.SetRenderState(RenderState.AlphaRef, 1); StateManager.SetRenderState(RenderState.AlphaFunc, Compare.GreaterEqual); StateManager.SetRenderState(RenderState.AlphaBlendEnable, true); StateManager.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); StateManager.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); StateManager.SetRenderState(RenderState.ZEnable, false); StateManager.SetRenderState(RenderState.ZWriteEnable, false); StateManager.SetRenderState(RenderState.MultisampleAntialias, false); StateManager.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp); StateManager.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp); StateManager.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point); StateManager.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point); StateManager.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Point); View.Device9.SetTransform(TransformState.Projection, camera.Projection); View.Device9.SetTransform(TransformState.View, camera.View); View.Device9.PixelShader = null; View.Device9.VertexShader = null; View.Device9.SetStreamSource(0, null, 0, 0); View.Device9.SetStreamSourceFrequency(1, 0, StreamSource.InstanceData); View.Device9.SetStreamSource(1, null, 0, 0); View.Device9.SetRenderState(SlimDX.Direct3D9.RenderState.FillMode, FillMode.Wireframe); for(int i=0; i < 10; i++) View.Device9.SetTexture(i, null); }
public override void LoadContent() { // load the fancy title effects LoadTitleContent(); // create the wheel menu GraphicsDevice device = ScreenManager.GraphicsDevice; scale = (float)device.Viewport.Height / 1080f; ContentManager content = ScreenManager.Game.Content; Camera camera = new Camera( MathHelper.PiOver4, device.Viewport.AspectRatio, 1f, 100f, new Vector3( 0, 3f, 10 ), new Vector3( 0, 3f, 0 ) ); // this should prevent spikes in sign-in screen when creating first avatar new Avatar( AvatarDescription.CreateRandom(), AvatarAnimationPreset.Stand0, 1f, Vector3.UnitZ, Vector3.Zero ); float wheelScale = 3f; // 2.5f old wheelMenu = new WheelMenu( this, camera, wheelScale, scale, -3, 0, 3, wheelScale / 2 ); if ( Guide.IsTrialMode ) WheelMenu.EntryActiveScale = 1.4f; else WheelMenu.EntryActiveScale = 1.75f; WheelMenuEntry entry; wheelMenu.AcceptingInput = false; entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/playText" ) ); entry.Selected += PlayMenuEntrySelected; wheelMenu.AddEntry( entry ); if ( Guide.IsTrialMode ) { entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/buyText" ) ); entry.Selected += GameCore.Instance.ShowBuy; entry.IsBuyOption = true; wheelMenu.AddEntry( entry ); } entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/howToPlayText" ) ); entry.Selected += HowToPlayMenuEntrySelected; wheelMenu.AddEntry( entry ); entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/leaderboardText" ) ); entry.Selected += LeaderboardMenuEntrySelected; wheelMenu.AddEntry( entry ); entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/optionsText" ) ); entry.Selected += OptionsMenuEntrySelected; wheelMenu.AddEntry( entry ); entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/creditsText" ) ); entry.Selected += CreditsMenuEntrySelected; wheelMenu.AddEntry( entry ); entry = new WheelMenuEntry( wheelMenu, content.Load<Texture2D>( "Textures/exitText" ) ); entry.Selected += OnCancel; wheelMenu.AddEntry( entry ); MenuItems.Add( wheelMenu ); signInMenuScreen = new SignInMenuScreen( ScreenManager ); controlsMenuScreen = new ControlsMenuScreen( ScreenManager ); optionsMenuScreen = new OptionsMenuScreen( ScreenManager ); creditsMenuScreen = new CreditsMenuScreen( ScreenManager ); highscoreScreen = new HighscoreScreen( ScreenManager ); // pre-load other stuff here content.Load<Texture2D>( "Textures/messageBox" ); }
public SignInMenuScreen( ScreenManager screenManager ) { TransitionOnTime = TimeSpan.FromSeconds( 1 ); TransitionOffTime = TimeSpan.FromSeconds( .25 ); this.ScreenManager = screenManager; ContentManager content = screenManager.Game.Content; GraphicsDevice device = screenManager.GraphicsDevice; boxModel = content.Load<CustomModel>( "Models/signInBox" ); foreach ( CustomModel.ModelPart part in boxModel.ModelParts ) { part.Effect.CurrentTechnique = part.Effect.Techniques["Color"]; } camera = new Camera( MathHelper.PiOver4, device.Viewport.AspectRatio, 1, 100, new Vector3( 0, 0, 10 ), new Vector3( 0, 0, 0 ) ); StaticImageMenuItem item; Vector2 itemPosition; SpriteFont nameFont = content.Load<SpriteFont>( "Fonts/signInNameFont" ); Texture2D joinTexture = content.Load<Texture2D>( "Textures/aJoinText" ); Texture2D addCpuTexture = content.Load<Texture2D>( "Textures/xAddCPUText" ); Texture2D removeCpuTexture = content.Load<Texture2D>( "Textures/yRemoveCPUText" ); Texture2D aStartTexture = content.Load<Texture2D>( "Textures/aStartText" ); Texture2D readyTexture = content.Load<Texture2D>( "Textures/readyText" ); screenScale = device.Viewport.Height / 1080f; textScale *= screenScale; Rectangle rectangle = ScreenRects.FourByThree; float x = textColumnStart * (float)rectangle.Width + (float)rectangle.X; float xStep = (float)rectangle.Width * ( 1f - ( 2f * textColumnStart ) ) / 3f; float nameY = nameHeight * (float)rectangle.Height + (float)rectangle.Y; float joinY = joinHeight * (float)rectangle.Height + (float)rectangle.Y; float cpuY = cpuHeight * (float)rectangle.Height + (float)rectangle.Y; float readyY = readyHeight * (float)rectangle.Height + (float)rectangle.Y; // Full version required for multiplayer Vector2 nagPos = new Vector2( device.Viewport.Width / 2, device.Viewport.Height * .14f ); nagText = new TextMenuItem( this, nagPos, "Full version required for multiplayer.", nameFont ); nagText.TransitionOnPosition = nagPos; nagText.TransitionOffPosition = nagPos; nagText.Centered = true; nagText.Color = Color.DarkOrange; nagText.DeathBegin = .01f; MenuItems.Add( nagText ); for ( int i = 0; i < 4; ++i ) { // <GAMERTAG> itemPosition = new Vector2( x, nameY ); TextMenuItem textItem = new TextMenuItem( this, itemPosition, null, nameFont ); textItem.Centered = true; textItem.MaxWidth = xStep; textItem.Scale = screenScale; slots[i].NameItem = textItem; MenuItems.Add( textItem ); // A Join itemPosition = new Vector2( x, joinY ); item = new StaticImageMenuItem( this, itemPosition, joinTexture ); item.SetImmediateScale( textScale ); slots[i].JoinItem = item; MenuItems.Add( item ); // X Add CPU itemPosition = new Vector2( x, cpuY ); item = new StaticImageMenuItem( this, itemPosition, addCpuTexture ); item.SetImmediateScale( textScale ); slots[i].AddCPUItem = item; MenuItems.Add( item ); // Y Add CPU itemPosition = new Vector2( x, cpuY ); item = new StaticImageMenuItem( this, itemPosition, removeCpuTexture ); item.SetImmediateScale( textScale ); slots[i].RemoveCPUItem = item; MenuItems.Add( item ); // A Start itemPosition = new Vector2( x, readyY ); item = new StaticImageMenuItem( this, itemPosition, aStartTexture ); item.SetImmediateScale( textScale ); slots[i].StartItem = item; MenuItems.Add( item ); // Ready! itemPosition = new Vector2( x, readyY ); item = new StaticImageMenuItem( this, itemPosition, readyTexture ); item.SetImmediateScale( textScale ); slots[i].ReadyItem = item; MenuItems.Add( item ); x += xStep; } }
public void DrawCircle(Camera camera, Matrix world, Vector3 position, float radius, int nSegmnets, Color color) { List<Vector3> lines = new List<Vector3>(); for (int i = 0; i <= nSegmnets; i++) { float angel = (float)(Math.PI * 2 * (float)i/(float)nSegmnets); Vector3 diff = Common.Math.Vector3FromAngleXY(angel)*radius; lines.Add(position + diff); } Draw3DLines(camera, world, lines.ToArray(), color); }
public void DrawArc(Camera camera, Matrix world, Vector3 position, float radius, int nSegmnets, float direction, float angle, Color color) { List<Vector3> lines = new List<Vector3>(); angle = Math.Min(angle, (float)Math.PI); float startAngle = direction - angle; float endAngle = direction + angle; lines.Add(position); float angleStep = angle * 2 / (float)nSegmnets; for (int i = 0; i <= nSegmnets; i++) { Vector3 diff = Common.Math.Vector3FromAngleXY(startAngle + angleStep * i) * radius; lines.Add(position + diff); } lines.Add(position); Draw3DLines(camera, world, lines.ToArray(), color); }
public void Draw3DLines(Camera camera, Matrix world, Vector3[] lines, Color color) { LineDrawer.Begin(); List<Vector2> trans = new List<Vector2>(); foreach (var v in lines) { var p = Vector3.Project(v, Viewport.X, Viewport.Y, Viewport.Width, Viewport.Height, Viewport.MinZ, Viewport.MaxZ, world * camera.ViewProjection); trans.Add(Common.Math.ToVector2(p)); } LineDrawer.Draw(trans.ToArray(), color); //LineDrawer.DrawTransformed(lines, world * camera.View * camera.Projection, color); LineDrawer.End(); }
public void Draw3DAABB(Camera camera, Matrix world, Vector3 min, Vector3 max, Color color) { //LineDrawer.Begin(); //LineDrawer.DrawTransformed( Draw3DLines(camera, world, new Vector3[] { //bottom new Vector3(min.X, min.Y, min.Z), new Vector3(max.X, min.Y, min.Z), new Vector3(max.X, max.Y, min.Z), new Vector3(min.X, max.Y, min.Z), new Vector3(min.X, min.Y, min.Z), new Vector3(min.X, min.Y, max.Z), new Vector3(max.X, min.Y, max.Z), new Vector3(max.X, min.Y, min.Z), new Vector3(max.X, min.Y, max.Z), new Vector3(max.X, max.Y, max.Z), new Vector3(max.X, max.Y, min.Z), new Vector3(max.X, max.Y, max.Z), new Vector3(min.X, max.Y, max.Z), new Vector3(min.X, max.Y, min.Z), new Vector3(min.X, max.Y, max.Z), new Vector3(min.X, min.Y, max.Z), }, //world * camera.View * camera.Projection, color); //LineDrawer.End(); }
public override void DrawEffectiveAttackRangeCircle(Camera camera, float lookatDir, System.Drawing.Color color) { Program.Instance.DrawCircle(Game.Instance.Scene.Camera, Matrix.Identity, TargetPosition, EffectiveRange, 12, color); }
public override void DrawEffectiveAttackRangeCircle(Camera camera, float lookatDir, System.Drawing.Color color) { var gbe = new GhostBulletExplosion { TargetPosition = TargetPosition }; gbe.DrawEffectiveAttackRangeCircle(camera, lookatDir, color); }
private Common.Bounding.Frustum FrustumWithMargin(Camera camera, Graphics.GraphicsDevice.Viewport viewport) { return camera.FrustumFromRectangle(viewport, new Point(-enLargement, -enLargement), new Point((int)viewport.Width + enLargement, (int)viewport.Height + enLargement)); }
public Camera(Camera cpy) { this.ZFar = cpy.ZFar; this.ZNear = cpy.ZNear; }
public WorldViewProbe(View view, Camera camera) { this.View = view; this.Camera = camera; WorldProbe = new Common.EmptyWorldProbe(); }