예제 #1
0
        public void UpdatePlayer(GameTime gameTime)
        {
            if (!IsBorn)
            {
                BornTime = gameTime.TotalGameTime;
                IsBorn   = true;
            }
            Age       = gameTime.TotalGameTime;
            DebugText = "Age: " + Age.Ticks + " Born: " + BornTime.Ticks;
            var time = BornTime.Add(new TimeSpan(0, 0, 3));

            if (Age > time)
            {
                IsDeadly = true;
            }
            Sprite.UpdateSprite(gameTime, CurrentPlayerDirection, GetType() != typeof(Enemy) || IsDeadly);

            SpritePosition.KeepSpriteOnScreen(Sprite, _graphicsDevice);

            _currentTimer = gameTime.TotalGameTime.TotalSeconds;

            _screenText.SetPosition((int)Sprite.Position.X, (int)Sprite.Position.Y - 50);
            if (JumpInProgress)
            {
                CheckIfStillJumping();
            }
        }
예제 #2
0
        public static ViewportCoordinates OffsetFor(this SpritePosition p, RenderType t)
        {
            ViewportCoordinates result;

            OffsetFor(p, t, out result);
            return(result);
        }
예제 #3
0
        public bool Tick()
        {
            var spriteAddress = 0xfe00 + 4 * _i;

            switch (_state)
            {
            case State.ReadingY:
                _spriteY = _oemRam.GetByte(spriteAddress);
                _state   = State.ReadingX;
                break;

            case State.ReadingX:
                _spriteX = _oemRam.GetByte(spriteAddress + 1);
                if (_spritePosIndex < _sprites.Length && Between(_spriteY, _registers.Get(GpuRegister.Ly) + 16,
                                                                 _spriteY + _lcdc.GetSpriteHeight()))
                {
                    _sprites[_spritePosIndex++] = new SpritePosition(_spriteX, _spriteY, spriteAddress);
                }

                _i++;
                _state = State.ReadingY;
                break;
            }

            return(_i < 40);
        }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     enemy          = this.GetComponent <Enemy>();
     myCharacter    = this.GetComponent <Character>();
     spritePosition = this.GetComponentInChildren <SpritePosition>();
     HP             = MaxHP;
     isBurning      = false;
 }
예제 #5
0
        public void MatchFound(SpritePosition pos, TRenderTile result, TContext context)
        {
            if (result == null)
            {
                throw new ArgumentNullException();
            }

            Renderer.Draw(result, context, pos, Screen);
        }
예제 #6
0
 void OnValidate()
 {
     if (spritePosition != currentSpritePosition)
     {
         currentSpritePosition = spritePosition;
         offsetIndex           = (int)spritePosition * 2;
         UpdateListeners();
     }
 }
예제 #7
0
        public static int SpritesheetMaximum(SpriteSheet spriteSheet, SpritePosition spritePosition)
        {
            switch (spritePosition)
            {
            case SpritePosition.Highest:
                int highestPixel = int.MaxValue;
                for (int i = 0; i < spriteSheet.textures.Length; i++)
                {
                    int textureHighestPixel = SpriteHighestPixel(spriteSheet.textures[i]);
                    if (textureHighestPixel < highestPixel)
                    {
                        highestPixel = textureHighestPixel;
                    }
                }
                return(highestPixel);

            case SpritePosition.Lowest:
                int lowestPixel = 0;
                for (int i = 0; i < spriteSheet.textures.Length; i++)
                {
                    int textureLowestPixel = SpriteLowestPixel(spriteSheet.textures[i]);
                    if (textureLowestPixel > lowestPixel)
                    {
                        lowestPixel = textureLowestPixel;
                    }
                }
                return(lowestPixel);

            case SpritePosition.Leftmost:
                int leftmostPixel = int.MaxValue;
                for (int i = 0; i < spriteSheet.textures.Length; i++)
                {
                    int textureLeftmostPixel = SpriteLeftmostPixel(spriteSheet.textures[i]);
                    if (textureLeftmostPixel < leftmostPixel)
                    {
                        leftmostPixel = textureLeftmostPixel;
                    }
                }
                return(leftmostPixel);

            case SpritePosition.Rightmost:
                int rightmostPixel = 0;
                for (int i = 0; i < spriteSheet.textures.Length; i++)
                {
                    int textureRightmostPixel = SpriteRightmostPixel(spriteSheet.textures[i]);
                    if (textureRightmostPixel > rightmostPixel)
                    {
                        rightmostPixel = textureRightmostPixel;
                    }
                }
                return(rightmostPixel);

            default: return(0);
            }
        }
예제 #8
0
        public static void OffsetFor(this SpritePosition p, RenderType t, out ViewportCoordinates result)
        {
            if (t.IsIsometric())
            {
                switch (p)
                {
                case SpritePosition.CellMap:
                    result = new ViewportCoordinates(0, 2);
                    break;

                case SpritePosition.Whole:
                    result = new ViewportCoordinates(0, 0);
                    break;

                case SpritePosition.Up:
                    result = new ViewportCoordinates(0, -1);
                    break;

                case SpritePosition.Right:
                    result = new ViewportCoordinates(1, 0);
                    break;

                case SpritePosition.Down:
                    result = new ViewportCoordinates(0, 1);
                    break;

                case SpritePosition.Left:
                    result = new ViewportCoordinates(-1, 0);
                    break;

                default:
                    result = new ViewportCoordinates(0, 0);
                    break;
                }
            }
            else
            {
                switch (p)
                {
                case SpritePosition.CellMap:
                    result = new ViewportCoordinates(2, -2);
                    break;

                case SpritePosition.Whole:
                    result = new ViewportCoordinates(0, 0);
                    break;

                case SpritePosition.Up:
                    result = new ViewportCoordinates(-1, -1);
                    break;

                case SpritePosition.Right:
                    result = new ViewportCoordinates(1, -1);
                    break;

                case SpritePosition.Down:
                    result = new ViewportCoordinates(1, 1);
                    break;

                case SpritePosition.Left:
                    result = new ViewportCoordinates(-1, 1);
                    break;

                default:
                    result = new ViewportCoordinates(0, 0);
                    break;
                }
            }
        }
예제 #9
0
 public RenderAtCall(TRenderTile tile, TContext context, SpritePosition pos)
 {
     this.tile    = tile;
     this.context = context;
     this.pos     = pos;
 }
예제 #10
0
 public MonsterRenderer(PkMnGame parent, int x, int y, int width, int height)
     : base(parent, x, y, width, height)
 {
     Position = SpritePosition.Hidden;
     Display  = SpriteDisplay.Normal;
 }