当前位置: 首页>>代码示例>>C#>>正文


C# IGameContext类代码示例

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


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


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