///<summary> ///Scans through the children of the levelManager in the editor and populates the level array with them. ///</summary> private void getLevelFromScene() { // First get the furthest cube in each direction to create a level array of the right size Vector3Int levelBounds = new Vector3Int(0, 0, 0); // for each child CubeObject of level manager foreach (Transform blockTransform in transform) { Debug.Assert(blockTransform.GetComponent <CubeObject>() != null, "Warning: CubeObject in level is missing CubeObject script!"); CubeObject block = blockTransform.GetComponent <CubeObject>(); // also populate the laserBlock list if (block is LaserBlock) { laserBlocks.Add((LaserBlock)block); } for (int i = 0; i < 3; i++) { if (block.levelPos[i] > levelBounds[i]) { levelBounds[i] = block.levelPos[i]; } } } levelBounds = levelBounds + new Vector3Int(1, 1, 1); // account for zero-indexing level = new CubeObject[levelBounds.x, levelBounds.y, levelBounds.z]; // now populate the level array foreach (Transform blockTransform in transform) { addBlock(blockTransform.GetComponent <CubeObject>()); } // printLevel(); }
private bool iterateFalling(List <Vector3Int> blockPositions) { bool blocksFell = false; for (int i = 0; i < blockPositions.Count; i++) { CubeObject blockToFall = getCubeObjIn(blockPositions[i]); Debug.Assert(blockToFall != null, "Warning: tryFall called on null block!"); // certain block types don't fall if (blockToFall is StaticBlock || blockToFall is CrackedBlock) { continue; } Vector3Int below = blockPositions[i] + Vector3Int.down; if (!isInBounds(below)) { blocksFell = true; fallOut(blockToFall); blockPositions.RemoveAt(i); i--; } else if (getCubeObjIn(below) == null) { blocksFell = true; // update position in level array and updatedBlocks moveInArray(blockToFall.levelPos, below); blockPositions[i] = below; // move block in world blockToFall.updatePos(Vector3Int.down); } } return(blocksFell); }
private void SpawnObject(GameObject InSpawnPoint) { SpawnedObject = (GameObject)Instantiate(PrefabToSpawn, InSpawnPoint.transform.position, InSpawnPoint.transform.rotation); SpawnedObject.transform.LookAt(Player.transform.position); Spawnable ObjectComponent = SpawnedObject.GetComponent <Spawnable>(); if (ObjectComponent != null) { ObjectComponent.TimeLifespan = SpawnedObjectLifespan; ObjectComponent.WasSpawned = true; Spawnable.OnDestroyed += OnSpawnedObjectDestroyed; ObjectComponent.SpawnedBy = this; AudioSource Speaker = GetComponent <AudioSource>(); CubeObject CubeObj = SpawnedObject.GetComponent <CubeObject>(); if (CubeObj != null) { CubeObj.StunnerProgressBar = SpawnStunProgressBar(); } else { Debug.Log("Spawned obj is not of type CubeObject."); } Speaker.Play(); } else { Debug.Log("FATAL ERROR ! Spawned object dont have Spawnable component."); } IsSpawnedObjectAlive = true; }
public static CubeObject Boardparent_axis(float x, float y, float z, float scale) { CubeObject aCube = new CubeObject(); Color color = Color.white; var instance = GameObject.CreatePrimitive(PrimitiveType.Cube); instance.GetComponent <Renderer>().material.color = color; instance.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; instance.transform.localPosition = new Vector3(x, y, z); instance.transform.localScale = new Vector3(0.03f, scale, 0.03f); instance.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); aCube.left = instance; var right = GameObject.CreatePrimitive(PrimitiveType.Cube); right.GetComponent <Renderer>().material.color = color; right.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; right.transform.localPosition = new Vector3(x + 7.74f, y, z); right.transform.localScale = new Vector3(0.03f, scale, 0.03f); right.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); aCube.right = right; var top = GameObject.CreatePrimitive(PrimitiveType.Cube); top.GetComponent <Renderer>().material.color = color; top.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; top.transform.localPosition = new Vector3(x + 3.88f, y, z + 2.49f); top.transform.localScale = new Vector3(-7.75f, 0.02f, 0.05f); top.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); aCube.top = top; var bottom = GameObject.CreatePrimitive(PrimitiveType.Cube); bottom.GetComponent <Renderer>().material.color = color; bottom.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; bottom.transform.localPosition = new Vector3(x + 3.88f, y, z - 2.49f); bottom.transform.localScale = new Vector3(-7.75f, 0.02f, 0.05f); bottom.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); aCube.bottom = bottom; //var space = GameObject.CreatePrimitive(PrimitiveType.Cube); //space.transform.parent = aCube.left.transform; //space.transform.localPosition = new Vector3(118.7f, 0, 187.6f); //space.transform.localScale = new Vector3(235.931f, 1, 365.6683f); //space.transform.localRotation = Quaternion.Euler(0, 0, 0); ////Material newmat = new Material("space"); //Material newmat = (Material)Resources.Load("Materials/space"); ////space.GetComponent<Renderer>().material = newmat; //space.GetComponent<MeshRenderer>().material = newmat; ////FF263E24 //Color color1 = new Color(0xFF, 0x26, 0x3E, 0x24); ////color1.a = 0.2f; //space.GetComponent<Renderer>().material.color = color1; target_outlines.Add(aCube); //aCube.name = each_outline.Count.ToString(); each_outline.Add(aCube); return(aCube); }
private void fallOut(CubeObject blockToFall) { Rigidbody body = blockToFall.GetComponent <Rigidbody>(); body.useGravity = true; body.isKinematic = false; Destroy(blockToFall.gameObject, 1); DestroyImmediate(blockToFall); }
public static ObjectTagRelation NewObjectTagRelation(Tag tag, CubeObject cubeObject) { if (tag == null) { throw new Exception("Given tag was null."); } if (cubeObject == null) { throw new Exception("Given cubeObject was null."); } return new ObjectTagRelation() { CubeObject = cubeObject, Tag = tag }; }
void Awake() { levelManager = GameObject.Find("LevelManager").GetComponent <LevelManager>(); Debug.Assert(levelManager != null, "Warning: Level Manager object not found in scene!"); characterManager = GameObject.Find("CharacterManager").GetComponent <CharacterManager>(); Debug.Assert(characterManager != null, "Warning: Spawner object not found in scene!"); cubeObject = GetComponent <CubeObject>(); Debug.Assert(cubeObject != null, "Warning: Character initialized with no CubeObject attached!"); isGrabbing = false; audioSource = GetComponent <AudioSource>(); characterAnimator = GetComponentInChildren <Animator>(); }
public void InitSpell(CubeObject caster, Vector3 castPoint) { if (!caster) { return; } Caster = caster; Origin = caster.transform.position; Direction = castPoint - Origin; Direction.z = 0; Direction = Direction.normalized; CastPoint = castPoint; }
public void spawn(Transform robotPrefab) { if (currChar == null) // make sure you can't press the button multiple times { currChar = Instantiate(robotPrefab, spawnLoc, Quaternion.identity, levelManager.transform); CubeObject charCubeObj = currChar.GetComponent <CubeObject>(); // we'll need this bool to check later because the actual object will have been destroyed charIsScientist = charCubeObj is Scientist; levelManager.addBlock(charCubeObj); charCam.follow(currChar); moveSpawnPanel(true); } }
private void applyInput(Vector3Int direction) { if (cubeObject.modelIsMoving()) { return; } CubeObject facingBlock = levelManager.getCubeObjIn(cubeObject.levelPos + cubeObject.orientation); if (direction == cubeObject.orientation) { characterAnimator.SetBool("isMovingForward", true); if (isGrabbing) { levelManager.move(cubeObject.levelPos, direction); isGrabbing = levelManager.getCubeObjIn(cubeObject.levelPos + cubeObject.orientation) != null; // TODO: keep better track of grabbing, this breaks down if the block you were grabbing falls and is replaced } else if (facingBlock != null) { tryJump(direction); } else { levelManager.move(cubeObject.levelPos, direction); } } else if (direction == cubeObject.orientation * -1) { characterAnimator.SetBool("isMovingBack", true); //can't jump up backwards if (isGrabbing) { levelManager.move(facingBlock.levelPos, direction); isGrabbing = levelManager.getCubeObjIn(cubeObject.levelPos + cubeObject.orientation) != null; // TODO: keep better track of grabbing, this breaks down if the block you were grabbing falls and is replaced } else { levelManager.move(cubeObject.levelPos, direction); } } else // movement axis doesn't align with current orientation // drop grabbed block { isGrabbing = false; cubeObject.updateOrientation(direction); //TODO: rotate block on head (?) } characterAnimator.SetBool("isGrabbing", isGrabbing); }
public bool CanPlace(ref CubeObject cube) { Vector3 start = cube.transform.InverseTransformPoint(Raycaster.GetPoint()); for (int i = 0; i < cube.ConnectionPoints.Count; i++) { Vector3 vector = cube.ConnectionPoints[i]; float mostDistance = GetMostDistance(start, vector); if (mostDistance < Margin && mostDistance > 1f - Margin) { return(true); } } return(false); }
public Vector3 GetPlacementPosition(ref CubeObject cube) { Vector3 start = cube.transform.InverseTransformPoint(Raycaster.GetPoint()); for (int i = 0; i < cube.ConnectionPoints.Count; i++) { Vector3 vector = cube.ConnectionPoints[i]; float mostDistance = GetMostDistance(start, vector); if (mostDistance < Margin && mostDistance > 1f - Margin) { return(cube.transform.TransformPoint(vector)); } } return(Vector3.zero); }
public void explodeOutwards(Vector3Int pos, List <Vector3Int> updatedBlocks) { CubeObject blockToExplode = getCubeObjIn(pos); Debug.Assert(blockToExplode != null, "Warning: attempting to explode an empty block somehow."); DestroyImmediate(blockToExplode.gameObject); // immediate prevents other explosions from re-exploding this block animateExplosion(pos); for (int sign = -1; sign <= 1; sign += 2) { for (int i = 0; i < 3; i++) { Vector3Int searchOrientation = new Vector3Int(0, 0, 0); searchOrientation[i] = sign; explodeInDirection(searchOrientation, pos, updatedBlocks); } } }
public void printLevel() { for (int x = 0; x < level.GetLength(0); x++) { for (int y = 0; y < level.GetLength(1); y++) { for (int z = 0; z < level.GetLength(2); z++) { if (level[x, y, z] != null) { CubeObject block = level[x, y, z].GetComponent <CubeObject>(); Debug.Log("Cube at " + block.levelPos.ToString()); Debug.Log("Orientation: " + block.orientation.ToString()); } } } } }
private void getMoveConsequences(List <Vector3Int> updatedBlocks) { // kill blocks in lasers, explosions will add blocks to updatedBlocks list foreach (LaserBlock laserBlock in laserBlocks) { CubeObject laserTarget = getLaserTarget(laserBlock.levelPos, laserBlock.orientation); if (laserTarget is ExplodeBlock) { audioSource.clip = explodeClip; audioSource.Play(); explodeOutwards(laserTarget.levelPos, updatedBlocks); } else if (laserTarget is BlockRobot) { audioSource.clip = blockClip; audioSource.Play(); ((BlockRobot)laserTarget).spawnCorpse(); laserTarget.die(); } else if (laserTarget is Scientist) { audioSource.clip = scientistClip; audioSource.Play(); laserTarget.die(); } } // prune dead blocks from updatedBlocks, check if won for (int i = 0; i < updatedBlocks.Count; i++) { Vector3Int blockPos = updatedBlocks[i]; CubeObject block = getCubeObjIn(blockPos); if (block == null) { updatedBlocks.RemoveAt(i); i--; } else if (block is Scientist && getCubeObjIn(blockPos + Vector3Int.down) is GoalBlock) { win(); } } }
private CubeObject getLaserTarget(Vector3Int laserPos, Vector3Int direction) { Vector3Int adjacentPos = laserPos + direction; if (!isInBounds(adjacentPos)) { return(null); } CubeObject adjacentBlock = getCubeObjIn(adjacentPos); if (adjacentBlock == null || adjacentBlock is GlassBlock) { // there's no block in the way, keep searching in this direction return(getLaserTarget(adjacentPos, direction)); } else { return(adjacentBlock); } }
private bool tryPush(Vector3Int pos, Vector3Int direction, List <Vector3Int> updatedBlocks) { CubeObject blockToMove = getCubeObjIn(pos); Debug.Assert(blockToMove != null, "Warning: trying to push a null block!"); Vector3Int adjacentPos = pos + direction; if (blockToMove.isMovable && isInBounds(adjacentPos)) { CubeObject adjacentBlock = getCubeObjIn(adjacentPos); if (adjacentBlock == null || tryPush(adjacentPos, direction, updatedBlocks)) { // can push, update position in level array moveInArray(pos, adjacentPos); // move block in world blockToMove.updatePos(direction); updatedBlocks.Add(blockToMove.levelPos); // try to move blocks on top of the pushed block if (getCubeObjIn(pos + Vector3Int.up) != null) { bool aboveWasPushed = tryPush(pos + Vector3Int.up, direction, updatedBlocks); if (!aboveWasPushed) { // add all blocks above here to updatedBlocks so that they fall, since their base has been removed Vector3Int currPos = pos + Vector3Int.up; while (isInBounds(currPos) && getCubeObjIn(currPos) != null) { updatedBlocks.Add(currPos); currPos += Vector3Int.up; } } } return(true); } } return(false); }
private void explodePos(Vector3Int pos, List <Vector3Int> updatedBlocks) { CubeObject occupant = getCubeObjIn(pos); if (occupant == null) { animateExplosion(pos); } else if (occupant is ExplodeBlock) { explodeOutwards(pos, updatedBlocks); } else if (occupant is BlockRobot || occupant is Scientist || occupant is CrackedBlock || occupant is NormalBlock) { occupant.die(); Vector3Int currPos = pos + Vector3Int.up; // add blocks above to updatedBlocks so they fall after their foundation is destroyed while (isInBounds(currPos) && getCubeObjIn(currPos) != null) { updatedBlocks.Add(currPos); currPos += Vector3Int.up; } } }
public CubeIntersectionResult(CubeObject cubeObject, QuadIntersectionResult quadObjectIntersectionResult) { Object = cubeObject; QuadObjectIntersectionResult = quadObjectIntersectionResult; }
/// <summary> /// Parses and inserts cube objects, photos and thumbnails. /// </summary> /// <param name="pathToDataset"></param> private static void InsertCubeObjects(string pathToDataset) { string[] files = Directory.GetFiles(pathToDataset); Console.WriteLine("Inserting photos as CubeObjects:"); using (var context = new ObjectContext()) { int fileCount = 1; foreach (string file in files) { string filename = Path.GetFileName(file); if (!filename.EndsWith(".csv")) { Console.WriteLine("Saving file: " + fileCount++ + " out of " + files.Length + " files. " + "Filename: " + filename + ". (" + (((double)fileCount / (double)files.Length) * 100).ToString("0.0") + @"%)"); //If Image is already in database (Assuming no two file has the same name): if (context.CubeObjects .Include(co => co.Photo) .FirstOrDefault(co => co.Photo.FileName.Equals(filename)) != null) { //Don't add it again. Console.WriteLine("Image " + filename + " is already in the database"); } //Else add it: else { //Loading and saving image: using (Image <Rgba32> image = SixLabors.ImageSharp.Image.Load(file)) { using (MemoryStream ms = new MemoryStream()) { image.SaveAsJpeg(ms); //Copy to ms //Create Cube and Photo objects: CubeObject cubeObject = DomainClassFactory.NewCubeObject( filename, FileType.Photo, DomainClassFactory.NewPhoto( ms.ToArray(), filename ) ); //Creating and saving thumbnail: //Thumbnails needs to be power of two in width and height to avoid extra image manipulation client side. if (image.Width > image.Height) { int destinationHeight = 1024; //1024px decimal downscaleFactor = Decimal.Parse(destinationHeight + "") / Decimal.Parse(image.Height + ""); int newWidth = (int)(image.Width * downscaleFactor); int newHeight = (int)(image.Height * downscaleFactor); image.Mutate(i => i .Resize(newWidth, newHeight) //Scale .Crop(destinationHeight, destinationHeight) //Crop ); } else { int destinationWidth = 1024; //1024px decimal downscaleFactor = Decimal.Parse(destinationWidth + "") / Decimal.Parse(image.Width + ""); int newWidth = (int)(image.Width * downscaleFactor); int newHeight = (int)(image.Height * downscaleFactor); image.Mutate(i => i .Resize(newWidth, newHeight) //Scale .Crop(destinationWidth, destinationWidth) //Crop ); } //int destinationWidth = 1024; //1024px //decimal downscaleFactor = Decimal.Parse(destinationWidth+"") / Decimal.Parse(image.Width+""); //int newWidth = (int)(image.Width * downscaleFactor); //int newHeight = (int)(image.Height * downscaleFactor); //image.Mutate(i => i // .Resize(newWidth, newHeight)); using (MemoryStream ms2 = new MemoryStream()) { image.SaveAsJpeg(ms2); //Copy to ms cubeObject.Thumbnail = new Thumbnail() { Image = ms2.ToArray() }; } //Save cube object: context.CubeObjects.Add(cubeObject); context.SaveChanges(); } } } } } } }
/// <summary> /// Parses and inserts tags and tagsets. Also tags Photos. /// </summary> /// <param name="pathToTagFile"></param> /// <param name="pathToErrorLogFile"></param> static void InsertTags(string pathToTagFile, string pathToErrorLogFile) { Console.WriteLine("Inserting TagsSets and Tags:"); int lineCount = 1; string[] linesInFile = File.ReadAllLines(pathToTagFile); //Looping over each line in the tag file. foreach (string line in linesInFile) { Console.WriteLine("Inserting line: " + lineCount++ + " out of " + linesInFile.Length); //File format: "FileName:TagSet:Tag:TagSet:Tag:(...)" string[] split = line.Split(":"); string fileName = split[0]; int numTagPairs = (split.Length - 2) / 2; //Looping over each pair of tags: for (int i = 0; i < numTagPairs; i++) { string tagsetName = split[(i * 2) + 1]; string tagName = split[(i * 2) + 2]; using (var context = new ObjectContext()) { //Adding tagset to db: Tagset tagsetFromDb = context.Tagsets .Where(ts => ts.Name.Equals(tagsetName)) .Include(ts => ts.Tags) .FirstOrDefault(); //If tagset doesn't exist in db, add it: if (tagsetFromDb == null) { tagsetFromDb = DomainClassFactory.NewTagSet(tagsetName); context.Tagsets.Add(tagsetFromDb); context.SaveChanges(); //Also creates a tag with same name: Tag tagWithSameNameAsTagset = DomainClassFactory.NewTag(tagsetName, tagsetFromDb); //Add tag to tagset: tagWithSameNameAsTagset.Tagset = tagsetFromDb; tagsetFromDb.Tags.Add(tagWithSameNameAsTagset); //Add and update changes: context.Tags.Add(tagWithSameNameAsTagset); context.SaveChanges(); } //Checking if tag exists, and creates it if it doesn't exist. Tag tagFromDb = context.Tags .Where(t => t.TagsetId == tagsetFromDb.Id && t.Name.Equals(tagName)) .Include(t => t.ObjectTagRelations) .FirstOrDefault(); //If tag doesn't exist in db, add it if (tagFromDb == null) { tagFromDb = DomainClassFactory.NewTag(tagName, tagsetFromDb); context.Tags.Add(tagFromDb); context.SaveChanges(); } //Add tag to tagset if tagset doesn't have it: if (!tagsetFromDb.Tags .Any(t => t.TagsetId == tagFromDb.Id)) //If tag does not exist in tagset, add it { tagsetFromDb.Tags.Add(tagFromDb); tagFromDb.Tagset = tagsetFromDb; context.Update(tagsetFromDb); context.Update(tagFromDb); context.SaveChanges(); } //Adding tag to cube object with FileName: CubeObject cubeObjectFromDb = context.CubeObjects .Where(co => co.Photo.FileName.Equals(fileName)) .Include(co => co.Photo) .Include(co => co.ObjectTagRelations) .FirstOrDefault(); if (cubeObjectFromDb == null) { File.AppendAllText(pathToErrorLogFile, "File " + fileName + " was not found while parsing line " + lineCount); //throw new Exception("Expected cubeobject to be in the DB already, but it isn't!"); } else { if (cubeObjectFromDb.ObjectTagRelations .FirstOrDefault(otr => otr.TagId == tagFromDb.Id) == null) //If Cubeobject does not already have tag asscociated with it, add it { ObjectTagRelation newObjectTagRelation = DomainClassFactory.NewObjectTagRelation(tagFromDb, cubeObjectFromDb); context.ObjectTagRelations.Add(newObjectTagRelation); context.SaveChanges(); } } } } } }
public static CubeObject parent_axis(float x, float y, float z, float scale, string name) { CubeObject aCube = new CubeObject(); Color color = Color.white; var instance = GameObject.CreatePrimitive(PrimitiveType.Cube); instance.GetComponent <Renderer>().material.color = color; instance.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; instance.transform.localPosition = new Vector3(x, y, z); instance.transform.localScale = new Vector3(0.03f, scale, 0.03f); instance.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); instance.name = "none"; aCube.left = instance; GameObject box = new GameObject(); box.AddComponent <BoxCollider>(); var collider = box.GetComponent <BoxCollider>(); box.transform.parent = instance.transform; collider.transform.localPosition = new Vector3(117.8f, 0, 1.3f); collider.transform.localScale = new Vector3(0, 1, 240); collider.transform.localRotation = Quaternion.Euler(0, 90, 0); box.name = "subspace_" + name; var right = GameObject.CreatePrimitive(PrimitiveType.Cube); right.GetComponent <Renderer>().material.color = color; right.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; right.transform.localPosition = new Vector3(x + 7.11f, y, z); right.transform.localScale = new Vector3(0.03f, scale, 0.03f); right.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); right.name = "none"; aCube.right = right; var top = GameObject.CreatePrimitive(PrimitiveType.Cube); top.GetComponent <Renderer>().material.color = color; top.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; top.transform.localPosition = new Vector3(x + 3.548f, y, z + 2.09f); top.transform.localScale = new Vector3(-7.14f, 0.02f, 0.05f); top.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); top.name = "none"; aCube.top = top; var bottom = GameObject.CreatePrimitive(PrimitiveType.Cube); bottom.GetComponent <Renderer>().material.color = color; bottom.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; bottom.transform.localPosition = new Vector3(x + 3.548f, y, z - 2.09f); bottom.transform.localScale = new Vector3(-7.14f, 0.02f, 0.05f); bottom.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); bottom.name = "none"; aCube.bottom = bottom; var graph = GameObject.CreatePrimitive(PrimitiveType.Cube); graph.transform.parent = SmokeyController.all_targets[SmokeyController.detectedImageCount].transform; graph.transform.localPosition = new Vector3(x + 3.57f, y + 9.6f, z); graph.transform.localRotation = Quaternion.Euler(0, 0, 0); graph.transform.localScale = new Vector3(2f, 2f, 2f); graph.GetComponent <Renderer>().material = white; graph.GetComponent <Renderer>().material.color = Color.gray; graph.name = (graphnodes.Count + 1).ToString(); graphnodes.Add(graph); //var space = GameObject.CreatePrimitive(PrimitiveType.Cube); //space.transform.parent = aCube.left.transform; //space.transform.localPosition = new Vector3(118.7f, 0, 187.6f); //space.transform.localScale = new Vector3(235.931f, 1, 365.6683f); //space.transform.localRotation = Quaternion.Euler(0, 0, 0); //Material newmat = (Material)Resources.Load("Materials/space"); //space.GetComponent<MeshRenderer>().material = newmat; ////FF263E24 ////402BA9FF purple //Color color1 = new Color(0xFF, 0x26, 0x3E, 0x24); //space.GetComponent<Renderer>().material.color = color1; target_outlines.Add(aCube); each_outline.Add(aCube); return(aCube); }
protected override void FixChildrenObj(string objectID, Quaternion roration, Vector3 pos, Vector3 size, int layer) { if (string.IsNullOrEmpty(objectID)) { return; } GeometryObject baseCube = new CubeObject(objectID + m_PostfixStr[0]); baseCube.SetParent(this); baseCube.LocalPosition = new Vector3(0f, 0f, 0f); baseCube.LocalRotation = new Quaternion(); GeometryObject[] axisTaper = new GeometryObject[6]; Material redMat = new Material(Shader.Find("Diffuse")); redMat.color = Color.red; axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X] = new TaperObject(objectID + m_PostfixStr[(int)AXISTAPER_INDEX.AXISTRAPER_X + 1]); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X].SetParent(this); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X].LocalPosition = new Vector3(1.5f, 0f, 0f); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X].LocalRotation = Quaternion.AngleAxis(90, new Vector3(0f, 0f, 1f)); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X].DefaultMat = redMat; axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X_NEG] = new TaperObject(objectID + m_PostfixStr[(int)AXISTAPER_INDEX.AXISTRAPER_X_NEG + 1]); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X_NEG].SetParent(this); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X_NEG].LocalPosition = new Vector3(-1.5f, 0f, 0f); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_X_NEG].LocalRotation = Quaternion.AngleAxis(-90, new Vector3(0f, 0f, 1f)); Material greenMat = new Material(Shader.Find("Diffuse")); greenMat.color = Color.green; axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y] = new TaperObject(objectID + m_PostfixStr[(int)AXISTAPER_INDEX.AXISTRAPER_Y + 1]); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y].SetParent(this); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y].LocalPosition = new Vector3(0f, 1.5f, 0f); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y].LocalRotation = Quaternion.AngleAxis(180, new Vector3(0f, 0f, 1f)); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y].DefaultMat = greenMat; axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y_NEG] = new TaperObject(objectID + m_PostfixStr[(int)AXISTAPER_INDEX.AXISTRAPER_Y_NEG + 1]); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y_NEG].SetParent(this); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y_NEG].LocalPosition = new Vector3(0f, -1.5f, 0f); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Y_NEG].LocalRotation = Quaternion.AngleAxis(0, new Vector3(0f, 0f, 1f)); Material bluewMat = new Material(Shader.Find("Diffuse")); bluewMat.color = Color.blue; axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z] = new TaperObject(objectID + m_PostfixStr[(int)AXISTAPER_INDEX.AXISTRAPER_Z + 1]); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z].SetParent(this); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z].LocalPosition = new Vector3(0f, 0f, 1.5f); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z].LocalRotation = Quaternion.AngleAxis(-90, new Vector3(1f, 0f, 0f)); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z].DefaultMat = bluewMat; axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z_NEG] = new TaperObject(objectID + m_PostfixStr[(int)AXISTAPER_INDEX.AXISTRAPER_Z_NEG + 1]); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z_NEG].SetParent(this); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z_NEG].LocalPosition = new Vector3(0f, 0f, -1.5f); axisTaper[(int)AXISTAPER_INDEX.AXISTRAPER_Z_NEG].LocalRotation = Quaternion.AngleAxis(90, new Vector3(1f, 0f, 0f)); //TextObject axisText_x = new TextObject(objectID + "x_Text"); //axisText_x.SetParent(this); //axisText_x.LocalPosition = new Vector3(2.7f, 0f, 0f); //axisText_x.Rotation = Quaternion.identity; //axisText_x.Text = "x"; //TextObject axisText_y = new TextObject(objectID + "y_Text"); //axisText_y.SetParent(this); //axisText_y.LocalPosition = new Vector3(0f, 2.7f, 0f); //axisText_y.Rotation = Quaternion.identity; //axisText_y.Text = "y"; //TextObject axisText_z = new TextObject(objectID + "z_Text"); //axisText_z.SetParent(this); //axisText_z.LocalPosition = new Vector3(0f, 0f, 2.7f); //axisText_z.Rotation = Quaternion.identity; //axisText_z.Text = "z"; m_Children.Add(baseCube); m_Children.AddRange(axisTaper.ToList <GeometryObject>()); //m_Children.Add(axisText_x); //m_Children.Add(axisText_y); //m_Children.Add(axisText_z); }
public bool CanDestroy(ref CubeObject cube) { return(true); }
public void spawnCorpse() { CubeObject corpse = Instantiate(corpsePrefab, levelPos, Quaternion.Euler(90, 0, 0), levelManager.transform).GetComponent <CubeObject>(); levelManager.addBlock(corpse); }
private void CreateGeometryObj(string id, GEOMETRYTYPE type, Quaternion roration, Vector3 pos, Vector3 size, Material mat, int layer, out GeometryObject obj, List <object> param = null) { obj = null; if (string.IsNullOrEmpty(id)) { return; } if (!IsObjExist(id, out obj)) { switch (type) { case GEOMETRYTYPE.GEOMETRY_TYPE_CUBE: obj = new CubeObject(id, roration, pos, size, mat, layer); break; case GEOMETRYTYPE.GEOMETRY_TYPE_TAPER: obj = new TaperObject(id, roration, pos, size, mat, layer); break; case GEOMETRYTYPE.GEOMETRY_TYPE_AXIS: obj = new AxisObject(id, roration, pos, size, mat, layer); break; case GEOMETRYTYPE.GEOMETRY_TYPE_TEXT: obj = new TextObject(id, roration, pos, size, mat, layer); break; case GEOMETRYTYPE.GEOMETRY_TYPE_RING: obj = new RingObject(id, roration, pos, size, mat, layer); break; case GEOMETRYTYPE.GEOMETRY_TYPE_SECTOR: obj = new SectorObject(id, roration, pos, size, mat, layer, param); break; case GEOMETRYTYPE.GEOMETRY_TYPE_SPHERE: obj = new SphereObject(id, roration, pos, size, mat, layer); break; default: break; } if (obj != null) { obj.DrawCounter++; m_ObjectTbl.Add(obj); } } else { if (obj != null) { obj.Rotation = roration; obj.Position = pos; obj.Scale = size; obj.DefaultMat = mat; obj.Layer = layer; obj.DrawCounter++; } } }
public void addBlock(CubeObject blockToAdd) { Vector3Int pos = blockToAdd.levelPos; level[pos.x, pos.y, pos.z] = blockToAdd; }