Exemplo n.º 1
0
        public EvilCow(World world, Vector2 initPos, Player player)
            : base(world, initPos, player)
        {
            this.setHealth(1200);
            mPlayer = player;
            mAnimationPlayer = new SpriteAnimationPlayer();
            mAnimationPlayer.SetAnimationToPlay(lightningCowAnimation);

            mFixture = FixtureFactory.AttachRectangle(90f * Camera.kPixelsToUnits, 90f * Camera.kPixelsToUnits, 1f, new Vector2(0, 0), new Body(mPhysicsWorld));
            mFixture.Body.BodyType = BodyType.Dynamic;
            mFixture.CollisionCategories = Category.Cat4;
            mFixture.CollidesWith = Category.All & ~Category.Cat3;
            mFixture.Body.OnCollision += monsterOnCollision;

            //Correct for meters vs pixels
            mFixture.Body.Position = new Vector2(mPosition.X, mPosition.Y);
            //mFixture.Body.UserData = "Monster";
            mFixture.Body.UserData = "Monster";
            mFixture.UserData = "Monster";

            //mTimeSinceCall = 10000; //so that they call upon spawning
            //mCallFrequency = 10000; //how often cow moos, in ms
            justSpawned = true;
            mMooVolume = .4f;
            mThunderVolume = .3f;

            //Init direction
            getNextDirection(mPlayer);

            /*
            //mBody = BodyFactory.CreateRectangle(mPhysicsWorld, 3f, 3f, .0125f);

            mFixture = FixtureFactory.AttachRectangle(3f, 3f, .0125f, new Vector2(0,0), new Body(mPhysicsWorld));
            mFixture.Body.BodyType = BodyType.Dynamic;
            mFixture.UserData = "EvilCow";
            mFixture.Body.UserData = "EvilCow";
            mFixture.CollisionCategories = Category.Cat3;
            mFixture.Body.OnCollision += monsterOnCollision;*/
        }
Exemplo n.º 2
0
        //this is never called. We need it for physics object
        public Soul(World world, Vector2 initPos)
            : base(world, initPos)
        {
            mSpriteAnimPlayer = new SpriteAnimationPlayer();
            mSpriteAnimPlayer.SetAnimationToPlay(mSoulAnimation);

            mFixture = FixtureFactory.AttachRectangle(30 * Camera.kPixelsToUnits, 30 * Camera.kPixelsToUnits,
                1f, // density
                kFrameSizeInPixels / 2 * Camera.kPixelsToUnits, // offset
                new Body(mPhysicsWorld));
            mFixture.Body.CollisionCategories = Category.Cat30;
            mFixture.Body.CollidesWith        = Category.All;// &~Category.Cat31;
            mFixture.CollisionCategories      = Category.Cat30;
            mFixture.CollidesWith             = Category.All;//& ~Category.Cat31;
            mFixture.Body.OnCollision        += soulOnCollision;
            mFixture.Body.BodyType            = BodyType.Static;

            mFixture.UserData      = "Soul";
            mFixture.Body.UserData = "Soul";

            mFixture.Body.Position = mPosition;
            mFloatie = 0;
        }
Exemplo n.º 3
0
        //this is never called. We need it for physics object
        //*/
        public Player(World world, Vector2 initPos)
            : base(world, initPos)
        {
            mRadius = 1f;

            //mBody = BodyFactory.CreateRectangle(mPhysicsWorld, 1f, 1f, 1f);
               // mBody.BodyType = BodyType.Dynamic;

            mFixture = FixtureFactory.AttachRectangle(30 * Camera.kPixelsToUnits, 50 * Camera.kPixelsToUnits, 1f, new Vector2(0f, 0f), new Body(mPhysicsWorld));
            mFixture.Body.CollisionCategories = Category.Cat1;
            mFixture.Body.CollidesWith        = Category.All & ~Category.Cat1 & ~Category.Cat2;
            mFixture.CollisionCategories      = Category.Cat1;
            mFixture.CollidesWith             = Category.All & ~Category.Cat1 & ~Category.Cat2;
            mFixture.Body.OnCollision        += playerOnCollision;
            mFixture.Body.BodyType            = BodyType.Dynamic;

            mFixture.UserData      = "Player";
            mFixture.Body.UserData = "Player";
            //mBody.UserData = "Player";

            mSpriteAnimPlayer = new SpriteAnimationPlayer();
            mSpriteAnimPlayer.SetAnimationToPlay(mBlinkingAnimation);
        }
Exemplo n.º 4
0
 protected void HandleStun(GameTime gameTime, SpriteAnimationPlayer player, SpriteAnimation normal, SpriteAnimation pain)
 {
     if (mStunTimeout > 0)
     {
         mStunTimeout -= (float)gameTime.ElapsedGameTime.TotalSeconds;
         if (player.GetAnimationToPlay() != pain)
         {
             player.SetAnimationToPlay(pain);
         }
     }
     else
     {
         if (player.GetAnimationToPlay() != normal)
         {
             player.SetAnimationToPlay(normal);
         }
     }
 }