public void DrawGrid()
        {
#if EDITOR && WINDOWS
            if (UseGrid.get() && GridSize.get().X > 0 && GridSize.get().Y > 0)
            {
                Vector2 StartPos = new Vector2(
                    (float)Math.Floor(DrawCamera.getTopLeftCorner().X / GridSize.get().X) * GridSize.get().X
                    ,
                    (float)Math.Floor(DrawCamera.getTopLeftCorner().Y / GridSize.get().Y) * GridSize.get().Y
                    );
                //StartPos.X = Math.Max(StartPos.X, MinBoundary.X());
                //StartPos.Y = Math.Max(StartPos.Y, MinBoundary.Y());

                Vector2 EndPos = DrawCamera.getBottomRightCorner();
                //EndPos.X = Math.Min(EndPos.X, MaxBoundary.X());
                //EndPos.Y = Math.Min(EndPos.Y, MaxBoundary.Y());

                for (float x = StartPos.X; x < EndPos.X; x += GridSize.get().X)
                {
                    if (x >= MinBoundary.X() && x <= MaxBoundary.X())
                    {
                        Render.DrawLine(new Vector2(x, Math.Max(StartPos.Y, MinBoundary.Y())), new Vector2(x, Math.Min(EndPos.Y, MaxBoundary.Y())), GridColor * 0.5f, 1 / DrawCamera.getZoom());
                    }
                }
                for (float y = StartPos.Y; y < EndPos.Y; y += GridSize.get().Y)
                {
                    if (y >= MinBoundary.Y() && y <= MaxBoundary.Y())
                    {
                        Render.DrawLine(new Vector2(Math.Max(StartPos.X, MinBoundary.X()), y), new Vector2(Math.Min(EndPos.X, MaxBoundary.X()), y), GridColor * 0.5f, 1 / DrawCamera.getZoom());
                    }
                }
            }
            Render.DrawOutlineRect(MinBoundary.get(), MaxBoundary.get(), 1 / DrawCamera.getZoom(), Color.Red);
#endif
        }
Exemplo n.º 2
0
        private void TestTrigger(GameTime gameTime)
        {
            if (Used.get() && !AllowReset.get())
            {
                return;
            }
            if (TriggeringObject.get() != null && TestCollision((Basic3DObject)TriggeringObject.get()))
            {
                if (!Used.get())
                {
                    MyEvent.Trigger();
                    Used.set(true);
                }
                return;
            }

            if (Used.get())
            {
                ResetTime += gameTime.ElapsedGameTime.Milliseconds;
                if (ResetTime > ResetDelay.get())
                {
                    ResetTime = 0;
                    Used.set(false);
                }
            }
        }
 private void RealtimeChange()
 {
     if (RealtimeShadows.get() && UseShadows.get())
     {
         AddTag(GameObjectTag._3DPreDraw);
     }
     else
     {
         RemoveTag(GameObjectTag._3DPreDraw);
     }
 }
 public Vector3 getRandomPosition()
 {
     if (!Sphere.get())
     {
         return(Position.get() + Vector3.Transform(Rand.V3() / 2, ScaleMatrix));
     }
     else
     {
         return(Position.get() + Vector3.Transform(Rand.VECTV3() / 2, ScaleMatrix));
     }
 }
Exemplo n.º 5
0
 private void ClickDeferred()
 {
     if (UseDeferred.get())
     {
         AddTag(GameObjectTag._3DDeferredGBuffer);
     }
     else
     {
         RemoveTag(GameObjectTag._3DDeferredGBuffer);
     }
 }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            TimePrevious = Time;
            Time        += gameTime.ElapsedGameTime.Milliseconds;

            for (int i = 0; i < EventCount.get(); i++)
            {
                if (Time > Times[i].get() && TimePrevious < Times[i].get())
                {
                    Events[i].Trigger();
                }
            }

            if (Time > MaxTime)
            {
                if (Loop.get())
                {
                    Time = ResetTime.get();
                }
                else
                {
                    Triggered.set(false);
                }
            }

            base.Update(gameTime);
        }
Exemplo n.º 7
0
 private void Trigger()
 {
     if (Triggered.get())
     {
         AddTag(GameObjectTag.Update);
     }
     else
     {
         RemoveTag(GameObjectTag.Update);
     }
 }
Exemplo n.º 8
0
 public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
 {
     Game1.graphicsDevice.BlendState        = Additive.get() ? BlendState.Additive : BlendState.Opaque;
     Game1.graphicsDevice.DepthStencilState = DepthRead.get() ? DepthStencilState.DepthRead : DepthStencilState.Default;
     if (!Applied)
     {
         Applied = true;
         ApplyEffects();
     }
     base.Draw3D(camera, DrawTag);
 }
 private void ChangeWorldViewer()
 {
     if (IsWorldViewer.get())
     {
         AddTag(GameObjectTag.WorldViewer);
     }
     else
     {
         RemoveTag(GameObjectTag.WorldViewer);
     }
 }
Exemplo n.º 10
0
 private void ClickShadow()
 {
     if (CastShadow.get())
     {
         AddTag(GameObjectTag._3DShadow);
     }
     else
     {
         RemoveTag(GameObjectTag._3DShadow);
     }
 }
