public void Handle(UnlockDoor command) { }
public void Handle(UnlockDoor command) { }
//Instantiate a cell based on its type private void InstantiateCell(Cell c) { Vector3 cellPos = new Vector3(c.position.x * cellSize, 0, c.position.y * cellSize); CellInstance instanceCell; if (c.type == CellType.DeadEnd) { instanceCell = Instantiate(deadEndPrefab.gameObject, Vector3.zero, Quaternion.identity).GetComponent <CellInstance>(); } else if (c.type == CellType.Room) { instanceCell = Instantiate(roomFloorPrefab.gameObject, Vector3.zero, Quaternion.identity).GetComponent <CellInstance>(); } else if (c.type == CellType.Start) { instanceCell = Instantiate(startPrefab.gameObject, Vector3.zero, Quaternion.identity).GetComponent <CellInstance>(); } else if (c.type == CellType.End) { instanceCell = Instantiate(endPrefab.gameObject, Vector3.zero, Quaternion.identity).GetComponent <CellInstance>(); } else if (c.type == CellType.RoomEntry) { instanceCell = Instantiate(roomTrigger.gameObject, Vector3.zero, Quaternion.identity).GetComponent <CellInstance>(); } else { instanceCell = Instantiate(groundPrefab.gameObject, Vector3.zero, Quaternion.identity).GetComponent <CellInstance>(); } //Spawn a ceiling GameObject ceiling = Instantiate(groundPrefab.gameObject, Vector3.zero, Quaternion.identity); ceiling.name = "Ceiling"; ceiling.transform.localScale = new Vector3(cellSize, instanceCell.transform.localScale.y, cellSize); instanceCell.name = "Cell (" + c.position.x + "," + c.position.y + ")"; instanceCell.transform.localScale = new Vector3(cellSize, instanceCell.transform.localScale.y, cellSize); instanceCell.associatedCell = c; ceiling.transform.localPosition = cellPos + new Vector3(0, cellSize, 0); instanceCell.gameObject.transform.SetParent(this.gameObject.transform); instanceCell.transform.localPosition = cellPos; ceiling.transform.SetParent(instanceCell.gameObject.transform); //Spawn each wall based on its position and direction for (int i = 0; i < 4; i++) { if (c.walls[i]) { Quaternion rotation = ((Directions)i).ToRotation(); IntVector2 vec2 = ((Directions)i).ToVector(); //Might want to multiply by cellSize, but right now we don't have to because the parent cell is scaled anyway Vector3 wallPos = new Vector3(cellSize * vec2.x * 0.5f, cellSize * 0.5f, cellSize * vec2.y * 0.5f) + cellPos; GameObject instanceWall = Instantiate(wallPrefab, Vector3.zero, rotation); instanceWall.transform.localScale = new Vector3(cellSize, instanceWall.transform.localScale.y, cellSize); instanceWall.transform.localPosition = wallPos; instanceWall.name = ((Directions)i).ToString() + "Wall"; instanceWall.transform.SetParent(instanceCell.gameObject.transform); } //If we're spawning the end cell, we'll spawn the locked door to prevent player from escaping else if (c.type == CellType.End && ((Directions)i) != Directions.NORTH) { Quaternion rotation = ((Directions)i).ToRotation(); IntVector2 vec2 = ((Directions)i).ToVector(); //TODO: Might want to multiply by cellSize, but right now we don't have to because the parent cell is scaled anyway Vector3 wallPos = new Vector3(cellSize * vec2.x * 0.5f, cellSize * 0.5f, cellSize * vec2.y * 0.5f) + cellPos; exitInstance = Instantiate(exitPrefab, Vector3.zero, rotation) as UnlockDoor; exitInstance.transform.localScale = new Vector3(cellSize, exitInstance.transform.localScale.y, cellSize); exitInstance.transform.localPosition = wallPos; exitInstance.name = ((Directions)i).ToString() + "LOCKED DOOR"; exitInstance.transform.SetParent(instanceCell.gameObject.transform); } } }
void BehaviorTree() { root = new Selector(); //First two sequences Sequence sequenceLeft = new Sequence(); sequenceLeft.parent = root; root.children.Add(sequenceLeft); Sequence sequenceRight = new Sequence(); sequenceRight.parent = root; root.children.Add(sequenceRight); //Left sequence WalkToDoor walkToDoor = new WalkToDoor(); walkToDoor.success = false; walkToDoor.parent = sequenceLeft; sequenceLeft.children.Add(walkToDoor); Selector selectorLeft = new Selector(); selectorLeft.parent = sequenceLeft; sequenceLeft.children.Add(selectorLeft); WalkThroughDoor walkThroughDoor = new WalkThroughDoor(); walkThroughDoor.success = true; walkThroughDoor.parent = sequenceLeft; sequenceLeft.children.Add(walkThroughDoor); CloseDoor closeDoor = new CloseDoor(); closeDoor.success = true; closeDoor.parent = sequenceLeft; sequenceLeft.children.Add(closeDoor); //Selector Left OpenDoor openDoor = new OpenDoor(); openDoor.success = false; openDoor.parent = selectorLeft; selectorLeft.children.Add(openDoor); Sequence sequenceLeftTwo = new Sequence(); sequenceLeftTwo.parent = selectorLeft; selectorLeft.children.Add(sequenceLeftTwo); SmashDoor smashDoor = new SmashDoor(); smashDoor.success = true; smashDoor.parent = selectorLeft; selectorLeft.children.Add(smashDoor); //Sequence Left Two UnlockDoor unlockDoor = new UnlockDoor(); unlockDoor.success = false; unlockDoor.parent = sequenceLeftTwo; sequenceLeftTwo.children.Add(unlockDoor); OpenDoor openDoor2 = new OpenDoor(); openDoor2.success = true; openDoor2.parent = sequenceLeftTwo; sequenceLeftTwo.children.Add(openDoor2); //Right Sequence WalkToWindow walkToWindow = new WalkToWindow(); walkToWindow.success = true; walkToWindow.parent = sequenceRight; sequenceRight.children.Add(walkToWindow); Selector selectorRight = new Selector(); selectorRight.parent = sequenceRight; sequenceRight.children.Add(selectorRight); ClimbThroughWindow climbThroughWindow = new ClimbThroughWindow(); climbThroughWindow.success = true; climbThroughWindow.parent = sequenceRight; sequenceRight.children.Add(climbThroughWindow); CloseWindow closeWindow = new CloseWindow(); closeWindow.success = true; closeWindow.parent = sequenceRight; sequenceRight.children.Add(closeWindow); //Selector Right OpenWindow openWindow = new OpenWindow(); openWindow.success = false; openWindow.parent = selectorRight; selectorRight.children.Add(openWindow); Sequence sequenceRightTwo = new Sequence(); sequenceRightTwo.parent = selectorRight; selectorRight.children.Add(sequenceRightTwo); SmashWindow smashWindow = new SmashWindow(); smashWindow.success = true; smashWindow.parent = selectorRight; selectorRight.children.Add(smashWindow); //Sequence Right Two UnlockWindow unlockWindow = new UnlockWindow(); unlockWindow.success = true; unlockWindow.parent = sequenceRightTwo; sequenceRightTwo.children.Add(unlockWindow); OpenWindow openWindow2 = new OpenWindow(); openWindow2.success = true; openWindow2.parent = sequenceRightTwo; sequenceRightTwo.children.Add(openWindow2); }