本文整理汇总了C#中Level.getItemByName方法的典型用法代码示例。如果您正苦于以下问题:C# Level.getItemByName方法的具体用法?C# Level.getItemByName怎么用?C# Level.getItemByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.getItemByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: start
public void start(Level level, List<Level> menus, List<Level> huds)
{
Console.WriteLine("SceneManager.start");
mouseCursor = new MouseCursor();
TextureItem textureItem;
string name = null;
/*
* Load mouse cursor
* */
Item mouseItem = level.getItemByName("MouseCursor");
textureItem = (TextureItem)mouseItem;
name = ResourceManager.getInstance.loadName(textureItem, "Name");
mouseCursor = new MouseCursor(textureItem.texture, textureItem.Position, textureItem.Rotation, textureItem.Origin,
textureItem.Scale, name);
/*
* Initializes camera and set its view
* IMPORTANT: The item used here have to point to the player
* */
//2389 and 5227 is hard coded players start position
camera = new Camera(Matrix.Identity, new Vector2(Renderer.getInstance.getScreenCenter().X - 2389,
Renderer.getInstance.getScreenCenter().Y - 5227));
camera.setView(Matrix.CreateTranslation(new Vector3(camera.getPosition() - Renderer.getInstance.getScreenCenter(), 0f)) *
Matrix.CreateTranslation(new Vector3(Renderer.getInstance.getScreenCenter(), 0f)));
loadMenus(menus);
loadHud(huds);
Console.WriteLine("Camera: " + camera.getPosition());
//Console.WriteLine("Player: " + item.Position);
}
示例2: loadLevel
public void loadLevel(Level level)
{
player1 = new Character();
backgroundObjects = new List<BackgroundObject>();
middleObjects = new List<MiddleObject>();
resourceObjects = new List<MiddleObject>();
collision = false;
List<TextureItem> textureItems;
AABB axisAlignedBox = null;
List<AABB> axisAlignedBoxes = null;
List<Polygon> polygons = null;
float depthPosition = 0.0f;
string name = null;
bool isAnimated = false;
RectangleItem levelCollisionBox = (RectangleItem)level.getItemByName("LevelAABB");
axisAlignedBox = new AABB(levelCollisionBox.Position, levelCollisionBox.Width, levelCollisionBox.Height);
this.axisAlignedBox = axisAlignedBox;
/*
* Load background objects
* */
textureItems = level.getTextureItems("ObjectType", "BackgroundObject");
foreach (TextureItem item in textureItems)
{
polygons = null;
axisAlignedBoxes = null;
axisAlignedBoxes = ResourceManager.getInstance.loadAxisAlignedBoxes(item, "CollisionBox"); //AABB
polygons = ResourceManager.getInstance.loadPolygons(item, "Polygon"); //Polygon
name = ResourceManager.getInstance.loadName(item, "Name");
if (axisAlignedBoxes != null)
{
backgroundObjects.Add(new BackgroundObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, axisAlignedBoxes, name));
}
else if (polygons != null)
{
backgroundObjects.Add(new BackgroundObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, polygons, null, name));
}
else
{
backgroundObjects.Add(new BackgroundObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, null, name));
}
}
/*
* Load resource objects
* */
textureItems = level.getTextureItems("ObjectType", "ResourceObject");
foreach (TextureItem item in textureItems)
{
depthPosition = ResourceManager.getInstance.loadDepthPosition(item, "DepthPosition");
name = ResourceManager.getInstance.loadName(item, "Name");
resourceObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, null, depthPosition, name));
}
/*
* Load middle objects
* */
textureItems = level.getTextureItems("ObjectType", "MiddleObject");
foreach (TextureItem item in textureItems)
{
polygons = null;
axisAlignedBoxes = null;
axisAlignedBoxes = ResourceManager.getInstance.loadAxisAlignedBoxes(item, "CollisionBox"); //AABB
polygons = ResourceManager.getInstance.loadPolygons(item, "Polygon"); //Polygon
depthPosition = ResourceManager.getInstance.loadDepthPosition(item, "DepthPosition");
name = ResourceManager.getInstance.loadName(item, "Name");
isAnimated = ResourceManager.getInstance.loadIsAnimated(item, "IsAnimated");
if (!isAnimated)
{
if (axisAlignedBoxes != null)
{
middleObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, axisAlignedBoxes, depthPosition, name));
}
else if (polygons != null)
{
middleObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, polygons, null, depthPosition, name));
}
else
{
middleObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, null, depthPosition, name));
}
}
else
{
Texture2D[] animationSprites = ResourceManager.getInstance.loadAnimationSprite(item, "AnimationPath");
int numberOfAnimations = ResourceManager.getInstance.loadAnimationProperty(item, "NumberOfAnimations");
int[] animationSpeeds = ResourceManager.getInstance.loadAnimationProperty2(item, "AnimationSpeed");
int[] numberOfFrames = ResourceManager.getInstance.loadAnimationProperty2(item, "NumberOfFrames");
int[] numberOfRows = ResourceManager.getInstance.loadAnimationProperty2(item, "NumberOfRows");
if (name == "Player")
{
if (axisAlignedBoxes != null && polygons != null)
{
//.........这里部分代码省略.........