Beispiel #1
0
        public void Update(ref Monkey SingeJoueur)
        {
            ConducteurAP.PlayAnimation(ConducteurA);
            TireurAP.PlayAnimation(TireurA);

            if (CptAvancementX < AvancementX)
            {
                Position.X     -= StaticInfo.SpeedMoto;
                CptAvancementX += StaticInfo.SpeedMoto;
            }

            RandomY    += 0.15f;
            Position.Y += (float)Math.Sin(RandomY) * 2;

            for (int i = 0; i < SingeJoueur.ListBananes.Count; i++)
            {
                if (SingeJoueur.ListBananes[i].RecCollision.Intersects(RecCollision))
                {
                    SingeJoueur.ListBananes[i].Delete = true;
                    CptDegat++;
                    ApplyDamage(1);
                }
            }

            CptTimerMissiles += StaticInfo.SpeedTimerMissile;
            if (CptTimerMissiles > 1)
            {
                Missiles.Add(new Missile(Position));
                CptTimerMissiles = 0;
            }

            for (int i = 0; i < Missiles.Count; i++)
            {
                Missiles[i].Update();

                for (int j = 0; j < SingeJoueur.ListBananes.Count; j++)
                {
                    if (SingeJoueur.ListBananes[j].RecCollision.Intersects(Missiles[i].RecCollision))
                    {
                        Missiles[i].Delete = true;
                        SingeJoueur.ListBananes[j].Delete = true;
                    }
                }

                if (Missiles[i].RecCollision.Intersects(SingeJoueur.RecCollision))
                {
                    SingeJoueur.ApplyDamage(StaticInfo.DamageMissile);
                    Missiles[i].Delete = true;
                }

                if (Missiles[i].Delete)
                {
                    Missiles.RemoveAt(i);
                    i--;
                }
            }

            if (CptDegat > 3)
            {
                Delete = true;
            }

            base.Udpate(RecCollision);
            RecCollision.X = (int)Position.X;
            RecCollision.Y = (int)(Position.Y - RecCollision.Height * 1.5f);
        }
Beispiel #2
0
        public void Update(ref Monkey SingeJoueur)
        {
            if (!ArriveADestination)
            {
                Position.X -= StaticInfo.SpeedCamion;
            }

            if (Position.X < StaticInfo.LimiteXCamion + DecalageX && ArriveADestination == false)
            {
                Position.X         = StaticInfo.LimiteXCamion + DecalageX;
                ArriveADestination = true;
            }

            RandomY    += 0.15f;
            Position.Y += (float)Math.Sin(RandomY) * 2;


            for (int i = 0; i < SingeJoueur.ListBananes.Count; i++)
            {
                if (SingeJoueur.ListBananes[i].RecCollision.Intersects(RecCollision))
                {
                    SingeJoueur.ListBananes[i].Delete = true;
                    CptDegat++;
                    ApplyDamage(1);
                    if (Life.CurrentLife < 0)
                    {
                        Delete = true;
                    }
                }
            }

            switch (CptDegat)
            {
            case 0: CamionAP.PlayAnimation(CamionPOD0); break;

            case 5: CamionAP.PlayAnimation(CamionPOD1); break;

            case 10: CamionAP.PlayAnimation(CamionPOD2); break;

            case 15: CamionAP.PlayAnimation(CamionPOD3); break;

            case 20: Delete = true; break;
            }


            RecCollision.X = ((int)(Position.X - RecCollision.Width / 2));
            RecCollision.Y = ((int)(Position.Y - RecCollision.Height));

            if (ArriveADestination && Motos.Count < MotoMax)
            {
                cptTimerMotos += StaticInfo.SpeedApparitionMoto;
                if (cptTimerMotos > 1)
                {
                    cptTimerMotos = 0;
                    Motos.Add(new Moto(Position));
                    Motos[Motos.Count - 1].SetDecalage();
                }
            }

            for (int i = 0; i < Motos.Count; i++)
            {
                Motos[i].Update(ref SingeJoueur);
                if (Motos[i].Delete)
                {
                    Motos.RemoveAt(i);
                    i--;
                }
            }
            base.Udpate(RecCollision);
        }