public void Initialize(Texture2D a_texture, Vector2 a_position)
        {
            EnvTexture = a_texture;
            Position = a_position;
            BoundingBox = new BoundingRect(Position.X, Position.Y, Width, Height);

            //DebugRect = new Rectangle((int)Position.X, (int)Position.Y, (int)Width, (int)Height);
            //DebugRectColor = Color.Red;
        }
示例#2
0
        public void Initialize( Texture2D a_texture, Vector2 a_position)
        {
            isActive = false;

            texture = a_texture;
            color = Color.White;
            scale = 1f;

            Position = a_position;

            width = texture.Width;
            height = texture.Height;

            BoundingBox = new BoundingRect(this.Position.X, this.Position.Y, this.Width, this.Height);

        }
示例#3
0
        // INIT //
        public void Initialize(Texture2D a_texture, Vector2 a_position)
        {
            tex      = a_texture;
            position = a_position;

            speed = 1.5f;
            scale = 0.8f;

            // Change later if needed //
            width  = tex.Width;
            height = tex.Height;

            boundingBox = new BoundingRect(position, Width, Height);

            dir       = Direction.LEFT;
            behaviour = Behaviour.PATH;

            isAlive = true;

            attackPower = 1;
        }
示例#4
0
        // INIT //
        public void Initialize(Texture2D a_texture, Vector2 a_position)
        {
            tex = a_texture;
            position = a_position;

            speed = 1.5f;
            scale = 0.8f;

            // Change later if needed //
            width = tex.Width;
            height = tex.Height;

            boundingBox = new BoundingRect(position, Width, Height);

            dir = Direction.LEFT;
            behaviour = Behaviour.PATH;

            isAlive = true;

            attackPower = 1;
        }
        public void MakeCollisionAreas()
        {
            // if left mouse button has just been pressed
            if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released)
            {
                // store location for min coordinate
                minX = currentMouseState.X;
                minY = currentMouseState.Y;

                // Initialize rectangle preview drawing position at pointer
                drawArea = new Rectangle(minX, minY, 0, 0);
            }

            // if left button is still held down
            if (currentMouseState.LeftButton == ButtonState.Pressed)
            {
                // modify size of the rectangle with current mouse values
                drawArea = new Rectangle(drawArea.X, drawArea.Y, currentMouseState.X - drawArea.X, currentMouseState.Y - drawArea.Y);
            }

            // if left mouse has been released
            if (currentMouseState.LeftButton == ButtonState.Released && previousMouseState.LeftButton == ButtonState.Pressed)
            {
                // store mouse location for dimension calculation // ** maybe change to just use drawArea?
                maxX = currentMouseState.X;
                maxY = currentMouseState.Y;
                w    = maxX - minX;
                h    = maxY - minY;

                // make a Bounding Rectangle and store it in the list
                BoundingRect newArea = new BoundingRect(minX, minY, w, h);
                collisionAreas.Add(newArea);

                // reset drawArea
                drawArea = new Rectangle(-1, -1, 0, 0);
            }
        }
        //public static BoundingRect Intersect(BoundingRect rect1, BoundingRect rect2)
        //{
        //    BoundingRect result;

        //    float num8 = rect1.Right;
        //    float num7 = rect2.Right;
        //    float num6 = rect1.Bottom;
        //    float num5 = rect2.Bottom;
        //    float num2 = (rect1.Position.X > rect2.Position.X) ? rect1.Position.X : rect2.Position.X;
        //    float num = (rect1.Position.Y > rect2.Position.Y) ? rect1.Position.Y : rect2.Position.Y;
        //    float num4 = (num8 < num7) ? num8 : num7;
        //    float num3 = (num6 < num5) ? num6 : num5;

        //    if ((num4 > num2) && (num3 > num))
        //    {
        //        result.Position.X = num2;
        //        result.Position.Y = num;
        //        result.Right = num4;
        //        result.Bottom = num3;

        //        return result;
        //    }

        //    result.Position.X = 0;
        //    result.Position.Y = 0;
        //    result.Right = 0;
        //    result.Bottom = 0;

        //    return result;
        //}

        //public static void Intersect(ref BoundingRect rect1, ref BoundingRect rect2, out BoundingRect result)
        //{
        //    float num8 = rect1.Right;
        //    float num7 = rect2.Right;
        //    float num6 = rect1.Bottom;
        //    float num5 = rect2.Bottom;
        //    float num2 = (rect1.Position.X > rect2.Position.X) ? rect1.Position.X : rect2.Position.X;
        //    float num = (rect1.Position.Y > rect2.Position.Y) ? rect1.Position.Y : rect2.Position.Y;
        //    float num4 = (num8 < num7) ? num8 : num7;
        //    float num3 = (num6 < num5) ? num6 : num5;

        //    if ((num4 > num2) && (num3 > num))
        //    {
        //        result.Position.X = num2;
        //        result.Position.Y = num;
        //        result.Right = num4;
        //        result.Bottom = num3;
        //    }

        //    result.Position.X = 0;
        //    result.Position.Y = 0;
        //    result.Right = 0;
        //    result.Bottom = 0;
        //}

        //public static BoundingRect Union(BoundingRect rect1, BoundingRect rect2)
        //{
        //    BoundingRect result;

        //    float num6 = rect1.Right;
        //    float num5 = rect2.Right;
        //    float num4 = rect1.Bottom;
        //    float num3 = rect2.Bottom;
        //    float num2 = (rect1.Position.X < rect2.Position.X) ? rect1.Position.X : rect2.Position.X;
        //    float num = (rect1.Position.Y < rect2.Position.Y) ? rect1.Position.Y : rect2.Position.Y;
        //    float num8 = (num6 > num5) ? num6 : num5;
        //    float num7 = (num4 > num3) ? num4 : num3;

        //    result.Position.X = num2;
        //    result.Position.Y = num;
        //    result.Right = num8;
        //    result.Bottom = num7;

        //    return result;
        //}

        //public static void Union(ref BoundingRect rect1, ref BoundingRect rect2, out BoundingRect result)
        //{
        //    float num6 = rect1.Right;
        //    float num5 = rect2.Right;
        //    float num4 = rect1.Bottom;
        //    float num3 = rect2.Bottom;
        //    float num2 = (rect1.Position.X < rect2.Position.X) ? rect1.Position.X : rect2.Position.X;
        //    float num = (rect1.Position.Y < rect2.Position.Y) ? rect1.Position.Y : rect2.Position.Y;
        //    float num8 = (num6 > num5) ? num6 : num5;
        //    float num7 = (num4 > num3) ? num4 : num3;

        //    result.Position.X = num2;
        //    result.Position.Y = num;
        //    result.Right = num8;
        //    result.Bottom = num7;
        //}

        public bool Equals(BoundingRect other)
        {
            return
                (this.Position.X == other.Position.X) &&
                (this.Position.Y == other.Position.Y) &&
                (this.Right == other.Right) &&
                (this.Bottom == other.Bottom);
        }
 public void Intersects(ref BoundingRect rect, out bool result)
 {
     result =
         (this.Position.X < rect.Right) &&
         (this.Position.Y < rect.Bottom) &&
         (this.Right > rect.Position.X) &&
         (this.Bottom > rect.Position.Y);
 }
 public bool Intersects(BoundingRect rect)
 {
     return
         (this.Position.X < rect.Right) &&
         (this.Position.Y < rect.Bottom) &&
         (this.Right > rect.Position.X) &&
         (this.Bottom > rect.Position.Y);
 }
 public void Contains(ref BoundingRect rect, out bool result)
 {
     result =
         (this.Position.X <= rect.Position.X) &&
         (this.Position.Y <= rect.Position.Y) &&
         (this.Right >= rect.Right) &&
         (this.Bottom >= rect.Bottom);
 }
