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


C# Enemy.setEnemySpeed方法代码示例

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


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

示例1: LoadTiles

        /*************************************************
         * Load tiles from file and populate levelTiles
         *************************************************/
        public void LoadTiles(string fileStream)
        {
            // Load the level and ensure all of the lines are the same length.
            int width = 0;

            List<string> lines = new List<string>();
            using (StreamReader reader = new StreamReader(fileStream))
            {
                string line = reader.ReadLine();
                width = line.Length;

                while (line != null)
                {
                    lines.Add(line);
                    if (line.Length != width)
                        throw new Exception(String.Format("The length of line {0} is different from all preceeding lines.", lines.Count));
                    line = reader.ReadLine();
                }
            }

            LEVEL_WIDTH = width;
            LEVEL_HEIGHT = lines.Count();
            levelTiles = new Tile[LEVEL_WIDTH, LEVEL_HEIGHT];
            camera.setGameScale();
            currentLevelName = allLevels.ElementAt(currentLevelNr - 1);
            int y = 0;
            foreach (string row in lines)
            {
                int x = 0;
                foreach (char aChar in row)
                {
                    //Block tile
                    if(aChar.ToString().Equals("#"))
                        levelTiles[x, y] = Tile.createBlocked();

                    //Empty tile
                    if (aChar.ToString().Equals("."))
                        levelTiles[x, y] = Tile.createEmpty();

                    //Trap I.E Disco tile
                    if (aChar.ToString().Equals("T"))
                        levelTiles[x, y] = Tile.createTrap();

                    //Player start position
                    if (aChar.ToString().Equals("1"))
                    {
                        levelTiles[x, y] = Tile.createEmpty();
                        player.setPlayerPosition(new Vector2(x, y));
                    }

                    //Exit tile
                    if (aChar.ToString().Equals("X"))
                        levelTiles[x, y] = Tile.createExit();

                    //Heart Tile/gem
                    if (aChar.ToString().Equals("L"))
                    {
                        levelTiles[x, y] = Tile.createEmpty();
                        Vector2 gemPos = new Vector2(x, y);
                        Gem aGem = new Gem(gemPos);
                        aGem.setGemType(Gem.GemType.Life);
                        gemList.Add(aGem);
                    }

                    // Enemy - Rasta
                    if (aChar.ToString().Equals("R"))
                    {
                        levelTiles[x, y] = Tile.createEmpty();
                        Vector2 enemyPos = new Vector2(x, y);
                        Enemy theEnemy = new Enemy(enemyPos, camera.getScaleX());
                        theEnemy.setEnemyType(Enemy.EnemyType.Rasta);
                        enemyList.Add(theEnemy);
                    }

                    // Enemy - HipHopper
                    if (aChar.ToString().Equals("H"))
                    {
                        levelTiles[x, y] = Tile.createEmpty();
                        Vector2 enemyPos = new Vector2(x, y);
                        Enemy theEnemy = new Enemy(enemyPos, camera.getScaleX());
                        theEnemy.setEnemyType(Enemy.EnemyType.HipHopper);
                        enemyList.Add(theEnemy);
                    }

                    // Enemy - Ghost
                    if (aChar.ToString().Equals("G"))
                    {

                        levelTiles[x, y] = Tile.createEmpty();
                        Vector2 enemyPos = new Vector2(x, y);
                        Enemy theEnemy = new Enemy(enemyPos, camera.getScaleX());
                        theEnemy.setEnemySpeed(new Vector2(2.0f * ((float)randMovement.NextDouble() / (float)1f) - 1.0f, (float)randMovement.NextDouble()));
                        theEnemy.setEnemyType(Enemy.EnemyType.Ghost);
                        enemyList.Add(theEnemy);
                    }

                    levelTiles[x, y].setTilePosition(new Vector2(x, y));
//.........这里部分代码省略.........
开发者ID:hamatzu,项目名称:GSP-Projekt,代码行数:101,代码来源:Level.cs


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