Пример #1
0
        public void init_adamsStuff()
        {
            phraseint = 0;
            time      = 6;


            worldObjectspre  = new List <I_WorldObject>();
            worldtextObjects = new List <I_WorldObject>();

            foreach (Vector2 textPosition in WorldData.GetInstance().textPositions)
            {
                messagebox box = new messagebox("poke_text_messagenew", textPosition);
                box.setPosition(new Vector2(-25, 110));
                worldObjectspre.Add(box);
            }

            foreach (String s in WorldData.GetInstance().fieldvaluepairs)
            {
                messagetexts text = new messagetexts(s, new Vector2(0, 0));
                text.setPosition(new Vector2(200, 540));
                worldtextObjects.Add(text);
            }
        }
Пример #2
0
        public void alertCollision(I_WorldObject collidedObject)
        {
            if (collidedObject.getName() == "nun")
            {
                this.setVelocity(Vector2.Zero);
                this.setDirection(new Vector2(1, 0));
                this.setSpeed(Vector2.Zero);
                this.setPhysics(false);

                playerPosition = WorldData.GetInstance().playerInitialPosition;
            }

            if (!collidedObject.isRigid())
            {
                if (collidedObject.getName() == "Spikes" || collidedObject.getName() == "SpikeField")
                {
                    setAlive(false);

                    this.setVelocity(Vector2.Zero);
                    this.setDirection(new Vector2(1, 0));
                    this.setSpeed(Vector2.Zero);
                    this.setPhysics(false);

                    playerPosition = WorldData.GetInstance().playerInitialPosition;

                    setAlive(true);
                }


                if (collidedObject.getName() == "scroll")
                {
                    collidedObject.setAlive(false);
                    WorldData.level++;
                }
            }

            if (collidedObject.isRigid())
            {
                //this.playerColor = Color.Red;

                BoundingBox myAABB = this.playerBoundingBox;
                BoundingBox other  = collidedObject.getBoundingBox();

                int leftBound  = (int)Math.Max(myAABB.Min.X, other.Min.X);
                int rightBound = (int)Math.Min(myAABB.Max.X, other.Max.X);
                int upperBound = (int)Math.Max(myAABB.Min.Y, other.Min.Y);
                int lowerBound = (int)Math.Min(myAABB.Max.Y, other.Max.Y);

                int xMovement = rightBound - leftBound;
                int yMovement = lowerBound - upperBound;

                if (xMovement < yMovement)
                {
                    if (myAABB.Min.X < other.Min.X)
                    {
                        this.playerPosition.X -= xMovement - 1;
                    }
                    else
                    {
                        this.playerPosition.X += xMovement + 1;
                    }
                }
                else
                {
                    if (myAABB.Min.Y < other.Min.Y)
                    {
                        this.playerState = State.GROUNDED;

                        this.playerPosition.Y -= (yMovement);
                        this.setVelocity(new Vector2(0, 0));
                    }
                    else
                    {
                        //this.playerState = State.HIGH;
                        this.playerPosition.Y += (yMovement);
                        this.setVelocity(new Vector2(0, 0));
                        //this.gravityState = true;
                    }
                }
            }
        }
Пример #3
0
 protected void AddData(XElement elem)
 {
     XMLParse.AddValueToClassInstance(elem, WorldData.GetInstance());
 }
