Esempio n. 1
0
        public override void PostRender(Scene s, Matrix4 VP)
        {
            if (game.GameStats.CastFilling > 0 && game.GameStats.CurrentCast != null && game.GameStats.CastMetal > -1)
            {
                UpdateCastMatrix();
                Matrix4 fillModelspace = Matrix4.CreateScale(1, 1, game.GameStats.CastFilling * game.GameStats.CurrentCast.FillHeight) * fillMatrix * Modelspace;

                ISimpleShader shader;
                if (game.GameStats.CastingTemprature > 25)
                {
                    shader = LiquidShader.Instance;
                    shader.Bind();
                    LiquidShader.Instance.UseTexture();
                    LiquidShader.Instance.AutoPan();
                    LiquidShader.Instance.SetEmission(Util.DefaultEmission);
                }
                else
                {
                    shader = BasicShader.Instance;
                    shader.Bind();
                }

                shader.SetModelspaceMatrix(fillModelspace);
                shader.SetMVP(fillModelspace * VP);
                shader.SetColor(KnownMetal.GetColor(game.GameStats.CastMetal));
                fill.Draw();
            }

            if (game.TooltipHelper.GetOwner() == this)
            {
                game.TooltipHelper.RenderNormalDialog(Input.OrthoMouseX, Input.OrthoMouseY, Util.White60);
            }
        }
Esempio n. 2
0
        public void RenderBlade(Matrix4 VP, float x, float y, float z, float zRot, float[] heat, Vector3 eyePos)
        {
            Matrix4     modelspace = Type.MeshScaleMatrix * Matrix4.CreateRotationZ(zRot) * Matrix4.CreateTranslation(x, y, z);
            BladeShader Instance   = BladeShader.Instance;

            Instance.Bind();
            Instance.SetModelspaceMatrix(modelspace);
            Instance.SetMVP(modelspace * VP);
            Instance.SetColor(KnownMetal.GetColor(Metal));
            UpdateHeatMap(heat);
            Instance.SetMaps(sharpnessMap, heatMap);
            Instance.SetEyePos(eyePos);
            Type.Mesh.Draw();

            BasicShader Instance0 = BasicShader.Instance;

            Instance0.Bind();
            for (int i = 0; i < Type.Points.Length; i++)
            {
                Matrix4 diamondModelspace = Matrix4.CreateTranslation(Type.Points [i], -0.15f + (float)Math.Sin(Time.CurrentTime() * 4 + Type.Points [i] * Util.PI) * 0.03f, 0) * modelspace;
                Instance0.SetModelspaceMatrix(diamondModelspace);
                Instance0.SetMVP(diamondModelspace * VP);
                Instance0.SetColor(Sharpness[i] < 0.95f?diamondColor * (1 - Sharpness[i]) + sharperDiamondColor * Sharpness[i]:sharpDiamondColor);
                MeshCollection.Diamond.Draw();
            }
        }
Esempio n. 3
0
        public void AddMetal(int metal, float purity, float amount)
        {
            if (amount <= 0)
            {
                return;
            }

            KnownMetal m = KnownMetal.Metals [metal];

            color        = totalAmount * color + amount * m.Color;
            totalAmount += amount;
            color       /= totalAmount;

            impurity += (1 - purity) * amount;

            if (m.MeltingPoint - 15 > highestMeltingPoint)
            {
                highestMeltingPoint = m.MeltingPoint - 15;
            }

            for (int i = 0; i < metals.Count; i++)
            {
                if (metals [i].Metal == metal)
                {
                    metals [i].Amount += amount;
                    return;
                }
            }
            metals.Add(new MetalMass(metal, amount));
        }
