Ejemplo n.º 1
0
        public IntervalShoot(Enemy parent, double newInterval, BulletPool.BulletType type)
        {
            interval = newInterval;
            bulletType = type;

            timeSinceLastShot = 0;
        }
Ejemplo n.º 2
0
 public void update(Enemy parent, GameTime currentTime)
 {
     if (parent.onTheGround)
     {
         if (Game1.gameRandom.Next() % 30 == 0)
         {
             parent.velocity.Y = -0.4f;
         }
     }
 }
Ejemplo n.º 3
0
        public void update(Enemy parent, GameTime currentTime)
        {
            if (!isEnabled)
            {
                return;
            }

            timeSinceLastShot += currentTime.ElapsedGameTime.Milliseconds;

            if (timeSinceLastShot > interval)
            {
                float direction = 0.0f;

                if (parent.velocity.X < 0.0f)
                {
                    direction += (float)(Math.PI);
                }

                Vector2 bulletPosition = parent.Position;

                if (parent is Lolrus)
                {
                    bulletPosition.Y += 4;

                    if (parent.velocity.X >= 0.0f)
                    {
                        bulletPosition.X += parent.HitBox.X;
                    }
                }

                BulletPool.pushBullet(bulletType, bulletPosition.X, bulletPosition.Y, currentTime, direction);

                timeSinceLastShot = 0;

                if (parent is Lolrus)
                {
                    ((Lolrus)parent).lolrusFire();
                }
            }
        }
Ejemplo n.º 4
0
        public void update(Enemy parent, GameTime currentTime)
        {
            if (!isEnabled)
            {
                return;
            }

            if (walkSwitchTimer == 0)
            {
                walkSwitchTimer = currentTime.TotalGameTime.TotalMilliseconds;
            }

            if (parent.onTheGround)
            {
                foreach (Entity en in Entity.globalEntityList)
                {
                    if (en is Player)
                    {
                        if (en.horizontal_pos - parent.horizontal_pos > -100 && en.horizontal_pos - parent.horizontal_pos < 100 && en.vertical_pos - parent.vertical_pos > -5 && en.vertical_pos - parent.vertical_pos < 5)
                        {
                            chasePlayer = true;
                        }
                        else
                        {
                            chasePlayer = false;
                        }

                        if (chasePlayer == true)
                        {
                            if (en.horizontal_pos - parent.horizontal_pos > -500 && en.horizontal_pos - parent.horizontal_pos < -30)
                            {

                                if (walkingLeft == false)
                                {
                                    walkingLeft = true;
                                }

                                parent.velocity.X = -2 * walkerSpeed;
                            }
                            else if (en.horizontal_pos - parent.horizontal_pos > -30 && en.horizontal_pos - parent.horizontal_pos < 30)
                            {
                                parent.velocity.X = 0.0f;
                            }
                            else if (en.horizontal_pos - parent.horizontal_pos > 30 && en.horizontal_pos - parent.horizontal_pos < 500)
                            {
                                if (walkingLeft == true)
                                {
                                    walkingLeft = false;
                                }

                                parent.velocity.X = 2 * walkerSpeed;
                            }
                        }
                    }
                }
               if( chasePlayer == false)
               {
                   walkState.update(parent, currentTime);
               }
            }
        }
Ejemplo n.º 5
0
 public Chase(Enemy parent)
 {
     walkState = new Walk(parent);
 }
