Exemplo n.º 1
0
 public Archer(ContentManager content)
 {
     texture           = content.Load <Texture2D>("Player\\player");
     position.X        = 0;
     position.Y        = SCREEN_HEIGHT - texture.Height;
     collidable        = new CollidableObject(texture, position, 0.0f);
     collidable.Origin = new Vector2(0, 0);
 } // Archer constructor
Exemplo n.º 2
0
 public ArcheryTarget(ContentManager content)
 {
     texture           = content.Load <Texture2D>("bullsEye");
     position          = new Vector2(SCREEN_WIDTH - texture.Width, 0);
     collidable        = new CollidableObject(texture, position, 0.0f);
     collidable.Origin = new Vector2(0, 0);
     moveVelocity      = MOVE_SPEED;
 } // constructor
Exemplo n.º 3
0
        public bool IsColliding(CollidableObject collidable)
        {
            bool retval = false;

            if (this.BoundingRectangle.Intersects(collidable.BoundingRectangle))
            {
                if (IntersectPixels(this.Transform, this.Texture.Width, this.Texture.Height, this.TextureData, collidable.Transform, collidable.Texture.Width, collidable.Texture.Height, collidable.TextureData))
                {
                    retval = true;
                }
            }

            return(retval);
        }
Exemplo n.º 4
0
 public Arrow(ContentManager content, float x, float y)
 {
     changeY    = 0;
     docked     = true;
     inAir      = true;
     isOnTarget = false;
     texture    = content.Load <Texture2D>("Player\\arrow");
     Position.X = x;
     Position.Y = y;
     Origin.X   = 2;
     Origin.Y   = 2;
     rotation   = 0;
     Collidable = new CollidableObject(texture, Position, rotation);
     Collidable.LoadTexture(texture, Origin);
     beenshot      = false;
     stopxveloc    = false;
     archerytarget = new ArcheryTarget(content);
 }
Exemplo n.º 5
0
        public Menu(ContentManager content)
        {
            xPos   = 410;
            archer = content.Load <Texture2D>("Menu\\archer");
            target = content.Load <Texture2D>("Menu\\target");
            bear   = content.Load <Texture2D>("Menu\\bear");
            exit   = content.Load <Texture2D>("Menu\\exit");

            archerbox = new Rectangle();
            targetbox = new Rectangle();
            bearbox   = new Rectangle();
            exitbox   = new Rectangle();

            archerbox.X = xPos;
            targetbox.X = xPos;
            bearbox.X   = xPos;
            exitbox.X   = xPos;

            archerbox.Y = ORIGARCHPOS;
            targetbox.Y = ORIGARCHPOS + 180;
            bearbox.Y   = ORIGARCHPOS + 180 + 80;
            exitbox.Y   = ORIGARCHPOS + 180 + 80 + 80;

            archerbox.Width  = archer.Width;
            archerbox.Height = archer.Height;

            targetbox.Width  = target.Width;
            targetbox.Height = target.Height;

            bearbox.Width  = bear.Width;
            bearbox.Height = bear.Height;

            exitbox.Width        = exit.Width;
            exitbox.Height       = exit.Height;
            archerCollide        = new CollidableObject(archer, new Vector2(archerbox.X, archerbox.Y));
            targetCollide        = new CollidableObject(target, new Vector2(targetbox.X, targetbox.Y));
            bearCollide          = new CollidableObject(bear, new Vector2(bearbox.X, bearbox.Y));
            exitCollide          = new CollidableObject(exit, new Vector2(exitbox.X, exitbox.Y));
            archerCollide.Origin = new Vector2(0, 0);
            targetCollide.Origin = new Vector2(0, 0);
            bearCollide.Origin   = new Vector2(0, 0);
            exitCollide.Origin   = new Vector2(0, 0);
        }
Exemplo n.º 6
0
 public Nyan(ContentManager content)
 {
     rand              = new Random();
     elapsed           = 0;
     randlapsed        = 0f;
     deadlapsed        = 0f;
     isDead            = false;
     nyan1             = content.Load <Texture2D>("Nyan\\nyan1");
     nyan2             = content.Load <Texture2D>("Nyan\\nyan2");
     nyanDead          = content.Load <Texture2D>("Nyan\\nyandead");
     texture           = nyan1;
     position.X        = -300;
     position.Y        = 3;
     angle             = 0;
     Collidable        = new CollidableObject(texture, position);
     nyanSongIsPlaying = false;
     meowHasPlayed     = false;
     thudHasPlayed     = false;
 }
