public bool destroyWall(string type) { if (type == "south" && southWall != null) { DestroyImmediate(southWall.gameObject); //print("SOTH WALL DESTROYED"); southWall = null; return(true); } else if (type == "north" && northWall != null) { DestroyImmediate(northWall.gameObject); //print("NORTH WALL DESTROYED"); northWall = null; return(true); } else if (type == "east" && eastWall != null) { DestroyImmediate(eastWall.gameObject); //print("EAST WALL DESTROYED"); eastWall = null; return(true); } else if (type == "west" && westWall != null) { DestroyImmediate(westWall.gameObject); //print("WEST WALL DESTROYED"); westWall = null; return(true); } else { return(false); } }
private void CreateCorridorWalls(DungeonCell cell, int dir, Transform parent) { if (dir == 0) { if (tileMatrix[cell.Coordinates.z + 1, cell.Coordinates.x] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.North], Direction.North, cell, parent); cell.addWallRefenceToCell(aWall, "north"); } if (tileMatrix[cell.Coordinates.z - 1, cell.Coordinates.x] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.South], Direction.South, cell, parent); cell.addWallRefenceToCell(aWall, "south"); } } if (dir == 1) { if (tileMatrix[cell.Coordinates.z, cell.Coordinates.x - 1] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.West], Direction.West, cell, parent); cell.addWallRefenceToCell(aWall, "west"); } if (tileMatrix[cell.Coordinates.z, cell.Coordinates.x + 1] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.East], Direction.East, cell, parent); cell.addWallRefenceToCell(aWall, "east"); } } }
public void addWallRefenceToCell(WallUnit aWall, string type) { if (type == "south") { southWall = aWall; southWalls = "south"; } else if (type == "north") { northWall = aWall; northWalls = "north"; } else if (type == "east") { eastWall = aWall; eastWalls = "east"; } else if (type == "west") { westWall = aWall; westWalls = "west"; } else { Debug.Log("WRONG WALL TYPE"); } }
// Use this for initialization void Start() { soldierUnit = SoldierUnit.Instance; shooterUnit = ShooterUnit.Instance; wallUnit = WallUnit.Instance; bombUnit = BombUnit.Instance; playerBase = GameObject.FindGameObjectWithTag("PlayerBase"); if (soldierUnit != null) { SetSoldierParams(); } if (shooterUnit != null) { SetShooterParams(); } if (wallUnit != null) { SetWallParams(); } if (bombUnit != null) { SetBombUnitParams(); } if (playerBase != null) { playerBase.GetComponent <DefenceHealth>().maxHealth = health; } }
private WallUnit InstanciateWall(IntVector2 wallDirection, Direction direction, DungeonCell cell, Transform parent) { WallUnit aWall = Instantiate(wallPrefab) as WallUnit; aWall.transform.parent = cell.transform; aWall.transform.localPosition = new Vector3(wallDirection.x, 0.5f, wallDirection.z); aWall.transform.localRotation = direction.ToRotation(); aWall.transform.parent = parent; return(aWall); }
private void createSingleWall(DungeonCell cell, string type, Transform parent) { if (type == "north") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.North], Direction.North, cell, parent); cell.addWallRefenceToCell(aWall, "north"); } if (type == "south") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.South], Direction.South, cell, parent); cell.addWallRefenceToCell(aWall, "south"); } if (type == "east") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.East], Direction.East, cell, parent); cell.addWallRefenceToCell(aWall, "east"); } if (type == "west") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.West], Direction.West, cell, parent); cell.addWallRefenceToCell(aWall, "west"); } }
//questa funzione oltre ad istanziare un game object muro per un cella, salva anche il riferimento al //muro nella cella in modo che in fase di creazine dei corridoi si riescano a rimuovere le celle di muro //per creare i collegamenti private void CreateWall(int x, int z, int width, int height, DungeonCell cell) { if (z == 0 && x >= 0 && x < width) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.South], Direction.South, cell, "south wall"); cell.addWallRefenceToCell(aWall, "south"); } if (z == height - 1 && x >= 0 && x < width) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.North], Direction.North, cell, "north wall"); cell.addWallRefenceToCell(aWall, "north"); } if (x == 0 && z >= 0 && z < height) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.West], Direction.West, cell, "west wall"); cell.addWallRefenceToCell(aWall, "west"); } if (x == width - 1 && z >= 0 && z < height) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.East], Direction.East, cell, "east wall"); cell.addWallRefenceToCell(aWall, "east"); } }
void Awake() { Instance = this; }
/// <summary> /// 上方を地面の法線に合わせる回転を取得する。ただし、壁とみなせる場合は無回転が返る。 /// </summary> public Quaternion rotGroundMovableOnWorld(WallUnit wall) { return(wall.isMovable(normal) ? rotGroundOnWorld : Quaternion.identity); }