コード例 #1
0
ファイル: Level.cs プロジェクト: TurketSmash/NewTurkeySmash
        void Init(string backgroundName)
        {
            float Xwin = TurkeySmashGame.WindowSize.X;
            float Ywin = TurkeySmashGame.WindowSize.Y;

            switch (backgroundName)
            {
                case "Jeu\\level1\\background1":
                    #region Level 1

                    respawnPoint = new Vector2(Xwin * 0.510f, Ywin * 0.444f);
                    spawnPoints[0] = new Vector2(Xwin * 0.331f, Ywin * 0.528f);
                    spawnPoints[1] = new Vector2(Xwin * 0.729f, Ywin * 0.444f);
                    spawnPoints[2] = new Vector2(Xwin * 0.106f, Ywin * 0.537f);
                    spawnPoints[3] = new Vector2(Xwin * 0.621f, Ywin * 0.557f);

                    bodylist = new StaticPhysicsObject[5];

                    #region Sprites Loading

                    Sprite plateforme1Mid = new Sprite();
                    plateforme1Mid.Load(TurkeySmashGame.content, "Jeu\\level1\\plateforme1Mid");
                    Sprite plateforme1Left = new Sprite();
                    plateforme1Left.Load(TurkeySmashGame.content, "Jeu\\level1\\plateforme1Left");
                    //Sprite plateforme1Right = new Sprite();
                    //plateforme1Right.Load(TurkeySmashGame.content, "Jeu\\plateforme1Right");   //créé un bug CHELOU
                    Sprite plateforme2 = new Sprite();
                    plateforme2.Load(TurkeySmashGame.content, "Jeu\\level1\\plateforme2");

                    #endregion

                    #region Bodies

                    bodylist[0] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.111f, Ywin * 0.611f), 1, plateforme2);
                    bodylist[1] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.512f, Ywin * 0.515f), 1, plateforme2); //3 plateformes volantes
                    bodylist[2] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.735f, Ywin * 0.520f), 1, plateforme2);

                    bodylist[3] = new StaticPhysicsObject(world, new Vector2((Xwin / 2) - (plateforme1Mid.Width / 2) + (plateforme1Left.Width / 2), (2 * Ywin / 3) - (plateforme1Mid.Height / 2) - (plateforme1Left.Height / 2) + 1), 1, plateforme1Left); //partie gauche de la plateforme centrale
                    bodylist[4] = new StaticPhysicsObject(world, new Vector2(Xwin / 2, 2 * Ywin / 3), 1, plateforme1Mid); //partie central de la plateforme centrale
                    //bodylist[5] = new StaticPhysicsObject(world, new Vector2((Xwin/2) + (plateforme1Mid.Width/2) - (plateforme1Right.Width/2) -1,(2*Ywin/3)-(plateforme1Mid.Height /2) - (plateforme1Right.Height/2)+1), 1, plateforme1Right); //partie droite de la plateforme centrale

                    #endregion

                    #region Items

                    #endregion

                    #endregion
                    break;

                case "Jeu\\level2\\background2":
                    #region Level 2

                    respawnPoint = new Vector2(Xwin * 0.427f, Ywin * 0.417f);
                    spawnPoints[0] = new Vector2(Xwin * 0.328f, Ywin * 0.602f);
                    spawnPoints[1] = new Vector2(Xwin * 0.620f, Ywin * 0.602f);
                    spawnPoints[2] = new Vector2(Xwin * 0.463f, Ywin * 0.546f);
                    spawnPoints[3] = new Vector2(Xwin * 0.941f, Ywin * 0.638f);

                    bodylist = new StaticPhysicsObject[4];

                    #region Sprites Loading

                    Sprite plateforme3 = new Sprite();
                    plateforme3.Load(TurkeySmashGame.content, "Jeu\\level2\\plateforme3");
                    Sprite plateformeBlocBleu = new Sprite();
                    plateformeBlocBleu.Load(TurkeySmashGame.content, "Jeu\\level2\\plateformeBlocBleu");
                    Sprite plateformeBlocJaune = new Sprite();
                    plateformeBlocJaune.Load(TurkeySmashGame.content, "Jeu\\level2\\plateformeBlocJaune");
                    Sprite plateformeBlocRouge = new Sprite();
                    plateformeBlocRouge.Load(TurkeySmashGame.content, "Jeu\\level2\\plateformeBlocRouge");

                    #endregion

                    #region Bodies
                    bodylist[0] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.479f, Ywin * 0.741f), 1, plateforme3);
                    bodylist[1] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.861f + (plateformeBlocBleu.Width / 2), Ywin * 0.64f + plateformeBlocBleu.Height / 2), 1, plateformeBlocBleu);
                    bodylist[2] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.191f + (plateformeBlocJaune.Width / 2), Ywin * 0.457f + plateformeBlocJaune.Height / 2), 1, plateformeBlocJaune);
                    bodylist[3] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.383f + plateformeBlocRouge.Width / 2, Ywin * 0.55f + plateformeBlocRouge.Height / 2), 1, plateformeBlocRouge);

                    #endregion

                    #region Items
                    #endregion

                    #endregion
                    break;

                case "Jeu\\level3\\background3":
                    #region Level 3

                    respawnPoint = new Vector2(Xwin * 0.670f, Ywin * 0.400f);
                    spawnPoints[0] = new Vector2(Xwin * 0.176f, Ywin * 0.737f);
                    spawnPoints[1] = new Vector2(Xwin * 0.744f, Ywin * 0.400f);
                    spawnPoints[2] = new Vector2(Xwin * 0.677f, Ywin * 0.737f);
                    spawnPoints[3] = new Vector2(Xwin * 0.431f, Ywin * 0.742f);

                    bodylist = new StaticPhysicsObject[4];

                    #region Sprites Loading

                    Sprite plateformePrincipale = new Sprite();
                    plateformePrincipale.Load(TurkeySmashGame.content, "Jeu\\level3\\plateforme1");
                    Sprite plateformes = new Sprite();
                    plateformes.Load(TurkeySmashGame.content, "Jeu\\level3\\plateforme2");

                    #endregion

                    #region Bodies
                    bodylist[0] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.484f, Ywin * 0.860f), 1, plateformePrincipale);
                    bodylist[1] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.810f + (plateformes.Width / 2), Ywin * 0.465f + plateformes.Height / 2), 1, plateformes);
                    bodylist[2] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.578f + (plateformes.Width / 2), Ywin * 0.495f + plateformes.Height / 2), 1, plateformes);
                    bodylist[3] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.330f + plateformes.Width / 2, Ywin * 0.350f + plateformes.Height / 2), 1, plateformes);
                    bodylist[1].body.Rotation = MathHelper.ToRadians(90);
                    bodylist[3].body.Rotation = MathHelper.ToRadians(45);
                    #endregion

                    #region Items
                    #endregion

                    #endregion
                    break;

                case "Jeu\\level4\\background4":
                    #region Level 4

                    respawnPoint = new Vector2(Xwin * 0.5f, Ywin * 0.2f);
                    spawnPoints[0] = new Vector2(Xwin * 0.150f, Ywin * 0.635f);
                    spawnPoints[1] = new Vector2(Xwin * 0.800f, Ywin * 0.635f);
                    spawnPoints[2] = new Vector2(Xwin * 0.350f, Ywin * 0.635f);
                    spawnPoints[3] = new Vector2(Xwin * 0.575f, Ywin * 0.635f);

                    bodylist = new StaticPhysicsObject[4];

                    #region Sprites Loading

                    Sprite plateformelvl4 = new Sprite();
                    plateformelvl4.Load(TurkeySmashGame.content, "Jeu\\level4\\plateformePrincipale");

                    #endregion

                    #region Bodies
                    bodylist[0] = new StaticPhysicsObject(world, new Vector2(Xwin * 0.5f, Ywin * 0.860f), 1, plateformelvl4);

                    #endregion

                    #region Items
                    #endregion

                    #endregion
                    break;
            }
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: TurketSmash/NewTurkeySmash
        public Level(World _world, string backgroundName, Character[] personnages, ContentManager content)
        {
            nextItemSpawn = ((OptionsCombat.itemSpawnMin + OptionsCombat.itemSpawnMax) / 2) * 1000; //init des premier spawn
            bonusSpawnMax = (int)(OptionsCombat.itemSpawnMax * 1.5f);
            bonusSpawnMin = (int)(OptionsCombat.itemSpawnMin * 1.5f);
            nextBonusSpawn = ((bonusSpawnMax + bonusSpawnMin) / 2) * 1000;
            this.world = _world;
            this.personnages = personnages;

            background = new Sprite();
            background.Load(content, backgroundName);

            football.Load(TurkeySmashGame.content, "Jeu\\level2\\football");
            caisseSprite.Load(TurkeySmashGame.content, "Jeu\\Objets\\caisse");
            blocSwag.Load(TurkeySmashGame.content, "Jeu\\level2\\blocSwag");
            pingpong.Load(TurkeySmashGame.content, "Jeu\\Objets\\PingPong");
            baguette.Load(TurkeySmashGame.content, "Jeu\\Objets\\baguette");
            pneu.Load(TurkeySmashGame.content, "Jeu\\Objets\\pneu");
            pq.Load(TurkeySmashGame.content, "Jeu\\Objets\\rouleauPQ");
            tv.Load(TurkeySmashGame.content, "Jeu\\Objets\\télé");

            dinde.Load(TurkeySmashGame.content, "Jeu\\Objets\\dinde");
            hamburger.Load(TurkeySmashGame.content, "Jeu\\Objets\\hamburger");
            raquette.Load(TurkeySmashGame.content, "Jeu\\Objets\\raquette");
            invincible.Load(TurkeySmashGame.content, "Jeu\\Objets\\invincible");

            animSortie = new AnimatedSpriteDef()
            {
                AssetName = "Jeu\\effets\\Ejection",
                FrameRate = 60,
                FrameSize = new Point(81, 100),
                Loop = false,
                NbFrames = new Point(7, 1),
            };

            Init(backgroundName);
        }
