public override void GetOffsetAndHeading(out Vector offset, out Axis heading)
        {
            switch (FastRand.NextInteger(3))
            {
            case 0:
            {         // Left
                offset = new Vector(Width * -0.5f, FastRand.NextSingle(Height * -0.5f, Height * 0.5f));
                break;
            }

            case 1:
            {         // Top
                offset = new Vector(FastRand.NextSingle(Width * -0.5f, Width * 0.5f), Height * -0.5f);
                break;
            }

            case 2:
            {         // Right
                offset = new Vector(Width * 0.5f, FastRand.NextSingle(Height * -0.5f, Height * 0.5f));
                break;
            }

            default:
            {         // Bottom
                offset = new Vector(FastRand.NextSingle(Width * -0.5f, Width * 0.5f), Height * 0.5f);
                break;
            }
            }

            FastRand.NextUnitVector(out heading);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Main logic update function. Is called once per frame. Use this for all program logic and user inputs
        /// </summary>
        /// <param name="gameTime">Can use this to compute the delta between frames</param>
        /// <param name="isActive">The window status. If this is not the active window we shouldn't do anything</param>
        public void Update(GameTime gameTime, bool isActive)
        {
            if (!isActive)
            {
                return;
            }

            //Upd
            Input.Update(gameTime, Camera);

            //VolumeTexture.RotationMatrix = testEntity.WorldTransform.InverseWorld;
            //VolumeTexture.Scale = testEntity.WorldTransform.Scale;

            //Make the lights move up and down
            //for (var i = 2; i < PointLights.Count; i++)
            //{
            //    PointLight point = PointLights[i];
            //    point.Position = new Vector3(point.Position.X, point.Position.Y, (float)(Math.Sin(gameTime.TotalGameTime.TotalSeconds * 0.8f + i) * 10 - 13));
            //}

            //KeyInputs for specific tasks


            //If we are currently typing stuff into the console we should ignore the following keyboard inputs
            if (DebugScreen.ConsoleOpen)
            {
                return;
            }

            //Starts the "editor mode" where we can manipulate objects
            if (Input.WasKeyPressed(Keys.Space))
            {
                GameSettings.e_enableeditor = !GameSettings.e_enableeditor;
            }



            //Spawns a new light on the ground
            if (Input.keyboardState.IsKeyDown(Keys.L))
            {
                AddPointLight(position: new Vector3(FastRand.NextSingle() * 250 - 125, FastRand.NextSingle() * 50 - 25, FastRand.NextSingle() * 30 - 19),
                              radius: 20,
                              color: FastRand.NextColor(),
                              intensity: 40,
                              castShadows: false,
                              isVolumetric: true);
            }

            //Switch which rendertargets we show
            if (Input.WasKeyPressed(Keys.F1))
            {
                _renderModeCycle++;
                if (_renderModeCycle > Enum.GetNames(typeof(Renderer.Renderer.RenderModes)).Length - 1)
                {
                    _renderModeCycle = 0;
                }

                GameSettings.g_rendermode = (Renderer.Renderer.RenderModes)_renderModeCycle;
            }
        }
Exemplo n.º 3
0
        public override void GetOffsetAndHeading(out Vector offset, out Axis heading)
        {
            var vect = Axis * FastRand.NextSingle(Length * -0.5f, Length * 0.5f);

            offset = new Vector(vect.X, vect.Y);
            FastRand.NextUnitVector(out heading);
        }
Exemplo n.º 4
0
        public override void GetOffsetAndHeading(out Vector2 offset, out Axis heading)
        {
            offset = new Vector2(FastRand.NextSingle(Width * -0.5f, Width * 0.5f),
                                 FastRand.NextSingle(Height * -0.5f, Height * 0.5f));

            FastRand.NextUnitVector(out heading);
        }
Exemplo n.º 5
0
        public override void GetOffsetAndHeading(out Vector offset, out Axis heading)
        {
            var angle = Direction.Map((x, y) => (float)Math.Atan2(y, x));

            angle = FastRand.NextSingle(angle - Spread / 2f, angle + Spread / 2f);

            offset  = Vector.Zero;
            heading = new Axis((float)Math.Cos(angle), (float)Math.Sin(angle));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Main logic update function. Is called once per frame. Use this for all program logic and user inputs
        /// </summary>
        /// <param name="gameTime">Can use this to compute the delta between frames</param>
        /// <param name="isActive">The window status. If this is not the active window we shouldn't do anything</param>
        public void Update(GameTime gameTime, bool isActive)
        {
            if (!isActive)
            {
                return;
            }

            //Upd
            Input.Update(gameTime, Camera);

            if (GameSettings.s_rotateModel)
            {
                truck1.AngleZ += 0.5f * gameTime.ElapsedGameTime.TotalSeconds;
                truck2.AngleZ += 0.5f * gameTime.ElapsedGameTime.TotalSeconds;
            }
            //Make the lights move up and down
            //for (var i = 2; i < PointLights.Count; i++)
            //{
            //    PointLight point = PointLights[i];
            //    point.Position = new Vector3(point.Position.X, point.Position.Y, (float)(Math.Sin(gameTime.TotalGameTime.TotalSeconds * 0.8f + i) * 10 - 13));
            //}

            //KeyInputs for specific tasks

            //If we are currently typing stuff into the console we should ignore the following keyboard inputs
            if (DebugScreen.ConsoleOpen)
            {
                return;
            }

            //Starts the "editor mode" where we can manipulate objects
            //Spawns a new light on the ground
            if (Input.keyboardState.IsKeyDown(Keys.L))
            {
                AddPointLight(position: new Vector3(FastRand.NextSingle() * 250 - 125, FastRand.NextSingle() * 50 - 25, FastRand.NextSingle() * 30 - 19),
                              radius: 20,
                              color: FastRand.NextColor(),
                              intensity: 10,
                              castShadows: false,
                              isVolumetric: true);
            }

            //Switch which rendertargets we show
            if (Input.WasKeyPressed(Keys.F1))
            {
                _renderModeCycle++;
                if (_renderModeCycle > 11)
                {
                    _renderModeCycle = 0;
                }

                switch (_renderModeCycle)
                {
                }
            }
        }
Exemplo n.º 7
0
        public override void GetOffsetAndHeading(out Vector offset, out Axis heading)
        {
            var dist = FastRand.NextSingle(0f, Radius);

            FastRand.NextUnitVector(out heading);

            offset = Radiate == CircleRadiation.In
                ? new Vector(-heading.X * dist, -heading.Y * dist)
                : new Vector(heading.X * dist, heading.Y * dist);

            if (Radiate == CircleRadiation.None)
            {
                FastRand.NextUnitVector(out heading);
            }
        }
Exemplo n.º 8
0
        public override void GetOffsetAndHeading(out Vector offset, out Axis heading)
        {
            var rand = FastRand.NextInteger((int)(2 * Width + 2 * Height));

            if (rand < Width) // Top
            {
                offset = new Vector(FastRand.NextSingle(Width * -0.5f, Width * 0.5f), Height * -0.5f);
            }
            else if (rand < 2 * Width) // Bottom
            {
                offset = new Vector(FastRand.NextSingle(Width * -0.5f, Width * 0.5f), Height * 0.5f);
            }
            else if (rand < 2 * Width + Height) // Left
            {
                offset = new Vector(Width * -0.5f, FastRand.NextSingle(Height * -0.5f, Height * 0.5f));
            }
            else // Right
            {
                offset = new Vector(Width * 0.5f, FastRand.NextSingle(Height * -0.5f, Height * 0.5f));
            }

            FastRand.NextUnitVector(out heading);
        }