本文整理汇总了C#中Maze.GetCell方法的典型用法代码示例。如果您正苦于以下问题:C# Maze.GetCell方法的具体用法?C# Maze.GetCell怎么用?C# Maze.GetCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maze
的用法示例。
在下文中一共展示了Maze.GetCell方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
// Update is called once per frame
void Update ()
{
if(mGen == null)
mGen = FindObjectOfType<MazeGenerator>();
else if(m == null && mGen != null)
{
m = mGen.currentMaze();
if(m != null)
{
Texture2D t = new Texture2D((int)m.Dimensions().x, (int)m.Dimensions().y, TextureFormat.ARGB4444, false);
for(int x=0; x<t.width; x++)
{
for(int y=0; y<t.height; y++)
{
if(m.GetCell(x,y).isWall)
t.SetPixel(x,y,Color.black);
else
t.SetPixel(x,y,Color.white);
}
}
t.anisoLevel = 0;
t.filterMode = FilterMode.Point;
t.Apply();
im.sprite = Sprite.Create(t, new Rect(0,0,t.width,t.height), Vector2.one/2);
}
}
}
示例2: BeginGame
private IEnumerator BeginGame()
{
mazeInstance = Instantiate(mazePrefab) as Maze;
yield return StartCoroutine (mazeInstance.Generate());
playerInstance = Instantiate(playerPrefab) as Player;
playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
StartCoroutine(mazeInstance.Generate());
}
示例3: BeginGame
private IEnumerator BeginGame () {
Camera.main.clearFlags = CameraClearFlags.Skybox;
Camera.main.rect = new Rect(0f, 0f, 1f, 1f);
mazeInstance = Instantiate(mazePrefab) as Maze;
yield return StartCoroutine(mazeInstance.Generate());
playerInstance = Instantiate(playerPrefab) as Player;
playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
Camera.main.clearFlags = CameraClearFlags.Depth;
Camera.main.rect = new Rect(0f, 0f, 0.5f, 0.5f);
}
示例4: BeginGame
private IEnumerator BeginGame()
{
Camera.main.clearFlags = CameraClearFlags.Skybox;
Camera.main.rect = new Rect(0f, 0f, 1f, 1f);
mazeInstance = Instantiate(mazePrefab) as Maze;
yield return StartCoroutine(mazeInstance.Generate());
playerInstance = Instantiate(playerPrefab) as Player;
boxInstance = Instantiate (boxPrefab) as Box;
boxInstance2 = Instantiate (boxPrefab) as Box;
boxInstance3 = Instantiate (boxPrefab) as Box;
samuraiInstance = Instantiate (samurai) as Player;
playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
boxInstance.SetLocation (mazeInstance.GetCell (mazeInstance.RandomCoordinates));
boxInstance2.SetLocation (mazeInstance.GetCell (mazeInstance.RandomCoordinates));
boxInstance3.SetLocation (mazeInstance.GetCell (mazeInstance.RandomCoordinates));
samuraiInstance.SetLocation (mazeInstance.GetCell (mazeInstance.RandomCoordinates));
this.transform.position = samuraiInstance.transform.position;
audio.Play ();
Debug.Log (this.transform.GetChild (0).transform.name);
this.transform.GetChild (0).audio.Play ();
start = true;
Camera.main.clearFlags = CameraClearFlags.Depth;
Camera.main.rect = new Rect(0f, 0f, 0.5f, 0.5f);
}
示例5: BeginGame
private IEnumerator BeginGame()
{
Camera.main.clearFlags = CameraClearFlags.Skybox;
Camera.main.rect = new Rect(0f, 0f, 1f, 1f);
HUDInfo._Hunger = 200;
mazeInstance = Instantiate(mazePrefab) as Maze;
yield return StartCoroutine(mazeInstance.Generate());
playerInstance = Instantiate(playerPrefab) as Player;
playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
Player.gameOver = false;
foodInstance = Instantiate(foodPrefab) as Food;
SpawnNewFood();
Camera.main.clearFlags = CameraClearFlags.Depth;
Camera.main.rect = new Rect(0f, 0f, 0.5f, 0.5f);
}
示例6: CreateMiniMap
public void CreateMiniMap(Maze maze)
{
_totalIslands = 0;
_miniMapIslands = new GameObject[maze.width, maze.height];
_miniMapHorizontalBridges = new GameObject[maze.width, maze.height];
_miniMapVerticalBridges = new GameObject[maze.width, maze.height];
//Count islands
for (int y = 0; y < maze.height; y++) {
for (int x = 0; x < maze.width; x++) {
if (!maze.GetCell(x, y).HasNoDoors()) {
_totalIslands++;
}
}
}
print("MiniMap found: " + _totalIslands + " islands");
}
示例7: BeginGame
private void BeginGame()
{
//Camera.main.clearFlags = CameraClearFlags.Skybox;
Camera.main.rect = new Rect(0f, 0f, 1f, 1f);
mazeInstance = Instantiate(mazePrefab) as Maze;
//StartCoroutine(mazeInstance.Generate());
mazeInstance.Generate();
playerInstance = Instantiate(playerPrefab) as GameObject;
playerInstance.GetComponent<Player>().SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
Vector3 scaleVector = new Vector3(0.1f, 0.1f, 0.1f);
playerInstance.transform.localScale = scaleVector;
//playerInstance.GetComponent<Renderer>().transform.localScale = scaleVector;
//Camera.main.clearFlags = CameraClearFlags.Color;
Camera.main.SetReplacementShader(Shader.Find("Unlit/Color"), "");
Camera.main.rect = new Rect(0f, 0f, 0.2f, 0.2f);
}
示例8: BeginGame
private IEnumerator BeginGame () {
audio.PlayOneShot(_Introduction, 1f);
mazeInstance = Instantiate(mazePrefab) as Maze;
yield return StartCoroutine(mazeInstance.Generate());
SpawnPlayer();
SpawnMinotaur();
exitInstance = Instantiate(exitPrefab) as ExitPoint;
exitInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates));
Lives = 1;
alive = true;
winState = false;
gameOver = false;
restart = false;
}
示例9: InstantiateMazeBridges
private void InstantiateMazeBridges(Maze maze)
{
for (int y = 0; y < maze.height; y++)
{
for (int x = 0; x < maze.width; x++)
{
bool[] doors = maze.GetCell(x, y).doors;
GameObject island1Anchor;
GameObject island2Anchor;
//Only instantiate bridges right & down (to avoid double bridges)
if (doors[2]) {
island1Anchor = FindBridgeAnchor(mazeCellInstances[x, y], Opening.RIGHT);
island2Anchor = FindBridgeAnchor(mazeCellInstances[x+1, y], Opening.LEFT);
mazeBridgeInstances.Add(InstantiateSpanningBridge(
bridgeSpanPrefab, bridgeEndPrefab, mazeCellInstances[x, y], mazeCellInstances[x+1, y], island1Anchor, island2Anchor));
}
if (doors[3]) {
island1Anchor = FindBridgeAnchor(mazeCellInstances[x, y], Opening.BOT);
island2Anchor = FindBridgeAnchor(mazeCellInstances[x, y+1], Opening.TOP);
mazeBridgeInstances.Add( InstantiateSpanningBridge(
bridgeSpanPrefab, bridgeEndPrefab, mazeCellInstances[x, y], mazeCellInstances[x, y+1], island1Anchor, island2Anchor));
}
}
}
}
示例10: InstantiateMaze
private void InstantiateMaze(Maze maze)
{
mazeCellInstances = new GameObject[maze.width, maze.height];
for (int y = 0; y < maze.height; y++)
{
for (int x = 0; x < maze.width; x++)
{
int dictionaryKey = ConvertDoorsToDictionaryKey(maze.GetCell(x, y).doors);
//If start cell
if(x == mazeFromX && y == mazeFromY) {
Vector3 randomizedCellPosition = GetRandomCellDisplacement(x * cellSpacing, -y * cellSpacing, cellSpacing);
mazeCellInstances[x,y] = (GameObject)GameObject.Instantiate(StartCell, randomizedCellPosition, Quaternion.identity);
}
else if ( !maze.GetCell(x, y).HasNoDoors() )
{
Vector3 randomizedCellPosition = GetRandomCellDisplacement(x * cellSpacing, -y * cellSpacing, cellSpacing);
//print ("ins: " + dictionaryKey);
//var cells = (GameObject[]) mazeCellPrefabs[dictionaryKey];
var validIslands = (GameObject[]) mazeCellPrefabs[dictionaryKey];
mazeCellInstances[x,y] = InstantiateCell(validIslands , Random.Range (0, validIslands.Length), randomizedCellPosition, maze, x, y);
}
if (mazeCellInstances[x, y] != null) {
mazeCellInstances[x, y].AddComponent<MazeInstance>().represents = maze.GetCell(x, y);
}
}
}
}
示例11: InstantiateCell
private GameObject InstantiateCell(GameObject[] mazeCellPrefab, int prefabNumber, Vector3 position, Maze maze, int x, int y)
{
var fab = mazeCellPrefab[prefabNumber];
var mCell = maze.GetCell(x, y);
GameObject cell;
if(!BossCellInstansiated && mCell.stepsFromOrigin == maze.MaxSteps) {
cell = (GameObject) Instantiate(BossCell, position, BossCell.transform.rotation);
BossCellInstansiated = true;
} else
cell = (GameObject) Instantiate(fab, position, fab.transform.rotation);
cell.name = "Distance" + mCell.stepsFromOrigin + "Generation" + mCell.generationNumber;
return cell;
}