コード例 #1
0
        private void StartShadowSearchPanelAnimations()
        {
            Storyboard sb     = new Storyboard();
            var        to_top = Search_Grid.Margin.Top;

            if (to_top == 0)
            {
                return;
            }
            doubleAnimation = new DoubleAnimation {
                EasingFunction = new CubicEase {
                    EasingMode = EasingMode.EaseInOut
                },
                Duration = new Duration(TimeSpan.FromMilliseconds(1020)),
                From     = 0,
                To       = -to_top,
            };
            doubleAnimation.Completed += DoublAnimation_Completed;
            Storyboard.SetTarget(doubleAnimation, Search_Grid.RenderTransform as TranslateTransform);
            Storyboard.SetTargetProperty(doubleAnimation, "Y");
            sb.Children.Add(doubleAnimation);
            Out_ani.SpeedRatio = 0.5;
            SB.Begin();
            sb.Begin();
        }
コード例 #2
0
        public override void Draw(GameTime gameTime)
        {
            G.Clear(Color.Black);

            SB.Begin();
            SB.Draw(tWisp, G.Viewport.Bounds, Color.Lerp(Color.Transparent, Color.White, MathHelper.Clamp(et / TRANS_DURATION, 0, 1)));
            SB.End();
        }
コード例 #3
0
ファイル: RTSScreen.cs プロジェクト: Antr0py/VoxelRTS
        public override void Draw(GameTime gameTime)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (!pauseRender)
            {
                camera.Update(state.CGrid, RTSConstants.GAME_DELTA_TIME);
                renderer.Update(state);
                renderer.Draw(state, RTSConstants.GAME_DELTA_TIME);
            }
            else
            {
                G.Clear(Color.Black);
            }
            vInput.Draw(renderer, SB);
            DrawFPS(gameTime);
            game.DrawDevConsole();
            game.DrawMouse();

            if (tPopup != null)
            {
                SB.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
                SB.Draw(tPopup, rPopup, Color.White);
                SB.End();
            }

            if (end)
            {
                tl -= dt;
                if (tl < 0)
                {
                    State = ScreenState.ChangePrevious;
                }

                Vector2 center = new Vector2(G.Viewport.Width, G.Viewport.Height) * 0.5f;
                SB.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone);
                SB.Draw(
                    gResult < 0 ? tDefeat : tVictory,
                    center, null,
                    Color.Lerp(Color.Transparent, Color.White, MathHelper.Clamp(3f - tl, 0, 1)),
                    0f,
                    gResult < 0 ? ctD : ctV,
                    MathHelper.Lerp(0.3f, 1f, MathHelper.Clamp(3f - tl, 0, 1)),
                    SpriteEffects.None,
                    0f
                    );
                SB.End();
            }
            else if (state.gtC.VictoriousTeam.HasValue)
            {
                end     = true;
                tl      = 3f;
                gResult = state.gtC.VictoriousTeam.Value;
            }
        }
コード例 #4
0
ファイル: TestScene.cs プロジェクト: StrongCod3r/MGArkanoid
        public override void Draw(GameTime gameTime)
        {
            SB.Begin();
            //-------------------------------------

            paddleSprite.Draw(SB, 300, 200, 500, 300);

            //-------------------------------------
            SB.End();
            base.Draw(gameTime);
        }
コード例 #5
0
        public override void Draw(GameTime gameTime)
        {
            SB.Begin();
            //-------------------------------------
            SB.DrawSprite(backgrounTexture, new Rectangle(0, 0, Game.SCREEN_WIDTH, Game.SCREEN_HEIGHT), Color.White);

            //-------------------------------------
            SB.End();

            base.Draw(gameTime);
        }
コード例 #6
0
ファイル: RTSScreen.cs プロジェクト: Antr0py/VoxelRTS
 void DrawFPS(GameTime gameTime)
 {
     if (!DevConsole.IsActivated)
     {
         // Show FPS
         double fps = gameTime.ElapsedGameTime.TotalSeconds;
         fps = Math.Round(1000.0 / fps) / 1000.0;
         SB.Begin();
         SB.DrawString(sfDebug, fps + " / " + eFPS, Vector2.One * 10, Color.White);
         SB.End();
     }
 }
コード例 #7
0
        public override void Draw(GameTime gameTime)
        {
            G.Clear(Color.Black);
            if (ShouldRebuild)
            {
                Rebuild(fIn, fOut);
            }

            if (rtHeight != null)
            {
                SB.Begin();
                SB.Draw(rtHeight, G.Viewport.TitleSafeArea, Color.White);
                SB.End();
            }
        }