示例#10
0
 public bool Contains(BoundingRect rect)
 {
     return
         (this.Position.X <= rect.Position.X) &&
         (this.Position.Y <= rect.Position.Y) &&
         (this.Right >= rect.Right) &&
         (this.Bottom >= rect.Bottom);
 }
示例#11
0
        public void HandleCollisionWithSolid(BoundingRect solidRect)
        {
            // need to recalc in case other collisions moved the body this frame
            UpdateBoundingBoxes();

            if (CollisionTop.Intersects(solidRect))
            {
                Console.WriteLine("Top Hit");
                CollisionTop.DebugRectColor = Color.Green;
                position.Y = solidRect.Position.Y - Height;
                if (this.velocity.Y < 0f)
                {
                    this.velocity.Y = 0f;
                }
            }
            else
            {
                CollisionTop.DebugRectColor = Color.Red;
            }

            if (CollisionBottom.Intersects(solidRect))
            {
                Console.WriteLine("Bottom Hit");
                CollisionBottom.DebugRectColor = Color.Green;
                position.Y = solidRect.Position.Y - this.Height - 1;
                if (this.velocity.Y > 0f)
                {
                    this.velocity.Y = 0f;
                    this.isOnGround = true;
                }
            }
            else
            {
                CollisionBottom.DebugRectColor = Color.Red;
            }

            if (CollisionLeft.Intersects(solidRect))
            {
                Console.WriteLine("Left Hit");
                CollisionLeft.DebugRectColor = Color.Green;
                position.X = solidRect.Position.X + solidRect.Width;
                if (this.velocity.X < 0f)
                {
                    this.velocity.X = 0f;
                }

                // ninja - if in midair and collides on side, grab wall
                if (this.isOnGround == false)
                {
                    if (solidRect.isLadder)
                    {
                        this.isOnLadder = true;
                    }
                    this.isWallGrabbing     = true;
                    this.isWallGrabbingLeft = true;
                    //GravityAcceleration
                    this.velocity.Y = 0f;
                }
            }
            else
            {
                CollisionLeft.DebugRectColor = Color.Red;
            }

            if (CollisionRight.Intersects(solidRect))
            {
                Console.WriteLine("Right Hit");
                CollisionRight.DebugRectColor = Color.Green;
                if (this.velocity.X > 0f)
                {
                    this.velocity.X = 0f;
                }
                position.X = solidRect.Position.X - Width;

                // ninja - if in midair and collides on side, grab wall
                if (this.isOnGround == false)
                {
                    if (solidRect.isLadder)
                    {
                        this.isOnLadder = true;
                    }
                    this.isWallGrabbing      = true;
                    this.isWallGrabbingRight = true;
                    //GravityAcceleration
                    this.velocity.Y = 0;
                }
            }
            else
            {
                CollisionRight.DebugRectColor = Color.Red;
            }
        }
