Esempio n. 1
0
        // ia AR avec sol avec aller et retour sur meme plateform
        public void collision_ia_AR_sol(IA_Manager_max ia, ref Platform_manager platform_m)
        {
            bool b, b2, b3, b4;
            int top, pos;
            for (int i = 0; i < ia.Ia_manage.Count; ++i) // pour chaque ia
            {
                b = false; top = 0; pos = 0;
                b2 = false; b3 = false; b4 = false;
                foreach (platform plato in platform_m.plato)// pour chaque platform
                {
                    //voir si l ia est sur la plaeform
                    if ((ia.Ia_manage[i].rectangle_C.Bottom >= plato.rectangle_C.Top && ia.Ia_manage[i].rectangle_C.Right >= plato.rectangle_C.Left &&
                        ia.Ia_manage[i].rectangle_C.Left <= plato.rectangle_C.Right && ia.Ia_manage[i].rectangle_C.Bottom - 9 <= plato.rectangle_C.Top))
                    {
                        b |= true;
                        top = plato.rectangle_C.Top;
                        // voir si l ia doit aller ds l autre sens
                        if (ia.Ia_manage[i].rectangle_C.Right + ia.Ia_manage[i].Speed / 3 > plato.rectangle_C.Right)
                        {
                            // verification si on est sur deux plateform a la fois donc on va ds la meme direction
                            foreach (platform plato2 in platform_m.plato)
                            {
                                b4 |= (plato != plato2 && ((ia.Ia_manage[i].rectangle_C.Bottom >= plato2.rectangle_C.Top && ia.Ia_manage[i].rectangle_C.Right >= plato2.rectangle_C.Left &&
                                    ia.Ia_manage[i].rectangle_C.Left <= plato2.rectangle_C.Right && ia.Ia_manage[i].rectangle_C.Bottom - 9 <= plato2.rectangle_C.Top)));
                            }
                            b2 ^= true;
                            pos = plato.rectangle_C.Right - ia.Ia_manage[i].rectangle_C.Width - ia.Ia_manage[i].decalageX - ia.Ia_manage[i].Speed - 1;

                        }
                        if (ia.Ia_manage[i].rectangle_C.Left - ia.Ia_manage[i].Speed / 3 < plato.rectangle_C.Left)
                        {
                            foreach (platform plato2 in platform_m.plato)
                            {
                                b4 |= (plato != plato2 && ((ia.Ia_manage[i].rectangle_C.Bottom >= plato2.rectangle_C.Top && ia.Ia_manage[i].rectangle_C.Right >= plato2.rectangle_C.Left &&
                                    ia.Ia_manage[i].rectangle_C.Left <= plato2.rectangle_C.Right && ia.Ia_manage[i].rectangle_C.Bottom - 9 <= plato2.rectangle_C.Top)));

                            }
                            b3 ^= true;
                            pos = plato.rectangle_C.Left + ia.Ia_manage[i].decalageX + ia.Ia_manage[i].Speed + 1;
                        }
                        break;
                    }
                }
                if (b)
                {
                    ia.Ia_manage[i].tombe = false;
                    ia.Ia_manage[i].rectangle.Y = top - ia.Ia_manage[i].rectangle_C.Height-15;

                }
                else
                    ia.Ia_manage[i].tombe = true;
                if (!b4 && (b2 || b3))
                {
                    ia.Ia_manage[i].dir = -ia.Ia_manage[i].dir;
                    ia.Ia_manage[i].rectangle.X = pos;
                }

            }
        }