コード例 #8
0
 private void DrawLightning(LightningData data, float w)
 {
     SB.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone);
     for (int i = 0; i < data.Lines.Count;)
     {
         Vector2 s    = data.Lines[i++];
         Vector2 e    = data.Lines[i++];
         Vector2 d    = e - s;
         float   dist = d.Length();
         d /= dist;
         float r = (float)Math.Atan2(d.Y, d.X);
         SB.Draw(tLightning, s, rsLEndL, data.Color, r, originLEndL, new Vector2(w, w) * scaleLEnd, SpriteEffects.None, 0);
         SB.Draw(tLightning, s, rsLMid, data.Color, r, originLMid, new Vector2(dist, w) * scaleLMid, SpriteEffects.None, 0);
         SB.Draw(tLightning, e, rsLEndR, data.Color, r, originLEndR, new Vector2(w, w) * scaleLEnd, SpriteEffects.None, 0);
     }
     SB.End();
 }
コード例 #9
0
        // keep incase we dont need to traverse the visual tree recursively (itll output last first so be aware)
        //static private IEnumerable<DependencyObject> FindInputElements(DependencyObject parent)
        //{
        //    if (parent == null)
        //        yield break;

        //    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
        //    {
        //        DependencyObject o = VisualTreeHelper.GetChild(parent, i);

        //        foreach (DependencyObject obj in FindInputElements(o))

        //            yield return (UIElement)obj;

        //    }

        //    yield return parent;
        //}

        public static void PerformPageEntranceAnimation(Page page)
        {
            //traverse the visual tree of a page and perform the fade in and translate in on each frameworkitem
            // general idea from EntranceThemeTransition and rebuilt as a behavior here
            // https://jeremiahmorrill.wordpress.com/2014/04/02/entrancethemetransitionbehavior-behavior-for-wpf/
            List <Storyboard> StoryBoardCollection = new List <Storyboard>();
            List <UIElement>  AnimatableChildren   = new List <UIElement>();
            double            StaggerDelay         = 0.0;
            double            TotalStagger         = (((Windows.UI.Xaml.Controls.Panel)page.Content).Children.Count * 100d) + 500d;
            double            distanceToTranslate;

            // Traverses the first content area on the page in linear order to show everything
            foreach (UIElement child in ((Windows.UI.Xaml.Controls.Panel)page.Content).Children)
            {
                if (null != child && child != page && (child is IAnimate || child is Canvas || child is Grid))// handle special case for canvas// dont do the page either
                {
                    ParseAnimatableChildren(child, ref AnimatableChildren);
                }
            }
            TotalStagger = AnimatableChildren.Count * 100d + 500d;
            foreach (UIElement OrderedChild in AnimatableChildren)
            {
                Storyboard storyboard           = null;
                IAnimate   AnimatedOrderedChild = (IAnimate)OrderedChild;
                distanceToTranslate = 100 * (AnimatedOrderedChild.Direction() != AnimationDirection.Left ? 1 : -1);
                storyboard          = CreateEasingAnimation(OrderedChild, "Opacity", 0.0, 0.0, 1.0, TotalStagger, StaggerDelay, false, false, new RepeatBehavior(1d));
                StoryBoardCollection.Add(storyboard);
                if (AnimatedOrderedChild.HasPageEntranceTranslation())
                {
                    storyboard = CreateTranslateAnimation(OrderedChild, "X", distanceToTranslate, distanceToTranslate, 0.0, TotalStagger, StaggerDelay, false, false, new RepeatBehavior(1d));
                    StoryBoardCollection.Add(storyboard);
                }

                StaggerDelay += 100;
            }


            foreach (Storyboard SB in StoryBoardCollection)
            {
                SB.Begin();
            }
        }
コード例 #10
0
        public void Play_old(int L)
        {
            if (ImageList == null || ImageList.Count == 0)
            {
                return;
            }

            int index = 0;

            imageBrushList = new List <BitmapImage>();
            foreach (var source in ImageList)
            {
                var bmp = FunctionLib.RYTFile.ReadFileByType(source, "image") as BitmapImage;
                if (bmp != null)
                {
                    imageBrushList.Add(bmp);
                }
            }

            if (imageBrushList.Count == 0)
            {
                return;
            }

            //SB = new Storyboard();

            ObjectAnimationUsingKeyFrames da       = new ObjectAnimationUsingKeyFrames();
            DiscreteObjectKeyFrame        keyFrame = new DiscreteObjectKeyFrame();

            keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(seconds / ImageList.Count));
            var bitmap = imageBrushList[index++];

            keyFrame.Value = bitmap;
            da.KeyFrames.Add(keyFrame);

            Storyboard.SetTarget(da, img);
            Storyboard.SetTargetProperty(da, new PropertyPath(Image.SourceProperty));

            SB.Children.Add(da);

            if (ImageList.Count == 1)
            {
                img.Source = bitmap;
            }

            int repeatCountIndex = 1;

            SB.Completed += (s, e) =>
            {
                try
                {
                    img.TransformToVisual(null);
                }
                catch
                {
                    RYTong.LogLib.RYTLog.Log("检测到未stop的animation动画,自动释放ing ..");
                    Dispose();
                    return;
                }
                if (index >= ImageList.Count)
                {
                    if (Loop)
                    {
                        index = 0;
                    }
                    else if (RepeatCount > 0 && RepeatCount > repeatCountIndex)
                    {
                        index = 0;
                        repeatCountIndex++;
                    }
                    else
                    {
                        Dispose();
                        if (AnimationCompleted != null)
                        {
                            AnimationCompleted(this, null);
                        }

                        if (StopFunctionId != 0)
                        {
                            LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(StopFunctionId, this);//
                        }

                        return;
                    }
                }
                ////??? problem
                if (index < imageBrushList.Count)
                {
                    keyFrame.Value = imageBrushList[index++];
                }
                SB.Begin();
            };

            if (StartFunctionId != 0)
            {
                LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(StartFunctionId, this);//
            }

            SB.Begin();
        }
