public MonsterSpawner(World world, Vector2 initPos, Player player)
            : base(world, initPos)
        {
            mPhysicsWorld = world;
            mMonsters = new List<Monster>();

            mPlayer = player;
            nextBasic = mRand.Next(1, 3);
            nextCow = mRand.Next(3, 10);
        }
Exemplo n.º 2
0
        public Monster(World world, Vector2 initPos, Player player)
            : base(world, initPos)
        {
            mRadius = 1;
               // setRandDirection();
            //Body = BodyFactory.CreateRectangle(mPhysicsWorld, 1f, 1f, .0125f);
            //mBody.BodyType = BodyType.Dynamic;

            //reference to the player
            mPlayer = player;

            // hit points
            //mHealth = 3;

            mMonMonCollVolume = .01f;

            mStunTimeout = 0;
        }
Exemplo n.º 3
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.º 4
0
        private void getNextDirection(Player mPlayer)
        {
            int randomnum = cowRand.Next(1, 100);

            if (randomnum <= 20)
            {
                cowDirection = DIRECTION.NONE;
            }

            else
            {
                Vector2 playerPos = mPlayer.GetPosition();
                float xDifference = Math.Abs((playerPos.X - mFixture.Body.Position.X));
                float yDifference = Math.Abs((playerPos.Y - mFixture.Body.Position.Y));

                if (randomnum > 20 && randomnum <= 90)
                {
                    if (xDifference >= yDifference)
                    {
                        if (playerPos.X < mFixture.Body.Position.X)
                        {
                            cowDirection = DIRECTION.LEFT;
                        }

                        else
                        {
                            cowDirection = DIRECTION.RIGHT;
                        }

                    }

                    else
                    {

                        if (playerPos.Y < mFixture.Body.Position.Y)
                        {
                            cowDirection = DIRECTION.DOWN;
                        }

                        else
                        {
                            cowDirection = DIRECTION.UP;
                        }

                    }

                }

                else
                {

                    if (xDifference >= yDifference)
                    {

                        if (playerPos.X > mFixture.Body.Position.X)
                        {
                            cowDirection = DIRECTION.RIGHT;
                        }

                        else
                        {
                            cowDirection = DIRECTION.LEFT;
                        }

                    }

                    if (yDifference > xDifference)
                    {

                        if (playerPos.Y > mFixture.Body.Position.Y)
                        {
                            cowDirection = DIRECTION.UP;
                        }

                        else
                        {
                            cowDirection = DIRECTION.DOWN;
                        }

                    }

                }

            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            mSpriteBatch = new SpriteBatch(GraphicsDevice);
            drawFont = Content.Load<SpriteFont>("drawFont");

            mLifeWorld.LoadContent(mGraphics.GraphicsDevice, Content);
            mDeathWorld.LoadContent(mGraphics.GraphicsDevice, Content);

            Player.LoadData(this);
            DeadPlayer.LoadData(this);
            MonsterSpawner.LoadData(this);
            Monster.LoadData(this);
            Snake.LoadData(this);
            EvilCow.LoadData(this);
            SwordSlash.LoadData(this);
            Grave.LoadData(this);
            Soul.LoadData(this);

            mLifeWorld.loadTiles(this);

            mLifeWorld.AddGameObject(mAlivePlayer = new AlivePlayer(mLifeWorld.mPhysicsWorld, new Vector2(0, 0)));
            mLifeWorld.mPlayer = mAlivePlayer;
            mDeathWorld.AddGameObject(mDeadPlayer = new DeadPlayer(mDeathWorld.mPhysicsWorld, new Vector2(0, 0)));
            mDeathWorld.mPlayer = mDeadPlayer;

            mDeathTheme = Content.Load<SoundEffect>("Audio/DeathTheme");
            mDeathThemeSEI = mDeathTheme.CreateInstance();
            mDeathThemeSEI.IsLooped = true;
            mDeathThemeSEI.Volume = 1;

            mPlayerFallSnd = Content.Load<SoundEffect>("Audio/playerFall");
            mGongSnd = Content.Load<SoundEffect>("Audio/gong");

            mLifeTheme = Content.Load<SoundEffect>("Audio/LifeTheme");
            mLifeThemeSEI = mLifeTheme.CreateInstance();
            mLifeThemeSEI.IsLooped = true;
            mLifeThemeSEI.Volume = 1;
            mLifeThemeSEI.Play();

            mClock = Content.Load<Texture2D>("Clock");
            mClockhand = Content.Load<Texture2D>("ClockHand");

            mLifeWorld.WakeUp();
        }