本文整理汇总了C#中Level.fixLimits方法的典型用法代码示例。如果您正苦于以下问题:C# Level.fixLimits方法的具体用法?C# Level.fixLimits怎么用?C# Level.fixLimits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.fixLimits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: remoteCall
protected IEnumerator remoteCall()
{
changinglevels = true;
WWW content = new WWW(@"http://wiki-412.appspot.com/json/alpha2.json");
while(!content.isDone)
{
Debug.Log("fetching");
yield return null;
}
string hold = content.text;
currentlevel = JsonMapper.ToObject<Level>(hold);
currentlevel.fixLimits();
currentlevel.constructMatrix(3);
generateLevel();
changinglevels = false;
}
示例2: mapLevel
//breadth first mapping of level, that goes one extra block out. Naive implementation. Need to get character away from cubes to work
public Level mapLevel(string name)
{
//Create array of directions to check for mapping
Vector3[] directions = new Vector3[6]; //declare array to go through, maybe find more elegant way
directions[0] = Vector3.right;
directions[1] = Vector3.left;
directions[2] = Vector3.up;
directions[3] = Vector3.down;
directions[4] = Vector3.forward;
directions[5] = Vector3.back;
List<Point> reached = new List<Point>();
List<Point> toreach = new List<Point>();
toreach.Add(new Point(GameObject.FindGameObjectWithTag("block").transform.position,true));
Vector3 position;
bool occupied;
Level level = new Level();
Entity template;
RaycastHit hitblock;
while(toreach.Count!=0)
{
position = toreach[0].position;
occupied = toreach[0].occupied;
template = new Entity(); //new Entity
for(int i = 0;i<6;i++) //check all 6 sides for blocks and unchecked spaces
{
if(Physics.Raycast(position,directions[i],out hitblock,1f))//if object in direction and it hasn't been reached or will be reached, add it to scan que
{
if(hitblock.collider.tag=="block")
{
Point temp = new Point(position+directions[i],true);
if(!reached.Contains(temp)&&!toreach.Contains(temp))
toreach.Add(temp);
}
else if(hitblock.collider.tag=="character")
{
Entity temp = new Entity();
temp.setData(Mathf.RoundToInt(position.x+directions[i].x),Mathf.RoundToInt(position.y+directions[i].y),Mathf.RoundToInt(position.z+directions[i].z),states.character,(int) charactertypes.basic);
if(!level.Objects.Contains(temp))
level.addObject(temp);
}
}
else if(!Physics.Raycast(position,directions[i],1f)&&occupied == true)//if no object in front and coming from occupied block, and not in either list, then add
{
Point temp = new Point(position+directions[i],false);
if(!reached.Contains(temp)&&!toreach.Contains(temp))
toreach.Add(temp);
}
}
//if block then add
if(occupied==true)
{
template.setData(Mathf.RoundToInt(position.x),Mathf.RoundToInt(position.y),Mathf.RoundToInt(position.z),states.block,(int) blocktypes.basic);//add entity for occupied spaces
level.addObject(template);
}
//add to reached points, remove from points to scan
reached.Add(toreach[0]);
toreach.Remove(toreach[0]);
}
level.name = name;
level.fixLimits();
return level;
}
示例3: read
//Use stream reader and external json library to read in a saved level
//after loading in make sure to fix limits to the maximums so that padding will be consistent when added
//then make the matrix of right size, including padding
protected void read(int padding)
{
Debug.Log ("reading level");
if(!Application.isWebPlayer)
{
using(StreamReader file = new StreamReader(Application.dataPath+"/Levels/"+currentlevel.name+".json"))
{
string hold = file.ReadToEnd();
currentlevel = JsonMapper.ToObject<Level>(hold);
}
currentlevel.fixLimits();
currentlevel.constructMatrix(padding);
generateLevel();
}
else if(Application.isWebPlayer)
{
StartCoroutine(remoteCall());
}
}