示例#12
0
        // vvvvvvvvvv TRASH vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

        //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


        public void Initialize(NinjaGaiDemake_Game game, Texture2D a_texture, Vector2 a_position, Weapon a_sword)
        {
            // temp
            color = Color.White;
            scale = 0.4f;

            IsAlive = true;
            health  = 15;

            this.game = game;

            // set texture // ** to be animation later **
            playerTexture = a_texture;

            // Set starting position
            Position = a_position;

            // original width and height of texture
            width  = playerTexture.Width;
            height = playerTexture.Height;

            // Set health

            // set collision area calculation variables
            thirdOfWidth    = Width / 3f;
            halfOfWidth     = Width / 2f;
            quarterOfHeight = Height / 4f;
            thirdOfHeight   = Height / 3f;
            halfOfHeight    = Height / 2f;

            // set smaller collision areas
            CollisionTop    = new BoundingRect(this.Position.X + thirdOfWidth, this.Position.Y - 5f, thirdOfWidth, quarterOfHeight + 10f);
            CollisionBottom = new BoundingRect(this.Position.X + thirdOfWidth, this.Position.Y + quarterOfHeight * 3f, thirdOfWidth, quarterOfHeight + 5f);
            CollisionLeft   = new BoundingRect(this.Position.X, this.Position.Y + quarterOfHeight, halfOfWidth, halfOfHeight);
            CollisionRight  = new BoundingRect(this.Position.X + halfOfWidth, this.Position.Y + quarterOfHeight, halfOfWidth, halfOfHeight);

            // set broad collision area
            BoundingBox = new BoundingRect(this.Position.X - 10f, CollisionTop.Position.Y, this.Width + 20f, this.Height + 10f);

            // Set player health
            //health = 100;

            fuel = 100;

            fuelOutline = new Rectangle(8, 64, 201, 20);
            fuelFill    = new Rectangle(9, 64, fuelFill.X + (fuel * 25), 19);

            // weapons
            sword        = a_sword;
            isUsingSword = false;


            // sound effects
            // jetFart = game.Content.Load<SoundEffect>("Sound\\Fart");
            //squeak = game.Content.Load<SoundEffect>("Sound\\ShortSqueak");

            //Creating effect Instance
            //jetFartEffect = jetFart.CreateInstance();
            //jetFartEffect.Volume = 0.01f;
            //jetFartEffect.IsLooped = false;
            ////Creating an instance of squeak
            //squeakEffect = squeak.CreateInstance();
            //squeakEffect.Volume = 0.1f;
            //squeakEffect.IsLooped = false;
        }
        public void MakeCollisionAreas()
        {
            // if left mouse button has just been pressed
            if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released)
            {
                // store location for min coordinate
                minX = currentMouseState.X;
                minY = currentMouseState.Y;

                // Initialize rectangle preview drawing position at pointer
                drawArea = new Rectangle(minX, minY, 0, 0);
            }

            // if left button is still held down
            if (currentMouseState.LeftButton == ButtonState.Pressed)
            {
                // modify size of the rectangle with current mouse values
                drawArea = new Rectangle(drawArea.X, drawArea.Y, currentMouseState.X - drawArea.X, currentMouseState.Y - drawArea.Y);
            }

            // if left mouse has been released
            if (currentMouseState.LeftButton == ButtonState.Released && previousMouseState.LeftButton == ButtonState.Pressed)
            {
                // store mouse location for dimension calculation // ** maybe change to just use drawArea?
                maxX = currentMouseState.X;
                maxY = currentMouseState.Y;
                w = maxX - minX;
                h = maxY - minY;

                // make a Bounding Rectangle and store it in the list
                BoundingRect newArea = new BoundingRect(minX, minY, w, h);
                collisionAreas.Add(newArea);

                // reset drawArea
                drawArea = new Rectangle(-1, -1, 0, 0);
            }
        }
