Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        public void alertCollision(I_WorldObject collidedObject)
        {
            if (collidedObject.getName() == "usf" || collidedObject.getName() == "Spikes")
            {
                //update boundingBox size
            }

            //this.blockColor = Color.Red;
        }
Ejemplo n.º 3
0
        public void alertCollision(I_WorldObject collidedObject)
        {
            Console.WriteLine(collidedObject.getName());

            if (collidedObject.getName() == "fire particle")
            {
                nunCount++;
                gameWorld.nunCount.text = "nuns impaled: " + nunCount;
                this.setAlive(false);
            }

            if (collidedObject.isRigid())
            {
                this.enemyVelocity *= -1;
            }

            //this.blockColor = Color.Red;
        }
Ejemplo n.º 4
0
        public void DrawText(I_WorldObject text)
        {
            Vector2 objPosInCameraSpace = text.getPosition();

            objPosInScreenSpace = objPosInCameraSpace;
            string texttowrite = parseText(text.getName());

            mSpriteBatch.DrawString(font, texttowrite, objPosInScreenSpace, Color.Black, text.getRotation(), text.getTextureOrigin(), 1.0f, SpriteEffects.None, 0);
        }
Ejemplo n.º 5
0
        public void alertCollision(I_WorldObject collidedObject)
        {
            if (collidedObject.getName() != "fire particle")
            {
                coinSound_instance.Play();

                scoreDisplay.text = "coins: " + ++cointCount;
                this.setAlive(false);
            }
        }
Ejemplo n.º 6
0
        private Rectangle boundingBoxToRectangle(I_WorldObject obj)
        {
            Rectangle AABB;

            if (obj.getName().CompareTo("coin") == 0)
            {
                AABB = new Rectangle((int)obj.getPosition().X, (int)obj.getPosition().Y,
                                     20, obj.getTexture().Height);
            }
            else
            {
                AABB = new Rectangle((int)obj.getPosition().X, (int)obj.getPosition().Y,
                                     obj.getTexture().Width, obj.getTexture().Height);
            }


            return(AABB);
        }
Ejemplo n.º 7
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;
                    }
                }
            }
        }