public GameObject addDecoration(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec) { GameObject newdecoration = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject; newdecoration.name = "Decoration (clone)"; newdecoration.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); newdecoration.GetComponent <Decoration>().Father = this; Decoration der = newdecoration.GetComponent <Decoration>(); der.IsoDec = dec; der.setParameters(position, angle, parallel, centered); return(newdecoration); }
public GameObject addGhost(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity) { if (this.ghost == null) { ghost = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject; ghost.name = "GhostDer"; ghost.hideFlags = HideFlags.HideAndDontSave; Material ghostMaterial = new Material(Shader.Find("Transparent/Diffuse")); ghostMaterial.color = new Color(ghostMaterial.color.r, ghostMaterial.color.g, ghostMaterial.color.b, intensity); ghost.GetComponent <Renderer>().sharedMaterial = ghostMaterial; } Decoration der = ghost.GetComponent <Decoration>(); der.Father = this; der.IsoDec = dec; der.setParameters(position, angle, parallel, centered); return(this.ghost); }
public void ghostDecoration(Cell cs, Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity) { checkTransform(); if (ghost == null || ghostType != 2) { removeGhost(); ghostType = 2; ghost = cs.addGhost(position, angle, parallel, centered, dec, intensity); } else { if (ghost.GetComponent <Decoration>().Father != cs) { removeGhost(); ghostType = 2; ghost = cs.addGhost(position, angle, parallel, centered, dec, intensity); } } Decoration der = ghost.GetComponent <Decoration>(); der.IsoDec = dec; der.setParameters(position, angle, parallel, centered); }
public void colocate() { if (this.father is Cell) { Cell celdapadre = this.father as Cell; this.transform.parent = celdapadre.transform; Vector3 invfather = celdapadre.transform.InverseTransformPoint(this.center); //################### // / \ // / \ // / \ // / 0 \ // |\ /| // | \ / | // | \ / | // | 2 \_/ 1 | // \ | / // \ | / // \ | / // \|/ //#################### Vector3 position = new Vector3(); this.transform.localRotation = celdapadre.transform.rotation; // Segun la zona de actuacion, definiremos la posicion de una manera u otra. switch (this.angle) { case 0: { if (this.centered) { if (!this.parallel) { position = new Vector3(-0.5f, (celdapadre.Height * celdapadre.Width) + this.transform.localScale.y / 2, -0.5f); } else { position = new Vector3(-0.5f, (celdapadre.Height * celdapadre.Width + 0.01f), -0.5f); } } else if (!this.parallel) { position = new Vector3(invfather.x, (celdapadre.Height * celdapadre.Width) + this.transform.localScale.y / 2, invfather.z); } else { position = new Vector3(invfather.x, (celdapadre.Height * celdapadre.Width) + 0.01f, invfather.z); } break; } case 1: { if (this.centered) { if (!this.parallel) { position = new Vector3(-celdapadre.Width / 2 + ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad)), invfather.y - (invfather.y % celdapadre.Width) + 1, -celdapadre.Width / 2 - ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad))); } else { position = new Vector3(-celdapadre.Width / 2, invfather.y - (invfather.y % celdapadre.Width) + 1 + (this.transform.localScale.y / 2), -0.01f - celdapadre.Width / 2); } } else if (!this.parallel) { position = new Vector3(invfather.x + ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad)), invfather.y, invfather.z - ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad))); } else { position = new Vector3(invfather.x, invfather.y + (this.transform.localScale.y / 2), -0.01f - celdapadre.Width / 2); } break; } case 2: { if (this.centered) { if (!this.parallel) { position = new Vector3(-celdapadre.Width / 2 - ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad)), invfather.y - (invfather.y % celdapadre.Width) + 1, -celdapadre.Width / 2 + ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad))); } else { position = new Vector3(-0.01f - celdapadre.Width / 2, invfather.y - (invfather.y % celdapadre.Width) + 1 + (this.transform.localScale.y / 2), -celdapadre.Width / 2); } } else if (!this.parallel) { position = new Vector3(invfather.x - ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad)), invfather.y, invfather.z + ((this.transform.localScale.x / 2) * Mathf.Cos(45 * Mathf.Deg2Rad))); } else { position = new Vector3(-0.01f - celdapadre.Width / 2, invfather.y + (this.transform.localScale.y / 2), invfather.z); } break; } } if (!this.centered) { this.transform.localPosition = invfather; } this.transform.localPosition = position; } else if (this.father is Decoration) { Decoration decorationpadre = this.father as Decoration; this.transform.parent = decorationpadre.transform.parent; Vector3 position = new Vector3(0f, this.transform.localScale.y, 0f); this.transform.position = decorationpadre.transform.position; this.transform.localPosition -= this.transform.worldToLocalMatrix.MultiplyVector(Vector3.forward * 0.01f); } }
public void removeDecoration(Decoration d) { }
// Use this for initialization void Start() { dec = this.GetComponent <Decoration>(); }