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

C# Playfield类代码示例

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

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



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

示例1: PrintTable

        public static void PrintTable(Playfield playfield)
        {
            string columnHeader = "    ";
            for (int i = 0; i < playfield.Width; i++)
            {
                columnHeader += i.ToString().PadLeft(3);
            }

            Console.WriteLine(columnHeader);

            Console.WriteLine("    " + new String('-', playfield.Width * 3));

            for (int row = 0; row < playfield.Height; row++)
            {
                Console.Write(row.ToString().PadLeft(2) + " | ");
                for (int col = 0; col < playfield.Width; col++)
                {
                    Console.Write(playfield.Field[row, col].ToString().PadLeft(2) + " ");
                }

                Console.WriteLine("| ");
            }

            Console.WriteLine("    " + new String('-', playfield.Width * 3));
        }
开发者ID:TishoAngelov,项目名称:TelerikAcademy,代码行数:25,代码来源:ConsoleIOFacade.cs


示例2: TestRenderFieldGrid_PlayerAtStartPosition

        public void TestRenderFieldGrid_PlayerAtStartPosition()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 0, 1, 1},
                            {1, 1, 1, 0, 0, 0, 1},
                            {0, 0, 0, 0, 1, 0, 0},
                            {1, 0, 1, 0, 1, 1, 1},
                            {1, 0, 0, 1, 0, 0, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {1, 0, 0, 1, 0, 1, 0}
                        };
            Playfield playfield = new Playfield(labyrinthGrid);

            string actualOutput = Renderer.RenderField(playfield.LabyrinthGrid,
                                                       playfield.PlayerPosition.Row, playfield.PlayerPosition.Col);

            StringBuilder expectedOutput = new StringBuilder();
            expectedOutput.AppendLine("--XX-XX");
            expectedOutput.AppendLine("XXX---X");
            expectedOutput.AppendLine("----X--");
            expectedOutput.AppendLine("X-X*XXX");
            expectedOutput.AppendLine("X--X---");
            expectedOutput.AppendLine("X-X--XX");
            expectedOutput.AppendLine("X--X-X-");

            bool areEqual = actualOutput == expectedOutput.ToString();
            Assert.IsTrue(areEqual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:29,代码来源:RendererTests.cs


示例3: TestIsValidMove_CanMoveDown

        public void TestIsValidMove_CanMoveDown()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 1, 1, 0, 1, 1, 1},
                            {0, 0, 0, 0, 0, 0, 1},
                            {1, 0, 1, 0, 1, 0, 1},
                            {1, 0, 1, 0, 1, 0, 0},
                            {0, 1, 1, 1, 1, 1, 0},
                            {0, 0, 1, 0, 0, 0, 1},
                            {1, 0, 0, 0, 0, 0, 0}
                        };

            Playfield playfield = new Playfield(labyrinthGrid);

            //Moving playerPosition at row=5 and col=2
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Down);

            Direction directionDown = Direction.Down;
            bool expected = true;
            bool actual = MovesChecker.IsValidMove(playfield, directionDown);
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:27,代码来源:MovesCheckerTests.cs


示例4: TestGetTopResults

        public void TestGetTopResults()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);

            string expected = engine.GetTopResults();
            string actual = new ScoreBoard().ShowScoreboard();
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:9,代码来源:GameEngineTests.cs