示例#14
0
        public void HandleCollisionWithSolid(BoundingRect solidRect)
        {
            // need to recalc in case other collisions moved the body this frame
            UpdateBoundingBoxes();

            if (CollisionTop.Intersects(solidRect))
            {
                Console.WriteLine("Top Hit");
                CollisionTop.DebugRectColor = Color.Green;
                position.Y = solidRect.Position.Y - Height;
                if (this.velocity.Y < 0f)
                    this.velocity.Y = 0f;
            }
            else
                CollisionTop.DebugRectColor = Color.Red;

            if (CollisionBottom.Intersects(solidRect))
            {
                Console.WriteLine("Bottom Hit");
                CollisionBottom.DebugRectColor = Color.Green;
                position.Y = solidRect.Position.Y - this.Height - 1;
                if (this.velocity.Y > 0f)
                {
                    this.velocity.Y = 0f;
                    this.isOnGround = true;
                }
            }
            else
                CollisionBottom.DebugRectColor = Color.Red;

            if (CollisionLeft.Intersects(solidRect))
            {
                Console.WriteLine("Left Hit");
                CollisionLeft.DebugRectColor = Color.Green;
                position.X = solidRect.Position.X + solidRect.Width;
                if (this.velocity.X < 0f)
                    this.velocity.X = 0f;

                // ninja - if in midair and collides on side, grab wall
                if (this.isOnGround == false)
                {
                    if (solidRect.isLadder)
                        this.isOnLadder = true;
                    this.isWallGrabbing = true;
                    this.isWallGrabbingLeft = true;
                    //GravityAcceleration
                    this.velocity.Y = 0f;
                }

            }
            else
                CollisionLeft.DebugRectColor = Color.Red;

            if (CollisionRight.Intersects(solidRect))
            {
                Console.WriteLine("Right Hit");
                CollisionRight.DebugRectColor = Color.Green;
                if (this.velocity.X > 0f)
                    this.velocity.X = 0f;
                position.X = solidRect.Position.X - Width;

                // ninja - if in midair and collides on side, grab wall
                if (this.isOnGround == false)
                {
                    if (solidRect.isLadder)
                        this.isOnLadder = true;
                    this.isWallGrabbing = true;
                    this.isWallGrabbingRight = true;
                    //GravityAcceleration
                    this.velocity.Y = 0;
                }
            }
            else
                CollisionRight.DebugRectColor = Color.Red;

        }
