Exemplo n.º 1
0
        public override void Render(Scene scene)
        {
            Draw.Rect(0f, 0f, 320f, 180f, Color.Black);
            Level level = scene as Level;
            Color color = tint ?? (level.Session.Dreaming ? Color.Teal * 0.7f : Color.White);
            int   count = starCount ?? (level.Session.Dreaming ? 100 : 50);

            for (int i = 0; i < count; i++)
            {
                List <MTexture> starTextures = textures[stars[i].TextureSet];
                int             starFrame    = (int)((Math.Sin(stars[i].Timer) + 1.0) / 2.0 * starTextures.Count);
                starFrame %= starTextures.Count;
                Vector2  position      = stars[i].Position;
                MTexture frameToRender = starTextures[starFrame];
                if (level.Session.Dreaming)
                {
                    position.Y -= level.Camera.Y;
                    position.Y += falling * stars[i].Rate;
                    position.Y %= 180f;
                    if (position.Y < 0f)
                    {
                        position.Y += 180f;
                    }
                    for (int j = 0; j < colors.Length; j++)
                    {
                        frameToRender.Draw(position - Vector2.UnitY * j, center, colors[j]);
                    }
                }
                frameToRender.Draw(position, center, color);
            }
        }
Exemplo n.º 2
0
        public void RenderHair(On.Celeste.PlayerHair.orig_Render orig, PlayerHair self)
        {
            Player player = self.Entity as Player;

            if (player == null || self.GetSprite().Mode == PlayerSpriteMode.Badeline || Character == null)
            {
                orig(self);
                return;
            }
            if (Character.HasHair)
            {
                if (self.Sprite.HasHair)
                {
                    Vector2 origin = new Vector2(5f, 5f);
                    Color   color  = self.Border * self.Alpha;

                    Vector2 offset = new Vector2(Character.HairOffset.X * (self.GetHairScale(0).X > 0 ? 1 : -1), Character.HairOffset.Y);

                    if (self.DrawPlayerSpriteOutline)
                    {
                        Color   color2   = self.Sprite.Color;
                        Vector2 position = self.Sprite.Position;
                        self.Sprite.Color = color;

                        self.Sprite.Position = position + new Vector2(0f, -1f) + offset;
                        self.Sprite.Render();
                        self.Sprite.Position = position + new Vector2(0f, 1f) + offset;
                        self.Sprite.Render();
                        self.Sprite.Position = position + new Vector2(-1f, 0f) + offset;
                        self.Sprite.Render();
                        self.Sprite.Position = position + new Vector2(1f, 0f) + offset;
                        self.Sprite.Render();
                        self.Sprite.Color    = color2;
                        self.Sprite.Position = position;
                    }
                    self.Nodes[0] = self.Nodes[0].Floor();
                    if (color.A > 0)
                    {
                        for (int i = 0; i < self.Sprite.HairCount; i++)
                        {
                            MTexture hairTexture = self.GetHairTexture(i);
                            Vector2  hairScale   = self.GetHairScale(i);
                            hairTexture.Draw(self.Nodes[i] + new Vector2(-1f, 0f) + offset, origin, color, hairScale);
                            hairTexture.Draw(self.Nodes[i] + new Vector2(1f, 0f) + offset, origin, color, hairScale);
                            hairTexture.Draw(self.Nodes[i] + new Vector2(0f, -1f) + offset, origin, color, hairScale);
                            hairTexture.Draw(self.Nodes[i] + new Vector2(0f, 1f) + offset, origin, color, hairScale);
                        }
                    }
                    for (int num = self.Sprite.HairCount - 1; num >= 0; num--)
                    {
                        self.GetHairTexture(num).Draw(self.Nodes[num] + offset, origin, self.GetHairColor(num), self.GetHairScale(num));
                    }
                    if (Character.SpriteName.Contains("baldemonika"))
                    {
                        GFX.Game["characters/player/baldemonikaribbon"].Draw(self.Nodes[0] + offset - new Vector2(self.GetHairScale(0).X > 0 ? 1 : -1, 2), origin, Color.White, self.GetHairScale(0));
                    }
                }
            }
        }
        public override void Render()
        {
            if (!sprite.HasHair)
            {
                return;
            }

            Vector2 origin      = new Vector2(5f, 5f);
            Color   colorBorder = Border * Alpha;

            if (DrawPlayerSpriteOutline)
            {
                Color   colorSprite = sprite.Color;
                Vector2 position    = sprite.Position;
                sprite.Color    = colorBorder;
                sprite.Position = position + new Vector2(0f, -1f);
                sprite.Render();
                sprite.Position = position + new Vector2(0f, 1f);
                sprite.Render();
                sprite.Position = position + new Vector2(-1f, 0f);
                sprite.Render();
                sprite.Position = position + new Vector2(1f, 0f);
                sprite.Render();
                sprite.Color    = colorSprite;
                sprite.Position = position;
            }

            Nodes[0] = Nodes[0].Floor();
            if (colorBorder.A > 0)
            {
                for (int i = 0; i < sprite.HairCount; i++)
                {
                    int      hairFrame = sprite.HairFrame;
                    MTexture hair      = (i == 0) ? bangs[hairFrame] : GFX.Game["characters/player/hair00"];
                    Vector2  hairScale = GetHairScale(i);
                    hair.Draw(Nodes[i] + new Vector2(-1f, 0f), origin, colorBorder, hairScale);
                    hair.Draw(Nodes[i] + new Vector2(1f, 0f), origin, colorBorder, hairScale);
                    hair.Draw(Nodes[i] + new Vector2(0f, -1f), origin, colorBorder, hairScale);
                    hair.Draw(Nodes[i] + new Vector2(0f, 1f), origin, colorBorder, hairScale);
                }
            }

            for (int i = sprite.HairCount - 1; i >= 0; i--)
            {
                int      hairFrame = sprite.HairFrame;
                MTexture hair      = (i == 0) ? bangs[hairFrame] : GFX.Game["characters/player/hair00"];
                hair.Draw(Nodes[i], origin, GetHairColor(i), GetHairScale(i));
            }
        }
