Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IWorld"/> class.
        /// </summary>
        /// <param name="PhysicWorld">The physic world.</param>
        /// <param name="particleManager">The particle manager.</param>
        /// <param name="culler">The culler.</param>
        public I2DWorld(I2DPhysicWorld PhysicWorld, IParticleManager particleManager = null, I2DCuller culler = null)
        {
            if (PhysicWorld == null)
            {
                ActiveLogger.LogMessage("Physic World cannot be null", LogLevel.FatalError);
                Debug.Assert(PhysicWorld != null);
                throw new Exception("Physic World cannot be null");
            }

            if (culler == null)
            {
                this.culler = new Simple2DCuller();                
            }
            else
            {
                this.culler = culler;
            }
            this.culler.world = this;
            
            this.particleManager = particleManager;            
            this.PhysicWorld = PhysicWorld;                        
            Dummies = new List<IDummy>();            
            Objects = new List<I2DObject>();
            SoundEmiters2D = new List<ISoundEmitter2D>();
            CleanUpObjectsOnDispose = true;


#if !WINDOWS_PHONE && !REACH
            Lights2D = new List<PloobsEngine.Light2D.Light2D>();
#endif

        }
Esempio n. 2
0
        public IWorld(IPhysicWorld PhysicWorld, ICuller Culler, IParticleManager particleManager = null)
#endif
        {
            if (PhysicWorld == null)
            {
                ActiveLogger.LogMessage("Physic World cannot be null", LogLevel.FatalError);
                Debug.Assert(PhysicWorld != null);
                throw new Exception("Physic World cannot be null");
            }
            if (Culler == null)
            {
                ActiveLogger.LogMessage("Culler cannot be null", LogLevel.FatalError);
                Debug.Assert(Culler != null);
                throw new Exception("Culler cannot be null");
            }

            this.particleManager = particleManager;            
            this.PhysicWorld = PhysicWorld;            
            this.CameraManager = new CameraManager();            
            Dummies = new List<IDummy>();
            Lights = new List<ILight>();
            Objects = new List<IObject>();
            Triggers = new List<ITrigger>();
            SoundEmiters3D = new List<ISoundEmitter3D>();
            this.Culler = Culler;
            this.culler.world = this;
            CleanUpObjectsOnDispose = true;
#if WINDOWS
            this.multThreading = multiThread;
#endif
        }
Esempio n. 3
0
        /// <summary>
        /// Cleans up.
        /// </summary>
        public virtual void CleanUp()
        {
            Camera2D.CleanUp();

            foreach (var item in Objects.ToArray())
            {
                this.RemoveObject(item);
            }
            
            if (CleanUpObjectsOnDispose)
            {
                foreach (var item in Objects)
                {
                    item.CleanUp(graphicsFactory);
                }
            }

            

            foreach (var item in SoundEmiters2D.ToArray())
            {
                this.RemoveSoundEmitter(item);
            }
            

            foreach (var item in SoundEmiters2D)
            {
                item.CleanUp(graphicsFactory);
            }

            Objects.Clear();
            Camera2D = null;
            Dummies.Clear();
            SoundEmiters2D.Clear();
            particleManager = null;
            PhysicWorld = null;
            this.culler = null;
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IWorld"/> class.
 /// </summary>
 /// <param name="PhysicWorld">The physic world.</param>
 /// <param name="Culler">The culler.</param>
 /// <param name="particleManager">The particle manager.</param>
 /// <param name="multiThread">if set to <c>true</c> [mult thread].</param>
 public IWorld(IPhysicWorld PhysicWorld, ICuller Culler, IParticleManager particleManager = null,bool multiThread = false)
Esempio n. 5
0
        /// <summary>
        /// Cleans up.
        /// </summary>
        public virtual void CleanUp()
        {
            foreach (var item in this.CameraManager.GetCamerasDescription())
            {
                item.cam.CleanUp();
            }
            
            foreach (var item in SoundEmiters3D.ToArray())
            {
                this.RemoveSoundEmitter(item);
            }

            foreach (var item in Triggers.ToArray())
            {
                this.RemoveTrigger(item);
            }

            foreach (var item in Lights.ToArray())
            {
                this.RemoveLight(item);
            }


            if (CleanUpObjectsOnDispose)
            {
                foreach (var item in Objects.ToArray())
                {
                    this.RemoveObject(item);
                    item.CleanUp(graphicFactory);

                }
            }
            else
            {
                foreach (var item in Objects.ToArray())
                {
                    this.RemoveObject(item);
                }
            }

            

            foreach (var item in SoundEmiters3D)
            {
                item.CleanUp(graphicFactory);
            }

            Objects.Clear();
            Lights.Clear();            
            Dummies.Clear();
            this.culler = null;
            SoundEmiters3D.Clear();
            CameraManager = null;
            Triggers.Clear();
            if (particleManager != null)
            {
                particleManager.iCleanUp();
                particleManager = null;
            }
            this.PhysicWorld.iCleanUp();
            this.PhysicWorld = null;
        }