/// <summary> /// Erstellt einen neuen RenderEffect. /// </summary> /// <param name='screen'> /// Game State. /// </param> public RenderEffect(GameScreen screen) { this.screen = screen; renderTarget = new RenderTargetCache (screen.device); spriteBatch = new SpriteBatch (screen.device); background = Color.Transparent; }
public PipeModel(GameScreen screen, PipeModelInfo info) : base(screen, info) { if (Info.Direction.Y == 1) { Info.Rotation += Angles3.FromDegrees (90, 0, 0); } else if (Info.Direction.Y == -1) { Info.Rotation += Angles3.FromDegrees (270, 0, 0); } if (Info.Direction.X == 1) { Info.Rotation += Angles3.FromDegrees (0, 90, 0); } else if (Info.Direction.X == -1) { Info.Rotation += Angles3.FromDegrees (0, 270, 0); } float length = (info.PositionTo - info.PositionFrom).Length (); float radius = Info.Scale.PrimaryVector ().Length (); Bounds = VectorHelper.CylinderBounds (length, radius, Info.Direction, info.PositionFrom); /*float distance = radius / 4; Bounds = new BoundingSphere[(int)(length / distance)]; for (int offset = 0; offset < (int)(length / distance); ++offset) { Bounds [offset] = new BoundingSphere (info.PositionFrom + Info.Direction * offset * distance, radius); //Console.WriteLine ("sphere[" + offset + "]=" + Bounds [offset]); }*/ }
public DropDownMenu(GameScreen screen, DisplayLayer drawOrder, int itemNum, MenuItemInfo info) : base(screen, drawOrder, itemNum, info) { // drop-down menu dropdown = new VerticalMenu (screen, new WidgetInfo (), DisplayLayer.SubMenu); dropdown.ItemForegroundColor = DropDownForegroundColor; dropdown.ItemBackgroundColor = DropDownBackgroundColor; dropdown.ItemAlignX = HorizontalAlignment.Left; dropdown.ItemAlignY = VerticalAlignment.Center; dropdown.Border = new Border (new Color (0xb4, 0xff, 0x00), 5, 5, 0, 0); dropdown.IsVisible = false; // selected value MenuItemInfo valueInfo = new MenuItemInfo () { Text = "---", RelativePosition = () => ValuePosition (0), RelativeSize = () => ValueSize (0), OnClick = () => info.OnClick (), }; selected = new MenuButton (screen, DisplayLayer.MenuItem, 0, valueInfo); selected.Info.ForegroundColor = () => DropDownForegroundColor (selected.ItemState); selected.Info.BackgroundColor = () => DropDownBackgroundColor (selected.ItemState); // action to open the drop-down menu info.OnClick = () => { GameScreens.VideoOptionScreen.Collapse (this); if (dropdown.IsVisible == true) { dropdown.IsVisible = false; } else { dropdown.IsVisible = true; } }; }
public TextInput(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { // load fonts font = HfGDesign.MenuFont (screen); spriteBatch = new SpriteBatch (screen.device); }
public FadeEffect(GameScreen screen, GameScreen oldState) : base(screen) { if (oldState != null) { lastFrame = oldState.PostProcessingEffect.RenderTarget; alpha = 1.0f; } }
public ShadowGameObject(GameScreen screen, IGameObject obj) { this.screen = screen; Info = new GameObjectInfo (); Obj = obj; Info.IsVisible = true; Info.IsSelectable = false; Info.IsMovable = false; }
public GameModel(GameScreen screen, GameModelInfo info) { this.screen = screen; Info = info; // colors BaseColor = Color.Transparent; HighlightColor = Color.Transparent; HighlightIntensity = 0f; Alpha = 1f; }
public GameModel this[GameScreen screen, GameModelInfo info] { get { if (cache.ContainsKey (info)) { return cache [info]; } else { return cache [info] = CreateModel(screen, info); } } }
public TextInputDialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { var textInputInfo = new WidgetInfo () { RelativePosition = TextInputPosition, RelativeSize = TextInputSize, RelativePadding = () => new Vector2 (0.005f, 0.005f), ForegroundColor = () => Color.Black, BackgroundColor = () => Color.White }; TextInput = new TextInput (screen, textInputInfo, DisplayLayer.SubMenu); }
/// <summary> /// Initializes a new Overlay- /// </summary> public Overlay(GameScreen screen, World world) : base(screen, DisplayLayer.Overlay) { // game world World = world; // create a new SpriteBatch, which can be used to draw textures effect = new BasicEffect (screen.device); spriteBatch = new SpriteBatch (screen.device); effect.VertexColorEnabled = true; effect.World = Matrix.CreateFromYawPitchRoll (0, 0, 0); }
public TexturedRectangle(GameScreen screen, TexturedRectangleInfo info) { this.screen = screen; Info = info; SetPosition (Info.Position); basicEffect = new BasicEffect (screen.device); texture = TextureHelper.LoadTexture (screen.content, info.Texturename); if (texture != null) { FillVertices (); } }
public VerticalMenu(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { info.RelativeSize = () => new Vector2 ( RelativeItemSize (-1).X, RelativeItemSize (-1).Y * Items.Count + Info.RelativePadding ().Y * (Items.Count - 1) ); RelativeItemSize = (i) => new Vector2 (300, 0); RelativeItemPosition = (n) => { return Info.RelativePosition () + new Vector2 (0, (RelativeItemSize (-1).Y + Info.RelativePadding ().Y) * n); }; Border = Border.Zero; spriteBatch = new SpriteBatch (screen.device); }
/// <summary> /// Initializes a new instance of the <see cref="Knot3.Core.Camera"/> class. /// </summary> /// <param name='screen'> /// Game State. /// </param> public Camera(GameScreen screen, World world) : base(screen, DisplayLayer.None) { World = world; DefaultPosition = new Vector3 (400, 400, 700); Position = DefaultPosition; Target = new Vector3 (0, 0, 0); UpVector = Vector3.Up; FoV = MathHelper.ToDegrees (MathHelper.PiOver4); aspectRatio = screen.viewport.AspectRatio; nearPlane = 0.5f; farPlane = 10000.0f; UpdateMatrices (null); }
public static Model LoadModel(GameScreen screen, string name) { ContentManager content; if (contentManagers.ContainsKey (screen.CurrentRenderEffects.Current.ToString ())) { content = contentManagers [screen.CurrentRenderEffects.Current.ToString ()]; } else { contentManagers [screen.CurrentRenderEffects.Current.ToString ()] = content = new ContentManager (screen.content.ServiceProvider, screen.content.RootDirectory); } Model model = LoadModel (content, screen.CurrentRenderEffects.Current, name + "-" + Quality); if (model == null) { model = LoadModel (content, screen.CurrentRenderEffects.Current, name); } return model; }
public ArrowModel(GameScreen screen, ArrowModelInfo info) : base(screen, info) { if (Info.Direction.Y == 1) { Info.Rotation += Angles3.FromDegrees (90, 0, 0); } else if (Info.Direction.Y == -1) { Info.Rotation += Angles3.FromDegrees (270, 0, 0); } if (Info.Direction.X == 1) { Info.Rotation += Angles3.FromDegrees (0, 90, 0); } else if (Info.Direction.X == -1) { Info.Rotation += Angles3.FromDegrees (0, 270, 0); } Bounds = VectorHelper.CylinderBounds (Info.Length, Info.Diameter / 2, Info.Direction, info.Position - info.Direction * Info.Length / 2); }
public Dialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { IsVisible = true; Done = () => { IsVisible = false; }; // create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch (screen.device); // menu WidgetInfo menuInfo = new WidgetInfo (); buttons = new Menu (screen, menuInfo, DisplayLayer.Menu); buttons.ItemForegroundColor = ButtonForegroundColor; buttons.ItemBackgroundColor = ButtonBackgroundColor; buttons.ItemAlignX = HorizontalAlignment.Center; buttons.ItemAlignY = VerticalAlignment.Center; }
public ConfirmDialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { // text Text = new string[] {}; // actions Action onYesClick = () => { OnYesClick (); if (CanClose) { Done (); } }; Action onNoClick = () => { OnNoClick (); Done (); }; Action onCancelClick = () => { OnCancelClick (); Done (); }; // buttons buttons.RelativeItemPosition = RelativeButtonPosition; buttons.RelativeItemSize = RelativeButtonSize; var itemInfo = new MenuItemInfo () { Text = "Yes", OnClick = onYesClick }; buttons.AddButton (itemInfo); itemInfo = new MenuItemInfo () { Text = "No", OnClick = onNoClick }; buttons.AddButton (itemInfo); itemInfo = new MenuItemInfo () { Text = "Cancel", OnClick = onCancelClick }; buttons.AddButton (itemInfo); }
public KnotInputHandler(GameScreen screen, World world) : base(screen, DisplayLayer.None) { // game world World = world; // default values screen.input.GrabMouseMovement = false; ResetMousePosition (); // keys to accept ValidKeys = new List<Keys> (); ValidKeys.AddRange ( new [] { Keys.A, Keys.D, Keys.W, Keys.S, Keys.R, Keys.F, Keys.Q, Keys.E, Keys.A, Keys.D, Keys.W, Keys.S, Keys.R, Keys.F, Keys.Q, Keys.E, Keys.Left, Keys.Right, Keys.Up, Keys.Down, Keys.OemPlus, Keys.OemMinus, Keys.Enter, Keys.LeftAlt, Keys.Tab } ); }
public ColorPicker(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { info.BackgroundColor = () => Color.Black; info.ForegroundColor = () => Color.White; info.AlignX = HorizontalAlignment.Left; info.AlignY = VerticalAlignment.Top; // colors colors = new List<Color> (CreateColors (64)); colors.Sort (Utilities.ColorHelper.SortColorsByLuminance); tiles = new List<Vector2> (CreateTiles (colors)); // create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch (screen.device); info.RelativePosition = () => (Vector2.One - info.RelativeSize ()) / 2; info.RelativeSize = () => { float sqrt = (float)Math.Ceiling (Math.Sqrt (colors.Count)); return tileSize * sqrt; }; }
public static void DrawLines(ref List<Vector2> linePoints, int lineWidth, SpriteBatch spriteBatch, GameScreen screen, GameTime time) { lineWidth = (int)new Vector2 (lineWidth, lineWidth).Scale (screen.viewport).X; if (texture == null) { texture = TextureHelper.Create (screen.device, Color.White); } if (linePoints.Count >= 2) { Rectangle[] rects = new Rectangle[linePoints.Count - 1]; for (int i = 1; i < linePoints.Count; ++i) { Vector2 nodeA = linePoints [i - 1]; Vector2 nodeB = linePoints [i]; if (nodeA.X == nodeB.X || nodeA.Y == nodeB.Y) { Vector2 direction = (nodeB - nodeA).PrimaryDirection (); Vector2 position = nodeA.Scale (screen.viewport); int length = (int)(nodeB - nodeA).Scale (screen.viewport).Length (); if (direction.X == 0 && direction.Y > 0) { rects [i - 1] = CreateRectangle (lineWidth, position.X, position.Y, 0, length); } else if (direction.X == 0 && direction.Y < 0) { rects [i - 1] = CreateRectangle (lineWidth, position.X, position.Y - length, 0, length); } else if (direction.Y == 0 && direction.X > 0) { rects [i - 1] = CreateRectangle (lineWidth, position.X, position.Y, length, 0); } else if (direction.Y == 0 && direction.X < 0) { rects [i - 1] = CreateRectangle (lineWidth, position.X - length, position.Y, length, 0); } } } foreach (Rectangle inner in rects) { Rectangle outer = new Rectangle (inner.X - 1, inner.Y - 1, inner.Width + 2, inner.Height + 2); spriteBatch.Draw (texture, outer, OutlineColor); } foreach (Rectangle rect in rects) { spriteBatch.Draw (texture, rect, LineColor); } } }
float outlineThreshold = 0.2f; // current edge detection threshold #endregion Fields #region Constructors public CelShadingEffect(GameScreen screen) : base(screen) { /* Set our light direction for the cel-shader */ lightDirection = new Vector4 (0.0f, 0.0f, 1.0f, 1.0f); /* Load and initialize the cel-shader effect */ celShader = screen.LoadEffect ("CelShader"); celShader.Parameters ["LightDirection"].SetValue (lightDirection); celMap = screen.content.Load<Texture2D> ("CelMap"); celShader.Parameters ["Color"].SetValue (Color.Green.ToVector4 ()); celShader.Parameters ["CelMap"].SetValue (celMap); /* Load and initialize the outline shader effect */ outlineShader = screen.LoadEffect ("OutlineShader"); outlineShader.Parameters ["Thickness"].SetValue (outlineThickness); outlineShader.Parameters ["Threshold"].SetValue (outlineThreshold); outlineShader.Parameters ["ScreenSize"].SetValue ( new Vector2 (screen.viewport.Bounds.Width, screen.viewport.Bounds.Height)); }
/// <summary> /// Initializes a new MousePicking component. /// </summary> public ModelMouseHandler(GameScreen screen, World world) : base(screen, DisplayLayer.None) { World = world; }
/// <summary> /// Initializes a new mouse pointer. /// </summary> /// <param name='screen'> /// State. /// </param> public MousePointer(GameScreen screen) : base(screen, DisplayLayer.Cursor) { // create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch (screen.device); }
public BlurEffect(GameScreen screen) : base(screen) { testEffect = screen.LoadEffect ("blur"); }
public Menu(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { Items = new List<MenuItem> (); }
public ShadowGameModel(GameScreen screen, GameModel model) : base(screen, model) { Model = model; }
public StandardEffect(GameScreen screen) : base(screen) { }
public MenuButton(GameScreen screen, DisplayLayer drawOrder, int itemNum, MenuItemInfo info) : base(screen, drawOrder, itemNum, info) { }
public EdgeColoring(GameScreen screen) : base(screen, DisplayLayer.None) { ValidKeys = new List<Keys> (); ValidKeys.Add (Keys.C); }
public MovableGameObject(GameScreen screen, IGameObject obj) { this.screen = screen; Obj = obj; Obj.Info.IsMovable = true; }