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


C# World.PrepareCombatGrid方法代码示例

本文整理汇总了C#中Game.World.PrepareCombatGrid方法的典型用法代码示例。如果您正苦于以下问题:C# World.PrepareCombatGrid方法的具体用法?C# World.PrepareCombatGrid怎么用?C# World.PrepareCombatGrid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game.World的用法示例。


在下文中一共展示了World.PrepareCombatGrid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Begin


//.........这里部分代码省略.........
            var blockTile = World.AddTile("block", typeof(Game.Tiles.BlockTile), new TilePropertyBag
                {
                    Texture = RenderContext.White
                });

            var floorTile = World.AddTile("floor", typeof(Game.Tiles.FloorTile), new TilePropertyBag
                {
                    Texture = Content.Load<Texture2D>("floor01")
                });

            var rampTile = World.AddTile("ramp", typeof(Game.Tiles.RampTile), new TilePropertyBag
                {
                    Texture = Content.Load<Texture2D>("floor01")
                });

            World.Grid.ForEachTile((t, x, y, z) =>
                {
                    if (x == 0 || x == 15 || y == 9)
                        t.Tile = blockTile;
                    else if (z == 0)
                        t.Tile = floorTile;
                });

            World.Grid.CellAt(7, 3, 1).Tile = floorTile;
            World.Grid.CellAt(7, 4, 0).Tile = rampTile;
            World.Grid.CellAt(8, 4, 1).Tile = floorTile;
            World.Grid.CellAt(8, 3, 1).Tile = floorTile;

            SceneGraph = new Gem.Render.BranchNode();

            var testActorProperties = new Actors.AnimatedSpritePropertyBag
            {
                Sprite = Content.Load<Texture2D>("char"),
                NormalMap = RenderContext.NeutralNormals,
                DropShadow = Content.Load<Texture2D>("shadow"),
                Height = 1.5f,
                Width = 1.0f,
                Animations = new Gem.AnimationSet(
                    new Gem.Animation("idle", 0.15f, 0),
                    new Gem.Animation("run", 0.15f, 1, 2, 3, 4, 5, 6)),
                SpriteSheet = new Gem.SpriteSheet(4, 4),
                HiliteOnHover = true,
                HoverOverlay = Content.Load<Texture2D>("outline")
            };

            var commandSet = new List<Input.PlayerCommand>();
            testActorProperties.Upsert("commands", commandSet);

            var walkCommand = new Input.PlayerCommand(World);
            walkCommand.Check("can-walk", "actor", "cell", "path");
            walkCommand.Perform("do-walk", "actor", "path");
            testActorProperties.Upsert("walk-command", walkCommand);

            World.GlobalRules.Check<Actor, CombatCell, Pathfinding<CombatCell>.PathNode>("can-walk")
                .When((a, c, n) => n.PathCost > a.Properties.GetPropertyAsOrDefault<int>("turn-energy") || n.PathCost < 1)
                .Do((a, c, n) => SharpRuleEngine.CheckResult.Disallow);
            World.GlobalRules.Check<Actor, CombatCell, Pathfinding<CombatCell>.PathNode>("can-walk")
                .Do((a, c, n) => SharpRuleEngine.CheckResult.Allow);

            World.GlobalRules.Perform<Actor, Pathfinding<CombatCell>.PathNode>("do-walk")
                .Do((a, p) =>
                {
                    var energy = a.Properties.GetPropertyAs<int>("turn-energy");
                    energy -= (int)p.PathCost;
                    a.Properties.Upsert("turn-energy", energy);
                    a.NextAction = new Actors.Actions.WalkPath(p.ExtractPath());
                    PushInputState(new Input.WaitForIdle(a));
                    return SharpRuleEngine.PerformResult.Continue;
                });

            PlayerActor = World.SpawnActor(typeof(Actors.AnimatedSpriteActor),
                testActorProperties,
                new Vector3(4.5f, 4.5f, 0.25f));

            World.SpawnActor(typeof(Actors.AnimatedSpriteActor), testActorProperties, new Vector3(4.5f, 6.5f, 0.25f));

            Camera.Position = CameraFocus + new Vector3(0, -4, 3);
            Camera.LookAt(CameraFocus);
            Camera.Position = CameraFocus + (Camera.GetEyeVector() * CameraDistance);

            Main.Input.AddBinding("RIGHT", new KeyboardBinding(Keys.Right, KeyBindingType.Held));
            Main.Input.AddBinding("LEFT", new KeyboardBinding(Keys.Left, KeyBindingType.Held));
            Main.Input.AddBinding("UP", new KeyboardBinding(Keys.Up, KeyBindingType.Held));
            Main.Input.AddBinding("DOWN", new KeyboardBinding(Keys.Down, KeyBindingType.Held));
            Main.Input.AddBinding("CLICK", new MouseButtonBinding("LeftButton", KeyBindingType.Pressed));
            Main.Input.AddBinding("GRID-UP", new KeyboardBinding(Keys.Q, KeyBindingType.Pressed));
            Main.Input.AddBinding("GRID-DOWN", new KeyboardBinding(Keys.E, KeyBindingType.Pressed));

            Main.Input.AddBinding("CAMERA-DISTANCE-TOGGLE", new KeyboardBinding(Keys.R, KeyBindingType.Held));

            Main.ScriptBuilder.DeriveScriptsFrom("MonoCardCrawl.ScriptBase");

            var StaticWorld = WorldModel.CreateStaticGeometryBuffers(World, Main.GraphicsDevice);
            SceneGraph.Add(StaticWorld);
            SceneGraph.Add(new ActorSceneNode(World));

            World.PrepareCombatGrid();

            PushInputState(new Input.TurnScheduler(World.Actors));
        }
开发者ID:Blecki,项目名称:CCDC,代码行数:101,代码来源:WorldScreen.cs


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