Ejemplo n.º 1
0
 public static SideType FromFacing(SpriteState.HorizontalFacing horizontalFacing,
     SpriteState.VerticalFacing verticalFacing)
 {
     if (verticalFacing == SpriteState.VerticalFacing.Up)
     {
         return SideType.TopSide;
     }
     if (verticalFacing == SpriteState.VerticalFacing.Down)
     {
         return SideType.BottomSide;
     }
     if (horizontalFacing == SpriteState.HorizontalFacing.Left)
     {
         return SideType.LeftSide;
     }
     return SideType.RightSide;
 }
Ejemplo n.º 2
0
        public void InitializeSprite(ContentManager Content, SpriteState spriteState)
        {
            TileUnit tileY = spriteState.horizontalFacing == SpriteState.HorizontalFacing.Left ?
                Convert.ToUInt32(CharacterFrame) : Convert.ToUInt32(1 + CharacterFrame);

            TileUnit tileX = 0;
            switch (spriteState.motionType)
            {
                case SpriteState.MotionType.Walking:
                    tileX = Convert.ToUInt32(WalkFrame);
                    break;
                case SpriteState.MotionType.Standing:
                    tileX = Convert.ToUInt32(StandFrame);
                    break;
                case SpriteState.MotionType.Interacting:
                    tileX = Convert.ToUInt32(BackFrame);
                    break;
                case SpriteState.MotionType.Jumping:
                    tileX = Convert.ToUInt32(JumpFrame);
                    break;
                case SpriteState.MotionType.Falling:
                    tileX = Convert.ToUInt32(FallFrame);
                    break;
                case SpriteState.MotionType.LastMotionType:
                    break;
            }

            switch (spriteState.verticalFacing)
            {
                case SpriteState.VerticalFacing.Horizontal:
                    break;
                case SpriteState.VerticalFacing.Up:
                    tileX += Convert.ToUInt32(UpFrameOffset);
                    break;
                case SpriteState.VerticalFacing.Down:
                    tileX = Convert.ToUInt32(DownFrame);
                    break;
                default:
                    break;
            }

            if (spriteState.motionType == SpriteState.MotionType.Walking)
            {
                switch (spriteState.strideType)
                {
                    case SpriteState.StrideType.StrideMiddle:
                        break;
                    case SpriteState.StrideType.StrideLeft:
                        tileX += 1;
                        break;
                    case SpriteState.StrideType.StrideRight:
                        tileX += 2;
                        break;
                    default:
                        break;
                }
                sprites.Add(spriteState, new Sprite(Content, SpriteFilePath,
                    Units.TileToPixel(tileX), Units.TileToPixel(tileY),
                    Units.TileToPixel(1), Units.TileToPixel(1)));
            }
            else
            {
                sprites.Add(spriteState, new Sprite(Content, SpriteFilePath,
                    Units.TileToPixel(tileX), Units.TileToPixel(tileY),
                    Units.TileToPixel(1), Units.TileToPixel(1)));
            }
        }
Ejemplo n.º 3
0
 public Projectile(Sprite sprite,
     SpriteState.HorizontalFacing horizontalDirection, SpriteState.VerticalFacing verticalDirection,
     GameUnit x, GameUnit y,
     GunLevelUnit gunLevel, ParticleTools particleTools)
 {
     this.sprite = sprite;
     this.horizontalDirection = horizontalDirection;
     this.verticalDirection = verticalDirection;
     this.x = x;
     this.y = y;
     this.gunLevel = gunLevel;
     offset = 0;
     alive = true;
     particleTools.FrontSystem.AddNewParticle(ProjectileStarParticle.Create(particleTools.Content, x, y));
 }
Ejemplo n.º 4
0
 private GameUnit GunY(SpriteState.VerticalFacing verticalFacing, bool gunUp, GameUnit playerY)
 {
     GameUnit gunY = playerY;
     if (verticalFacing == SpriteState.VerticalFacing.Up)
     {
         gunY -= Units.HalfTile / 2;
     }
     else if (verticalFacing == SpriteState.VerticalFacing.Down)
     {
         gunY += Units.HalfTile / 2;
     }
     if (gunUp)
     {
         gunY -= 2;
     }
     return gunY;
 }
Ejemplo n.º 5
0
 private GameUnit GunX(SpriteState.HorizontalFacing horizontalFacing, GameUnit playerX)
 {
     if (horizontalFacing == SpriteState.HorizontalFacing.Left)
     {
         return playerX - Units.HalfTile;
     }
     else
     {
         return playerX;
     }
 }
