Esempio n. 1
0
 /// <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;
     }
 }
Esempio n. 2
0
        public static void PreUpdate(IMainGame mainGame)
        {
            currentMouseState       = mainGame.Mouse.GetState();
            currentKeyboardState    = mainGame.Keyboard.GetState();
            currentPressedKeys      = currentKeyboardState.GetPressedKeys();
            currentScrollWheelValue = mainGame.Mouse.GetState().ScrollWheelValue;

            CheckForRelease();
            CheckForScroll();
        }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
 /// <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;
     }
 }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 8
0
 public virtual void LoadContent(IMainGame mainGame)
 {
     SpriteSheet.LoadContent(mainGame);
     CreateTimerEvent();
 }
Esempio n. 9
0
 public static Texture2D GetSelfShadow(IMainGame mainGame, Texture2D texture)
 {
     return(GetMask(mainGame, texture, new Color(109, 117, 141)));
 }
Esempio n. 10
0
 public static Texture2D GetAntiShadow(IMainGame mainGame, Texture2D texture)
 {
     return(GetMask(mainGame, texture, Color.Black));
 }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
 public Sprite(IMainGame mainGame, SpriteSheet spriteSheet, AnimArgs animArgs)
     : this(mainGame, spriteSheet, Vector2.Zero, Alignment.TopLeft, animArgs)
 {
 }
Esempio n. 13
0
 public GhostMarker(IMainGame mainGame, SpriteSheet spriteSheet) : base(mainGame, spriteSheet)
 {
     Alpha = 0.3f;
 }
Esempio n. 14
0
        public static Point GetMouseWindowPosition(IMainGame mainGame)
        {
            MouseState state = mainGame.Mouse.GetState();

            return(new Point(state.X, state.Y));
        }
Esempio n. 15
0
 /// <summary>
 /// Call this to load texture content from path.
 /// </summary>
 public void LoadContent(IMainGame mainGame)
 {
     Texture = mainGame.Content.Load <Texture2D>(ContentPath);
     Register();
 }
Esempio n. 16
0
 public Sprite(IMainGame mainGame, SpriteSheet spriteSheet, Vector2 position)
     : this(mainGame, spriteSheet, position, Alignment.TopLeft, null)
 {
 }
Esempio n. 17
0
 public Sprite(IMainGame mainGame, SpriteSheet spriteSheet)
     : this(mainGame, spriteSheet, Vector2.Zero)
 {
 }
Esempio n. 18
0
 public void LoadContent(IMainGame mainGame)
 {
     Texture     = mainGame.Content.Load <Texture2D>(TexturePath);
     PositionMap = ConstructPositionMap();
 }
Esempio n. 19
0
 public override void LoadContent(IMainGame mainGame)
 {
     // Do nothing.
 }
Esempio n. 20
0
 public CubeDesignerViewModel(IMainGame mainGame)
 {
     MainGame = mainGame;
     C_Import = new RelayCommand((o) => Import());
 }
Esempio n. 21
0
 public override void LoadContent(IMainGame mainGame)
 {
     base.LoadContent(mainGame);
     Image.LoadContent(mainGame);
 }
Esempio n. 22
0
 public Player(IMainGame mainGame, SpriteSheet spriteSheet, AnimArgs switchAnimArgs) : base(mainGame, spriteSheet, switchAnimArgs)
 {
     PositionOffset = new Vector2(0, -54);
 }