private void Killme() { dead = true; this.GetComponent <NavMeshAgent>().updatePosition = false; this.GetComponent <NavMeshAgent>().updateRotation = false; this.rb.isKinematic = false; this.rb.useGravity = false; rb.velocity = Vector3.zero; this.rb.detectCollisions = false; this.GetComponent <BoxCollider>().enabled = false; var PUP = GameManager.roll <GameObject>(PowerUPprefabs, weights); if (PUP != null) { PUP = GameObject.Instantiate(PUP); PUP.transform.position = this.gameObject.transform.position; } if (!unRegistered) { RoomTools.entityDestroyed("ChainsawNose"); unRegistered = true; } anim.SetBool("Walk", true); anim.SetBool("Die", true); GameObject.Destroy(this.gameObject, 5); }
private bool generateWall(GameObject host, Vector2 bottomSize, Vector2 topSize, float lowerHeight, float upperHeight) { QuadMesh meshBuilder = new QuadMesh(); Vector3 bottomLeft, topLeft, topRight, bottomRight; //+x Wall bottomLeft = new Vector3(bottomSize.x / 2, lowerHeight, bottomSize.y / 2); topLeft = new Vector3(topSize.x / 2, upperHeight, topSize.y / 2); topRight = new Vector3(topSize.x / 2, upperHeight, -topSize.y / 2); bottomRight = new Vector3(bottomSize.x / 2, lowerHeight, -bottomSize.y / 2); meshBuilder.addQuad(bottomLeft, topLeft, topRight, bottomRight); //-x Wall bottomLeft = new Vector3(-bottomSize.x / 2, lowerHeight, -bottomSize.y / 2); topLeft = new Vector3(-topSize.x / 2, upperHeight, -topSize.y / 2); topRight = new Vector3(-topSize.x / 2, upperHeight, topSize.y / 2); bottomRight = new Vector3(-bottomSize.x / 2, lowerHeight, bottomSize.y / 2); meshBuilder.addQuad(bottomLeft, topLeft, topRight, bottomRight); //+z Wall bottomLeft = new Vector3(-bottomSize.x / 2, lowerHeight, bottomSize.y / 2); topLeft = new Vector3(-topSize.x / 2, upperHeight, topSize.y / 2); topRight = new Vector3(topSize.x / 2, upperHeight, topSize.y / 2); bottomRight = new Vector3(bottomSize.x / 2, lowerHeight, bottomSize.y / 2); meshBuilder.addQuad(bottomLeft, topLeft, topRight, bottomRight); //-z Wall bottomLeft = new Vector3(bottomSize.x / 2, lowerHeight, -bottomSize.y / 2); topLeft = new Vector3(topSize.x / 2, upperHeight, -topSize.y / 2); topRight = new Vector3(-topSize.x / 2, upperHeight, -topSize.y / 2); bottomRight = new Vector3(-bottomSize.x / 2, lowerHeight, -bottomSize.y / 2); meshBuilder.addQuad(bottomLeft, topLeft, topRight, bottomRight); Mesh wallMesh = meshBuilder.getMesh(); RoomTools.addMeshWithCol(host, wallMesh, RoomTools.wallRenderMaterial, RoomTools.wallPhysicMaterial); return(true); }
public Room createRandNextRoom() { Vector3 nextRoomDimensions = this.dimensions; float transitionHeight = 0f; Color color = this.roomColor; float transitionRnd = UnityEngine.Random.Range(-RoomTools.transitionVariation / 2, RoomTools.transitionVariation / 2); float rnd = UnityEngine.Random.Range(0.0f, 1.0f); if (rnd <= RoomTools.biggerModeProb) { color = RoomTools.getRndLightColor(); nextRoomDimensions = RoomTools.getRndDimensions(this.dimensions, RoomTools.maxDimensions); } else if (rnd <= RoomTools.biggerModeProb + RoomTools.smallerModeProb) { color = RoomTools.getRndLightColor(); nextRoomDimensions = RoomTools.getRndDimensions(RoomTools.minDimensions, this.dimensions); } transitionHeight = Math.Max(Math.Abs(nextRoomDimensions.x - this.dimensions.x), Math.Abs(nextRoomDimensions.z - this.dimensions.z)) / 2 + transitionRnd; transitionHeight = Math.Max(RoomTools.minTransition, transitionHeight); return(createNextRoom(nextRoomDimensions, transitionHeight, color)); }
public void setDoorMesh(Mesh mesh) { RoomTools.addMeshWithCol(zPlusDoor, mesh, RoomTools.doorRenderMaterial, RoomTools.doorPhysicMaterial, true); RoomTools.addKinematicRigidbody(zPlusDoor); RoomTools.addMeshWithCol(zMinusDoor, mesh, RoomTools.doorRenderMaterial, RoomTools.doorPhysicMaterial, true); RoomTools.addKinematicRigidbody(zMinusDoor); //Rotate zMinusDoor zMinusDoor.transform.Rotate(new Vector3(0f, 180f, 0f)); }
private void GoCommitDie() { if (!unRegistered) { RoomTools.entityDestroyed("Crate"); unRegistered = true; } GameObject.Destroy(this.gameObject); var PUP = GameManager.roll <GameObject>(PowerUPprefabs, weights); if (PUP != null) { PUP = GameObject.Instantiate(PUP); PUP.transform.position = this.gameObject.transform.position; } }
private bool generateEntities() { int halfRangeX = (int)(dimensions.x / 2 - 0.5f); int halfRangeZ = (int)(dimensions.z / 2 - 0.5f); for (int x = -halfRangeX; x < halfRangeX; ++x) { for (int z = -halfRangeZ; z < halfRangeZ; ++z) { GameObject entity = RoomTools.rollAndInstanceEntity(); if (entity != null) { entity.transform.position = new Vector3((float)x, floorHeight, (float)z); } } } return(true); }