コード例 #3
0
ファイル: Level.cs プロジェクト: TurketSmash/NewTurkeySmash
        void gameFinished(Character personnage)
        {
            if (compteur > tempsAffichageFinDePartie)
                Basic.SetScreen(new EndGameScreen());
            else
                if (isFinish)
                {
                    finDePartie = new Sprite();
                    finDePartie.Load(TurkeySmashGame.content, "Menu1\\FR-PartieTerminée");
                    finDePartie.Position = new Vector2(TurkeySmashGame.WindowMid.X, TurkeySmashGame.WindowMid.Y);
                    if (gameOver)
                    {
                        gameOver = false;
                        gameOverSound.Play();
                    }
                }

            if (OptionsCombat.TypePartieSelect == "temps")
            {
                if (timer >= OptionsCombat.TempsPartie * 1000 * 60)
                {
                    isFinish = true;
                    timer = 0;
                    Results.SaveResults(tabScores, "temps");
                }
            }
            if (OptionsCombat.TypePartieSelect == "vie")
            {
                if (personnages[0] != null & personnages[1] == null & personnages[2] == null & personnages[3] == null |
                    personnages[0] == null & personnages[1] != null & personnages[2] == null & personnages[3] == null | //braaufganzuiafgnzfpuiazgfpauzfpaizfayi
                    personnages[0] == null & personnages[1] == null & personnages[2] != null & personnages[3] == null |
                    personnages[0] == null & personnages[1] == null & personnages[2] == null & personnages[3] != null)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        scoresLife[i][1] = tabScores[i][1];
                        scoresLife[i][2] = tabScores[i][2];
                    }
                    for (int i = 0; i < personnages.Length; i++)
                        if (personnages[i] != null)
                            Results.SaveResults(scoresLife, "vie");
                    isFinish = true;
                }
            }
        }