示例#15
0
        // vvvvvvvvvv TRASH vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

        //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


        public void Initialize(NinjaGaiDemake_Game game, Texture2D a_texture, Vector2 a_position, Weapon a_sword)
        {
            // temp
            color = Color.White;
            scale = 0.4f;

            IsAlive = true;
            health = 15;

            this.game = game;

            // set texture // ** to be animation later **
            playerTexture = a_texture;

            // Set starting position
            Position = a_position;

            // original width and height of texture
            width = playerTexture.Width;
            height = playerTexture.Height;

            // Set health

            // set collision area calculation variables
            thirdOfWidth = Width / 3f;
            halfOfWidth = Width / 2f;
            quarterOfHeight = Height / 4f;
            thirdOfHeight = Height / 3f;
            halfOfHeight = Height / 2f;

            // set smaller collision areas
            CollisionTop = new BoundingRect(this.Position.X + thirdOfWidth, this.Position.Y - 5f, thirdOfWidth, quarterOfHeight + 10f);
            CollisionBottom = new BoundingRect(this.Position.X + thirdOfWidth, this.Position.Y + quarterOfHeight * 3f, thirdOfWidth, quarterOfHeight + 5f);
            CollisionLeft = new BoundingRect(this.Position.X, this.Position.Y + quarterOfHeight, halfOfWidth, halfOfHeight);
            CollisionRight = new BoundingRect(this.Position.X + halfOfWidth, this.Position.Y + quarterOfHeight, halfOfWidth, halfOfHeight);

            // set broad collision area
            BoundingBox = new BoundingRect(this.Position.X - 10f, CollisionTop.Position.Y, this.Width + 20f, this.Height + 10f);

            // Set player health
            //health = 100;

            fuel = 100;

            fuelOutline = new Rectangle(8, 64, 201, 20);
            fuelFill = new Rectangle(9, 64, fuelFill.X + (fuel * 25), 19);

            // weapons
            sword = a_sword;
            isUsingSword = false;


            // sound effects
           // jetFart = game.Content.Load<SoundEffect>("Sound\\Fart");
           //squeak = game.Content.Load<SoundEffect>("Sound\\ShortSqueak");

            //Creating effect Instance
            //jetFartEffect = jetFart.CreateInstance();
            //jetFartEffect.Volume = 0.01f;
            //jetFartEffect.IsLooped = false;
            ////Creating an instance of squeak
            //squeakEffect = squeak.CreateInstance();
            //squeakEffect.Volume = 0.1f;
            //squeakEffect.IsLooped = false;

        }