Esempio n. 4
0
        public override void Update(Scene s)
        {
            UpdateDialog();
            if (Input.PourKeyPressed & game.TooltipHelper.GetOwner() == this)
            {
                if (game.GameStats.CurrentCast != null & game.GameStats.FoundryAlloy != null && game.GameStats.FoundryAlloy.Amount >= game.GameStats.CurrentCast.GetVolume() - 0.005f &
                    game.GameStats.CastFilling <= 0 & game.GameStats.FoundryTemprature > game.GameStats.FoundryAlloy.GetMeltingPoint())
                {
                    Alloy input = game.GameStats.FoundryAlloy;

                    float      bestPurity = 0;
                    KnownMetal bestMetal  = null;

                    foreach (KnownMetal metal in KnownMetal.Metals)
                    {
                        if (metal == null)
                        {
                            continue;
                        }
                        float newPurity = metal.GetPurityFrom(input);
                        if (newPurity > metal.GetMinimumPurity() & newPurity > bestPurity)
                        {
                            bestPurity = newPurity;
                            bestMetal  = metal;
                        }
                    }

                    if (bestMetal != null)
                    {
                        game.GameStats.CastMetal       = bestMetal.Id;
                        game.GameStats.CastMetalPurity = bestPurity;

                        game.GameStats.CastFilling       = 0.01f;
                        game.GameStats.OldFoundryAmount  = game.GameStats.FoundryAlloy.Amount;
                        game.GameStats.CastingTemprature = game.GameStats.FoundryTemprature;
                    }
                    else
                    {
                        game.ErrortipHelper.ShowError(Localization.GetLocalization("ui.error.notanalloy"), 200, 500, 2, false);
                    }
                }
            }

            if (game.GameStats.CastFilling > 0 & game.GameStats.CastFilling < 1)
            {
                game.GameStats.CastFilling += Time.Delta();
                if (game.GameStats.CastFilling >= 1)
                {
                    game.GameStats.CastFilling = 1;
                }
                game.GameStats.FoundryAlloy.SetAmount(game.GameStats.OldFoundryAmount - game.GameStats.CurrentCast.GetVolume() * game.GameStats.CastFilling);
            }

            if (game.GameStats.CastingTemprature > 25)
            {
                game.GameStats.CastingTemprature -= Time.Delta() * 150;
            }
        }
Esempio n. 5
0
        public override void RenderItem(float x, float y, float width, float height)
        {
            BladeShader Instance = BladeShader.Instance;

            Instance.Bind();
            Instance.SetMVP(OrthoRenderEngine.GetMVPForMesh(Type.CenteredScaledMeshMatirx * ItemMatrix, x + 4, y + 4, width - 8, height - 8));
            Instance.SetModelspaceMatrix(OrthoRenderEngine.DefaultModelspace);
            Instance.SetColor(KnownMetal.GetColor(Metal));
            Instance.SetMaps(sharpnessMap);
            Type.Mesh.Draw();
        }
Esempio n. 6
0
        public void UpdateHeatMap(float[] heat)
        {
            GL.BindTexture(TextureTarget.Texture1D, heatMap);
            var buffer = new byte[heatPixelSize * heatPixelCount];

            for (int i = 0; i < heatPixelCount; i++)
            {
                float pHeat = 0;
                for (int j = 0; j < heat.Length; j++)
                {
                    pHeat += Math.Max(0, heat [j] * (1 - 8 * Math.Abs(Type.Points [j] - (i / (heatPixelCount - 1f)))));
                }
                buffer [i * heatPixelSize]     = (byte)(KnownMetal.GetRedEmmission(Metal, pHeat) * 25);
                buffer [i * heatPixelSize + 1] = (byte)(KnownMetal.GetGreenEmmission(Metal, pHeat) * 25);
            }
            GL.TexImage1D <byte> (TextureTarget.Texture1D, 0, PixelInternalFormat.Rg8, heatPixelCount, 0, PixelFormat.Rg, PixelType.UnsignedByte, buffer);
        }
