Example #1
0
        public void Update(Perso_Speciaux.Kirby Joueur, List <ObjCollisionable> ObjCollisionnable)
        {
            recPerso = new Rectangle(Joueur.recPerso.X + 40, Joueur.recPerso.Y + 80, Joueur.recPerso.Width, 20);

            if (!Disable && !Killed)
            {
                RecZombie.X = (int)Position.X;
                RecZombie.Y = (int)Position.Y;

                #region deplacement
                //gere les Y a une certaine distance du personnage
                if (Math.Abs(Position.X - Joueur.position.X) < 200)
                {
                    if (Joueur.position.X > Position.X)
                    {
                        Position.X += 0.25f;
                    }
                    else if (Joueur.position.X < Position.X)
                    {
                        Position.X -= 0.25f;
                    }

                    if (Joueur.position.Y > Position.Y)
                    {
                        Position.Y += 0.25f;
                    }
                    else if (Joueur.position.Y < Position.Y)
                    {
                        Position.Y -= 0.25f;
                    }
                }
                else
                {
                    if (Joueur.position.X > Position.X)
                    {
                        Position.X += 0.25f;
                    }
                    else
                    {
                        Position.X -= 0.25f;
                    }
                }
                #endregion
            }

            //Decalement du Rectangle de collsion en conséquence du sens de l'ennemi
            if (recPerso.X > RecZombie.X)
            {
                flip = SpriteEffects.FlipHorizontally; RecZombie.X -= 50;
            }
            else
            {
                flip = SpriteEffects.None; RecZombie.X += 50;
            }

            #region Gestion Des Objects Collisionnable
            if (ObjCollisionnable != null)
            {
                foreach (ObjCollisionable O in ObjCollisionnable)
                {
                    O.Update(this, Joueur.position);
                }
            }
            #endregion

            #region Animation Selon l'environnement
            if (Killed)
            {
                APZ.PlayAnimation(Dead);
            }
            else if (recPerso.Intersects(RecZombie))
            {
                //Si touche a scie
                //Si touche pendant attack
                if (Joueur.attack || Joueur.jump)
                {
                    Killed = true;
                }

                else
                {
                    Remove      = true;
                    Joueur.hurt = true;
                }
            }

            else if (!Attack)
            {
                APZ.PlayAnimation(Walking);
            }
            #endregion

            #region si touche à l'air
            if (RecZombie.Intersects(Joueur.recAir) && Joueur.tir)
            {
                Killed = true;
            }
            #endregion

            #region Clignotement Si tuer
            if (Killed)
            {
                CompteurDead++; if (CompteurDead == 200)
                {
                    Remove = true;
                }
                DeadColor.A -= 10;
                DeadColor.B -= 10;
                DeadColor.G -= 10;
                DeadColor.R -= 10;
            }
            #endregion

            if (Killed && !SoundOneTime)
            {
                SoundOneTime = true; Ressources.ZombieDie.Play(0.1f, -1f, 0f);
            }
        }
Example #2
0
 public void Update(Vector2 PosCamera, Perso_Speciaux.Kirby Joueur)
 {
     Position      = PosCamera;
     PersoSpeciaux = true;
 }