示例5: TestInitializeField_IsCorrectStartPosition

        public void TestInitializeField_IsCorrectStartPosition()
        {
            Playfield playfield = new Playfield();
            playfield.InitializeField();

            Position expected = new Position(3, 3);
            Position actual = playfield.PlayerPosition;
            Assert.AreEqual(expected.Row, actual.Row);
            Assert.AreEqual(expected.Col, actual.Col);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:10,代码来源:PlayfieldTests.cs


示例6: TestProcessInput_OnWriteRestart

        public void TestProcessInput_OnWriteRestart()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            AssignEvents(engine, engine.UserInput);
            engine.UserInput.ProcessInput("restart");

            int expected = 0;
            int actual = engine.Score;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:ConsoleInputTests.cs


示例7: TestProcessInput_OnWriteExit

        public void TestProcessInput_OnWriteExit()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            AssignEvents(engine, engine.UserInput);
            engine.UserInput.ProcessInput("exit");

            bool expected = true;
            bool actual = engine.HasGameQuit;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:ConsoleInputTests.cs


示例8: TestMoveAtDirection_MoveAtUp

        public void TestMoveAtDirection_MoveAtUp()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            engine.MoveAtDirection(Direction.Up, engine.MoveUp);

            Position expected = new Position(2, 3);
            Position actual = playfield.PlayerPosition;
            Assert.AreEqual(expected.Row, actual.Row);
            Assert.AreEqual(expected.Col, actual.Col);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:GameEngineTests.cs


示例9: TestInitializeNewGame_ScoreIsUpdated

        public void TestInitializeNewGame_ScoreIsUpdated()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            engine.MoveAtDirection(Direction.Down, engine.MoveDown);
            engine.InitializeNewGame();

            int expected = 0;
            int actual = engine.Score;
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:11,代码来源:GameEngineTests.cs


示例10: TestProcessInput_OnWriteR

        public void TestProcessInput_OnWriteR()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);
            AssignEvents(engine, engine.UserInput);
            engine.UserInput.ProcessInput("R");

            Position expected = new Position(3, 4);
            Position actual = playfield.PlayerPosition;

            Assert.AreEqual(expected.Row, actual.Row);
            Assert.AreEqual(expected.Col, actual.Col);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:13,代码来源:ConsoleInputTests.cs


示例11: TestInitializeField_IsClearPlayerPosition

        public void TestInitializeField_IsClearPlayerPosition()
        {
            Playfield playfield = new Playfield();
            playfield.InitializeField();

            int expectedRow = 3;
            int expectedCol = 3;
            int actualRow = playfield.PlayerPosition.Row;
            int actualCol = playfield.PlayerPosition.Col;

            Position actual = playfield.PlayerPosition;
            Assert.AreEqual(expectedRow, actualRow);
            Assert.AreEqual(expectedCol, actualCol);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:14,代码来源:PlayfieldTests.cs


示例12: TestIsVictory_NorthEastCornerExit

        public void TestIsVictory_NorthEastCornerExit()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 1, 1, 0},
                            {1, 1, 1, 1, 0, 0, 1},
                            {0, 0, 0, 1, 0, 1, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {0, 1, 0, 1, 1, 0, 0},
                            {0, 0, 1, 0, 0, 0, 0},
                            {0, 0, 1, 0, 1, 0, 0}
                        };
            Position customPosition = new Position(0, 6);
            Playfield playfield = new Playfield(labyrinthGrid, customPosition);

            bool expected = true;
            bool actual = playfield.IsVictory();
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:19,代码来源:PlayfieldTests.cs


示例13: TestIsValidMove_CanMoveRight

        public void TestIsValidMove_CanMoveRight()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 1, 1, 1},
                            {1, 1, 1, 1, 1, 1, 1},
                            {0, 0, 0, 0, 0, 0, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {0, 1, 0, 1, 0, 0, 0},
                            {0, 0, 1, 0, 0, 0, 0},
                            {0, 0, 0, 0, 0, 0, 0}
                        };

            Playfield playfield = new Playfield(labyrinthGrid);
            Direction directionRight = Direction.Right;

            bool expected = true;
            bool actual = MovesChecker.IsValidMove(playfield, directionRight);
            Assert.AreEqual(expected, actual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:20,代码来源:MovesCheckerTests.cs


示例14: TestRenderFieldGrid_PlayerAtOtherPosition

        public void TestRenderFieldGrid_PlayerAtOtherPosition()
        {
            int[,] labyrinthGrid = new int[7, 7]
                        {
                            {0, 0, 1, 1, 0, 1, 1},
                            {1, 1, 1, 0, 0, 0, 1},
                            {0, 0, 0, 0, 1, 0, 0},
                            {1, 0, 1, 0, 1, 1, 1},
                            {1, 0, 0, 1, 0, 0, 0},
                            {1, 0, 1, 0, 0, 1, 1},
                            {1, 0, 0, 1, 0, 1, 0}
                        };
            Playfield playfield = new Playfield(labyrinthGrid);

            //Moving playerPosition at row=2 and col=6 (start index=0)
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Up);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);
            playfield.PlayerPosition.MoveAtDirection(Direction.Down);
            playfield.PlayerPosition.MoveAtDirection(Direction.Right);

            string actualOutput = Renderer.RenderField(playfield.LabyrinthGrid,
                                                       playfield.PlayerPosition.Row, playfield.PlayerPosition.Col);

            StringBuilder expectedOutput = new StringBuilder();
            expectedOutput.AppendLine("--XX-XX");
            expectedOutput.AppendLine("XXX---X");
            expectedOutput.AppendLine("----X-*");
            expectedOutput.AppendLine("X-X-XXX");
            expectedOutput.AppendLine("X--X---");
            expectedOutput.AppendLine("X-X--XX");
            expectedOutput.AppendLine("X--X-X-");

            bool areEqual = actualOutput == expectedOutput.ToString();
            Assert.IsTrue(areEqual);
        }
开发者ID:TelluriumHeroes,项目名称:HQPC-Teamwork-Project,代码行数:37,代码来源:RendererTests.cs


示例15: CreatePlayfield

 /// <summary>
 /// Creates the playfield matrix with the balloons in it
 /// </summary>
 public override Playfield CreatePlayfield()
 {
     var largePlayfield = new Playfield(Width, Height);
     return largePlayfield;
 }
开发者ID:Teamwork-Balloons-Pop-5,项目名称:Balloons-Pop,代码行数:8,代码来源:LargePlayfieldCreator.cs


示例16: getPlayfieldValue

        public override float getPlayfieldValue(Playfield p)
        {
            if (p.value >= -2000000) return p.value;
            int retval = 0;
            retval -= p.evaluatePenality;
            retval += p.owncards.Count * 3;

            retval += p.ownHero.Hp + p.ownHero.armor;
            retval += -(p.enemyHero.Hp + p.enemyHero.armor);

            retval += p.ownMaxMana * 15 - p.enemyMaxMana * 15;

            if (p.ownWeaponAttack >= 1)
            {
                retval += p.ownWeaponAttack * p.ownWeaponDurability;
            }

            if (!p.enemyHero.frozen)
            {
                retval -= p.enemyWeaponDurability * p.enemyWeaponAttack;
            }
            else
            {
                if (p.enemyHeroName != HeroEnum.mage && p.enemyHeroName != HeroEnum.priest)
                {
                    retval += 11;
                }
            }

            //RR card draw value depending on the turn and distance to lethal
            //RR if lethal is close, carddraw value is increased


            if (sf.Ai.lethalMissing <= 5) //RR
            {
                retval += p.owncarddraw * 100;
            }
            if (p.ownMaxMana < 4)
            {
                retval += p.owncarddraw * 2;
            }
            else
            {
                retval += p.owncarddraw * 5;
            }
            retval += p.owncarddraw * 5;
            retval -= p.enemycarddraw * 15;

            bool useAbili = false;
            bool usecoin = false;
            foreach (Action a in p.playactions)
            {
                if (a.actionType == actionEnum.attackWithHero && p.enemyHero.Hp <= p.attackFaceHP) retval++;
                if (a.actionType == actionEnum.useHeroPower) useAbili = true;
                if (p.ownHeroName == HeroEnum.warrior && a.actionType == actionEnum.attackWithHero && useAbili) retval -= 1;
                //if (a.actionType == actionEnum.useHeroPower && a.card.card.name == CardDB.cardName.lesserheal && (!a.target.own)) retval -= 5;
                if (a.actionType != actionEnum.playcard) continue;
                if ((a.card.card.name == CardDB.cardName.thecoin || a.card.card.name == CardDB.cardName.innervate)) usecoin = true;
            }
            if (usecoin && useAbili && p.ownMaxMana <= 2) retval -= 40;
            if (usecoin) retval -= 5 * p.manaTurnEnd;
            if (p.manaTurnEnd >= 2 && !useAbili)
            {
                retval -= 10;
                if (p.ownHeroName == HeroEnum.thief && (p.ownWeaponDurability >= 2 || p.ownWeaponAttack >= 2)) retval += 10;
            }
            //if (usecoin && p.mana >= 1) retval -= 20;

            foreach (Minion m in p.ownMinions)
            {
                retval += m.Hp * 1;
                retval += m.Angr * 2;
                retval += m.handcard.card.rarity;
                if (m.windfury) retval += m.Angr;
                if (m.taunt) retval += 1;
                if (!m.taunt && m.stealth && m.handcard.card.isSpecialMinion) retval += 20;
                if (m.handcard.card.name == CardDB.cardName.silverhandrecruit && m.Angr == 1 && m.Hp == 1) retval -= 5;
                if (m.handcard.card.name == CardDB.cardName.direwolfalpha || m.handcard.card.name == CardDB.cardName.flametonguetotem || m.handcard.card.name == CardDB.cardName.stormwindchampion || m.handcard.card.name == CardDB.cardName.raidleader) retval += 10;
                if (m.handcard.card.name == CardDB.cardName.nerubianegg)
                {
                    if (m.Angr >= 1) retval += 2;
                    if ((!m.taunt && m.Angr == 0) && (m.divineshild || m.maxHp > 2)) retval -= 10;
                }
            }

            foreach (Minion m in p.enemyMinions)
            {
                retval -= this.getEnemyMinionValue(m, p);
            }

            retval -= p.enemySecretCount;
            retval -= p.lostDamage;//damage which was to high (like killing a 2/1 with an 3/3 -> => lostdamage =2
            retval -= p.lostWeaponDamage;
            if (p.ownMinions.Count == 0) retval -= 20;
            if (p.enemyMinions.Count >= 4) retval -= 20;
            if (p.enemyHero.Hp <= 0) retval = 10000;
            //soulfire etc
            int deletecardsAtLast = 0;
            foreach (Action a in p.playactions)
            {
//.........这里部分代码省略.........
开发者ID:shuyi3,项目名称:AIPJ,代码行数:101,代码来源:BehaviorRush.cs


示例17: getEnemyMinionValue

        public override int getEnemyMinionValue(Minion m, Playfield p)
        {
            int retval = 0;
            if (p.enemyMinions.Count >= 4 || m.taunt || (m.handcard.card.targetPriority >= 1 && !m.silenced) || m.Angr >= 5)
            {
                retval += m.Hp;
                if (!m.frozen && !((m.name == CardDB.cardName.ancientwatcher || m.name == CardDB.cardName.ragnarosthefirelord) && !m.silenced))
                {
                    retval += m.Angr * 2;
                    if (m.windfury) retval += 2 * m.Angr;
                }
                if (m.taunt) retval += 5;
                if (m.divineshild) retval += m.Angr;
                if (m.frozen) retval -= 1; // because its bad for enemy :D
                if (m.poisonous) retval += 4;
                retval += m.handcard.card.rarity;
            }


            if (m.handcard.card.targetPriority >= 1 && !m.silenced) retval += m.handcard.card.targetPriority;
            if (m.Angr >= 4) retval += 20;
            if (m.Angr >= 7) retval += 50;
            if (m.name == CardDB.cardName.nerubianegg && m.Angr <= 3 && !m.taunt) retval = 0;
            return retval;
        }
开发者ID:shuyi3,项目名称:AIPJ,代码行数:25,代码来源:BehaviorRush.cs


示例18: onDeathrattle

 public virtual void onDeathrattle(Playfield p, Minion m)
 {
     return;
 }
开发者ID:martdeboer,项目名称:silverfish,代码行数:4,代码来源:SimTemplate.cs


示例19: onMinionWasSummoned

 public virtual void onMinionWasSummoned(Playfield p, Minion triggerEffectMinion, Minion summonedMinion)
 {
     return;
 }
开发者ID:martdeboer,项目名称:silverfish,代码行数:4,代码来源:SimTemplate.cs


示例20: onMinionDiedTrigger

 public virtual void onMinionDiedTrigger(Playfield p, Minion triggerEffectMinion, Minion diedMinion)
 {
     return;
 }
开发者ID:martdeboer,项目名称:silverfish,代码行数:4,代码来源:SimTemplate.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Playlist类代码示例发布时间:2022-05-24
下一篇:
C# Players类代码示例发布时间: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