Esempio n. 7
0
        public override void PostRender(Scene s, Matrix4 VP)
        {
            if (game.GameStats.FoundryAlloy.Amount >= 0.01f)
            {
                Matrix4       m = Matrix4.CreateScale(1, 1, game.GameStats.FoundryAlloy.Amount) * liquidTransform * Modelspace;
                ISimpleShader shader;
                if (game.GameStats.FoundryTemprature > game.GameStats.FoundryAlloy.GetMeltingPoint())
                {
                    shader = LiquidShader.Instance;
                    shader.Bind();
                    LiquidShader.Instance.UseTexture();
                    LiquidShader.Instance.AutoPan();
                    LiquidShader.Instance.SetEmission(Util.DefaultEmission);
                }
                else
                {
                    shader = BasicShader.Instance;
                    shader.Bind();
                }

                shader.SetModelspaceMatrix(m);
                shader.SetMVP(m * VP);
                shader.SetColor(game.GameStats.FoundryAlloy.GetColor());
                molten.Draw();
            }

            if (game.GameStats.CastFilling > 0 & game.GameStats.CastFilling <1 & game.GameStats.CastMetal> -1)
            {
                LiquidShader shader = LiquidShader.Instance;
                shader.Bind();
                shader.SetModelspaceMatrix(Modelspace);
                shader.SetMVP(Modelspace * VP);
                shader.SetColor(KnownMetal.GetColor(game.GameStats.CastMetal));
                shader.UseTexture();
                shader.AutoPan();
                shader.SetEmission(Util.DefaultEmission);
                fall.Draw();
            }

            if (game.TooltipHelper.GetOwner() == this)
            {
                game.TooltipHelper.RenderNormalDialog(Input.OrthoMouseX, Input.OrthoMouseY, Util.White60);
            }
        }
Esempio n. 8
0
 void UpdateDialog()
 {
     if (game.Player.IsLookingAt(this))
     {
         if (game.TooltipHelper.ClaimIfPossible(this))
         {
             game.TooltipHelper.Writer.Resize(300, 20 * 16 + 10);
             prevVal = -1;
         }
         if (game.TooltipHelper.GetOwner() == this && prevVal != (prevVal = (int)game.GameStats.FoundryTemprature))
         {
             game.TooltipHelper.Writer.Clear();
             int y = 20;
             if (game.GameStats.CurrentCast == null)
             {
                 game.TooltipHelper.Writer.DrawString(Localization.GetLocalization("ui.tooltip.nocast"), 0, 0, Color.White);
             }
             else
             {
                 game.TooltipHelper.Writer.DrawString(game.GameStats.CurrentCast.GetTooltipName(), 0, 0, Color.White);
                 game.TooltipHelper.Writer.DrawString(Localization.GetLocalization("ui.tooltip.volume:") + game.GameStats.CurrentCast.GetVolume() + " " + Localization.GetLocalization("ui.tooltip.unit.ingot" + ((int)game.GameStats.CurrentCast.GetVolume() == 1 ? "" : ".plural")), 0, 20, Color.Green);
                 y += 20;
                 if (game.GameStats.CastFilling > 0)
                 {
                     if (game.GameStats.CastFilling >= 1)
                     {
                         if (game.GameStats.CastingTemprature > 25)
                         {
                             game.TooltipHelper.Writer.DrawString("The casting is too hot (" + (int)game.GameStats.CastingTemprature + "°C)", 0, 40, Color.Red);
                         }
                         else
                         {
                             game.TooltipHelper.Writer.DrawString("Hit " + Input.GetKeyName(Input.INTERACTKEY) + " to pick up the casting", 0, 40, Color.Green);
                         }
                     }
                     else
                     {
                         game.TooltipHelper.Writer.DrawString("Casting...", 0, 40, Color.Red);
                     }
                     y += 20;
                 }
                 else if (game.GameStats.FoundryAlloy.Amount >= game.GameStats.CurrentCast.GetVolume() - 0.005f)
                 {
                     y += 20;
                     if (game.GameStats.FoundryTemprature < game.GameStats.FoundryAlloy.GetMeltingPoint())
                     {
                         game.TooltipHelper.Writer.DrawString("The foundry is too cold", 0, 40, Color.Red);
                     }
                     else
                     {
                         game.TooltipHelper.Writer.DrawString("Hit " + Input.GetKeyName(Input.POURKEY) + " to pour", 0, 40, Color.Red);
                         game.TooltipHelper.Writer.DrawString("Foundry contents:", 0, 60, Color.Green);
                         y += 20;
                         for (int i = 0; i < game.GameStats.FoundryAlloy.MetalCount; i++)
                         {
                             KnownMetal m = game.GameStats.FoundryAlloy [i];
                             game.TooltipHelper.Writer.DrawString((int)(game.GameStats.FoundryAlloy.GetMetalFraction(i) * 100 + .5f) / 100f + " " + m.Name + " (molten)", 10, y, Util.GetColorFromVector(m.Color));
                             y += 20;
                         }
                     }
                 }
                 else
                 {
                     game.TooltipHelper.Writer.DrawString(Localization.GetLocalization("ui.tooltip.notenoughmoltenmetal"), 0, 40, Color.Red);
                     y += 20;
                 }
             }
             if (y + 10 != game.TooltipHelper.Writer.Height)
             {
                 game.TooltipHelper.Writer.Resize(300, y + 10);
             }
         }
     }
     else if (game.TooltipHelper.GetOwner() == this)
     {
         game.TooltipHelper.UnClaim();
     }
 }
