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


C# Monster.LoadContent方法代码示例

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


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

示例1: RandomLevel

    /// <summary>
    /// Creating/generating the level itself
    /// </summary>
    /// <param name="roomNumber">The number of the room</param>
    /// <param name="tiles">The size the Mainpath should be, counted in tiles</param>
    /// <param name="chased">Whether or not the monster is chasing the player</param>
    public RandomLevel(int roomNumber, int tiles = 12, bool chased = false, int noteID = 0)
    {
        //Setting a boolean for the monster
        this.chased = chased;

        //Assining the variables
        tileList = new Dictionary<Point, Tile>();
        keyList = new List<Point>();

        random = GameEnvironment.Random;

        //Select the tiles to use
        int pathType = random.Next(4);
        if (pathType < 9)
            pathID = "0" + (pathType + 1);
        else
            pathID = "" + (pathType + 1);

        int wallType = random.Next(4);
        if (wallType < 9)
            wallID = "0" + (wallType + 1);
        else
            pathID = "" + (wallType + 1);
        newTile = new EntryTile(pathID);
        this.tiles = tiles;

        //Create the startpoint
        position = Point.Zero;
        tileList.Add(position, newTile);
        keyList.Add(position);

        //Creating the paths
        CreateMainPath();
        for (int i = random.Next(1, (int)Math.Pow(tiles,2/3)); i > 0; i--)
            CreateSidePath(random.Next(3, 15), chased);

        //making the tile grid
        TileGrid tileGrid = Grid;
        gameObjects.Add(tileGrid);

        //making the player
        player = new Player(Vector3.Zero);
        gameObjects.Add(player);
        player.Parent = this;
        player.LoadContent();

        foreach(GameObject obj in tileGrid.Objects)
        {
            if (obj != null)
                if(obj.ID == "EntryTile")
                {
                    player.Position = new Vector3(obj.Position.X, obj.Position.Y + GameObjectGrid.CellHeight, obj.Position.Z);
                    foreach(GameObject tile in tileGrid.Objects)
                    {
                        if (tile != null)
                        {
                            if (tile.Position.X == obj.Position.X + 200 && tile.Position.Z == obj.Position.Z && tile.ID == "PathTile")
                                player.viewAngleX = 0f;
                            if (tile.Position.X == obj.Position.X && tile.Position.Z == obj.Position.Z + 200 && tile.ID == "PathTile")
                                player.viewAngleX = (float)(Math.PI / 2);
                            if (tile.Position.X == obj.Position.X - 200 && tile.Position.Z == obj.Position.Z && tile.ID == "PathTile")
                                player.viewAngleX = (float)(Math.PI);
                            if (tile.Position.X == obj.Position.X && tile.Position.Z == obj.Position.Z - 200 && tile.ID == "PathTile")
                                player.viewAngleX = (float)(Math.PI * 1.5);
                        }
                    }
                }
        }

        //Adding decoration objects
        TileGrid grid = Find("TileGrid") as TileGrid;
        for (int x = 0; x < grid.Columns; x++)
            for (int y = 0; y < grid.Rows; y++)
                if (grid.Get(x, y) != null)
                {
                    if (grid.Get(x, y).ID == "WallTile" && GameEnvironment.Random.Next(15) == 0)
                    {
                        try
                        {
                            if (grid.Get(x + 1, y) != null && grid.Get(x + 1, y).ID == "PathTile" && grid.Get(x + 1, y).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(-1, 0, 0));
                                grid.Add(new DecorationTile(pathID), x + 1, y);
                            }
                            else if (grid.Get(x, y + 1) != null && grid.Get(x, y + 1).ID == "PathTile" && grid.Get(x, y + 1).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(0, 0, -1));
                                grid.Add(new DecorationTile(pathID), x, y + 1);
                            }
                            else if (grid.Get(x - 1, y) != null && grid.Get(x - 1, y).ID == "PathTile" && grid.Get(x - 1, y).ID != "DecorationTile")
                            {
                                AddDecoration(grid.Get(x, y).Position, new Vector3(1, 0, 0));
                                grid.Add(new DecorationTile(pathID), x - 1, y);
                            }
//.........这里部分代码省略.........
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:101,代码来源:RandomLevel.cs


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