コード例 #1
0
ファイル: Actor.cs プロジェクト: tmerge/RescueDog
        public Type type;   //represents which type of actor this actor is


        public Actor(GameScreen GameScreen, Vector2 Position, Type Type)
        {
            gameScreen = GameScreen;
            type       = Type;
            //create default actor values
            Point Cellsize     = new Point(0, 0);
            Point CurrentFrame = new Point(0, 0);
            Point FrameOffset  = new Point(0, 0);

            collisionRec     = new Rectangle(0, 0, 0, 0);
            collisionOffset  = new Point(0, 0);
            collisionPrevPos = new Point(0, 0);
            collisionNewPos  = new Point(0, 0);
            //create new animation lists
            idleStill        = new List <Point>();
            idleAnimation1   = new List <Point>();
            idleAnimation2   = new List <Point>();
            idleAnimation3   = new List <Point>();
            movingFrames     = new List <Point>();
            landingFrames    = new List <Point>();
            actionFrames     = new List <Point>();
            currentAnimation = new List <Point>();
            //create default sprite
            sprite              = new Sprite(gameScreen.screenManager, gameScreen.screenManager.game.spriteSheet, Position, Cellsize, CurrentFrame);
            movementSpeed       = 0.0f;
            sprite.spriteEffect = SpriteEffects.None;
            animationState      = State.Idle;
            inputState          = State.Idle;
            stateLocked         = false;
            currentAnimation    = idleStill;
            targetPosition      = new Vector2(Position.X, Position.Y);


            #region Define Dog

            if (Type == Type.Dog)
            {
                sprite.cellSize.X     = 32 * 1; sprite.cellSize.Y = 32 * 1;
                sprite.currentFrame.X = 0; sprite.currentFrame.Y = 2;
                sprite.CenterOrigin();
                sprite.zOffset = 0;

                collisionRec.Width = 30; collisionRec.Height = 5;
                collisionOffset.X  = 1; collisionOffset.Y = 12;

                //static idle animation
                idleStill.Add(new Point(0, 2));

                //idle animation 1
                idleAnimation1.Add(new Point(3, 3)); //tail wagging
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(4, 3));
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(3, 3)); //repeat
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(4, 3));
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(3, 3)); //repeat
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(4, 3));
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(3, 3)); //repeat
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(4, 3));
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(3, 3)); //repeat
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(4, 3));
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(3, 3)); //repeat
                idleAnimation1.Add(new Point(0, 2));
                idleAnimation1.Add(new Point(4, 3));
                idleAnimation1.Add(new Point(0, 2));

                //idle animation 2
                idleAnimation2.Add(new Point(5, 3)); //blink
                idleAnimation2.Add(new Point(6, 3)); //hold eyes closed
                idleAnimation2.Add(new Point(6, 3));
                idleAnimation2.Add(new Point(6, 3));
                idleAnimation2.Add(new Point(5, 3)); //open

                //idle animation 3
                idleAnimation3.Add(new Point(7, 2)); //lower head
                idleAnimation3.Add(new Point(6, 2));
                idleAnimation3.Add(new Point(5, 2)); //head down, tail wagging
                idleAnimation3.Add(new Point(7, 3));
                idleAnimation3.Add(new Point(5, 2)); //repeat
                idleAnimation3.Add(new Point(7, 3));
                idleAnimation3.Add(new Point(5, 2)); //repeat
                idleAnimation3.Add(new Point(7, 3));
                idleAnimation3.Add(new Point(5, 2)); //repeat
                idleAnimation3.Add(new Point(7, 3));
                idleAnimation3.Add(new Point(5, 2)); //repeat
                idleAnimation3.Add(new Point(7, 3));
                idleAnimation3.Add(new Point(6, 2)); //head up
                idleAnimation3.Add(new Point(7, 2));

                //setup walking animations
                movingFrames.Add(new Point(1, 2));
                movingFrames.Add(new Point(2, 2));
                movingFrames.Add(new Point(3, 2));
                movingFrames.Add(new Point(4, 2));
                movingFrames.Add(new Point(5, 2));

                //setup landing animations
                landingFrames.Add(new Point(6, 2));
                landingFrames.Add(new Point(7, 2));

                //setup action animations
                actionFrames.Add(new Point(0, 3));
                actionFrames.Add(new Point(1, 3));
                actionFrames.Add(new Point(2, 3));

                actionSoundFX = gameScreen.screenManager.game.soundManager.dogBarkIns;
            }

            #endregion


            #region Define Human

            else if (Type == Type.Human)
            {
                sprite.cellSize.X     = 32 * 1; sprite.cellSize.Y = 32 * 2;
                sprite.currentFrame.X = 0; sprite.currentFrame.Y = 2;
                sprite.CenterOrigin();
                sprite.zOffset = 32 + 0;

                collisionRec.Width = 22; collisionRec.Height = 5;
                collisionOffset.X  = 0; collisionOffset.Y = 40;

                //static idle animation
                idleStill.Add(new Point(0, 2));

                //idle animations 1, 2, 3
                idleAnimation1.Add(new Point(0, 2)); //blink
                idleAnimation1.Add(new Point(1, 2));
                idleAnimation1.Add(new Point(2, 2));
                idleAnimation1.Add(new Point(2, 2));
                idleAnimation1.Add(new Point(2, 2));
                idleAnimation1.Add(new Point(1, 2));
                idleAnimation2 = idleAnimation1;
                idleAnimation3 = idleStill;

                //setup walking animations
                movingFrames.Add(new Point(0, 3));
                movingFrames.Add(new Point(1, 3));
                movingFrames.Add(new Point(2, 3));
                movingFrames.Add(new Point(3, 3));
                movingFrames.Add(new Point(4, 3));
                movingFrames.Add(new Point(5, 3));
                movingFrames.Add(new Point(6, 3));
                movingFrames.Add(new Point(7, 3));

                //setup landing animations
                landingFrames.Add(new Point(0, 2));

                //setup death animations
                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(4, 2));
                actionFrames.Add(new Point(4, 2));

                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(4, 2));
                actionFrames.Add(new Point(4, 2));

                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(4, 2));
                actionFrames.Add(new Point(4, 2));

                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(3, 2));
                actionFrames.Add(new Point(4, 2));
                actionFrames.Add(new Point(4, 2));
                actionFrames.Add(new Point(5, 2));
                actionFrames.Add(new Point(5, 2));
                actionFrames.Add(new Point(6, 2));
                actionFrames.Add(new Point(7, 2));

                actionSoundFX = gameScreen.screenManager.game.soundManager.humanBitIns;
            }

            #endregion


            #region Define Spider

            else if (Type == Type.Spider)
            {
                sprite.cellSize.X     = 16 * 1; sprite.cellSize.Y = 16 * 1;
                sprite.currentFrame.X = 11; sprite.currentFrame.Y = 2;
                sprite.CenterOrigin();
                sprite.zOffset = 0;

                collisionRec.Width = 16; collisionRec.Height = 8;
                collisionOffset.X  = 1; collisionOffset.Y = 0;

                //static idle animation
                idleStill.Add(new Point(11, 2));
                idleAnimation1 = idleStill;
                idleAnimation2 = idleStill;
                idleAnimation3 = idleStill;

                //this causes the spider to rest after an attack
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));
                landingFrames.Add(new Point(11, 2));

                //moving animation
                movingFrames.Add(new Point(10, 2));
                movingFrames.Add(new Point(11, 2));
                movingFrames.Add(new Point(12, 2));
                movingFrames.Add(new Point(11, 2));

                actionFrames.Add(new Point(13, 2)); //jumping in air
                actionFrames.Add(new Point(13, 2));

                actionSoundFX = gameScreen.screenManager.game.soundManager.spiderJumpIns;
            }

            #endregion
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: tmerge/RescueDog
 public GameManager(GameScreen GameScreen)
 {
     gameScreen = GameScreen;
 }