Ejemplo n.º 6
0
        public void update(Enemy parent, GameTime currentTime)
        {
            hittingWall = false;

            if (walkSwitchTimer == 0)
            {
                walkSwitchTimer = currentTime.TotalGameTime.TotalMilliseconds;
            }

            foreach (Entity en in Entity.globalEntityList)
            {
                if(isClimbing == true)
                {
                    parent.acceleration.Y = 0.00f;
                }

                if (en is climbWall)
                {
                    if (parent.hitTest(en))
                    {
                        hittingWall = true;
                    }
                }
            }

            if (hittingWall && chasePlayer)
            {
                if (temp > 0)
                {
                    parent.currentAnimation = "angrySawWalkLeft";
                }
                else
                {
                    parent.currentAnimation = "angrySawWalkRight";
                }
                isClimbing = true;
                parent.velocity.X = 0.00f;
                parent.velocity.Y = -0.15f;
                parent.acceleration.Y = 0.0f;
                parent.acceleration.X = 0.0f;
            }
            else
            {
                isClimbing = false;

                foreach (Entity en in Entity.globalEntityList)
                {
                    if (en is Player)
                    {
                        if (parent.PushTime < 1 && en.horizontal_pos - parent.horizontal_pos > -200 && en.horizontal_pos - parent.horizontal_pos < 200 && en.vertical_pos - parent.vertical_pos > -160 && en.vertical_pos - parent.vertical_pos < 160)
                        {
                            chasePlayer = true;
                        }
                        else
                        {
                            chasePlayer = false;
                        }

                        if (chasePlayer == true)
                        {
                            if (en.horizontal_pos - parent.horizontal_pos > -1000 && en.horizontal_pos - parent.horizontal_pos < -30 )
                            {

                                if (walkingLeft == false)
                                {
                                    walkingLeft = true;
                                }

                                parent.velocity.X = -2.5f * walkerSpeed;
                                temp = parent.velocity.X;
                            }
                            else if (en.horizontal_pos - parent.horizontal_pos > -16 && en.horizontal_pos - parent.horizontal_pos < 16)
                            {
                                parent.velocity.X = 0.0f;
                            }
                            else if (en.horizontal_pos - parent.horizontal_pos > 30 && en.horizontal_pos - parent.horizontal_pos < 1000)
                           {
                                if (walkingLeft == true)
                                {
                                    walkingLeft = false;
                                }
                                parent.velocity.X = 2.5f * walkerSpeed;
                                temp = parent.velocity.X;
                            }
                        }
                    }
                }

               if( chasePlayer == false)
               {
                    walkState.update(parent, currentTime);
               }
            }
        }
Ejemplo n.º 7
0
 public climbChaser(Enemy parent)
 {
     walkState = new Walk(parent);
 }
Ejemplo n.º 8
0
        public void update(Enemy parent, GameTime currentTime)
        {
            if (!isEnabled)
            {
                return;
            }

            if (walkSwitchTimer == 0)
            {
                walkSwitchTimer = currentTime.TotalGameTime.TotalMilliseconds;
            }

            if (parent.onTheGround)
            {
                if (Math.Abs(parent.velocity.X) < 0.01f)
                {
                    walkingLeft = !walkingLeft;
                }

                if (walkingLeft && parent.velocity.X > -walkerSpeed)
                {
                    parent.acceleration.X = -0.001f;
                }
                else if (parent.velocity.X < walkerSpeed)
                {
                    parent.acceleration.X = 0.001f;
                }
                else if (parent.velocity.X < -walkerSpeed)
                {
                    //parent.velocity.X = -walkerSpeed;
                }
                else if (parent.velocity.X > walkerSpeed)
                {
                    //parent.velocity.X = walkerSpeed;
                }
            }

            bool touchingWalkMarker = false;
            foreach (Entity en in Entity.globalEntityList)
            {
                if (en is WalkMarker)
                {
                    if (parent.hitTest(en))
                    {
                        Entity player = null;
                        foreach (Entity p in Entity.globalEntityList)
                        {
                            if (p is Player)
                            {
                                player = p;
                            }
                        }

                        touchingWalkMarker = true;

                        if (!onWalkMarker && parent.PushTime <= 0)
                        {
                            onWalkMarker = true;

                            parent.velocity.X *= -1;
                        }
                    }
                }
            }

            if (!touchingWalkMarker && onWalkMarker)
            {
                onWalkMarker = false;
            }
        }
Ejemplo n.º 9
0
 public Walk(Enemy parent)
 {
     onWalkMarker = false;
 }
Ejemplo n.º 10
0
 public Jump(Enemy parent)
 {
 }