Exemplo n.º 4
0
        public override void Render()
        {
            PlayerSprite sprite = Sprite;

            if (!sprite.HasHair)
            {
                return;
            }

            Vector2 origin      = new Vector2(5f, 5f);
            Color   colorBorder = Border * Alpha;

            if (DrawPlayerSpriteOutline)
            {
                Color   colorSprite = sprite.Color;
                Vector2 position    = sprite.Position;
                sprite.Color    = colorBorder;
                sprite.Position = position + new Vector2(0f, -1f);
                sprite.Render();
                sprite.Position = position + new Vector2(0f, 1f);
                sprite.Render();
                sprite.Position = position + new Vector2(-1f, 0f);
                sprite.Render();
                sprite.Position = position + new Vector2(1f, 0f);
                sprite.Render();
                sprite.Color    = colorSprite;
                sprite.Position = position;
            }

            Nodes[0] = Nodes[0].Floor();
            if (colorBorder.A > 0)
            {
                for (int i = 0; i < sprite.HairCount; i++)
                {
                    MTexture hair      = GetHairTexture(i);
                    Vector2  hairScale = GetHairScale(i);
                    hair.Draw(Nodes[i] + new Vector2(-1f, 0f), origin, colorBorder, hairScale);
                    hair.Draw(Nodes[i] + new Vector2(1f, 0f), origin, colorBorder, hairScale);
                    hair.Draw(Nodes[i] + new Vector2(0f, -1f), origin, colorBorder, hairScale);
                    hair.Draw(Nodes[i] + new Vector2(0f, 1f), origin, colorBorder, hairScale);
                }
            }

            for (int i = sprite.HairCount - 1; i >= 0; i--)
            {
                MTexture hair = GetHairTexture(i);
                hair.Draw(Nodes[i], origin, GetHairColor(i), GetHairScale(i));
            }
        }
Exemplo n.º 5
0
        public override void Render()
        {
            base.Render();

            Holder.Draw(HolderPosition);
            CurBar.Draw(HolderPosition + BarOffset);
        }
Exemplo n.º 6
0
 public override void Render()
 {
     baseTexture.Draw(Position);
     if (currentMode == Modes.BUYHEART)
     {
         arrowTexture.Draw(Position + new Vector2(0x0F, 0x0C));
     }
     if (currentMode == Modes.ENTERSHOP)
     {
         shopTexture.Draw(Position + new Vector2(0x0C, 0x0C), Vector2.Zero, Color.White, 2f);
     }
     if (currentMode == Modes.BUYITEM)
     {
         arrowTexture.Draw(Position + new Vector2(0x0F, 0x0C));
         switch (itemBeingBought)
         {
         case GameData.Item.DOUBLEDICE:
             doubleDiceTexture.Draw(Position + new Vector2(0x16, 0x06));
             break;
         }
     }
     if (currentMode == Modes.BUYARBITRARY)
     {
         arrowTexture.Draw(Position + new Vector2(0x0F, 0x0C));
         arbitraryPurchase?.Draw(Position + new Vector2(0x16, 0x06));
     }
     base.Render();
 }
Exemplo n.º 7
0
        public static void RenderPlayer(On.Celeste.Player.orig_Render orig, Player self)
        {
            Vector2 renderPos = self.Sprite.RenderPosition;

            if (Settings.SkateboardEnabled)
            {
                self.Sprite.RenderPosition += SkateboardPlayerOffset;
            }
            if (Settings.DuckToDabEnabled && self.Ducking)
            {
                self.Sprite.RenderPosition += DabPlayerOffset;
            }

            orig(self);

            if (Settings.SkateboardEnabled)
            {
                Skateboard.Draw(
                    renderPos.Floor() + new Vector2(self.Facing == Facings.Left ? 9 : -8, -4),
                    Vector2.Zero, Color.White,
                    new Vector2(self.Facing == Facings.Left ? -1 : 1, 1)
                    );
            }

            if (Settings.SkateboardEnabled)
            {
                self.Sprite.RenderPosition -= SkateboardPlayerOffset;
            }
            if (Settings.DuckToDabEnabled && self.Ducking)
            {
                self.Sprite.RenderPosition -= DabPlayerOffset;
            }
        }
