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


C# Node.ChangeTexture方法代码示例

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


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

示例1: Update

        protected override void Update(GameTime gameTime)
        {
            timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000;
            timerInt = (int)timer;

            if (timerInt >= 5)
            {
                //Character p = new Character(this, new Vector3(1.25f, 0, 1.25f), new Vector3(0, 90, 0), new Vector3(0, 1, 0), ImageLibrary.getInstance().getImage("Player"), cam, path.origin);
                //enemys.Add(p);
                timer = 0;
            }

            this.keyboard.Update();

            enemysArray = enemys.ToArray();

            //Erro ao utilizar foreach no Update. Melhor Solução foi esta.
            for (int i = 0; i < enemysArray.Length; i++)
            {
                enemysArray[i].Update(gameTime);
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (this.keyboard.IsKeyDown(Keys.P))
            {
                Random rand = new Random();

                int x = rand.Next(3, 6);
                int y = rand.Next(0, 6);

                this.path.Search(this.grid.nodes[0, 0], this.grid.nodes[x, y], ref this.grid, this, ref allTrees, ref this.nodePath);
                ArrangeNodes(ref this.nodePath);

                player.setPosition(new Vector3(0, 1, 0));
                player.target = path.origin;
            }

            if (this.keyboard.IsKeyDown(Keys.Space)) //Ação!
            {
                if (activeNode.state == nodeState.OPEN)
                {
                    towers.Add(new Tree(this, new Vector3(1, 1, 1), new Vector3(0, 0, 0), new Vector3(activeNode.x * 2.5f, 0, activeNode.y * 2.5f), cam));
                }
            }

            if (this.keyboard.IsKeyDown(Keys.Down))
            {
                if (activeNode.y < 5)
                {
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("Floor"));
                    int x = activeNode.x;
                    int y = activeNode.y;

                    activeNode = grid.nodes[x, y + 1];
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("FloorSelected"));
                }
            }

            if (this.keyboard.IsKeyDown(Keys.Up))
            {
                if (activeNode.y > 0)
                {
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("Floor"));
                    int x = activeNode.x;
                    int y = activeNode.y;

                    activeNode = grid.nodes[x, y - 1];
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("FloorSelected"));
                }
            }

            if (this.keyboard.IsKeyDown(Keys.Right))
            {
                if (activeNode.x < 5)
                {
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("Floor"));
                    int x = activeNode.x;
                    int y = activeNode.y;

                    activeNode = grid.nodes[x + 1, y];
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("FloorSelected"));
                }
            }

            if (this.keyboard.IsKeyDown(Keys.Left))
            {
                if (activeNode.x > 0)
                {
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("Floor"));
                    int x = activeNode.x;
                    int y = activeNode.y;

                    activeNode = grid.nodes[x - 1, y];
                    activeNode.ChangeTexture(ImageLibrary.getInstance().getImage("FloorSelected"));
                }
            }

            foreach (Tree currentTree in allTrees)
//.........这里部分代码省略.........
开发者ID:manoela-reis,项目名称:computacaonatural-towerdefense,代码行数:101,代码来源:Game1.cs


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