• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IGameContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IGameContext的典型用法代码示例。如果您正苦于以下问题:C# IGameContext类的具体用法?C# IGameContext怎么用?C# IGameContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IGameContext类属于命名空间,在下文中一共展示了IGameContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CanMoveTo

        public bool CanMoveTo(IGameContext gameContext, float absX, float absZ, bool ignoreCrates = false)
        {
            var world = (PerceptionWorld)gameContext.World;
            try
            {
                var height = this.GetHeight(gameContext, absX, absZ, ignoreCrates);

                // check if there are doors there
                var door = world.Entities.OfType<DoorEntity>().FirstOrDefault(a => a.CollidesWithAdjustedObjectInfiniteY(this, absX, absZ));
                if (door != null && !door.Open)
                {
                    return false;
                }

                if (!ignoreCrates)
                {
                    /* foreach (var crate in gameContext.World.Entities.OfType<CrateEntity>().Where(
                        a => !(absX > a.X + a.Width || absX + this.Width < a.X || absZ > a.Z + a.Depth || absZ + this.Depth < a.Z)))
                    {
                        if (crate == this)
                        {
                            continue;
                        }

                        return false;
                    }*/
                }

                return this.Y >= height;
            }
            catch (IndexOutOfRangeException)
            {
                return false;
            }
        }
开发者ID:hach-que,项目名称:Perspective-Game,代码行数:35,代码来源:BaseCollisionEntity.cs


示例2: OnGround

 private bool OnGround(IGameContext gameContext)
 {
     return this.m_Platforming.IsOnGround(
         this,
         gameContext.World.GetEntitiesForWorld(_hierarchy).OfType<IBoundingBox>(),
         x => x is Solid);
 }
开发者ID:RedpointGames,项目名称:Protogame.Template.Platformer,代码行数:7,代码来源:Player.cs


示例3: Render

 public override void Render(IGameContext gameContext, IRenderContext renderContext)
 {
     if (renderContext.IsFirstRenderPass())
     {
         renderContext.AppendTransientRenderPass(_renderPass);
     }
 }
开发者ID:hach-que,项目名称:Protogame.Docs,代码行数:7,代码来源:game_runtimetransient.cs