Exemplo n.º 8
0
        public virtual void Render()
        {
            texture.Draw(pos, new Vector2(0, 0), Color.White, scale);

            foreach (GUIElement child in children)
            {
                child.Render();
            }
            //if(t == TYPE.TileButton)
            //LevelEditor.fgtileicons[id].Draw(new Vector2(x+8, y+8), new Vector2(0, 0), Color.White, 2f, 0f, SpriteEffects.None);
        }
        public override void Render()
        {
            Vector2 vector = Position + new Vector2(128f, 120f);
            float   num    = Ease.CubeInOut(Math.Max(0f, turningScale));
            float   num2   = Ease.CubeInOut(Math.Abs(Math.Min(0f, turningScale)));

            if (SaveData.Instance.CheatMode)
            {
                MTN.FileSelect["cheatmode"].DrawCentered(vector + new Vector2(80f, 360f), Color.White, 1f, 1.57079637f);
            }
            if (SaveData.Instance.AssistMode)
            {
                MTN.FileSelect["assist"].DrawCentered(vector + new Vector2(100f, 370f), Color.White, 1f, 1.57079637f);
            }
            MTexture mtexture = MTN.Journal["edge"];

            mtexture.Draw(vector + new Vector2((float)-mtexture.Width, 0f), Vector2.Zero, Color.White, 1f, rotation);
            if (PageIndex > 0)
            {
                MTN.Journal[PrevPage.PageTexture].Draw(vector, Vector2.Zero, backColor, new Vector2(-1f, 1f), rotation);
            }
            if (turningPage)
            {
                MTN.Journal[NextPage.PageTexture].Draw(vector, Vector2.Zero, Color.White, 1f, rotation);
                Draw.SpriteBatch.Draw(NextPageBuffer, vector, new Rectangle?(NextPageBuffer.Bounds), Color.White, rotation, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            }
            if (turningPage && num2 > 0f)
            {
                MTN.Journal[Page.PageTexture].Draw(vector, Vector2.Zero, backColor, new Vector2(-1f * num2, 1f), rotation);
            }
            if (num > 0f)
            {
                MTN.Journal[Page.PageTexture].Draw(vector, Vector2.Zero, Color.White, new Vector2(num, 1f), rotation);
                //Page.Redraw(CurrentPageBuffer);
                Draw.SpriteBatch.Draw(CurrentPageBuffer, vector, new Rectangle?(CurrentPageBuffer.Bounds), Color.White, rotation, Vector2.Zero, new Vector2(num, 1f), SpriteEffects.None, 0f);
            }
            if (Pages.Count > 0)
            {
                int      count     = Pages.Count;
                MTexture mtexture2 = GFX.Gui["dot_outline"];
                int      num3      = mtexture2.Width * count;
                Vector2  value     = new Vector2(960f, 1040f - 40f * Ease.CubeOut(dotEase));
                for (int i = 0; i < count; i++)
                {
                    mtexture2.DrawCentered(value + new Vector2((float)(-(float)num3 / 2) + mtexture2.Width * (i + 0.5f), 0f), Color.White * 0.25f);
                }
                float x = 1f + Calc.YoYo(dot % 1f) * 4f;
                mtexture2.DrawCentered(value + new Vector2((float)(-(float)num3 / 2) + mtexture2.Width * (dot + 0.5f), 0f), Color.White, new Vector2(x, 1f));
                GFX.Gui["dotarrow_outline"].DrawCentered(value + new Vector2((float)(-(float)num3 / 2 - 50), 32f * (1f - Ease.CubeOut(leftArrowEase))), Color.White * leftArrowEase, new Vector2(-1f, 1f));
                GFX.Gui["dotarrow_outline"].DrawCentered(value + new Vector2(num3 / 2 + 50, 32f * (1f - Ease.CubeOut(rightArrowEase))), Color.White * rightArrowEase);
            }
        }
Exemplo n.º 10
0
        public override void Render()
        {
            if (DrawLerp > 0f)
            {
                float   y       = -56f * Ease.CubeIn(1f - DrawLerp);
                Level   level   = Scene as Level;
                Session session = level.Session;

                TimeSpan timeSpan2  = TimeSpan.FromTicks((long)((finalTime > 0 ? finalTime : level.RawTimeActive - MinigameEntity.startTime) * 10000000));
                string   timeString = timeSpan2.ToString("mm\\:ss\\.fff");
                timerBg.Draw(new Vector2(816, y));
                DrawTime(new Vector2(816 + 16f, y + 52f), timeString, 1f + wiggler.Value * 0.15f, session.StartedFromBeginning, level.Completed, session.BeatBestTime);
            }
        }
        /// <summary>
        /// Render function for display object.
        /// </summary>
        public override void Render()
        {
            if (!enabled)
            {
                return;
            }

            Y = Calc.Approach(Y, GetYPos(), 100f * Engine.RawDeltaTime);
            Vector2 basePos = Vector2.Lerp(new Vector2(-width, Y), new Vector2(0, Y), Ease.CubeOut(lerp)).Round();

            bg.Draw(new Vector2(basePos.X + width - bg.Width, basePos.Y));
            heartgem.Draw(new Vector2(basePos.X + 26, basePos.Y - 24), Vector2.Zero, Color.White, new Vector2(0.29f, 0.29f));
            x.Draw(new Vector2(basePos.X + 94, basePos.Y - 15));
            ActiveFont.DrawOutline(text, new Vector2(basePos.X + TEXT_PAD_L, basePos.Y - 23), Vector2.Zero, Vector2.One, Color.White, 2, Color.Black);
        }
        private void RenderDisplacement()
        {
            MTexture mTexture = GFX.Game["util/displacementBlock"];
            Color    color    = Color.White * 0.3f;

            for (var index1 = 0; (double)index1 < (double)Width; index1 += 128)
            {
                for (var index2 = 0; (double)index2 < (double)Height; index2 += 128)
                {
                    mTexture.GetSubtexture((int)(offX % 128.0), (int)(offY % 128.0),
                                           (int)Math.Min(128f, Width - index1), (int)Math.Min(128f, Height - index2), temp);
                    temp.Draw(Position + new Vector2(index1, index2), Vector2.Zero, color);
                }
            }
        }
Exemplo n.º 13
0
 public override void Render()
 {
     if (LevelEditor.selected == this)
     {
         selected.Draw(pos, new Vector2(0, 0), Color.White, scale);
     }
     else
     {
         unselected.Draw(pos, new Vector2(0, 0), Color.White, scale);
     }
     LevelEditor.fgtileicons[id].Draw(pos + new Vector2(8, 8), new Vector2(0, 0), Color.White, scale);
     foreach (GUIElement child in children)
     {
         child.Render();
     }
 }
Exemplo n.º 14
0
        public override void Render()
        {
            var basePos = Vector2.Lerp(new Vector2(0 - _width, Y), new Vector2(0, Y), Ease.CubeOut(_lerp)).Round();

            _bg.Draw(new Vector2(_width - _bg.Width + basePos.X, Y));


            if (_width > _bg.Width + basePos.X)
            {
                Draw.Rect(0, Y, _width - _bg.Width + basePos.X, 38f, Color.Black);
            }

            _skull.Draw(new Vector2(basePos.X + 26, Y - 24));
            _x.Draw(new Vector2(basePos.X + 94, Y - 15));

            ActiveFont.DrawOutline(_text, new Vector2(basePos.X + TextPadLeft, Y - 25f), Vector2.Zero, Vector2.One, Color.White, 2f, Color.Black);
        }
Exemplo n.º 15
0
        private void DrawPipe()
        {
            if (switchState != TrackSwitchState.None)
            {
                for (int i = 0; i <= length; i += 8)
                {
                    disabledTrackSprite.Draw(Position + new Vector2(Horizontal ? i : 0, Horizontal ? 0 : i), Vector2.Zero, Color.White * trackStatePercent);
                }
            }

            int trackpercent = (int)(trackStatePercent * (length + 2));

            for (int i = (int)Util.Mod(trackConstantLooping ? Scene.TimeActive * 14 : TrackOffset, 8) + trackpercent; i <= length; i += 8)
            {
                trackSprite.Draw(Position + new Vector2(Horizontal ? i : 0, Horizontal ? 0 : i));
            }
        }
Exemplo n.º 16
0
        public static void RenderPlayerSprite(On.Celeste.PlayerSprite.orig_Render orig, PlayerSprite self)
        {
            Player player = self.Entity as Player;

            if (player == null || self.Mode == PlayerSpriteMode.Badeline)
            {
                orig(self);
                return;
            }

            if (Settings.DuckToDabEnabled && player.Ducking)
            {
                Dab.Draw(
                    self.RenderPosition.Floor() + new Vector2(player.Facing == Facings.Left ? 6 : -6, -7),
                    Vector2.Zero, Color.White,
                    self.Scale
                    );
                return;
            }

            orig(self);
        }
        public override void Render()
        {
            if (!flagStyle)
            {
                return;
            }

            bool            activated    = EntityAs <EndPoint>().Activated;
            List <MTexture> mTextureList = activated ? numbersActive : numbersEmpty;
            MTexture        mTexture     = baseActive;

            if (!activated)
            {
                mTexture = Scene.BetweenInterval(0.25f) ? baseEmpty : baseToggle;
            }

            mTexture.Draw(offset - new Vector2(mTexture.Width / 2f - 1, mTexture.Height / 2f));

            mTextureList[0]
            .DrawJustified(offset + Vector2.UnitX + new Vector2(-1f, 1f), new Vector2(1f, 0.0f));
            mTextureList[1]
            .DrawJustified(offset + Vector2.UnitX + new Vector2(0.0f, 1f), new Vector2(0.0f, 0.0f));
        }
Exemplo n.º 18
0
 public override void Render()
 {
     foreach (TitleText titleText in title)
     {
         titleText.Render();
     }
     if (list != null)
     {
         list.Draw(new Vector2(160f, 260f), new Vector2(0f, 0f), Vector2.One, 1f, 0, listIndex);
     }
     if (impossibleEase > 0f)
     {
         MTexture mtexture = Presentation.Gfx["Guy Clip Art"];
         float    num      = 0.75f;
         mtexture.Draw(new Vector2(Width - mtexture.Width * num, Height - 640f * impossibleEase), Vector2.Zero, Color.White, num);
         Matrix transformationMatrix = Matrix.CreateRotationZ(-0.5f + Ease.CubeIn(1f - impossibleEase) * 8f) * Matrix.CreateTranslation(Width - 500, Height - 600, 0f);
         Draw.SpriteBatch.End();
         Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, transformationMatrix);
         ActiveFont.Draw(Presentation.GetCleanDialog("PAGE2_IMPOSSIBLE"), Vector2.Zero, new Vector2(0.5f, 0.5f), Vector2.One * (2f + (1f - impossibleEase) * 0.5f), Color.Black * impossibleEase);
         Draw.SpriteBatch.End();
         Draw.SpriteBatch.Begin();
     }
 }