コード例 #11
0
        public void Play(int L)
        {
            if (ImageList == null || ImageList.Count == 0)
            {
                return;
            }

            ObjectAnimationUsingKeyFrames da = new ObjectAnimationUsingKeyFrames();
            var    cellSpan    = seconds / ImageList.Count;
            double flagKeyTime = 0;

            imageBrushList = new List <BitmapImage>();
            foreach (var source in ImageList)
            {
                var bmp = FunctionLib.RYTFile.ReadFileByType(source, "image") as BitmapImage;
                if (bmp != null)
                {
                    imageBrushList.Add(bmp);

                    DiscreteObjectKeyFrame keyFrame = new DiscreteObjectKeyFrame();
                    keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(flagKeyTime));
                    flagKeyTime     += cellSpan;

                    keyFrame.Value = bmp;
                    da.KeyFrames.Add(keyFrame);
                }
            }

            da.KeyFrames.Add(new DiscreteObjectKeyFrame {
                Value = imageBrushList.LastOrDefault(), KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(flagKeyTime))
            });

            if (imageBrushList.Count == 0)
            {
                return;
            }

            Storyboard.SetTarget(da, img);
            Storyboard.SetTargetProperty(da, new PropertyPath(Image.SourceProperty));

            SB.Children.Add(da);

            SB.Completed += (s, e) =>
            {
                if (AnimationCompleted != null)
                {
                    AnimationCompleted(this, null);
                }

                var page = LuaCommon.FindCurrentPage(img);
                if (page != LuaManager.GetLuaManager(L).DetailV_)
                {
                    RYTong.LogLib.RYTLog.Log("animation stoped,auto dispose it ..");
                    Dispose();
                    return;
                }

                Dispose();

                if (StopFunctionId != 0)
                {
                    LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(StopFunctionId, this);
                }
            };

            if (StartFunctionId != 0)
            {
                LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithParam(StartFunctionId, this);
            }

            SB.Begin();
        }
コード例 #12
0
ファイル: LoadScreen.cs プロジェクト: Antr0py/VoxelRTS
        public override void Draw(GameTime gameTime)
        {
            G.Clear(Color.Transparent);

            if (wr != null)
            {
                SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone);
                SB.Draw(tLoad, G.Viewport.Bounds, Color.White);
                if (tip != null)
                {
                    SB.Draw(tPixel, new Rectangle(TIPS_OFFSET, TIPS_OFFSET, G.Viewport.Width - TIPS_OFFSET * 2, TIPS_HEIGHT), COLOR_BACK);
                    SB.DrawString(font, tip, Vector2.One * (TIPS_OFFSET * 2), COLOR_HIGH);
                }
                SB.End();

                wr.Draw(SB);
            }
            else
            {
                int minX = BOUNDS_OFFSET - BAR_WIDTH;
                int maxX = G.Viewport.Bounds.Width - BOUNDS_OFFSET;

                // Calculate Progress Bar
                Rectangle rBar = G.Viewport.Bounds;
                rBar.X      = (int)(percent * (maxX - minX)) + minX;
                rBar.Y      = G.Viewport.Height - BOUNDS_OFFSET - BAR_HEIGHT;
                rBar.Height = BAR_HEIGHT;
                rBar.Width  = BAR_WIDTH;
                if (rBar.Width + rBar.X > maxX)
                {
                    rBar.Width = maxX - rBar.X;
                }
                else if (rBar.X < BOUNDS_OFFSET)
                {
                    rBar.Width = rBar.X + rBar.Width - BOUNDS_OFFSET;
                    rBar.X     = BOUNDS_OFFSET;
                }

                Rectangle rBack = G.Viewport.Bounds;
                rBack.X      = BOUNDS_OFFSET - BACK_SIZE;
                rBack.Y      = G.Viewport.Bounds.Height - BOUNDS_OFFSET - BAR_HEIGHT - BACK_SIZE;
                rBack.Width -= (BOUNDS_OFFSET - BACK_SIZE) * 2;
                rBack.Height = BAR_HEIGHT + BACK_SIZE * 2;

                SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone);
                // Draw A Background Image
                SB.Draw(tLoad, G.Viewport.Bounds, Color.White);
                // Draw The Progress Bar
                SB.Draw(tPixel, rBack, COLOR_BACK);
                SB.Draw(tPixel, rBar, Color.Lerp(COLOR_LOW, COLOR_HIGH, percent));

                if (tip != null)
                {
                    SB.Draw(tPixel, new Rectangle(TIPS_OFFSET, TIPS_OFFSET, G.Viewport.Width - TIPS_OFFSET * 2, TIPS_HEIGHT), COLOR_BACK);
                    SB.DrawString(font, tip, Vector2.One * (TIPS_OFFSET * 2), COLOR_HIGH);
                }
                SB.End();
            }

            game.DrawMouse();
        }