Пример #4
0
        public void init_everything()
        {
            endScene     = false;
            objectsToAdd = new List <I_WorldObject>();
            scareImg     = new ScaryImage();
            nunCount     = new TextBox(new Vector2(20, 0), "nuns impaled: 0", "HUDfont", Color.Yellow);
            scoreDisplay = new TextBox(new Vector2(20, 50), "coins: 0", "HUDfont", Color.Yellow);
            game         = containingGame;
            WorldWidth   = w;
            WorldHeight  = h;

            int worldX = 0;
            int worldY = 0;

            toDelete            = new List <I_WorldObject>();
            worldObjects        = new List <I_WorldObject>();
            intersectingObjects = new List <I_WorldObject>();

            p = new Player("Jordan", WorldData.GetInstance().playerInitialPosition, worldObjects);

            fl = new FlameThrower(this);

            camera = new Camera(containingGame.spriteBatch, p);

            foreach (Vector2 spikePos in WorldData.GetInstance().spikePositions)
            {
                if (spikePos.X > worldX)
                {
                    worldX = (int)spikePos.X;
                }
                if (spikePos.Y > worldY)
                {
                    worldY = (int)spikePos.Y;
                }

                TestBlock s = new TestBlock("Spikes", spikePos + new Vector2(0, 2), scareImg, this);
                s.setDirection(new Vector2(0, -1));
                s.setRigid(false);
                worldObjects.Add(s);
            }

            foreach (Vector2 enemPos in WorldData.GetInstance().enemyPositions)
            {
                if (enemPos.X > worldX)
                {
                    worldX = (int)enemPos.X;
                }
                if (enemPos.Y > worldY)
                {
                    worldY = (int)enemPos.Y;
                }

                Enemy e = new Enemy("nun", enemPos, this);
                e.setRigid(false);
                worldObjects.Add(e);
            }

            foreach (Vector2 platPos in WorldData.GetInstance().platformPositions)
            {
                if (platPos.X > worldX)
                {
                    worldX = (int)platPos.X;
                }
                if (platPos.Y > worldY)
                {
                    worldY = (int)platPos.Y;
                }

                TestBlock b = new TestBlock("usf", platPos, scareImg, this);
                worldObjects.Add(b);
            }

            foreach (Vector2 movingPlatPos in WorldData.GetInstance().movingPlatformPositions)
            {
                if (movingPlatPos.X > worldX)
                {
                    worldX = (int)movingPlatPos.X;
                }
                if (movingPlatPos.Y > worldY)
                {
                    worldY = (int)movingPlatPos.Y;
                }

                TestBlock mp = new TestBlock("movingPlatform", movingPlatPos, scareImg, this);
                worldObjects.Add(mp);
            }

            foreach (Vector2 coinPos in WorldData.GetInstance().coinPositions)
            {
                if (coinPos.X > worldX)
                {
                    worldX = (int)coinPos.X;
                }
                if (coinPos.Y > worldY)
                {
                    worldY = (int)coinPos.Y;
                }

                Coin c = new Coin("coin", 20, new Vector2(0, 0), true, 0.08f, coinPos, scoreDisplay);
                c.setRigid(false);
                worldObjects.Add(c);
            }


            foreach (Vector2 scrollPos in WorldData.GetInstance().scrollPositions)
            {
                if (scrollPos.X > worldX)
                {
                    worldX = (int)scrollPos.X;
                }
                if (scrollPos.Y > worldY)
                {
                    worldY = (int)scrollPos.Y;
                }

                TestBlock s = new TestBlock("scroll", scrollPos, scareImg, this);
                s.setRigid(false);
                worldObjects.Add(s);
            }

            TestBlock scareBLock = new TestBlock("ScareBlock", WorldData.GetInstance().playerInitialPosition + new Vector2(800, 300), scareImg, this);


            worldObjects.Add(scareBLock);

            worldObjects.Add(p);

            worldObjects.Add(fl);

            qt = new QuadTree(new Rectangle(0, 0, worldX, worldY));
        }
Пример #5
0
        public void Draw(I_WorldObject obj)
        {
            if (trackMe.getPosition().X >= WorldData.GetInstance().ScreenWidth / 2)
            {
                //Vector2 objPosInCameraSpace = obj.getPosition() - new Vector2((trackMe.getPosition()).X, 0);
                Vector2 objPosInCameraSpace = obj.getPosition() - new Vector2((trackMe.getPosition()).X - (WorldData.GetInstance().ScreenWidth / 2), 0);
                objPosInScreenSpace = objPosInCameraSpace;

                tracking = true;
            }
            else
            {
                tracking = false;
                Vector2 objPosInCameraSpace = obj.getPosition();
                objPosInScreenSpace = objPosInCameraSpace;
            }

            if (obj.getName() != "coin")
            {
                mSpriteBatch.Draw(obj.getTexture(), objPosInScreenSpace, null, obj.getColor(), obj.getRotation(), obj.getTextureOrigin(), 1.0f, SpriteEffects.None, 0);
            }
            else if (obj.getName() == "coin")
            {
                Rectangle srcRect = new Rectangle((int)obj.getFrame() * obj.getFrameWidth(), 0, obj.getFrameWidth(), obj.getTexture().Height);

                mSpriteBatch.Draw(obj.getTexture(), objPosInScreenSpace, srcRect, Color.White, obj.getRotation(), Vector2.Zero, obj.getScale(), SpriteEffects.None, 0);
            }
        }