Exemplo n.º 19
0
        public override void Render()
        {
            if (!flagStyle)
            {
                return;
            }

            bool            activated    = EntityAs <EndPoint>().Activated;
            List <MTexture> mTextureList = activated ? numbersActive : numbersEmpty;
            MTexture        mTexture     = baseActive;

            if (!activated)
            {
                mTexture = Scene.BetweenInterval(0.25f) ? baseEmpty : baseToggle;
            }

            // ReSharper disable once PossibleLossOfFraction
            mTexture.Draw(offset - new Vector2(mTexture.Width / 2 + 1, mTexture.Height / 2));

            mTextureList[0]
            .DrawJustified(numberOffset + new Vector2(-1f, 1f), new Vector2(1f, 0.0f));
            mTextureList[1]
            .DrawJustified(numberOffset + new Vector2(0f, 1f), new Vector2(0f, 0f));
        }
        private void BeforeRender()
        {
            List <Entity> glassBlocks = Scene.Tracker.GetEntities <CustomizableGlassBlock>();

            hasBlocks = (glassBlocks.Count > 0);
            if (!hasBlocks)
            {
                return;
            }

            Camera camera       = (Scene as Level).Camera;
            int    screenWidth  = 320;
            int    screenHeight = 180;

            // draw stars
            if (starsTarget == null)
            {
                starsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-surfaces", screenWidth, screenHeight);
            }

            Engine.Graphics.GraphicsDevice.SetRenderTarget(starsTarget);
            Engine.Graphics.GraphicsDevice.Clear(Color.Transparent);
            Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity);
            Vector2 origin = new Vector2(8f, 8f);

            for (int i = 0; i < stars.Length; i++)
            {
                MTexture starTexture        = stars[i].Texture;
                Color    starColor          = stars[i].Color * alpha;
                Vector2  starScroll         = stars[i].Scroll;
                Vector2  starActualPosition = default;
                starActualPosition.X = Mod(stars[i].Position.X - camera.X * (1f - starScroll.X), screenWidth);
                starActualPosition.Y = Mod(stars[i].Position.Y - camera.Y * (1f - starScroll.Y), screenHeight);
                starTexture.Draw(starActualPosition, origin, starColor);

                if (starActualPosition.X < origin.X)
                {
                    starTexture.Draw(starActualPosition + new Vector2(screenWidth, 0f), origin, starColor);
                }
                else if (starActualPosition.X > screenWidth - origin.X)
                {
                    starTexture.Draw(starActualPosition - new Vector2(screenWidth, 0f), origin, starColor);
                }

                if (starActualPosition.Y < origin.Y)
                {
                    starTexture.Draw(starActualPosition + new Vector2(0f, screenHeight), origin, starColor);
                }
                else if (starActualPosition.Y > screenHeight - origin.Y)
                {
                    starTexture.Draw(starActualPosition - new Vector2(0f, screenHeight), origin, starColor);
                }
            }
            Draw.SpriteBatch.End();

            // draw rays/beams
            int vertex = 0;

            for (int j = 0; j < rays.Length; j++)
            {
                Vector2 rayPosition = default;
                rayPosition.X = Mod(rays[j].Position.X - camera.X * 0.9f, screenWidth);
                rayPosition.Y = Mod(rays[j].Position.Y - camera.Y * 0.9f, screenHeight);
                DrawRay(rayPosition, ref vertex, ref rays[j]);
                if (rayPosition.X < 64f)
                {
                    DrawRay(rayPosition + new Vector2(screenWidth, 0f), ref vertex, ref rays[j]);
                }
                else if (rayPosition.X > (screenWidth - 64))
                {
                    DrawRay(rayPosition - new Vector2(screenWidth, 0f), ref vertex, ref rays[j]);
                }
                if (rayPosition.Y < 64f)
                {
                    DrawRay(rayPosition + new Vector2(0f, screenHeight), ref vertex, ref rays[j]);
                }
                else if (rayPosition.Y > (screenHeight - 64))
                {
                    DrawRay(rayPosition - new Vector2(0f, screenHeight), ref vertex, ref rays[j]);
                }
            }

            if (beamsTarget == null)
            {
                beamsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-beams", screenWidth, screenHeight);
            }

            Engine.Graphics.GraphicsDevice.SetRenderTarget(beamsTarget);
            Engine.Graphics.GraphicsDevice.Clear(Color.Transparent);
            GFX.DrawVertices(Matrix.Identity, verts, vertex);

            // if fading in, update the alpha value to fade in in ~0.25 seconds.
            if (alpha != 1f)
            {
                alpha = Calc.Approach(alpha, 1f, Engine.DeltaTime * 4f);
            }
        }