Ejemplo n.º 6
0
        public void StartFire(GameUnit playerX, GameUnit playerY,
            SpriteState.HorizontalFacing horizontalFacing,
            SpriteState.VerticalFacing verticalFacing,
            bool gunUp, ParticleTools particleTools)
        {
            if (projectileA != null && projectileB != null)
            {
                return;
            }
            GameUnit bulletX = GunX(horizontalFacing, playerX) - Units.HalfTile;
            GameUnit bulletY = GunY(verticalFacing, gunUp, playerY) - Units.HalfTile;
            switch (verticalFacing)
            {
                case SpriteState.VerticalFacing.Horizontal:
                    bulletY += NozzleHorizontalY;
                    if (horizontalFacing == SpriteState.HorizontalFacing.Left)
                    {
                        bulletX += NozzleHorizontalLeftX;
                    }
                    else
                    {
                        bulletX += NozzleHorizontalRightX;
                    }
                    break;
                case SpriteState.VerticalFacing.Up:
                    bulletY += NozzleUpY;
                    if (horizontalFacing == SpriteState.HorizontalFacing.Left)
                    {
                        bulletX += NozzleUpLeftX;
                    }
                    else
                    {
                        bulletX += NozzleUpRightX;
                    }
                    break;
                case SpriteState.VerticalFacing.Down:
                    bulletY += NozzleDownY;
                    if (horizontalFacing == SpriteState.HorizontalFacing.Left)
                    {
                        bulletX += NozzleDownLeftX;
                    }
                    else
                    {
                        bulletX += NozzleDownRightX;
                    }
                    break;
                default:
                    break;
            }

            if (projectileA == null)
            {
                projectileA = new Projectile(verticalFacing == SpriteState.VerticalFacing.Horizontal ?
                    horizontalProjectiles[CurrentLevel - 1] :
                    verticalProjectiles[CurrentLevel - 1],
                    horizontalFacing, verticalFacing, bulletX, bulletY, CurrentLevel, particleTools);
            }
            else if (projectileB == null)
            {
                projectileB = new Projectile(verticalFacing == SpriteState.VerticalFacing.Horizontal ?
                    horizontalProjectiles[CurrentLevel - 1] :
                    verticalProjectiles[CurrentLevel - 1],
                    horizontalFacing, verticalFacing, bulletX, bulletY, CurrentLevel, particleTools);
            }
        }
Ejemplo n.º 7
0
        public void Draw(SpriteBatch spriteBatch,
            SpriteState.HorizontalFacing horizontalFacing, SpriteState.VerticalFacing verticalFacing,
            bool gunUp,
            GameUnit playerX, GameUnit playerY)
        {
            GameUnit x = GunX(horizontalFacing, playerX);
            GameUnit y = GunY(verticalFacing, gunUp, playerY);

            sprites[new PolarStarSpriteState(new Tuple<SpriteState.HorizontalFacing, SpriteState.VerticalFacing>(
                horizontalFacing, verticalFacing))].Draw(spriteBatch, x, y);
            if (projectileA != null)
            {
                projectileA.Draw(spriteBatch);
            }
            if (projectileB != null)
            {
                projectileB.Draw(spriteBatch);
            }
        }
Ejemplo n.º 8
0
        public void InitializeSprite(ContentManager Content, SpriteState spriteState)
        {
            TileUnit tileY = spriteState.horizontalFacing == SpriteState.HorizontalFacing.Left ?
                             Convert.ToUInt32(CharacterFrame) : Convert.ToUInt32(1 + CharacterFrame);

            TileUnit tileX = 0;

            switch (spriteState.motionType)
            {
            case SpriteState.MotionType.Walking:
                tileX = Convert.ToUInt32(WalkFrame);
                break;

            case SpriteState.MotionType.Standing:
                tileX = Convert.ToUInt32(StandFrame);
                break;

            case SpriteState.MotionType.Interacting:
                tileX = Convert.ToUInt32(BackFrame);
                break;

            case SpriteState.MotionType.Jumping:
                tileX = Convert.ToUInt32(JumpFrame);
                break;

            case SpriteState.MotionType.Falling:
                tileX = Convert.ToUInt32(FallFrame);
                break;

            case SpriteState.MotionType.LastMotionType:
                break;
            }

            switch (spriteState.verticalFacing)
            {
            case SpriteState.VerticalFacing.Horizontal:
                break;

            case SpriteState.VerticalFacing.Up:
                tileX += Convert.ToUInt32(UpFrameOffset);
                break;

            case SpriteState.VerticalFacing.Down:
                tileX = Convert.ToUInt32(DownFrame);
                break;

            default:
                break;
            }

            if (spriteState.motionType == SpriteState.MotionType.Walking)
            {
                switch (spriteState.strideType)
                {
                case SpriteState.StrideType.StrideMiddle:
                    break;

                case SpriteState.StrideType.StrideLeft:
                    tileX += 1;
                    break;

                case SpriteState.StrideType.StrideRight:
                    tileX += 2;
                    break;

                default:
                    break;
                }
                sprites.Add(spriteState, new Sprite(Content, SpriteFilePath,
                                                    Units.TileToPixel(tileX), Units.TileToPixel(tileY),
                                                    Units.TileToPixel(1), Units.TileToPixel(1)));
            }
            else
            {
                sprites.Add(spriteState, new Sprite(Content, SpriteFilePath,
                                                    Units.TileToPixel(tileX), Units.TileToPixel(tileY),
                                                    Units.TileToPixel(1), Units.TileToPixel(1)));
            }
        }