Exemple #1
0
        protected virtual void checkGroundUnderneath(ArrayList solidObjects, ref ArrayList particles)
        {
            bool noGroungUnderneath = true;

            for (int i = 0; i < solidObjects.Count; i++)
            {
                SolidObject so = (SolidObject)solidObjects[i];
                if (sprite.checkCollision(so.box, 0, 1) == true &&                                     //if one bit below is obj.
                    (so.semiSolid == false ||                                                          //and it is solid
                     so.semiSolid == true && sprite.checkCollision(so.box, 0, 0) == false))            //or it is semi solid but now there is no collision with it
                {                                                                                      //then we have ground under foots
                    gravity            = 0;
                    vy                 = 0;
                    noGroungUnderneath = false;

                    doStuffCaseGroundUnderneath(ref particles);
                }
            }

            if (noGroungUnderneath)
            {
                gravity = maxGravity;
                doStuffCaseNoGroundUnderneath();
            }
        }
Exemple #2
0
        protected virtual void move(ArrayList solidObjects)
        {
            bool noCollisions = true;

            if (vx != 0 || vy != 0)
            {
                for (int i = 0; i < solidObjects.Count; i++)
                {
                    SolidObject so = (SolidObject)solidObjects[i];

                    if (!so.semiSolid && sprite.checkCollision(so.box, vx, vy) == true)
                    {
                        noCollisions = false;
                        break;
                    }
                }

                sprite.x += vx;
                sprite.y += vy;

                if (!noCollisions)
                {
                    vx       = 0;
                    vy       = 0;
                    gravity  = 0;
                    disarmed = true;
                }
            }

            vy += gravity;
        }
Exemple #3
0
 public void moveToObject(SolidObject so, int dx, int dy)
 {
     while (!sprite.checkCollision(so.box, dx, dy))
     {
         Y += dy;
         X += dx;
     }
 }
Exemple #4
0
 public void pushOut(SolidObject so, int dx, int dy)
 {
     do
     {
         Y += dy;
         X += dx;
     }while (sprite.checkCollision(so.box) == true);
 }
Exemple #5
0
        public virtual void move(ArrayList solidObjects)
        {
            bool noCollisions = true;

            for (int i = 0; i < solidObjects.Count; i++)
            {
                SolidObject so = (SolidObject)solidObjects[i];

                if (sprite.checkCollision(so.box, vx * speedMultiplier, 0) == true && so.semiSolid == false)
                {
                    noCollisions = false;
                    break;
                }
            }

            if (noCollisions)
            {
                X += vx * speedMultiplier;
            }

            noCollisions = true;
            for (int i = 0; i < solidObjects.Count; i++)
            {
                SolidObject so = (SolidObject)solidObjects[i];

                if (sprite.checkCollision(so.box, 0, vy) == true)                                         //if next step will be collision with obj.
                {
                    if (vy < 0 && so.semiSolid == false)
                    {
                        noCollisions = false;
                        break;
                    }
                    else
                    {
                        if (so.semiSolid == false ||                                                                                         //if obj. is solid
                            (so.semiSolid == true && vy >= 0 && sprite.checkCollision(so.box, 0, 0) == false && !fallThroughSemiSolid))      //or it is semiSolid, while now there is no collisions with obj. and player moving down
                        {
                            moveToObject(so, 0, 1);
                            noCollisions = false;
                        }
                    }
                }
            }

            if (noCollisions)
            {
                Y += vy;
            }
            else
            {
                vy = 0;
            }

            vy += gravity;
        }
Exemple #6
0
        private void move(ArrayList solidObjects)
        {
            bool noCollisions = true;

            if (vx != 0 || vy != 0)
            {
                for (int i = 0; i < solidObjects.Count; i++)
                {
                    SolidObject so = (SolidObject)solidObjects[i];

                    if (!so.semiSolid && sprite.checkCollision(so.box, vx, vy) == true)
                    {
                        noCollisions = false;
                        break;
                    }
                }

                sprite.x += vx;
                sprite.y += vy;

                if (!noCollisions)
                {
                    vx      = 0;
                    vy      = 0;
                    gravity = 0;

                    if (type == ProjectyleType.Slash || type == ProjectyleType.Slash_Axe)
                    {
                        timeToDie = true;
                    }
                    else
                    {
                        disarmed = true;
                    }
                }
            }

            vy += gravity;
        }
Exemple #7
0
        private void checkGroundUnderneath(ArrayList solidObjects)
        {
            bool noGroungUnderneath = true;

            for (int i = 0; i < solidObjects.Count; i++)
            {
                SolidObject so = (SolidObject)solidObjects[i];
                if (sprite.checkCollision(so.box, 0, 1) == true &&                           //if one bit below is obj.
                    (so.semiSolid == false ||                                                //and it is solid
                     so.semiSolid == true && sprite.checkCollision(so.box, 0, 0) == false))  //or it is semi solid but now there is no collision with it
                {                                                                            //then we have ground under foots
                    gravity            = 0;
                    vy                 = 0;
                    noGroungUnderneath = false;

                    if (inAir)
                    {
                        inAir = false;

                        if (weaponReadyToAction)
                        {
                            if (vx == 0)
                            {
                                setSprite("swing");
                                sprite.setFrame(0);
                            }
                            else
                            {
                                setSprite("runSwing");
                            }
                        }
                        else
                        {
                            if (vx == 0)
                            {
                                setSprite("stand");
                            }
                            else
                            {
                                setSprite("run");
                            }
                        }
                    }
                }
            }

            if (noGroungUnderneath)
            {
                inAir   = true;
                gravity = 0.5f;
                if (sprite != jump || sprite != jumpSwing)
                {
                    if (weaponReadyToAction)
                    {
                        setSprite("jumpSwing");
                        sprite.setFrame(0);
                    }
                    else
                    {
                        setSprite("jump");
                    }
                }
            }
        }
Exemple #8
0
        public void move(ArrayList solidObjects)
        {
            if (gameClass == GameClass.Bowman && vx != 0)
            {
                if (weaponReadyToAction)
                {
                    if (!inAir)
                    {
                        vx = movingSpeedX * 0.55f * face;
                    }
                    else
                    {
                        vx = movingSpeedX * 0.8f * face;
                    }
                }
                else
                {
                    vx = movingSpeedX * face;
                }
            }

            bool noCollisions = true;

            for (int i = 0; i < solidObjects.Count; i++)
            {
                SolidObject so = (SolidObject)solidObjects[i];

                if (sprite.checkCollision(so.box, vx, 0) == true && so.semiSolid == false)
                {
                    noCollisions = false;
                    break;
                }
            }

            if (noCollisions)
            {
                X += vx;
            }

            noCollisions = true;
            for (int i = 0; i < solidObjects.Count; i++)
            {
                SolidObject so = (SolidObject)solidObjects[i];

                if (sprite.checkCollision(so.box, 0, vy) == true)                                         //if next step will be collision with obj.
                {
                    if (vy < 0 && so.semiSolid == false)
                    {
                        noCollisions = false;
                        break;
                    }
                    else
                    {
                        if (so.semiSolid == false ||                                                                //if obj. is solid
                            (so.semiSolid == true && vy >= 0 && sprite.checkCollision(so.box, 0, 0) == false))      //or it is semiSolid, while now there is no collisions with obj. and player moving down
                        {
                            moveToObject(so, 0, 1);
                            noCollisions = false;
                        }
                    }
                }
            }

            if (noCollisions)
            {
                Y += vy;
            }
            else
            {
                vy = 0;
            }

            vy += gravity;
        }