Exemplo n.º 21
0
        public void RenderPlayerSprite(On.Celeste.PlayerSprite.orig_Render orig, PlayerSprite self)
        {
            Player player = self.Entity as Player;

            if (player == null || self.Mode == PlayerSpriteMode.Badeline || Character == null || player.StateMachine.State == 9 || player.StateMachine.State == 5)
            {
                // state 9 is dreamdashing, state 5 is red bubble
                orig(self);
                return;
            }

            if (Settings.Mode == MadikaModuleChar.Invisible)
            {
                return;
            }

            AirDuck |= (player.Ducking && !player.OnSafeGround);

            AirDuck &= (!player.OnSafeGround && Input.MoveY == 1);

            bool ducking = player.Ducking || AirDuck;

            Color playerColor = player.Stamina < 20 && spriteflashing ? Color.Red : Color.White;

            //int widthFix = (Character.Sprite.Width / 2 + 2) * (player.Facing == Facings.Left ? 1 : -1);

            int dashes = player.Dashes;

            if (Character.HasWalkStillTextures)
            {
                Character.Sprite = GFX.Game[Character.SpriteName + "_" + (player.Speed.X == 0 ? "walk" : "still")];
            }

            if (Character.HasDashTextures)
            {
                Character.Sprite = GFX.Game[Character.SpriteName + "_" + dashes];
            }

            Vector2 renderPosition = new Vector2(self.RenderPosition.X, self.RenderPosition.Y).Floor();

            renderPosition.X += (1f - self.Scale.X) * (Character.Sprite.Width / 2);
            renderPosition.Y += (1f - self.Scale.Y) * (Character.Sprite.Height / 2);

            renderPosition.X -= Character.Sprite.Width / 4 + (player.Facing == Facings.Left ? 0 : Character.Sprite.Width / 2);

            if (Character.Sprite == GFX.Game["characters/player/o"])
            {
                renderPosition.Y += (float)Math.Cos(timePassed * 1.5);
            }



            if (player.Speed.X != 0 && player.OnSafeGround)
            {
                MTexture Body = new MTexture(Character.Sprite, new Rectangle(0, 0, Character.Sprite.Width, Character.Sprite.Height - Character.FootHeight));

                Body.Draw(
                    renderPosition + new Vector2(0, -Character.Sprite.Height),
                    Vector2.Zero, playerColor,
                    self.Scale
                    );

                if (player.Facing == Facings.Left)
                {
                    Character.LeftFoot.Draw(
                        renderPosition + new Vector2((OffsetFeet ? 0 : 1), -Character.FootHeight),
                        Vector2.Zero, playerColor,
                        self.Scale
                        );
                    Character.RightFoot.Draw(
                        renderPosition + new Vector2((OffsetFeet ? 1 : 0) - Character.RightFootX, -Character.FootHeight),
                        Vector2.Zero, playerColor,
                        self.Scale
                        );
                }
                else
                {
                    Character.LeftFoot.Draw(
                        renderPosition + new Vector2(-(OffsetFeet ? 1 : 0), -Character.FootHeight),
                        Vector2.Zero, playerColor,
                        self.Scale
                        );
                    Character.RightFoot.Draw(
                        renderPosition + new Vector2(-(OffsetFeet ? 0 : 1) + Character.RightFootX, -Character.FootHeight),
                        Vector2.Zero, playerColor,
                        self.Scale
                        );
                }
            }
            else
            {
                Character.Sprite.Draw(
                    renderPosition + new Vector2(0, -Character.Sprite.Height * (ducking ? 0.4f : 1f)),
                    Vector2.Zero, playerColor,
                    new Vector2(self.Scale.X, ducking ? 0.3f : self.Scale.Y)
                    );
            }
        }