コード例 #3
0
        public Wall(GameScreen GameScreen, Vector2 Position, WallType Type)
        {
            gameScreen = GameScreen;
            Point   Cellsize       = new Point(0, 0);
            Point   CurrentFrame   = new Point(0, 0);
            Point   FrameOffset    = new Point(0, 0);
            Boolean flipHorizontal = false;

            type = Type;

            //set the cellsize + currentframe based on wall type
            if (Type == WallType.North)
            {
                Cellsize.X = 16 * 2; Cellsize.Y = 16 * 3; CurrentFrame.X = 2; CurrentFrame.Y = 0;
            }
            if (Type == WallType.South)
            {
                Cellsize.X = 16 * 2; Cellsize.Y = 16 * 1; CurrentFrame.X = 2; CurrentFrame.Y = 3;
            }
            if (Type == WallType.NorthShort)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 3; CurrentFrame.X = 4; CurrentFrame.Y = 0;
            }
            if (Type == WallType.SouthShort)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 1; CurrentFrame.X = 4; CurrentFrame.Y = 3;
            }

            if (Type == WallType.East)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 2; CurrentFrame.X = 6; CurrentFrame.Y = 0; FrameOffset.Y = 16;
            }
            if (Type == WallType.West)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 2; CurrentFrame.X = 6; CurrentFrame.Y = 0; FrameOffset.Y = 16; flipHorizontal = true;
            }

            if (Type == WallType.InteriorNE)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 2; CurrentFrame.X = 6; CurrentFrame.Y = 0;
            }
            if (Type == WallType.InteriorNW)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 2; CurrentFrame.X = 6; CurrentFrame.Y = 0; flipHorizontal = true;
            }
            if (Type == WallType.InteriorSE)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 1; CurrentFrame.X = 6; CurrentFrame.Y = 3;
            }
            if (Type == WallType.InteriorSW)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 1; CurrentFrame.X = 6; CurrentFrame.Y = 3; flipHorizontal = true;
            }

            if (Type == WallType.ExteriorNE)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 3; CurrentFrame.X = 3; CurrentFrame.Y = 0;
            }
            if (Type == WallType.ExteriorNW)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 3; CurrentFrame.X = 3; CurrentFrame.Y = 0; flipHorizontal = true;
            }
            if (Type == WallType.ExteriorSE)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 1; CurrentFrame.X = 3; CurrentFrame.Y = 3;
            }
            if (Type == WallType.ExteriorSW)
            {
                Cellsize.X = 16 * 1; Cellsize.Y = 16 * 1; CurrentFrame.X = 3; CurrentFrame.Y = 3; flipHorizontal = true;
            }

            sprite             = new Sprite(gameScreen.screenManager, gameScreen.screenManager.game.spriteSheet, Position, Cellsize, CurrentFrame);
            sprite.frameOffset = FrameOffset;
            if (flipHorizontal)
            {
                sprite.spriteEffect = SpriteEffects.FlipHorizontally;
            }

            collisionRec    = new Rectangle((int)Position.X, (int)Position.Y, Cellsize.X, Cellsize.Y);
            collisionOffset = new Point(0, 0);
        }