Exemplo n.º 7
0
        } // Draw

        public void HandleCollisions()
        {
            nyanCollide = nyancat.getCollidableObject();
            bool resetarrows = false;

            foreach (Arrow arrow in bow.getArrows())
            {
                if (!arrow.isinAir && arrow.isonTarget())
                {
                    arrow.changeArcheryTargetPosY(archeryTarget.getPosition().Y);
                }

                if (arrow.isinAir == true)
                {
                    if (arrow.getCollidableObject().IsColliding(nyanCollide))
                    {
                        nyancat.isdead();
                    }

                    switch (gameState)
                    {
                    case GameState.Target:

                        if (arrow.getCollidableObject().IsColliding(archeryTarget.getCollidable()))
                        {
                            arrow.isinAir  = false;
                            arrow.velocity = new Vector2(0, 0);
                            arrow.onTarget(Math.Abs(arrow.position.Y - archeryTarget.getPosition().Y), archeryTarget, Content);
                            targetModeScore += 50;
                        }

                        if (arrow.position.Y < 10 && arrow.position.X < 100)
                        {
                            resetarrows = true;
                            gameState   = GameState.Menu;
                        }
                        break;

                    case GameState.Bear:
                        foreach (Bear bear in bearMode.getBears())
                        {
                            if (!bear.isDead)
                            {
                                if (!arrow.isDocked() && arrow.getCollidableObject().IsColliding(bear.getCollidable()))
                                {
                                    bear.isDead           = true;
                                    bearMode.bearsKilled += 1;
                                    arrow.stopXVeloc();
                                }

                                if (player.getCollidable().IsColliding(bear.getCollidable()))
                                {
                                    resetarrows = true;
                                    gameState   = GameState.GameOver;
                                }
                            }
                        }
                        break;

                    case GameState.Menu:

                        if (arrow.getCollidableObject().IsColliding(menuObjects[0]))     // "Archer" logo
                        {
                            arrow.isinAir = false;
                        }
                        if (arrow.getCollidableObject().IsColliding(menuObjects[1]))     // "Target" logo
                        {
                            arrow.isinAir = false;
                            resetarrows   = true;
                            gameState     = GameState.Target;
                            break;
                        }
                        if (arrow.getCollidableObject().IsColliding(menuObjects[2]))     // "Bear" logo
                        {
                            arrow.isinAir = false;
                            resetarrows   = true;
                            gameState     = GameState.Bear;
                            bearMode.reset();
                            break;
                        }
                        if (arrow.getCollidableObject().IsColliding(menuObjects[3]))      // "Exit" logo
                        {
                            this.Exit();
                        }

                        if (arrow.position.Y < 10 && arrow.position.X < 100 && !LoggedIn)              // "Login" logo
                        {
                            resetarrows = true;
                            gameState   = GameState.Login;
                        }

                        break;
                    } // switch statement
                }     // if isInAir
            }         // foreach arrow

            if (resetarrows)
            {
                bow.resetArrows(Content);
            }
        } // HandleCollisions
Exemplo n.º 8
0
        } // handleRandJump

        public CollidableObject getCollidable()
        {
            CollidableObject collidable;
            Texture2D        theTexture;

            #region assignTexture
            switch (bearState)
            {
            case BearState.Walking:

                switch (walkingAnime.currFrame)
                {
                case 0:
                    theTexture = bearWalk1;
                    break;

                case 1:
                    theTexture = bearWalk2;
                    break;

                case 2:
                    theTexture = bearWalk3;
                    break;

                case 3:
                    theTexture = bearWalk4;
                    break;

                default: theTexture = bearWalk1;
                    break;
                }
                break;

            case BearState.Rolling:
                switch (rollingAnime.currFrame)
                {
                case 0:
                    theTexture = bearRoll1;
                    break;

                case 1:
                    theTexture = bearRoll2;
                    break;

                case 2:
                    theTexture = bearRoll3;
                    break;

                case 3:
                    theTexture = bearRoll4;
                    break;

                default:
                    theTexture = bearRoll1;
                    break;
                }
                break;

            case BearState.Jumping:
                switch (jumpingAnime.currFrame)
                {
                case 0:
                    theTexture = bearJump1;
                    break;

                case 1:
                    theTexture = bearJump2;
                    break;

                default: theTexture = bearJump1;
                    break;
                }
                break;

            default: theTexture = bearWalk1;
                break;
            }
            #endregion

            collidable = new CollidableObject(theTexture, position);
            collidable.LoadTexture(theTexture);
            collidable.Origin = new Vector2(0, 0);
            return(collidable);
        }