Exemplo n.º 22
0
 public override void Render()
 {
     texture.Draw(Position);
     base.Render();
 }
Exemplo n.º 23
0
        public override void Render()
        {
            if (!(drawLerp <= 0f) && fadeTime > 0f)
            {
                // get next best rank time
                string nextRankName      = GetNextRank(out float nextRankTime);
                string currentTimeString = TimeSpan.FromTicks(GetSpentTime()).ShortGameplayFormat();
                string rankTimeString    = TimeSpan.FromSeconds(nextRankTime).ShortGameplayFormat();

                float scale = 1f + wiggler.Value * 0.15f;

                Vector2 currentTimeSize = new Vector2(getTimeWidth(currentTimeString, scale), numberHeight);
                Vector2 rankTimeSize    = new Vector2(getTimeWidth(rankTimeString), numberHeight) * targetTimeScale;

                if (CollabModule.Instance.Settings.SpeedBerryTimerPosition == CollabSettings.SpeedBerryTimerPositions.TopCenter)
                {
                    // Current time
                    drawTime(new Vector2(Position.X - (currentTimeSize.X / 2), Y + currentTimeSize.Y * lineSeparationFactor),
                             currentTimeString, rankColors[nextRankName], 1f + wiggler.Value * 0.15f, 1f);
                    float fontOffset = Dialog.Language.Font.Face != "Renogare" ? -2f * targetTimeScale : 0f;

                    if (nextRankName != "None")
                    {
                        if (startChapterTimer == -1)
                        {
                            string silverRankTimeString = TimeSpan.FromSeconds(TrackedBerry.SilverTime).ShortGameplayFormat();
                            string bronzeRankTimeString = TimeSpan.FromSeconds(TrackedBerry.BronzeTime).ShortGameplayFormat();
                            drawNextRankTimeTopCenter(nextRankName, new Vector2(-320, 0), rankTimeString, rankTimeSize, fontOffset);
                            drawNextRankTimeTopCenter("Silver", new Vector2(0, 0), silverRankTimeString, new Vector2(getTimeWidth(silverRankTimeString), numberHeight) * targetTimeScale, fontOffset);
                            drawNextRankTimeTopCenter("Bronze", new Vector2(320, 0), bronzeRankTimeString, new Vector2(getTimeWidth(bronzeRankTimeString), numberHeight) * targetTimeScale, fontOffset);
                        }
                        else
                        {
                            drawNextRankTimeTopCenter(nextRankName, Vector2.Zero, rankTimeString, rankTimeSize, fontOffset);
                        }
                    }
                    else
                    {
                        // draw "time ran out!" text
                        ActiveFont.DrawOutline(Dialog.Clean($"collabutils2_speedberry_timeranout"),
                                               new Vector2(Position.X, Y + fontOffset),
                                               new Vector2(0.5f, 1f), Vector2.One * targetTimeScale, rankColors[nextRankName], 2f, Color.Black);
                    }
                }
                else
                {
                    // Current time
                    Vector2 timerOffset = startChapterTimer == -1 ? new Vector2(0, 70) : Vector2.Zero;
                    bg.Draw(new Vector2(Position.X - 568 + currentTimeSize.X, Y + currentTimeSize.Y * lineSeparationFactor - 45) + timerOffset);
                    drawTime(new Vector2(Position.X, Y + currentTimeSize.Y * lineSeparationFactor) + timerOffset,
                             currentTimeString, rankColors[nextRankName], 1f + wiggler.Value * 0.15f, 1f);

                    float fontOffset = Dialog.Language.Font.Face != "Renogare" ? -2f : 0f;

                    if (nextRankName != "None")
                    {
                        // draw next best rank time
                        if (startChapterTimer == -1)
                        {
                            string silverRankTimeString = TimeSpan.FromSeconds(TrackedBerry.SilverTime).ShortGameplayFormat();
                            string bronzeRankTimeString = TimeSpan.FromSeconds(TrackedBerry.BronzeTime).ShortGameplayFormat();
                            drawNextRankTimeTopLeft(nextRankName, Vector2.Zero, rankTimeString, rankTimeSize, fontOffset);
                            drawNextRankTimeTopLeft("Silver", new Vector2(0, 35), silverRankTimeString, new Vector2(getTimeWidth(silverRankTimeString), numberHeight) * targetTimeScale, fontOffset);
                            drawNextRankTimeTopLeft("Bronze", new Vector2(0, 70), bronzeRankTimeString, new Vector2(getTimeWidth(bronzeRankTimeString), numberHeight) * targetTimeScale, fontOffset);
                        }
                        else
                        {
                            drawNextRankTimeTopLeft(nextRankName, Vector2.Zero, rankTimeString, rankTimeSize, fontOffset);
                        }
                    }
                    else
                    {
                        // draw "time ran out!" text
                        bg.Draw(new Vector2(Position.X - 392 + ActiveFont.Measure(Dialog.Clean($"collabutils2_speedberry_timeranout")).X *targetTimeScale,
                                            Y - 32), Vector2.Zero, Color.White, 0.7f);

                        ActiveFont.DrawOutline(Dialog.Clean($"collabutils2_speedberry_timeranout"),
                                               new Vector2(Position.X + 3, Y + fontOffset),
                                               new Vector2(0f, 1f), Vector2.One * targetTimeScale, rankColors[nextRankName], 2f, Color.Black);
                    }
                }
            }
        }