コード例 #13
0
        public override void Draw(GameTime gameTime)
        {
            if (lastLightning > 0)
            {
                lastLightning--;
            }
            bool playSound = false;

            // Compute Lightning
            LightningData bolts    = new LightningData(lBoltArgs.Color);
            LightningData branches = new LightningData(lBranchArgs.Color);
            int           rC       = r.Next(LightningPerFrame);

            for (int i = 0; i < rC; i++)
            {
                Vector2 ts = Vector2.Zero, te = ts;
                if (r.NextDouble() > uic.BranchProbability)
                {
                    te = ViewSize / 2f;
                    ts = textPos[r.Next(textPos.Count)];
                    float d2 = float.MaxValue;
                    for (int ri = 0; ri < LightningNeighborChecks; ri++)
                    {
                        Vector2 tet = textPos[r.Next(textPos.Count)];
                        float   d2t = (tet - ts).LengthSquared();
                        if (d2t < d2)
                        {
                            d2 = d2t;
                            te = tet;
                        }
                    }
                    lBoltArgs.Start = ts;
                    lBoltArgs.End   = te;
                    LightningGenerator.CreateLightning(lBoltArgs, ref bolts, r);
                }
                else
                {
                    playSound = true;
                    float bsx = (float)r.NextDouble() * ViewSize.X;
                    lBranchArgs.Start = new Vector2(bsx, 0);
                    lBranchArgs.End   = new Vector2(bsx, ViewSize.Y * 10f);
                    LightningGenerator.CreateBranch(lBranchArgs, ref branches, r);
                }
            }
            playSound &= lastLightning == 0;
            if (playSound)
            {
                lastLightning = uic.LightningPlayPause;
                seLightning.Play();
            }
            // Set Render Target To Lightning
            G.SetRenderTarget(rtLightning);
            G.Clear(Color.Transparent);

            // Draw Faded Lightning
            SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
            SB.Draw(rtLightningPrev, G.Viewport.TitleSafeArea, new Color(BoltFade, BoltFade, BoltFade, BoltFade));
            SB.End();
            DrawLightning(bolts, uic.Bolt.Width);

            // Set Render Target To Lightning Branches
            G.SetRenderTarget(rtLightningBr);
            G.Clear(Color.Transparent);

            // Draw Faded Lightning Branches
            SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
            SB.Draw(rtLightningBrPrev, G.Viewport.TitleSafeArea, new Color(BoltFade, BoltFade, BoltFade, BoltFade));
            SB.End();
            DrawLightning(branches, uic.Branch.Width);
            SB.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
            SB.Draw(tLightning, ViewSize / 2f, null, Color.Black, 0, new Vector2(tLightning.Width, tLightning.Height) / 2f, new Vector2(4f, 0.7f), SpriteEffects.None, 0);
            SB.End();

            // Draw Lightning To User
            G.SetRenderTarget(null);
            G.Clear(uic.ColorBackground);
            SB.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
            SB.Draw(rtLightning, G.Viewport.TitleSafeArea, Color.White);
            SB.Draw(rtLightningBr, G.Viewport.TitleSafeArea, Color.White);
            SB.End();

            // Swap Lightning Render Targets
            var b = rtLightning;

            rtLightning     = rtLightningPrev;
            rtLightningPrev = b;
            b                 = rtLightningBr;
            rtLightningBr     = rtLightningBrPrev;
            rtLightningBrPrev = b;
        }
コード例 #14
0
ファイル: PressEnterScreen.cs プロジェクト: Antr0py/VoxelRTS
 public override void Draw(GameTime gameTime)
 {
     SB.Begin();
     SB.Draw(tImage, G.Viewport.Bounds, Color.White);
     SB.End();
 }