/// <summary> /// Core method used to re-instantiate non-serializable properties and delegates. This can create garbage if called during runtime. /// </summary> public virtual void LoadContent(IMainGame mainGame) { MainGame = mainGame; if (Animator != null) { Animator.LoadContent(mainGame); Animator.Sprite = this; } }
public static void PreUpdate(IMainGame mainGame) { currentMouseState = mainGame.Mouse.GetState(); currentKeyboardState = mainGame.Keyboard.GetState(); currentPressedKeys = currentKeyboardState.GetPressedKeys(); currentScrollWheelValue = mainGame.Mouse.GetState().ScrollWheelValue; CheckForRelease(); CheckForScroll(); }
public static Point GetScaledMouseWorldPosition(IMainGame mainGame, Camera camera) { if (camera.CurrentMode == CameraMode.Drag) { return(World.ZoomScaledPoint(new Point(-(int)camera.DragTransform.M41, -(int)camera.DragTransform.M42) + GetMouseWindowPosition(mainGame))); } else { return(Point.Zero); } }
/// <summary> /// Core method used to re-instantiate non-serializable properties and delegates. /// </summary> public override void LoadContent(IMainGame mainGame) { if (AnimatorTop != null) { AnimatorTop.LoadContent(mainGame); AnimatorTop.Sprite = this; } if (AnimatorBase != null) { AnimatorBase.LoadContent(mainGame); AnimatorBase.Sprite = this; } }
public Sprite(IMainGame mainGame, SpriteSheet spriteSheet, Vector2 position, Alignment alignment, AnimArgs animArgs) { MainGame = mainGame; // An animator is always required for the sprite to be drawn. The default constructor assumes the given spritesheet to be a single frame image. Animator = new Animator(this, spriteSheet); if (animArgs != null) { Animator.Reconfigure(animArgs); } if (GraphicsHelper.AntiShadowLibrary.ContainsKey(Animator.SpriteSheet.TexturePath)) { AntiShadow = GraphicsHelper.AntiShadowLibrary[Animator.SpriteSheet.TexturePath]; } else { AntiShadow = GraphicsHelper.GetAntiShadow(mainGame, Animator.SpriteSheet.Texture); GraphicsHelper.AntiShadowLibrary.Add(Animator.SpriteSheet.TexturePath, AntiShadow); } if (GraphicsHelper.SelfShadowLibrary.ContainsKey(Animator.SpriteSheet.TexturePath)) { SelfShadow = GraphicsHelper.SelfShadowLibrary[Animator.SpriteSheet.TexturePath]; } else { SelfShadow = GraphicsHelper.GetSelfShadow(mainGame, Animator.SpriteSheet.Texture); GraphicsHelper.SelfShadowLibrary.Add(Animator.SpriteSheet.TexturePath, SelfShadow); } if (alignment == Alignment.TopLeft) { Position = position; } else if (alignment == Alignment.TopRight) { Position = position + new Vector2(-spriteSheet.Texture.Width, 0); } else if (alignment == Alignment.Center) { Position = position + new Vector2(-spriteSheet.Texture.Width / 2, -spriteSheet.Texture.Height / 2); } else if (alignment == Alignment.BottomLeft) { Position = position + new Vector2(0, -spriteSheet.Texture.Height); } else if (alignment == Alignment.BottomRight) { Position = position + new Vector2(-spriteSheet.Texture.Width, -spriteSheet.Texture.Height); } }
public RunGame(IRenderBanner renderBanner, IFileReader fileReader, IRandomWordSelector randomWordSelector, IAssembleGuessedLetters assembleGuessedLetters, IDisplayWord displayWord, IMainGame mainGame, IResultsScreen resultsScreen) { _renderBanner = renderBanner; _fileReader = fileReader; _randomWordSelector = randomWordSelector; _assembleGuessedLetters = assembleGuessedLetters; _displayWord = displayWord; _mainGame = mainGame; _resultsScreen = resultsScreen; }
/// <summary> /// Returns a mask texture from a base texture. This creates garbage. /// </summary> public static Texture2D GetMask(IMainGame mainGame, Texture2D texture, Color color) { var totalPixels = texture.Width * texture.Height; Color[] maskPixels = new Color[totalPixels]; texture.GetData(maskPixels); for (int i = 0; i < maskPixels.Length; i++) { if (maskPixels[i].A != 0) { maskPixels[i] = color; } } var mask = new Texture2D(mainGame.GraphicsDevice, texture.Width, texture.Height); mask.SetData(maskPixels); return(mask); }
public virtual void LoadContent(IMainGame mainGame) { SpriteSheet.LoadContent(mainGame); CreateTimerEvent(); }
public static Texture2D GetSelfShadow(IMainGame mainGame, Texture2D texture) { return(GetMask(mainGame, texture, new Color(109, 117, 141))); }
public static Texture2D GetAntiShadow(IMainGame mainGame, Texture2D texture) { return(GetMask(mainGame, texture, Color.Black)); }
public DecoCatalogViewModel(IMainGame mainGame) { MainGame = mainGame; var decoCatalog1x1x1Args = new DecoCatalogArgs() { CatalogName = "1x1x1", ImportDirectory = UriHelper.Deco1x1x1Directory, DecoDimension = new Dimension(1, 1, 1), DecoPositionOffset = new Vector2(0, 0), ItemWidth = 72, ItemHeight = 75, }; DecoCatalog1x1x1 = new DecoCatalogManager(this, decoCatalog1x1x1Args); var decoCatalog1x1x2Args = new DecoCatalogArgs() { CatalogName = "1x1x2", ImportDirectory = UriHelper.Deco1x1x2Directory, DecoDimension = new Dimension(1, 1, 2), DecoPositionOffset = new Vector2(0, -36), ItemWidth = 72, ItemHeight = 111, }; DecoCatalog1x1x2 = new DecoCatalogManager(this, decoCatalog1x1x2Args); var decoCatalog1x1x3Args = new DecoCatalogArgs() { CatalogName = "1x1x3", ImportDirectory = UriHelper.Deco1x1x3Directory, DecoDimension = new Dimension(1, 1, 3), DecoPositionOffset = new Vector2(0, -72), ItemWidth = 72, ItemHeight = 147, }; DecoCatalog1x1x3 = new DecoCatalogManager(this, decoCatalog1x1x3Args); var decoCatalog2x2x2Args = new DecoCatalogArgs() { CatalogName = "2x2x2", ImportDirectory = UriHelper.Deco2x2x2Directory, DecoDimension = new Dimension(2, 2, 2), DecoPositionOffset = new Vector2(-36, -72), ItemWidth = 144, ItemHeight = 147, }; DecoCatalog2x2x2 = new DecoCatalogManager(this, decoCatalog2x2x2Args); var decoCatalog3x3x3Args = new DecoCatalogArgs() { CatalogName = "3x3x3", ImportDirectory = UriHelper.Deco3x3x3Directory, DecoDimension = new Dimension(3, 3, 3), DecoPositionOffset = new Vector2(-72, -108), ItemWidth = 216, ItemHeight = 219, }; DecoCatalog3x3x3 = new DecoCatalogManager(this, decoCatalog3x3x3Args); }
public Sprite(IMainGame mainGame, SpriteSheet spriteSheet, AnimArgs animArgs) : this(mainGame, spriteSheet, Vector2.Zero, Alignment.TopLeft, animArgs) { }
public GhostMarker(IMainGame mainGame, SpriteSheet spriteSheet) : base(mainGame, spriteSheet) { Alpha = 0.3f; }
public static Point GetMouseWindowPosition(IMainGame mainGame) { MouseState state = mainGame.Mouse.GetState(); return(new Point(state.X, state.Y)); }
/// <summary> /// Call this to load texture content from path. /// </summary> public void LoadContent(IMainGame mainGame) { Texture = mainGame.Content.Load <Texture2D>(ContentPath); Register(); }
public Sprite(IMainGame mainGame, SpriteSheet spriteSheet, Vector2 position) : this(mainGame, spriteSheet, position, Alignment.TopLeft, null) { }
public Sprite(IMainGame mainGame, SpriteSheet spriteSheet) : this(mainGame, spriteSheet, Vector2.Zero) { }
public void LoadContent(IMainGame mainGame) { Texture = mainGame.Content.Load <Texture2D>(TexturePath); PositionMap = ConstructPositionMap(); }
public override void LoadContent(IMainGame mainGame) { // Do nothing. }
public CubeDesignerViewModel(IMainGame mainGame) { MainGame = mainGame; C_Import = new RelayCommand((o) => Import()); }
public override void LoadContent(IMainGame mainGame) { base.LoadContent(mainGame); Image.LoadContent(mainGame); }
public Player(IMainGame mainGame, SpriteSheet spriteSheet, AnimArgs switchAnimArgs) : base(mainGame, spriteSheet, switchAnimArgs) { PositionOffset = new Vector2(0, -54); }