public Cell(Element._ element, GameObject block, Material mat) { this.type = element; this.baseObj = block; this.x = (int)baseObj.transform.position.x; this.z = (int)baseObj.transform.position.z; if (type == Element._.FLOOR || type == Element._.WALL) { block.transform.Rotate(new Vector3(0, 90 * Random.Range(0, 4), 0)); } bottomY = 0f; if (type == Element._.WALL) { bottomY = 1f; } if (type == Element._.DOOR_B) { bottomY = 1f; amDoor = true; } else if (type == Element._.DOOR_A) { amDoor = true; } else { amDoor = false; } Renderer renderer = baseObj.GetComponent <Renderer>(); renderer.material = mat; fallSpeed = 8 + Random.value * 15; }
public void smashCrate() { if (type != Element._.CRATE) { return; } if (crateObj == null) { return; } //CrateScript crate = (CrateScript)crateObj.GetComponent(typeof(CrateScript)); //crate.detonate(audioSource); if (amDoor) { type = Element._.DOOR_A; doorIsDown = true; } else { type = Element._.FLOOR; } crateObj = null; }
private void generateMap(int width, int height, string[] lines, bool rotate, int mirror) { int[] posPlayer1, posPlayer2; posPlayer1 = new int[2]; posPlayer2 = new int[2]; if (rotate && height * 1.5 < width) { map = new Element._[height, width]; //fill wih empty for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { map[j, i] = Element._.NOTHING; } } for (int j = 0; j < height; j++) { string row = lines[j]; for (int i = 0; i < row.Length; i++) { Element._ element = Element.get(row[i]); int[] mapIndex = new int[2]; if (mirror == 0) { mapIndex[0] = j; mapIndex[1] = i; } else if (mirror == 1) { mapIndex[0] = height - 1 - j; mapIndex[1] = i; } else if (mirror == 2) { mapIndex[0] = j; mapIndex[1] = row.Length - 1 - i; } else if (mirror == 3) { mapIndex[0] = height - 1 - j; mapIndex[1] = row.Length - 1 - i; } map[mapIndex[0], mapIndex[1]] = element; if (Element.get(row[i]) == Element._.PLAYER1) { posPlayer1[0] = mapIndex[0]; posPlayer1[1] = mapIndex[1]; } else if (Element.get(row[i]) == Element._.PLAYER2) { posPlayer2[0] = mapIndex[0]; posPlayer2[1] = mapIndex[1]; } } } } else { map = new Element._[width, height]; //fill wih empty for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { map[i, j] = Element._.NOTHING; } } for (int j = 0; j < height; j++) { string row = lines[j]; for (int i = 0; i < row.Length; i++) { Element._ element = Element.get(row[i]); int[] mapIndex = new int[2]; if (mirror == 0) { mapIndex[0] = i; mapIndex[1] = j; } else if (mirror == 1) { mapIndex[0] = row.Length - 1 - i; mapIndex[1] = j; } else if (mirror == 2) { mapIndex[0] = i; mapIndex[1] = height - 1 - j; } else if (mirror == 3) { mapIndex[0] = row.Length - 1 - i; mapIndex[1] = height - 1 - j; } map[mapIndex[0], mapIndex[1]] = element; if (Element.get(row[i]) == Element._.PLAYER1) { posPlayer1[0] = mapIndex[0]; posPlayer1[1] = mapIndex[1]; } else if (Element.get(row[i]) == Element._.PLAYER2) { posPlayer2[0] = mapIndex[0]; posPlayer2[1] = mapIndex[1]; } } } } // switch places if Player 2 is on the left if (posPlayer1[0] > posPlayer2[0]) { map[posPlayer1[0], posPlayer1[1]] = Element._.PLAYER2; map[posPlayer2[0], posPlayer2[1]] = Element._.PLAYER1; } }
public void setType(Element._ type) { this.type = type; }
public void addCrate(GameObject obj) { this.crateObj = obj; type = Element._.CRATE; //obj.transform.Rotate(new Vector3(0, 90 * Random.Range(0, 4), 0)); }