Esempio n. 2
0
        public override void LoadContent(ContentManager Content, GraphicsDevice graph, ref string level, ref string next, GraphicsDeviceManager graphics)
        {
            width = graphics.PreferredBackBufferWidth;
            height = graphics.PreferredBackBufferHeight;
            _pause.initbutton(ref level);
            //background
            backgroundT = Content.Load<Texture2D>("level1//fond_niv1");
            //sprite brouillon
            alllenT = Content.Load<Texture2D>("hero//fiches_sprite_allen");
              //  alllenT = Content.Load<Texture2D>("yoh3");
            //platfom
            platform_t = Content.Load<Texture2D>("level1//platform");
            //ia
            aster = Content.Load<Texture2D>("IA//asteroid//asteroide-sprite");
            naruto_stalker = Content.Load<Texture2D>("IA//naruto");
            eve = Content.Load<Texture2D>("IA//eve");
            truc_jaune = Content.Load<Texture2D>("IA//tuc_jaune");

            //background
            scrolling1 = new Scrolling_H(backgroundT, new Rectangle(0, 0, width, height), back_sc);
            //sprite brouillon
            allen = new sprite_broillon(alllenT , new Rectangle(width / 2, 0, 125, 93), collision, Content,'1');
            //instanciement du manager d ia
            platform_M = new Platform_manager(platform_t, width * 0.1f, height * 0.1f, front_sc, height, width);
            //intenciement des 3 ia
            managerAA = new IA_manager_AA(truc_jaune, new Rectangle(0, 0, 100, 100), front_sc, 3, height, width);
            managerAR = new IA_manager_AR(eve, new Rectangle(0, 0, 100, 100), front_sc, 4, height, width);
            manageS = new IA_manager_S(naruto_stalker, new Rectangle(0, 0, 100, 100), front_sc, 3, height, width);
            //instancie les donnees de la pause
            _pause.LoadContent(Content);

                // ajout ia aller retour (X,Y)
                managerAR.Add(1.1f, 0);
               /*     managerAR.Add(0.5f, 0.5f);
                managerAR.Add(2.1f, 0.5f);
                managerAR.Add(-0.5f, 0f);
                managerAR.Add(2.1f, 0.45f);
                managerAR.Add(2.4f, 0.55f);
                managerAR.Add(3.2f, 0.7f);
                managerAR.Add(3.6f, 0.7f);
              */  // ajout IA qui vont tous droit(X,Y)
                managerAA.Add(1.11f, 0);
                managerAA.Add(0.54f, 0.5f);
                managerAA.Add(2.14f, 0.5f);
                managerAA.Add(-0.58f, 0f);
                managerAA.Add(2.3f, 0.45f);
                managerAA.Add(2.6f, 0.45f);
                managerAA.Add(3.2f, 0.7f);
                // ajout des ia Stalker (X,Y)
                manageS.Add(1.15f, 0);
                manageS.Add(2f, 0.7f);
                manageS.Add(2.1f, 0.45f);
                manageS.Add(3.2f, 0.7f);

            // ajout platform (position X,position Y, nombre de plateforme juxtaposer)
            platform_M.Add(0.4f, 0.8f, 9);
            platform_M.Add(1f, 0.7f, 9);
            platform_M.Add(1.86f, 0.9f, 10);
            platform_M.Add(-0.76f, 0.6f, 10);
            platform_M.Add(1.9f,0.6f,5);
            platform_M.Add(2.6f, 0.6f, 2);
            platform_M.Add(2.4f, 0.7f, 1);
            platform_M.Add(2.9f, 0.8f, 1);
            platform_M.Add(3f, 0.9f, 1);
            platform_M.Add(3.2f, 0.9f, 6);
            platform_M.Add(3.1f, 1f, 1);
        }
Esempio n. 3
0
        // collision sprite sol fini
        public bool Collision_sp_sol(ref sprite_broillon sprite, ref Platform_manager platform_m)
        {
            foreach (platform plato in platform_m.plato)
                if (sprite.rectangle_C.Bottom >= plato.rectangle_C.Top && sprite.rectangle_C.Right >= plato.rectangle_C.Left &&
                    sprite.rectangle_C.Left <= plato.rectangle_C.Right && sprite.rectangle_C.Bottom - 9 <= plato.rectangle_C.Top)
                {

                    sprite.rectangle.Y = plato.rectangle_C.Top - sprite.decalageY - sprite.rectangle_C.Height;

                    return true;
                }
            return false;
        }
Esempio n. 4
0
        //ia stalker
        // collision ia_sprite sol fini
        public void collision_ia_sol(IA_Manager_max ia, ref Platform_manager platform_m)
        {
            bool b;
            int top = 0;
            for (int i = 0; i < ia.Ia_manage.Count; ++i)
            {
                b = false;
                foreach (platform plato in platform_m.plato)
                {

                    if (!b && (ia.Ia_manage[i].rectangle_C.Bottom >= plato.rectangle_C.Top && ia.Ia_manage[i].rectangle_C.Right >= plato.rectangle_C.Left &&
                        ia.Ia_manage[i].rectangle_C.Left <= plato.rectangle_C.Right && ia.Ia_manage[i].rectangle_C.Bottom - 9 <= plato.rectangle_C.Top))
                    {
                        top = plato.rectangle_C.Top;
                        b |= true;
                    }
                }
                if (b)
                {
                    ia.Ia_manage[i].tombe = false;
                    ia.Ia_manage[i].rectangle.Y = top - ia.Ia_manage[i].rectangle_C.Height - ia.Ia_manage[i].decalageY;
                }
                else
                    ia.Ia_manage[i].tombe = true;
            }
        }