Exemple #1
0
        public JeuMenu()
        {
            StartTime = 0;
            Game1.Penumbra.Lights.Clear();
            Game1.Penumbra.Hulls.Clear();
            Game1.Penumbra.AmbientColor = Color.Black;

            _hud = new Hud(Game1.Screen);
            Map  = new Map(45, Game1.Screen.ClientBounds);
            // m_Joueur = null;

            System.Random r = new System.Random();
            Point         p;
            bool          ShouldRun = true;

            do
            {
                p = new Point(r.Next() % Map.Width, r.Next() % Map.Height);
                if (!Map[p.X, p.Y].IsSolid)
                {
                    if (m_Joueur?.Weapon == null)
                    {
                        m_Joueur  = new Joueur(p.X * Map.EntityPixelPerCase, p.Y * Map.EntityPixelPerCase, Map);
                        ShouldRun = false;
                    }
                    else
                    {
                        /*Joueur tempJ = new Joueur(p.X * Map.EntityPixelPerCase, p.Y * Map.EntityPixelPerCase, Map);
                         * for (int i = 0; i < m_Joueur.Weapon.Length; i++)
                         * {
                         *  switch (m_Joueur.Weapon[i].WeaponType)
                         *  {
                         *      case WeaponType.Pistol:
                         *          tempJ.Weapon[i] = new Pistol(tempJ);
                         *          break;
                         *      case WeaponType.AssaultRifle:
                         *          tempJ.Weapon[i] = new AssaultRifle(tempJ);
                         *          break;
                         *      case WeaponType.Shotgun:
                         *          tempJ.Weapon[i] = new Shotgun(tempJ);
                         *          break;
                         *      case WeaponType.SemiAutoSniper:
                         *          tempJ.Weapon[i] = new SemiAutomaticSniper(tempJ);
                         *          break;
                         *  }
                         * }
                         * m_Joueur = tempJ;*/
                        ShouldRun = false;
                    }
                }
            }while (ShouldRun);
            EntityManager.InitInstance(m_Joueur, Map, 0);


            /*Enemy e;
             * for (int i = 0; i < 10; i++)
             * Enemy e;
             * for (int i = 0; i < 10; i++)
             * {
             *
             *  p = new Point(r.Next() % Map.Width, r.Next() % Map.Height);
             *  if (!Map[p.X, p.Y].IsSolid)
             *  {
             *      e = new KamikazeRobot(p.X * Map.EntityPixelPerCase, p.Y * Map.EntityPixelPerCase, Map);
             *      EntityManager.Instance.Add(e);
             *  }
             *
             *
             * }
             */
            _wrapper = new KeyWrapper(0, 0, 0);
        }
        public void TickEntities(GameTime gameTime)
        {
            lock (someLock)
            {
                List <AbsEntity> toUpdate = _entities.ToList();

                foreach (AbsEntity e in toUpdate)
                {
                    e.Tick((int)gameTime.ElapsedGameTime.TotalMilliseconds);
                    ITexturable Texturable = e as ITexturable;
                    if (Texturable != null)
                    {
                        Texturable.UpdateTexture((int)gameTime.ElapsedGameTime.TotalMilliseconds);
                    }
                }
                if (Joueur != null && Joueur.IsDead == false)
                {
                    Joueur.UpdateTexture((int)gameTime.ElapsedGameTime.TotalMilliseconds);  //Tick(DeltaTime);
                }
                if (Joueur != null && Joueur.IsDead == false)
                {
                    Joueur.Tick((long)gameTime.ElapsedGameTime.TotalMilliseconds);
                }

                /*if (_deadFire.Count != 0)
                 * {
                 *  FireFireStopped(this, new MultiFireEventArgs(_deadFire.ToArray(), false));
                 *  _deadFire = new List<Fire>();
                 * }*/
                List <absProjectile> projli = EntityManager.Instance.ProjectilesListFriendly;
                List <absProjectile> projho = EntityManager.Instance.ProjectilesListHostile;

                lock (someLock)
                {
                    for (int i = projli.Count - 1; i >= 0; i--)
                    {
                        try
                        {
                            if (projli[i].Update(gameTime))
                            {
                                projli.RemoveAt(i);
                            }
                        }
                        catch
                        {
                        }
                    }
                    for (int i = projho.Count - 1; i >= 0; i--)
                    {
                        try
                        {
                            if (projho[i].Update(gameTime))
                            {
                                projho.RemoveAt(i);
                            }
                        }
                        catch
                        {
                        }
                    }
                    for (int i = this.Bonus.Count - 1; i >= 0; i--)
                    {
                        this.Bonus[i].Tick((long)gameTime.ElapsedGameTime.TotalMilliseconds);
                    }
                }
            }
        }