Esempio n. 9
0
 public Part(KnownMetal metal, float amount) : this(metal.Id, amount)
 {
 }
Esempio n. 10
0
 public IngotItem(KnownMetal metal, float purity) : this(metal.Id, purity)
 {
 }
Esempio n. 11
0
        public void UpdateView(Scene s)
        {
            transition.UpdateTransition(Time.Delta() * 2);

            if (Input.CloseKeyPressed)
            {
                OnAnvilNotUsed();
                game.SetView(parentView);
                return;
            }
            if (Input.InteractKeyPressed | Input.MousePressed & Input.OrthoMouseX > 50 & Input.OrthoMouseX < 300 & Input.OrthoMouseY > 50 & Input.OrthoMouseY < 300)
            {
                game.SetView(table);
                table.OnTableUsed(heat, blade);
                OnAnvilNotUsed();
                return;
            }

            for (int i = 0; i < heat.Length; i++)
            {
                if (heat[i] > 25)
                {
                    heat [i] -= Time.Delta() * (i == diamond? 100 : 200);
                }
            }

            if (!hammerDown && Input.MousePressed & hammerMove <0.3f& Input.OrthoMouseX> OrthoRenderEngine.GetCanvasWidth() / 2 - 100 & Input.OrthoMouseX <OrthoRenderEngine.GetCanvasWidth() / 2 + 100 &
                                                                                                                                                           Input.OrthoMouseY> OrthoRenderEngine.GetCanvasHeight() / 2 - 70 & Input.OrthoMouseY < OrthoRenderEngine.GetCanvasHeight() / 2 + 70)
            {
                hammerDown = true;
                hammerX    = Util.NextFloat() - 0.5f;
                hammerY    = Util.NextFloat() - 0.5f;
            }

            if (hammerDown)
            {
                if (hammerMove < 1)
                {
                    hammerMove += Time.Delta() * 10;
                    if (hammerMove >= 1)
                    {
                        hammerDown = false;
                        hammerMove = 1;
                        if (diamond >= 0)
                        {
                            blade.Sharpness [diamond] = Math.Min(1, blade.Sharpness [diamond] + KnownMetal.GetRedEmmission(blade.Metal, heat[diamond]) * 0.01f * (1 - blade.Sharpness [diamond]));
                            blade.UpdateSharpnessMap();
                        }
                    }
                }
            }
            else if (hammerMove > 0)
            {
                hammerMove = Math.Max(0, hammerMove - Time.Delta() * 4);
            }

            if (Input.LeftKey)
            {
                panAngle -= (panAngle + 0.6f) * Time.Delta() * 3;
            }
            else if (Input.RightKey)
            {
                panAngle -= (panAngle - 0.6f) * Time.Delta() * 3;
            }
            else
            {
                panAngle -= panAngle * Time.Delta() * 3;
            }

            if (Input.DownKey)
            {
                panAngleY -= (panAngleY + 0.3f) * Time.Delta() * 3;
            }
            else if (Input.UpKey)
            {
                panAngleY -= (panAngleY - 0.28f) * Time.Delta() * 3;
            }
            else
            {
                panAngleY -= panAngleY * Time.Delta() * 3;
            }
        }
Esempio n. 12
0
 public Vector4 GetTooltipColor()
 {
     return(KnownMetal.GetColor(Metal));
 }
Esempio n. 13
0
 public string GetTooltipName()
 {
     return(KnownMetal.GetName(Metal) + Localization.GetLocalization("ui.blade." + Type.Name) + Localization.GetLocalization("ui.item.blade"));
 }