Exemplo n.º 24
0
        private void Render(On.Celeste.SpeedrunTimerDisplay.orig_Render orig, SpeedrunTimerDisplay self)
        {
            SpeedrunToolSettings settings = SpeedrunToolModule.Settings;

            if (!settings.Enabled || settings.RoomTimerType == RoomTimerType.Off || self.DrawLerp <= 0f)
            {
                orig(self);
                return;
            }

            RoomTimerType roomTimeType  = SpeedrunToolModule.Settings.RoomTimerType;
            RoomTimerData roomTimerData = roomTimeType == RoomTimerType.NextRoom ? nextRoomTimerData : currentRoomTimerData;

            string roomTimeString = roomTimerData.TimeString;
            string pbTimeString   = roomTimerData.PbTimeString;

            pbTimeString = "PB " + pbTimeString;

            const float topBlackBarWidth = 32f;
            const float topTimeHeight    = 38f;
            const float pbWidth          = 100;
            const float timeMarginLeft   = 32f;
            const float pbScale          = 0.6f;

            MTexture bg = GFX.Gui["strawberryCountBG"];
            float    x  = -300f * Ease.CubeIn(1f - self.DrawLerp);

            Draw.Rect(x, self.Y, topBlackBarWidth + 2, topTimeHeight, Color.Black);
            bg.Draw(new Vector2(x + topBlackBarWidth, self.Y));

            float roomTimeScale = 1f;

            if (roomTimerData.IsCompleted)
            {
                Wiggler wiggler = (Wiggler)self.GetFieldValue("wiggler");
                if (wiggler != null)
                {
                    roomTimeScale = 1f + wiggler.Value * 0.15f;
                }
            }

            SpeedrunTimerDisplay.DrawTime(new Vector2(x + timeMarginLeft, self.Y + 44f), roomTimeString, roomTimeScale,
                                          true,
                                          roomTimerData.IsCompleted, roomTimerData.BeatBestTime);

            if (roomTimerData.IsCompleted)
            {
                string comparePbString = ComparePb(roomTimerData.Time, roomTimerData.LastPbTime);
                DrawTime(
                    new Vector2(x + timeMarginLeft + SpeedrunTimerDisplay.GetTimeWidth(roomTimeString) + 10,
                                self.Y + 36f),
                    comparePbString, 0.5f,
                    roomTimerData.IsCompleted, roomTimerData.BeatBestTime);
            }

            // 遮住上下两块的间隙,游戏原本的问题
            Draw.Rect(x, self.Y + topTimeHeight - 1, pbWidth + bg.Width * pbScale, 1f, Color.Black);

            Draw.Rect(x, self.Y + topTimeHeight, pbWidth + 2, bg.Height * pbScale + 1f, Color.Black);
            bg.Draw(new Vector2(x + pbWidth, self.Y + topTimeHeight), Vector2.Zero, Color.White, pbScale);
            DrawTime(new Vector2(x + timeMarginLeft, (float)(self.Y + 66.4)), pbTimeString, pbScale, false, false, 0.6f);
        }