Exemplo n.º 11
0
        private void ChangeDead()
        {
#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
#endif
            {
                if (!Tags.Contains(GameObjectTag.Update))
                {
                    AddTag(GameObjectTag.Update);
                }

                if (Dead.get())
                {
                    lightState  = LightState.Dying;
                    FlickerMult = 1;
                    if (OldColor == Vector4.Zero && ColorParameter != null)
                    {
                        OldColor = ColorParameter.GetValueVector4();
                    }
                }
                else
                {
                    lightState  = LightState.Reviving;
                    FlickerMult = 0;
                }
            }
#if EDITOR && WINDOWS
            else
            {
                if (Dead.get())
                {
                    lightState = LightState.Dead;
                }
                else
                {
                    lightState = LightState.Alive;
                }
            }
#endif
        }
 private void AdditiveChange()
 {
     if (Additive.get())
     {
         RemoveTag(GameObjectTag._2DForward);
         AddTag(GameObjectTag._2DForward);
     }
     else
     {
         RemoveTag(GameObjectTag._2DForward);
         AddTag(GameObjectTag._2DForward);
     }
 }
        public override bool TriggerEvent(EventType Event, string[] args)
        {
            bool Passed = false;

            if (PassEvents.get())
            {
                foreach (GameObject g in HierarchyChildren)
                {
                    if (g.TriggerEvent(Event, args))
                    {
                        Passed = true;
                    }
                }
            }
            return(Passed);
        }
Exemplo n.º 14
0
 public override void Update(GameTime gameTime)
 {
     Timer += gameTime.ElapsedGameTime.Milliseconds;
     if (Timer > CinematicDelay.get())
     {
         Timer -= CinematicDelay.get();
         if (!NoInterpolate.get())
         {
             ParticleManager.CreateParticle(Position.get(), Logic.RLerp(MinVelocity.get(), MaxVelocity.get()), new Color(Logic.RLerp(MinColor.get(), MaxColor.get()) / 3), MathHelper.Lerp(MinSize.get(), MaxSize.get(), Rand.F()), ParticleType.get());
         }
         else
         {
             ParticleManager.CreateParticle(Position.get(), Logic.RLerp(MinVelocity.get(), MaxVelocity.get()), new Color(MinColor.get() / 3), MathHelper.Lerp(MinSize.get(), MaxSize.get(), Rand.F()), ParticleType.get());
         }
     }
     base.Update(gameTime);
 }
        public override void Update(GameTime gameTime)
        {
            if (Visible.get())
            {
                SizeMult += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * SizeChange.get();
                if (SizeMult > 1)
                {
                    SizeMult = 1;
                }
            }
            else
            {
                SizeMult -= gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * SizeChange.get();
                if (SizeMult < 0)
                {
                    SizeMult = 0;
                }
            }

            base.Update(gameTime);
        }
 private void NewProductionChange()
 {
     NewProduction = newProduction.get();
 }
        public override void  Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (MyEffect.get() == null)
                return;
            GraphicsDevice device = Game1.graphicsDevice;

            // Restore the vertex buffer contents if the graphics device was lost.
            if (vertexBuffer.IsContentLost)
            {
                vertexBuffer.SetData(particles);
            }

            if (NeedDurationChange && DurationParameter != null && ParticleDuration != null)
            {
                DurationParameter.SetValue(ParticleDuration.get());
                NeedDurationChange = false;
            }

            // If there are any particles waiting in the newly added queue,
            // we'd better upload them to the GPU ready for drawing.
            if (firstNewParticle != firstFreeParticle)
            {
                AddNewParticlesToVertexBuffer();
            }

            // If there are any active particles, draw them now!
            if (firstActiveParticle != firstFreeParticle)
            {
                Deferred3DEffect effect3D = (Deferred3DEffect)MyEffect.Holder;
                effect3D.SetFromCamera(camera);

                device.BlendState = Additive.get() ? BlendState.Additive : BlendState.AlphaBlend;
                device.DepthStencilState = UseDepth.get() ? DepthStencilState.DepthRead : DepthStencilState.None;

                effect3D.SetTextureSize(new Vector2(0.5f / device.Viewport.AspectRatio, -0.5f));
                effect3D.SetTime(Level.Time);
                device.SetVertexBuffer(vertexBuffer);
                device.Indices = indexBuffer;

                // Activate the particle effect.
                foreach (EffectPass pass in MyEffect.get().CurrentTechnique.Passes)
                {
                    pass.Apply();

                    if (firstActiveParticle < firstFreeParticle)
                    {
                        // If the active particles are all in one consecutive range,
                        // we can draw them all in a single call.
                        device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0,
                                                     firstActiveParticle * 4, (firstFreeParticle - firstActiveParticle) * 4,
                                                     firstActiveParticle * 6, (firstFreeParticle - firstActiveParticle) * 2);
                    }
                    else
                    {
                        // If the active particle range wraps past the end of the queue
                        // back to the start, we must split them over two draw calls.
                        device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0,
                                                     firstActiveParticle * 4, ((int)MaxParticles.get() - firstActiveParticle) * 4,
                                                     firstActiveParticle * 6, ((int)MaxParticles.get() - firstActiveParticle) * 2);

                        if (firstFreeParticle > 0)
                        {
                            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0,
                                                         0, firstFreeParticle * 4,
                                                         0, firstFreeParticle * 2);
                        }
                    }
                }
            }

            drawCounter++;
            base.Draw3D(camera, DrawTag);
        }
 private void UnitsCanTargetUnitsChange()
 {
     ShipsCanTargetShips = unitsCanTargetUnits.get();
 }
 private void TurretsCanTargetTurretsChange()
 {
     TurretsCanTargetTurrets = turretsCanTargetTurrets.get();
 }
 private void TurretLivesChange()
 {
     TurretLives = turretLives.get();
 }
 private void NewWavesChange()
 {
     NewWaves = newWaves.get();
 }
 private void IgnoreTurretBuildChange()
 {
     IgnoreTurretBuild = ignoreTurretBuild.get();
 }