Beispiel #1
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);
 }
Beispiel #2
0
        public void update(GameTime gametime, SoundBank soundbank)
        {
            angle += ANGLE;

            elapsed    += (float)gametime.ElapsedGameTime.TotalSeconds;
            randlapsed += (float)gametime.ElapsedGameTime.TotalSeconds;

            if (!nyanSongIsPlaying && ismoving)
            {
                NyanSong = soundbank.GetCue("Nyan Cat");
                NyanSong.Play();
                nyanSongIsPlaying = true;
            }

            // handle animation
            if (!isDead)
            {
                if (elapsed > .25f && texture == nyan1)
                {
                    texture = nyan2;
                    Collidable.LoadTexture(texture);
                }
                else if (elapsed > .5f && texture == nyan2)
                {
                    texture = nyan1;
                    Collidable.LoadTexture(texture);
                    elapsed = 0;
                }
            }
            else
            {
                texture = nyanDead;
                elapsed = 0;
            }

            // end animation handling

            // if angle is greater than pi * 2, reset to zero. 2PI == 0 DUHH NOOOB
            if (angle >= Math.PI * 2)
            {
                angle = 0;
            }

            if (!isDead) // if nyancat is dead, dont bother handling his random appearance. he can't appear if HES DEAD
            {
                handleWhenonScreen();
                position.Y += (float)Math.Sin(angle) * 3;
            }
            else // handles when falling after shot.
            {
                NyanSong.Stop(AudioStopOptions.AsAuthored);

                if (deadlapsed < 2.0f)
                {
                    deadlapsed += (float)gametime.ElapsedGameTime.TotalSeconds;
                }
                if (!meowHasPlayed)
                {
                    soundbank.PlayCue("meow");
                    meowHasPlayed = true;
                }

                ismoving = false;
                if (position.Y < SCREEN_HEIGHT - (texture.Height))
                {
                    position.Y += 30f;
                }
                else
                {
                    position.Y = SCREEN_HEIGHT - texture.Height;
                    if (!thudHasPlayed)
                    {
                        soundbank.PlayCue("thud");
                        thudHasPlayed = true;
                    }
                }
            }

            Collidable.Position = this.position; // sets bounding box to same position as where nyancat is being drawn.
        } // update
Beispiel #3
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);
        }