Exemplo n.º 25
0
        public override void Update()
        {
            base.Update();

            // pause menu
            if (pauseMenu != null)
            {
                pauseMenu.Update();
            }
            else if (!leaving && (Input.Pause.Pressed || Input.ESC.Pressed))
            {
                CreatePauseMenu();
            }
            pauseFade = Calc.Approach(pauseFade, pauseMenu != null ? 0.75f : 0f, Engine.DeltaTime * 6f);

            // Celeste锁帧60,而PCIO8锁帧30,此处dumb hack code目的是跳过一帧的Update
            // this is a pretty dumb hack but because Celeste is locked to 60fps
            // and PICO-8 runs at 30 ... we just skip every 2nd frame
            // the game buffers inputs so they wont get eaten
            skipFrame = !skipFrame;
            if (skipFrame)
            {
                return;
            }

            // don't update the game
            gameDelay -= Engine.DeltaTime;
            if (!gameActive || gameDelay > 0)
            {
                return;
            }

            // 重建PCIO 开机序列
            // recreating the PICO-8 Boot Sequence
            if (booting)
            {
                Engine.Graphics.GraphicsDevice.Textures[0] = null;
                Engine.Graphics.GraphicsDevice.Textures[1] = null;

                gameFrame++;
                var t = gameFrame - 20;

                //以下根据帧数刷新屏幕Color缓存

                if (t == 1)
                {
                    for (var y = 0; y < 128; y++)
                    {
                        for (var x = 2; x < 128; x += 8)
                        {
                            pixels[x + y * 128] = colors[Calc.Random.Next(4) + (y / 32)];
                        }
                    }
                    buffer.Target.SetData(pixels);
                }
                if (t == 4)
                {
                    for (var y = 0; y < 128; y += 2)
                    {
                        for (var x = 0; x < 128; x += 4)
                        {
                            pixels[x + y * 128] = colors[6 + (((x + y) / 8) & 7)];
                        }
                    }
                    buffer.Target.SetData(pixels);
                }
                if (t == 7)
                {
                    for (var y = 0; y < 128; y += 3)
                    {
                        for (var x = 2; x < 128; x += 4)
                        {
                            pixels[x + y * 128] = colors[10 + Calc.Random.Next(4)];
                        }
                    }
                    buffer.Target.SetData(pixels);
                }

                // wide
                if (t == 9)
                {
                    for (var y = 0; y < 128; y++)
                    {
                        for (var x = 1; x < 127; x += 2)
                        {
                            pixels[x + y * 128] = pixels[x + 1 + y * 128];
                        }
                    }
                    buffer.Target.SetData(pixels);
                }

                // stripe blank
                if (t == 12)
                {
                    for (var y = 0; y < 128; y++)
                    {
                        if ((y & 3) > 0)
                        {
                            for (var x = 0; x < 128; x++)
                            {
                                pixels[x + y * 128] = colors[0];
                            }
                        }
                    }
                    buffer.Target.SetData(pixels);
                }

                // clear
                if (t == 15)
                {
                    for (var y = 0; y < 128; y++)
                    {
                        for (var x = 0; x < 128; x++)
                        {
                            pixels[x + y * 128] = colors[0];
                        }
                    }
                    buffer.Target.SetData(pixels);
                }

                if (t == 30)
                {
                    Audio.Play(Sfxs.music_pico8_boot);
                }

                // logo
                if (t == 30 || t == 35 || t == 40)
                {
                    Engine.Graphics.GraphicsDevice.SetRenderTarget(buffer);
                    Engine.Graphics.GraphicsDevice.Clear(colors[0]);
                    Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, RasterizerState.CullNone);
                    picoBootLogo.Draw(new Vector2(1, 1));
                    if (t >= 35)
                    {
                        print("pico-8 0.1.9B", 1, 18, 6);
                    }
                    if (t >= 40)
                    {
                        print("(c) 2014-16 lexaloffle games llp", 1, 24, 6);
                        print("booting cartridge..", 1, 36, 6);
                    }
                    Draw.SpriteBatch.End();
                    Engine.Graphics.GraphicsDevice.SetRenderTarget(null);
                }

                // start it up
                if (t == 90)
                {
                    gameFrame = 0;
                    game      = new Classic();
                    game.Init(this);
                    if (bootLevel.X != 0 || bootLevel.Y != 0)
                    {
                        game.load_room(bootLevel.X, bootLevel.Y);
                    }
                }
            }
            else
            {
                //逻辑帧update
                gameFrame++;
                game.Update();

                if (game.freeze <= 0)
                {
                    // 绘制渲染帧
                    // draw
                    {
                        Engine.Graphics.GraphicsDevice.SetRenderTarget(buffer);
                        Engine.Graphics.GraphicsDevice.Clear(colors[0]);
                        Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, RasterizerState.CullNone, null, Matrix.CreateTranslation(-offset.X, -offset.Y, 0));
                        game.Draw();
                        Draw.SpriteBatch.End();

                        // unset in case we do a palette swap
                        Engine.Graphics.GraphicsDevice.SetRenderTarget(null);
                    }

                    // 调色板切换(改变场景色调)
                    // do a palette swap
                    // this could be done with a shader but on a 128x128 screen ... I don't really care
                    if (paletteSwap.Count > 0)
                    {
                        buffer.Target.GetData(pixels);

                        for (var i = 0; i < pixels.Length; i++)
                        {
                            var index = 0;
                            if (paletteSwap.TryGetValue(pixels[i], out index))
                            {
                                pixels[i] = colors[index];
                            }
                        }

                        buffer.Target.SetData(pixels);
                    }
                }
            }
        }