示例4: RenderDebug

        public void RenderDebug(IGameContext gameContext, IRenderContext renderContext, Agent agent, I2DRenderUtilities twoDRenderUtilities)
        {
            var wndPos = new Vector2(this.WanderDistance, 0);
            var wldPos = agent.Project(wndPos);

            for (var i = 0; i < 10; i++)
            {
                var r = MathHelper.ToRadians(36 * i);
                var r2 = MathHelper.ToRadians(36 * (i + 1));
                twoDRenderUtilities.RenderLine(
                    renderContext,
                    wldPos + (new Vector2((float)Math.Sin(r), (float)Math.Cos(r)) * this.WanderRadius),
                    wldPos + (new Vector2((float)Math.Sin(r2), (float)Math.Cos(r2)) * this.WanderRadius),
                    Color.Green);
            }

            wndPos = this.m_WanderTarget + new Vector2(this.WanderDistance, 0);
            wldPos = agent.Project(wndPos);

            for (var i = 0; i < 10; i++)
            {
                var r = MathHelper.ToRadians(36 * i);
                var r2 = MathHelper.ToRadians(36 * (i + 1));
                twoDRenderUtilities.RenderLine(
                    renderContext,
                    wldPos + (new Vector2((float)Math.Sin(r), (float)Math.Cos(r)) * 3),
                    wldPos + (new Vector2((float)Math.Sin(r2), (float)Math.Cos(r2)) * 3),
                    Color.Red);
            }
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:30,代码来源:WanderAI.cs


示例5: LoadState

        public override void LoadState(IGameContext context)
        {
            context.GameStateType = GameStateType.Playing;
            context.CurrentCommand = new ExecuteGameInstruction();

            context.GameHandler.InitGame(context.Game);
        }
开发者ID:ariugwu,项目名称:storybox,代码行数:7,代码来源:GameCommandState.cs


示例6: Execute

        public string Execute(IGameContext gameContext, string name, string[] parameters)
        {
            if (parameters.Length < 1)
                return "Not enough parameters (usage: give <name> [<weight>]).";

            var player = gameContext.World.Entities.OfType<PlayerEntity>().FirstOrDefault();
            if (player == null)
                return "Must be in-game to run this command.";
            Item item;
            if (parameters.Length == 1)
                item = new Item { Name = parameters[0] };
            else
            {
                try
                {
                    item = new WeightedItem
                    {
                        Name = parameters[0],
                        Weight = (Weight)Enum.Parse(typeof(Weight), parameters[1])
                    };
                }
                catch (ArgumentException)
                {
                    return "No such weighting exists.";
                }
            }

            player.RuntimeData.Inventory.Add(item);
            return "Added " + parameters[0] + " to player's inventory.";
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:30,代码来源:GiveCommand.cs


示例7: Process

        public void Process(IGameContext gameContext)
        {
            HandleRequest(gameContext);

            gameContext.GameState.LoadState(gameContext);

            gameContext.GameState.DisplayPrompt(gameContext);

            gameContext.CurrentCommand.UserInput = Console.ReadLine();

            gameContext.GameState.Interpret(gameContext.CurrentCommand); // TODO: Pick a better for this: 'InterpretUserInput'?

            gameContext.GameState.Process(gameContext); // TODO: Pick a better word for this: 'InitCommand'?

            gameContext.GameState.ExecuteCommand(gameContext);

            gameContext.GameState.DisplayResponse(gameContext);

            gameContext.GameState.UnloadState(gameContext);

            if (successor != null)
            {
                successor.Process(gameContext);
            }

            gameContext.CurrentCommand = null; // We're done with the command so blank it out. NOTE: This could be part of a 'Finalize' handler.
        }
开发者ID:ariugwu,项目名称:storybox,代码行数:27,代码来源:GameHandler.cs


示例8: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!CanvasesEnabled)
            {
                return;
            }

            if (renderContext.IsCurrentRenderPass<ICanvasRenderPass>())
            {
                var bounds = gameContext.Window.ClientBounds;
                bounds.X = 0;
                bounds.Y = 0;

                _lastRenderBounds = bounds;

                base.Render(gameContext, renderContext);

                Canvas?.Render(renderContext, _skinLayout, _skinDelegator, bounds);

                foreach (var window in Windows.OrderBy(x => x.Order))
                {
                    window.Render(renderContext, _skinLayout, _skinDelegator, window.Bounds);
                }
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:25,代码来源:CanvasEntity.cs


示例9: IsRenderTargetOutOfDate

        public bool IsRenderTargetOutOfDate(RenderTarget2D renderTarget, IGameContext gameContext)
        {
            if (renderTarget == null)
            {
                return true;
            }
            else
            {
                if (renderTarget.Width != gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferWidth)
                {
                    return true;
                }

                if (renderTarget.Height != gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferHeight)
                {
                    return true;
                }

                if (renderTarget.Format != gameContext.Graphics.GraphicsDevice.PresentationParameters.BackBufferFormat)
                {
                    return true;
                }

                if (renderTarget.DepthStencilFormat != gameContext.Graphics.GraphicsDevice.PresentationParameters.DepthStencilFormat)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:johnsonc,项目名称:Protogame,代码行数:31,代码来源:DefaultRenderTargetBackBufferUtilities.cs


示例10: Process

        public ClientChunk[] Process(
            TychaiaGameWorld world, 
            ChunkManagerEntity manager, 
            IGameContext gameContext, 
            IRenderContext renderContext)
        {
            foreach (
                var position in
                    this.m_PredeterminedChunkPositions.GetPurgableAbsolutePositions(
                        new Vector3(
                            world.IsometricCamera.Chunk.X,
                            world.IsometricCamera.Chunk.Y,
                            world.IsometricCamera.Chunk.Z)))
            {
                var chunk = world.ChunkOctree.Get((long)position.X, (long)position.Y, (long)position.Z);
                if (chunk != null)
                {
                    Console.WriteLine("FIXME: PURGING CHUNK");

                    // chunk.Purge();
                }
            }

            return null;
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:25,代码来源:PredeterminedChunkPurgerAI.cs


示例11: Render

        public void Render(IGameContext gameContext, IRenderContext renderContext, Rectangle rectangle)
        {
            if (!_networkEngine.GetRecentFrames().Any())
            {
                return;
            }

            var recent = _networkEngine.GetRecentFrames().Last();

            _sentSampler.Sample(
                recent.BytesSentByMessageType,
                recent.MessagesSentByMessageType,
                rectangle.Width);

            _receivedSampler.Sample(
                recent.BytesReceivedByMessageType,
                recent.MessagesReceivedByMessageType,
                rectangle.Width);
            
            _sentSampler.Render(
                renderContext,
                new Rectangle(
                    rectangle.X,
                    rectangle.Y,
                    rectangle.Width,
                    _sentSampler.Height));

            _receivedSampler.Render(
                renderContext,
                new Rectangle(
                    rectangle.X,
                    rectangle.Y + _sentSampler.Height,
                    rectangle.Width,
                    _receivedSampler.Height));
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:35,代码来源:NetworkTrafficProfilerVisualiser.cs


示例12: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            base.Render(gameContext, renderContext);

            // For each of the chunk AIs, process them.  It's not ideal to have this in
            // the Render() call, but some AIs need access to the render context so that
            // they can do bounding frustum checks to find out what's on screen.
            using (this.m_Profiler.Measure("tychaia-chunk_ai"))
            {
                foreach (var ai in this.m_ChunkAI)
                {
                    var result = ai.Process(this.m_World, this, gameContext, renderContext);
                    if (result != null)
                    {
                        this.m_ChunksToRenderNext = result;
                    }
                }
            }

            // Find the chunk that belongs at this position.
            using (this.m_Profiler.Measure("tychaia-chunk_render"))
            {
                foreach (var chunk in this.m_ChunksToRenderNext)
                {
                    if (chunk != null)
                    {
                        this.m_ChunkRenderer.Render(renderContext, chunk);
                    }
                }
            }
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:31,代码来源:ChunkManagerEntity.cs


示例13: Update

 /// <summary>
 /// Internally called by <see cref="SensorEngineHook"/> to update sensors
 /// during the update step.
 /// </summary>
 /// <param name="gameContext">The current game context.</param>
 /// <param name="updateContext">The current update context.</param>
 public void Update(IGameContext gameContext, IUpdateContext updateContext)
 {
     foreach (var sensor in _sensors)
     {
         sensor.Update(gameContext, updateContext);
     }
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:13,代码来源:DefaultSensorEngine.cs


示例14: RenderBelow

 public void RenderBelow(IGameContext gameContext, IRenderContext renderContext)
 {
     using (this.m_Profiler.Measure("clear"))
     {
         gameContext.Graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
     }
 }
开发者ID:RedpointGames,项目名称:Protogame.Template.Platformer,代码行数:7,代码来源:PROJECT_SAFE_NAMEWorld.cs


示例15: DisplayPrompt

 public override void DisplayPrompt(IGameContext context)
 {
     Console.WriteLine("1. Bubble Commander");
     Console.WriteLine("2. Syn");
     Console.WriteLine("Please type the game you want to play:");
     Console.Write(">");
 }
开发者ID:ariugwu,项目名称:storybox,代码行数:7,代码来源:GameSelectionState.cs


示例16: Render

 /// <summary>
 /// Internally called by <see cref="SensorEngineHook"/> to update sensors
 /// during the render step.
 /// </summary>
 /// <param name="gameContext">The current game context.</param>
 /// <param name="renderContext">The current render context.</param>
 public void Render(IGameContext gameContext, IRenderContext renderContext)
 {
     foreach (var sensor in _sensors)
     {
         sensor.Render(gameContext, renderContext);
     }
 }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:13,代码来源:DefaultSensorEngine.cs


示例17: Update

 public override void Update(IGameContext gameContext, IUpdateContext updateContext)
 {
     base.Update(gameContext, updateContext);
     
     var mouse = Mouse.GetState();
     var keyboard = Keyboard.GetState();
     if (mouse.LeftPressed(this))
     {
         this.X = mouse.X;
         this.Y = mouse.Y;
         this.XSpeed = 0;
         this.YSpeed = 0;
         this.m_JumpHandle.Play();
     }
     if (keyboard.IsKeyDown(Keys.Left))
         this.m_Platforming.ApplyMovement(this, -4, 0, gameContext.World.Entities.Cast<IBoundingBox>(), x => x is Solid);
     if (keyboard.IsKeyDown(Keys.Right))
         this.m_Platforming.ApplyMovement(this, 4, 0, gameContext.World.Entities.Cast<IBoundingBox>(), x => x is Solid);
     
     if (!this.OnGround(gameContext))
         this.m_Platforming.ApplyGravity(this, 0, 0.5f);
     else if (this.YSpeed > 0)
     {
         this.YSpeed = 0;
         this.m_Platforming.ApplyActionUntil(this, a => a.Y += 1, a => this.OnGround(gameContext), 12);
     }
     this.m_Platforming.ClampSpeed(this, null, 12);
     
     if (keyboard.IsKeyPressed(Keys.Up) && this.OnGround(gameContext))
         this.YSpeed = -6;
 }
开发者ID:hach-que,项目名称:Protogame.Examples,代码行数:31,代码来源:Player.cs


示例18: OnGround

 private bool OnGround(IGameContext gameContext)
 {
     return this.m_Platforming.IsOnGround(
         this,
         gameContext.World.Entities.Cast<IBoundingBox>(),
         x => x is Solid);
 }
开发者ID:hach-que,项目名称:Protogame.Examples,代码行数:7,代码来源:Player.cs


示例19: Execute

 /// <summary>
 /// Implements the execution of the command for restarting the game.
 /// </summary>
 /// <param name="context">The game context for the execution of the command.</param>
 public void Execute(IGameContext context)
 {
     this.printer.ClearScreen();
     context.Reset();
     context.IsGameRunning = true;
     this.printer.PrintLine(context.CurrentMessage);
 }
开发者ID:TA2015-HQC-Hangman-3,项目名称:Hangman-3,代码行数:11,代码来源:RestartCommand.cs


示例20: HandleEvent

        public bool HandleEvent(ISkinLayout skin, Rectangle layout, IGameContext context, Event @event)
        {
            var mousePressEvent = @event as MousePressEvent;
            if (mousePressEvent != null)
            {
                if (!layout.Contains(mousePressEvent.MouseState.X, mousePressEvent.MouseState.Y))
                {
                    return false;
                }

                State = LinkState.Clicked;

                Click?.Invoke(this, new EventArgs());

                return true;
            }

            var mouseReleaseEvent = @event as MouseReleaseEvent;
            if (mouseReleaseEvent != null)
            {
                if (!layout.Contains(mouseReleaseEvent.MouseState.X, mouseReleaseEvent.MouseState.Y))
                {
                    return false;
                }

                State = LinkState.None;
            }

            return false;
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:30,代码来源:Link.cs



注:本文中的IGameContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IGameEngine类代码示例发布时间:2022-05-24
下一篇:
C# IGame类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap