Example #1
0
        protected override void Initialize()
        {
            base.Initialize();

            this.CurrentEpisode = 0;

            if (WaveServices.Platform.IsEditor ||
                (string.IsNullOrEmpty(this.ShipEntityPath)) ||
                (string.IsNullOrEmpty(this.TerrainEntityPath)))
            {
                return;
            }

            this.randy = WaveServices.Random;

            this.shipComponent = this.Owner.Find(this.ShipEntityPath)?.FindComponent <ShipComponent>();
            this.terrain       = this.Owner.Find(this.TerrainEntityPath)?.FindComponent <TerrainMeshComponent>();

            this.networkService = WaveServices.GetService <Lunar3DNetworkService>();

            if (this.networkService != null)
            {
                this.networkService.ActionReveiced += this.OnActionReceived;
                this.networkService.OnReset        += this.OnReset;
                this.networkService.Updated        += this.OnUpdated;
                this.networkService.Rendered       += this.OnRendered;

                this.Owner.Scene.Pause();
                this.Owner.Scene.IsVisible = false;
            }
            else
            {
                this.Reset();
            }
        }
Example #2
0
 /// <summary>
 /// Resolves the dependencies.
 /// </summary>
 protected override void ResolveDependencies()
 {
     base.ResolveDependencies();
     this.rndService  = WaveServices.Random;
     this.Direction.X = (float)Math.Cos(this.rndService.NextInt());
     this.Direction.Y = (float)Math.Cos(this.rndService.NextInt());
 }
        /// <summary>
        /// Set the current settings to the particle system attached
        /// </summary>
        private void LoadParticleSystem()
        {
            this.random = WaveServices.Random;

            if (this.mesh != null)
            {
                if (this.mesh.IndexBuffer != null)
                {
                    this.GraphicsDevice.DestroyIndexBuffer(this.mesh.IndexBuffer);
                }

                if (this.mesh.VertexBuffer != null)
                {
                    this.GraphicsDevice.DestroyVertexBuffer(this.mesh.VertexBuffer);
                }

                this.mesh = null;
            }

            this.settings      = this.System;
            this.numParticles  = this.System.NumParticles;
            this.numPrimitives = this.numParticles * 2;
            this.numVertices   = this.numParticles * 4;
            this.numIndices    = this.numParticles * 6;
            this.particles     = new Particle[this.numParticles];

            // Create Indexbuffer
            ushort[] indices = new ushort[this.numIndices];

            for (int i = 0; i < this.numParticles; i++)
            {
                indices[(i * 6) + 0] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 1] = (ushort)((i * 4) + 2);
                indices[(i * 6) + 2] = (ushort)((i * 4) + 1);

                indices[(i * 6) + 3] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 4] = (ushort)((i * 4) + 3);
                indices[(i * 6) + 5] = (ushort)((i * 4) + 2);
            }

            IndexBuffer indexBuffer = new IndexBuffer(indices);

            // Initialize Particles
            for (int i = 0; i < this.numParticles; i++)
            {
                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life  = TimeSpan.FromMilliseconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalMilliseconds
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];
            DynamicVertexBuffer vertexBuffer = new DynamicVertexBuffer(VertexPositionColorTexture.VertexFormat);

            vertexBuffer.SetData(this.vertices, this.numVertices);

            this.mesh = new Mesh(0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }
Example #4
0
        public BridgeBehavior()
            : base("BridgeBehavior")
        {
            this.tables = new List<Entity>();

            this.secondsTime = 0;
            this.index = 0;
            this.random = WaveServices.Random;
            this.boxes = new List<Entity>(NUM_BOXES);
        }
Example #5
0
        public BridgeBehavior()
            : base("BridgeBehavior")
        {
            this.tables = new List <Entity>();

            this.secondsTime = 0;
            this.index       = 0;
            this.random      = WaveServices.Random;
            this.boxes       = new List <Entity>(NUM_BOXES);
        }
Example #6
0
        protected override void DefaultValues()
        {
            StartingLinesCount = 1;
            MaxLinesCount      = 10000;
            Size   = 200;
            lines  = new List <Line>();
            random = WaveServices.Random;

            l = new Line();
        }
Example #7
0
        protected override void DefaultValues()
        {
            base.DefaultValues();
            this.tables = new List <Entity>();

            this.secondsTime = 0;
            this.index       = 0;
            this.random      = WaveServices.Random;
            this.boxes       = new List <Entity>(NUM_BOXES);
            this.tableSize   = new Vector3(20, 1, 50);
            this.box_size    = Vector3.One;
        }
Example #8
0
        /// <summary>
        /// Initialize sound manager
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.random = WaveServices.Random;
            this.soundPlayer = WaveServices.SoundPlayer;

            this.bank = new SoundBank(this.Assets) { MaxConcurrentSounds = 40 };
            this.soundPlayer.RegisterSoundBank(this.bank);

            this.LoadSounds();
        }
Example #9
0
        public DrawableLines(int numOfLines)
            : base("DrawableLines")//, Layer.Opaque)
        {
            lines = new List<Line>();
            random = WaveServices.Random;

            l = new Line();

            for (int i = 0; i < numOfLines; i++)
            {
                AddNewLine();
            }
        }
Example #10
0
        public DrawableLines(int numOfLines)
            : base("DrawableLines")//, Layer.Opaque)
        {
            lines  = new List <Line>();
            random = WaveServices.Random;

            l = new Line();

            for (int i = 0; i < numOfLines; i++)
            {
                AddNewLine();
            }
        }
Example #11
0
        /// <summary>
        /// Initialize sound manager
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.random      = WaveServices.Random;
            this.soundPlayer = WaveServices.SoundPlayer;

            this.bank = new SoundBank(this.Assets)
            {
                MaxConcurrentSounds = 40
            };
            this.soundPlayer.RegisterSoundBank(this.bank);

            this.LoadSounds();
        }
Example #12
0
 public BoardGenerator()
 {
     this.candyColors = (CandyColors[])Enum.GetValues(typeof(CandyColors));
     this.random      = WaveServices.Random;
 }
 /// <summary>
 /// Resolves the dependencies.
 /// </summary>
 protected override void ResolveDependencies()
 {
     base.ResolveDependencies();
     this.rndService = WaveServices.Random;
     this.Direction.X = (float)Math.Cos(this.rndService.NextInt());
     this.Direction.Y = (float)Math.Cos(this.rndService.NextInt());
     this.Direction.Z = (float)Math.Cos(this.rndService.NextInt());
     this.color = this.GetRandomColor();
 }
Example #14
0
 protected override void Initialize()
 {
     base.Initialize();
     this.virtualScreenManager = this.Owner.Scene.VirtualScreenManager;
     this.randomService = WaveServices.Random;
 }
Example #15
0
 protected override void Initialize()
 {
     base.Initialize();
     this.virtualScreenManager = this.Owner.Scene.VirtualScreenManager;
     this.randomService        = WaveServices.Random;
 }
        protected override void DefaultValues()
        {
            base.DefaultValues();
            this.tables = new List<Entity>();

            this.secondsTime = 0;
            this.index = 0;
            this.random = WaveServices.Random;
            this.boxes = new List<Entity>(NUM_BOXES);
            this.tableSize = new Vector3(20, 1, 50);
            this.box_size = Vector3.One;
        }
        /// <summary>
        /// Set the current settings to the particle system attached
        /// </summary>
        private void LoadParticleSystem()
        {
            this.random = WaveServices.Random;

            if (this.mesh != null)
            {
                if (this.mesh.IndexBuffer != null)
                {
                    this.GraphicsDevice.DestroyIndexBuffer(this.mesh.IndexBuffer);
                }

                if (this.mesh.VertexBuffer != null)
                {
                    this.GraphicsDevice.DestroyVertexBuffer(this.mesh.VertexBuffer);
                }

                this.mesh = null;
            }

            this.settings = this.System;
            this.numParticles = this.System.NumParticles;
            this.numPrimitives = this.numParticles * 2;
            this.numVertices = this.numParticles * 4;
            this.numIndices = this.numParticles * 6;
            this.particles = new Particle[this.numParticles];

            // Sets the time passed between 2 particles creation.
            this.emitLapse = (this.settings.EmitRate > 0) ? 1000 / this.settings.EmitRate : 0;

            // Create Indexbuffer
            ushort[] indices = new ushort[this.numIndices];

            for (int i = 0; i < this.numParticles; i++)
            {
                indices[(i * 6) + 0] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 1] = (ushort)((i * 4) + 2);
                indices[(i * 6) + 2] = (ushort)((i * 4) + 1);

                indices[(i * 6) + 3] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 4] = (ushort)((i * 4) + 3);
                indices[(i * 6) + 5] = (ushort)((i * 4) + 2);
            }

            IndexBuffer indexBuffer = new IndexBuffer(indices);

            // Initialize Particles
            for (int i = 0; i < this.numParticles; i++)
            {
                double life = (this.settings.EmitRate > 0) ? -1 : TimeSpan.FromMilliseconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalMilliseconds;

                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life = life
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];

            // Initializes the coordinate textures of the vertices
            for (int i = 0; i < this.numVertices; i++)
            {
                this.vertices[i++].TexCoord = TEXCOORD1;
                this.vertices[i++].TexCoord = TEXCOORD2;
                this.vertices[i++].TexCoord = TEXCOORD3;
                this.vertices[i].TexCoord = TEXCOORD4;
            }

            DynamicVertexBuffer vertexBuffer = new DynamicVertexBuffer(VertexPositionColorTexture.VertexFormat);
            vertexBuffer.SetData(this.vertices, this.numVertices);

            this.mesh = new Mesh(0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }
        /// <summary>
        /// Set the current settings to the particle system attached
        /// </summary>
        private void LoadParticleSystem()
        {
            this.random = WaveServices.Random;

            if (this.mesh != null)
            {
                if (this.mesh.IndexBuffer != null)
                {
                    this.GraphicsDevice.DestroyIndexBuffer(this.mesh.IndexBuffer);
                }

                if (this.mesh.VertexBuffer != null)
                {
                    this.GraphicsDevice.DestroyVertexBuffer(this.mesh.VertexBuffer);
                }

                this.mesh = null;
            }

            this.settings = this.System;
            this.numParticles = this.System.NumParticles;
            this.numPrimitives = this.numParticles * 2;
            this.numVertices = this.numParticles * 4;
            this.numIndices = this.numParticles * 6;
            this.particles = new Particle[this.numParticles];

            // Create Indexbuffer
            ushort[] indices = new ushort[this.numIndices];

            for (int i = 0; i < this.numParticles; i++)
            {
                indices[(i * 6) + 0] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 1] = (ushort)((i * 4) + 2);
                indices[(i * 6) + 2] = (ushort)((i * 4) + 1);

                indices[(i * 6) + 3] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 4] = (ushort)((i * 4) + 3);
                indices[(i * 6) + 5] = (ushort)((i * 4) + 2);
            }

            IndexBuffer indexBuffer = new IndexBuffer(indices);            

            // Initialize Particles
            for (int i = 0; i < this.numParticles; i++)
            {
                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life = TimeSpan.FromMilliseconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalMilliseconds
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];
            DynamicVertexBuffer vertexBuffer = new DynamicVertexBuffer(VertexPositionColorTexture.VertexFormat);
            vertexBuffer.SetData(this.vertices, this.numVertices);

            this.mesh = new Mesh(0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }
Example #19
0
        /// <summary>
        /// Set the current settings to the particle system attached
        /// </summary>
        private void LoadParticleSystem()
        {
            this.random = WaveServices.Random;

            if (this.mesh != null)
            {
                if (this.mesh.IndexBuffer != null)
                {
                    this.GraphicsDevice.DestroyIndexBuffer(this.mesh.IndexBuffer);
                }

                if (this.mesh.VertexBuffer != null)
                {
                    this.GraphicsDevice.DestroyVertexBuffer(this.mesh.VertexBuffer);
                }

                this.mesh = null;
            }

            this.settings      = this.System;
            this.numParticles  = this.System.NumParticles;
            this.numPrimitives = this.numParticles * 2;
            this.numVertices   = this.numParticles * 4;
            this.numIndices    = this.numParticles * 6;
            this.particles     = new Particle[this.numParticles];

            // Sets the time passed between 2 particles creation.
            this.emitLapse = (this.settings.EmitRate > 0) ? 1000 / this.settings.EmitRate : 0;

            // Create Indexbuffer
            ushort[] indices = new ushort[this.numIndices];

            for (int i = 0; i < this.numParticles; i++)
            {
                indices[(i * 6) + 0] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 1] = (ushort)((i * 4) + 2);
                indices[(i * 6) + 2] = (ushort)((i * 4) + 1);

                indices[(i * 6) + 3] = (ushort)((i * 4) + 0);
                indices[(i * 6) + 4] = (ushort)((i * 4) + 3);
                indices[(i * 6) + 5] = (ushort)((i * 4) + 2);
            }

            IndexBuffer indexBuffer = new IndexBuffer(indices);

            // Initialize Particles
            for (int i = 0; i < this.numParticles; i++)
            {
                double life = (this.settings.EmitRate > 0) ? -1 : TimeSpan.FromMilliseconds(this.random.NextDouble() * (this.numParticles * InitTimeMultipler)).TotalMilliseconds;

                this.particles[i] = new Particle()
                {
                    Alive = true,
                    Life  = life
                };
            }

            this.vertices = new VertexPositionColorTexture[this.numVertices];

            // Initializes the coordinate textures of the vertices
            for (int i = 0; i < this.numVertices; i++)
            {
                this.vertices[i++].TexCoord = TEXCOORD1;
                this.vertices[i++].TexCoord = TEXCOORD2;
                this.vertices[i++].TexCoord = TEXCOORD3;
                this.vertices[i].TexCoord   = TEXCOORD4;
            }

            DynamicVertexBuffer vertexBuffer = new DynamicVertexBuffer(VertexPositionColorTexture.VertexFormat);

            vertexBuffer.SetData(this.vertices, this.numVertices);

            this.mesh = new Mesh(0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3, vertexBuffer, indexBuffer, PrimitiveType.TriangleList);
        }
Example #20
0
        protected override void DefaultValues()
        {
            StartingLinesCount = 1;
            MaxLinesCount = 10000;
            Size = 200;
            lines = new List<Line>();
            random = WaveServices.Random;

            l = new Line();
        }