// Paint the cell in function of the event type private void PaintCell(IsoUnity.Cell cell, EventTypes eventType) { showSelector(cell, eventType); IsoTexture texture = null; switch (eventType) { case EventTypes.ATTACK: case EventTypes.IA_ATTACK: texture = colorAttack; break; case EventTypes.MOVE: case EventTypes.IA_MOVE: texture = colorMove; break; case EventTypes.SKILL: texture = colorSkill; break; } cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = texture; cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = texture.getTexture(); cell.forceRefresh(); }
public override void OnInspectorGUI() { isoTexture = target as IsoTexture; if (GUILayout.Button("Open texture assistant")) { TextureAssistant.OpenWindowEditor(isoTexture); } }
public static void OpenWindowEditor(IsoTexture selected) { TextureAssistant assistant = EditorWindow.GetWindow(typeof(TextureAssistant)) as TextureAssistant; assistant.currentText = selected; IsoTexture[] textures = TextureManager.getInstance().textureList(); for(int i = 0; i< textures.Length; i++) if(selected == textures[i]) assistant.selected = i; }
public static void OpenWindowEditor(IsoTexture selected) { TextureAssistant assistant = EditorWindow.GetWindow(typeof(TextureAssistant)) as TextureAssistant; assistant.currentText = selected; IsoTexture[] textures = TextureManager.getInstance().textureList(); for (int i = 0; i < textures.Length; i++) { if (selected == textures[i]) { assistant.selected = i; } } }
public override void deleteTexture(IsoTexture texture) { //AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(texture)); }
public abstract void update(IsoTexture texture);
public abstract void deleteTexture(IsoTexture texture);
void OnGUI() { IsoTexture[] textures = TextureManager.getInstance().textureList(); GUIStyle style = new GUIStyle(GUI.skin.button); style.padding = new RectOffset(5,5,5,5); GUIStyle s = new GUIStyle(GUIStyle.none); s.fontStyle = FontStyle.Bold; /* NO me gusta como se ve esto la verdad... * EditorGUILayout.BeginHorizontal(); if(GUILayout.Button("New", style)) TextureManager.getInstance().newTexture(); if(GUILayout.Button("Delete", style)) if(selected < textures.Length){ TextureManager.getInstance().deleteTexture(TextureManager.getInstance().textureList()[selected]); selected = textures.Length; } EditorGUILayout.EndHorizontal(); GUIContent[] texts = new GUIContent[textures.Length]; for(int i = 0; i< textures.Length; i++){ texts[i] = new GUIContent(textures[i].name); } EditorGUILayout.PrefixLabel("IsoTextures List", s); scrollPos = EditorGUILayout.BeginScrollView(scrollPos,GUILayout.Width(0), GUILayout.Height(60)); selected = GUILayout.SelectionGrid(selected,texts,2,style,GUILayout.MaxWidth(auxWidth-25)); EditorGUILayout.EndScrollView(); */ if(selected < textures.Length && textures[selected] != null) currentText = textures[selected]; else currentText = null; EditorGUILayout.PrefixLabel("IsoTexture", s); currentText = EditorGUILayout.ObjectField(currentText, typeof(IsoTexture), false) as IsoTexture; for(int i = 0; i< textures.Length; i++) if(currentText == textures[i]) selected = i; // Textura if(currentText != null){ currentText.name = UnityEditor.EditorGUILayout.TextField("Name", currentText.name); currentText.setTexture(UnityEditor.EditorGUILayout.ObjectField("Base tile", currentText.getTexture(), typeof(Texture2D), true) as Texture2D); Texture2D texture = currentText.getTexture(); if(texture != null){ EditorGUILayout.PrefixLabel("Presets", s); if(GUILayout.Button("Top")){ currentText.Rotation = 0; currentText.setXCorner(Mathf.RoundToInt(currentText.getTexture().width/2f)); currentText.setYCorner(Mathf.RoundToInt(currentText.getTexture().height/2f)); } EditorGUILayout.BeginHorizontal(); if(GUILayout.Button("Left")){ currentText.Rotation = 0; currentText.setXCorner(0); currentText.setYCorner(Mathf.RoundToInt((2f*currentText.getTexture().height)/3f)); } if(GUILayout.Button("Right")){ currentText.Rotation = 3; currentText.setXCorner(currentText.getTexture().width); currentText.setYCorner(Mathf.RoundToInt(currentText.getTexture().height/3f)); } EditorGUILayout.EndHorizontal(); extra.target = EditorGUILayout.ToggleLeft("Advanced", extra.target); if (EditorGUILayout.BeginFadeGroup(extra.faded)) { EditorGUI.indentLevel++; if(GUILayout.Button("Rotation: " + currentText.Rotation*90)) currentText.Rotation++; EditorGUILayout.BeginHorizontal(); currentText.setXCorner(EditorGUILayout.IntField(currentText.getXCorner(),GUILayout.Width(30))); currentText.setXCorner(Mathf.FloorToInt(GUILayout.HorizontalSlider(currentText.getXCorner(),0,texture.width,null))); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); currentText.setYCorner(EditorGUILayout.IntField(currentText.getYCorner(),GUILayout.Width(30))); currentText.setYCorner(Mathf.FloorToInt(GUILayout.HorizontalSlider(currentText.getYCorner(),0,texture.height,null))); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); if(extra.faded != lastValue) this.Repaint(); lastValue = extra.faded; EditorGUILayout.Space(); Rect rect = GUILayoutUtility.GetLastRect(); if(Event.current.type == EventType.repaint){ float w = position.width; float h = position.height - rect.y; float rh = (w / texture.width*1.0f ) * (texture.height*1.0f) - 10; float rw = w - 10; if(rh > h){ rw = (h / texture.height*1.0f ) * texture.width - 10; rh = h - 10; } textureRect = new Rect(w/2f - rw/2f, rect.y + 5, rw, rh); } float converter = textureRect.width / texture.width; /*Rect auxRect = GUILayoutUtility.GetRect(auxWidth, auxHeight); auxRect.width = auxWidth;*/ GUI.DrawTexture(textureRect,texture); Vector2 rectCorner = new Vector2(textureRect.x,textureRect.y); Vector2 xCorner = rectCorner + new Vector2( converter *currentText.getXCorner(), 0); Vector2 yCorner = rectCorner + new Vector2(0, converter * currentText.getYCorner()); Vector2 xOtherCorner = rectCorner + new Vector2(converter * currentText.getOppositeXCorner(), textureRect.height); Vector2 yOtherCorner = rectCorner + new Vector2(textureRect.width, converter * currentText.getOppositeYCorner()); Drawing.DrawLine(xCorner,yCorner, Color.yellow, 0.5f, true); Drawing.DrawLine(yCorner,xOtherCorner, Color.yellow, 0.5f, true); Drawing.DrawLine(xOtherCorner,yOtherCorner, Color.yellow, 0.5f, true); Drawing.DrawLine(yOtherCorner,xCorner, Color.yellow, 0.5f, true); } else EditorGUILayout.LabelField("Please asign a texture!"); }else{ EditorGUILayout.LabelField("Please select a texture o create a new one!", style); } //GUI }
public void OnInspectorGUI() { //paintingMode = EditorGUILayout.BeginToggleGroup("Painting mode",paintingMode); EditorGUILayout.HelpBox("Press left button to put the textures over the faces of the cell. Hold shift and press left button to copy the current texture of the hovering face.", MessageType.None); EditorGUILayout.Space(); EditorGUILayout.PrefixLabel("Brush", GUIStyle.none, titleStyle); selectedBrush = EditorGUILayout.Popup(selectedBrush, brushNames); EditorGUILayout.PrefixLabel("Texture", GUIStyle.none, titleStyle); EditorGUILayout.BeginHorizontal(); paintingTexture = UnityEditor.EditorGUILayout.ObjectField("Tile", paintingTexture, typeof(Texture2D), false, GUILayout.MaxHeight(16)) as Texture2D; if (paintingTexture != null) { IsoTexture[] textures = TextureManager.getInstance().textureList(paintingTexture); List <string> texts = new List <string> (); int isoTextureIndex = textures.Length; for (int i = 0; i < textures.Length; i++) { texts.Add(textures[i].name); if (textures[i] == paintingIsoTexture) { isoTextureIndex = i; } } texts.Add("None"); //TODO CAMBIOS EN LA LISTA DEBERIAN DESELEECIONAR EL ELEMENTO ACTUAL SI ESTE YA NO ESTA EN LA LISTA isoTextureIndex = UnityEditor.EditorGUILayout.Popup(isoTextureIndex, texts.ToArray()); if (isoTextureIndex == textures.Length) { paintingIsoTexture = null; } else { paintingIsoTexture = textures[isoTextureIndex]; } } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f); // TODO podria hacerse una clase para este selector y asi reutilizarlo Event e = Event.current; EditorGUILayout.BeginVertical("Box"); IsoTexture[] isoTextures = TextureManager.getInstance().textureList(); int maxTextures = 8; float anchoTextura = (Screen.width - 30) / maxTextures; // This line controls the case when there are too many textures. In that case, // the line after the if creates a scroll to fix the size to a max, defined in // GUILayout.MaxHeight(<<designed size>>) if (isoTextures.Length > maxTextures * LTSS) { scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura * LTSS)); } int currentTexture = 0; foreach (IsoTexture it in isoTextures) { if (it.getTexture() == null) { continue; } if (currentTexture == 0) { EditorGUILayout.BeginHorizontal(); } Rect auxRect = GUILayoutUtility.GetRect(anchoTextura, anchoTextura); Rect border = new Rect(auxRect); auxRect.x += 2; auxRect.y += 2; auxRect.width -= 4; auxRect.height -= 4; if (e.isMouse && border.Contains(e.mousePosition)) { if (e.type == EventType.mouseDown) { paintingTexture = it.getTexture(); paintingIsoTexture = it; repaint = true; } } if (it == paintingIsoTexture) { EditorGUI.DrawRect(border, Color.yellow); } GUI.DrawTexture(auxRect, it.getTexture()); currentTexture++; if (currentTexture == maxTextures) { EditorGUILayout.EndHorizontal(); currentTexture = 0; } } if (currentTexture != 0) { GUILayoutUtility.GetRect((maxTextures - currentTexture) * anchoTextura, anchoTextura); EditorGUILayout.EndHorizontal(); } if (isoTextures.Length > maxTextures * LTSS) { EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }
public void OnSceneGUI(SceneView scene) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); RaycastHit info = new RaycastHit(); Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); GameObject selected = null; if(Physics.Raycast(ray, out info/*, LayerMask.NameToLayer("Cells Layer")*/)) //TODO Arreglar esto porque al parecer la distancia no funciona correctamente if(info.collider.transform.IsChildOf(this.map.transform)) selected = info.collider.gameObject; bool paintLater = false; bool backupTextures = false; /* * Mouse Events of painting mode */ if(Event.current.isMouse){ if(Event.current.button == 0){ if(Event.current.shift){ if(Event.current.type == EventType.mouseDown) collectTexture = true; if(collectTexture && Event.current.type != EventType.MouseUp) backupTextures = true; else collectTexture = false; }else if(Event.current.type == EventType.MouseDown){ painting = true; paintLater = true; }else if(Event.current.type == EventType.MouseUp){ painting = false; }else{ if(painting) paintLater = true; } } } /** * Working zone */ if(selected != null){ Cell cs = selected.GetComponent<Cell>(); if(cs!=null){ FaceNoSC f = cs.getFaceByPoint(info.point); if(f!=null){ if(paintLater && paintingTexture != null){ f.Texture = paintingTexture; f.TextureMapping = paintingIsoTexture; cs.forceRefresh(); } if(backupTextures){ this.paintingTexture = f.Texture; this.paintingIsoTexture = f.TextureMapping; repaint = true; } Vector3[] vertex = f.SharedVertex; int[] indexes = f.VertexIndex; Vector3[] puntos = new Vector3[4]; for(int i = 0; i< indexes.Length; i++) puntos[i] = cs.transform.TransformPoint(vertex[indexes[i]]); if(indexes.Length == 3) puntos[3] = cs.transform.TransformPoint(vertex[indexes[2]]); Handles.DrawSolidRectangleWithOutline(puntos, (Event.current.shift)? Color.blue : Color.yellow, Color.white); } } } }
public override void update(IsoTexture it) { regenerate(it.getTexture()); }
void OnGUI() { IsoTexture[] textures = TextureManager.getInstance().textureList(); GUIStyle style = new GUIStyle(GUI.skin.button); style.padding = new RectOffset(5, 5, 5, 5); GUIStyle s = new GUIStyle(GUIStyle.none); s.fontStyle = FontStyle.Bold; /* NO me gusta como se ve esto la verdad... * EditorGUILayout.BeginHorizontal(); * * if(GUILayout.Button("New", style)) * TextureManager.getInstance().newTexture(); * * * if(GUILayout.Button("Delete", style)) * if(selected < textures.Length){ * TextureManager.getInstance().deleteTexture(TextureManager.getInstance().textureList()[selected]); * selected = textures.Length; * } * * EditorGUILayout.EndHorizontal(); * * * GUIContent[] texts = new GUIContent[textures.Length]; * for(int i = 0; i< textures.Length; i++){ * texts[i] = new GUIContent(textures[i].name); * } * * EditorGUILayout.PrefixLabel("IsoTextures List", s); * * scrollPos = EditorGUILayout.BeginScrollView(scrollPos,GUILayout.Width(0), GUILayout.Height(60)); * selected = GUILayout.SelectionGrid(selected,texts,2,style,GUILayout.MaxWidth(auxWidth-25)); * EditorGUILayout.EndScrollView(); */ if (selected < textures.Length && textures[selected] != null) { currentText = textures[selected]; } else { currentText = null; } EditorGUILayout.PrefixLabel("IsoTexture", s); currentText = EditorGUILayout.ObjectField(currentText, typeof(IsoTexture), false) as IsoTexture; for (int i = 0; i < textures.Length; i++) { if (currentText == textures[i]) { selected = i; } } // Textura if (currentText != null) { currentText.name = UnityEditor.EditorGUILayout.TextField("Name", currentText.name); currentText.setTexture(UnityEditor.EditorGUILayout.ObjectField("Base tile", currentText.getTexture(), typeof(Texture2D), true) as Texture2D); Texture2D texture = currentText.getTexture(); if (texture != null) { EditorGUILayout.PrefixLabel("Presets", s); if (GUILayout.Button("Top")) { currentText.Rotation = 0; currentText.setXCorner(Mathf.RoundToInt(currentText.getTexture().width / 2f)); currentText.setYCorner(Mathf.RoundToInt(currentText.getTexture().height / 2f)); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Left")) { currentText.Rotation = 0; currentText.setXCorner(0); currentText.setYCorner(Mathf.RoundToInt((2f * currentText.getTexture().height) / 3f)); } if (GUILayout.Button("Right")) { currentText.Rotation = 3; currentText.setXCorner(currentText.getTexture().width); currentText.setYCorner(Mathf.RoundToInt(currentText.getTexture().height / 3f)); } EditorGUILayout.EndHorizontal(); extra.target = EditorGUILayout.ToggleLeft("Advanced", extra.target); if (EditorGUILayout.BeginFadeGroup(extra.faded)) { EditorGUI.indentLevel++; if (GUILayout.Button("Rotation: " + currentText.Rotation * 90)) { currentText.Rotation++; } EditorGUILayout.BeginHorizontal(); currentText.setXCorner(EditorGUILayout.IntField(currentText.getXCorner(), GUILayout.Width(30))); currentText.setXCorner(Mathf.FloorToInt(GUILayout.HorizontalSlider(currentText.getXCorner(), 0, texture.width, null))); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); currentText.setYCorner(EditorGUILayout.IntField(currentText.getYCorner(), GUILayout.Width(30))); currentText.setYCorner(Mathf.FloorToInt(GUILayout.HorizontalSlider(currentText.getYCorner(), 0, texture.height, null))); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); if (extra.faded != lastValue) { this.Repaint(); } lastValue = extra.faded; EditorGUILayout.Space(); Rect rect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.repaint) { float w = position.width; float h = position.height - rect.y; float rh = (w / texture.width * 1.0f) * (texture.height * 1.0f) - 10; float rw = w - 10; if (rh > h) { rw = (h / texture.height * 1.0f) * texture.width - 10; rh = h - 10; } textureRect = new Rect(w / 2f - rw / 2f, rect.y + 5, rw, rh); } float converter = textureRect.width / texture.width; /*Rect auxRect = GUILayoutUtility.GetRect(auxWidth, auxHeight); * auxRect.width = auxWidth;*/ GUI.DrawTexture(textureRect, texture); Vector2 rectCorner = new Vector2(textureRect.x, textureRect.y); Vector2 xCorner = rectCorner + new Vector2(converter * currentText.getXCorner(), 0); Vector2 yCorner = rectCorner + new Vector2(0, converter * currentText.getYCorner()); Vector2 xOtherCorner = rectCorner + new Vector2(converter * currentText.getOppositeXCorner(), textureRect.height); Vector2 yOtherCorner = rectCorner + new Vector2(textureRect.width, converter * currentText.getOppositeYCorner()); Drawing.DrawLine(xCorner, yCorner, Color.yellow, 0.5f, true); Drawing.DrawLine(yCorner, xOtherCorner, Color.yellow, 0.5f, true); Drawing.DrawLine(xOtherCorner, yOtherCorner, Color.yellow, 0.5f, true); Drawing.DrawLine(yOtherCorner, xCorner, Color.yellow, 0.5f, true); } else { EditorGUILayout.LabelField("Please asign a texture!"); } } else { EditorGUILayout.LabelField("Please select a texture o create a new one!", style); } //GUI }
public override void update(IsoTexture it) { regenerate (it.getTexture ()); }
public void OnInspectorGUI() { //paintingMode = EditorGUILayout.BeginToggleGroup("Painting mode",paintingMode); EditorGUILayout.HelpBox("Press left button to put the textures over the faces of the cell. Hold shift and press left button to copy the current texture of the hovering face.", MessageType.None); EditorGUILayout.Space(); EditorGUILayout.PrefixLabel("Brush", GUIStyle.none, titleStyle); selectedBrush = EditorGUILayout.Popup(selectedBrush, brushNames); EditorGUILayout.PrefixLabel("Texture", GUIStyle.none, titleStyle); EditorGUILayout.BeginHorizontal(); paintingTexture = UnityEditor.EditorGUILayout.ObjectField("Tile", paintingTexture, typeof(Texture2D), false, GUILayout.MaxHeight(16)) as Texture2D; if(paintingTexture != null){ IsoTexture[] textures = TextureManager.getInstance ().textureList (paintingTexture); List<string> texts = new List<string> (); int isoTextureIndex = textures.Length; for (int i = 0; i< textures.Length; i++){ texts.Add (textures[i].name); if(textures[i] == paintingIsoTexture) isoTextureIndex = i; } texts.Add("None"); //TODO CAMBIOS EN LA LISTA DEBERIAN DESELEECIONAR EL ELEMENTO ACTUAL SI ESTE YA NO ESTA EN LA LISTA isoTextureIndex = UnityEditor.EditorGUILayout.Popup(isoTextureIndex,texts.ToArray()); if(isoTextureIndex == textures.Length) paintingIsoTexture = null; else paintingIsoTexture = textures[isoTextureIndex]; } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f); // TODO podria hacerse una clase para este selector y asi reutilizarlo Event e = Event.current; EditorGUILayout.BeginVertical("Box"); IsoTexture[] isoTextures = TextureManager.getInstance().textureList(); int maxTextures = 8; float anchoTextura = (Screen.width - 30) / maxTextures; // This line controls the case when there are too many textures. In that case, // the line after the if creates a scroll to fix the size to a max, defined in // GUILayout.MaxHeight(<<designed size>>) if(isoTextures.Length > maxTextures*LTSS) scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura*LTSS)); int currentTexture = 0; foreach(IsoTexture it in isoTextures){ if(it.getTexture() == null) continue; if(currentTexture == 0) EditorGUILayout.BeginHorizontal(); Rect auxRect = GUILayoutUtility.GetRect(anchoTextura,anchoTextura); Rect border = new Rect(auxRect); auxRect.x+=2;auxRect.y+=2;auxRect.width-=4;auxRect.height-=4; if (e.isMouse && border.Contains(e.mousePosition)) { if(e.type == EventType.mouseDown){ paintingTexture = it.getTexture(); paintingIsoTexture = it; repaint = true; } } if(it == paintingIsoTexture) EditorGUI.DrawRect(border,Color.yellow); GUI.DrawTexture(auxRect,it.getTexture()); currentTexture++; if(currentTexture == maxTextures){EditorGUILayout.EndHorizontal(); currentTexture = 0;} } if(currentTexture != 0){ GUILayoutUtility.GetRect((maxTextures - currentTexture)*anchoTextura,anchoTextura); EditorGUILayout.EndHorizontal(); } if(isoTextures.Length > maxTextures*LTSS){ EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }
public void OnSceneGUI(SceneView scene) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); RaycastHit info = new RaycastHit(); Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); GameObject selected = null; if (Physics.Raycast(ray, out info /*, LayerMask.NameToLayer("Cells Layer")*/)) //TODO Arreglar esto porque al parecer la distancia no funciona correctamente { if (info.collider.transform.IsChildOf(this.map.transform)) { selected = info.collider.gameObject; } } bool paintLater = false; bool backupTextures = false; /* * Mouse Events of painting mode */ if (Event.current.isMouse) { if (Event.current.button == 0) { if (Event.current.shift) { if (Event.current.type == EventType.mouseDown) { collectTexture = true; } if (collectTexture && Event.current.type != EventType.MouseUp) { backupTextures = true; } else { collectTexture = false; } } else if (Event.current.type == EventType.MouseDown) { painting = true; paintLater = true; } else if (Event.current.type == EventType.MouseUp) { painting = false; } else { if (painting) { paintLater = true; } } } } /** * Working zone */ if (selected != null) { Cell cs = selected.GetComponent <Cell>(); if (cs != null) { FaceNoSC f = cs.getFaceByPoint(info.point); if (f != null) { if (paintLater && paintingTexture != null) { f.Texture = paintingTexture; f.TextureMapping = paintingIsoTexture; cs.forceRefresh(); } if (backupTextures) { this.paintingTexture = f.Texture; this.paintingIsoTexture = f.TextureMapping; repaint = true; } Vector3[] vertex = f.SharedVertex; int[] indexes = f.VertexIndex; Vector3[] puntos = new Vector3[4]; for (int i = 0; i < indexes.Length; i++) { puntos[i] = cs.transform.TransformPoint(vertex[indexes[i]]); } if (indexes.Length == 3) { puntos[3] = cs.transform.TransformPoint(vertex[indexes[2]]); } Handles.DrawSolidRectangleWithOutline(puntos, (Event.current.shift)? Color.blue : Color.yellow, Color.white); } } } }
public void OnEnable() { isoTexture = target as IsoTexture; }
public void paintCells(Cell cell, Skill skill, IsoTexture color, Entity entity = null) { Vector2 position = cell.Map.getCoords(cell.gameObject); changedCells = new Cell[((skill.getDistance() * 2) + 1) * ((skill.getDistance() * 2) + 1)]; oldTextures = new IsoTexture[((skill.getDistance() * 2) + 1) * ((skill.getDistance() * 2) + 1)]; int contador = 0; //busqueda directa float xcentral = position.x; float ycentral = position.y; //Vamos a marcar todas las casillas que esten en la distancia de la habilidad for (float i = position.x - skill.getDistance(); i <= position.x + skill.getDistance(); i++) { //vamos aumentando el radio de casillas hasta la distancia de la habilidad for (float j = position.y - skill.getDistance(); j <= position.y + skill.getDistance(); j++) { IsoUnity.Cell celdaAPintar = cell.Map.getCell(new Vector2(i, j)); if (celdaAPintar != null) { if (entity != null) { if (RoutePlanifier.planifyRoute(entity.mover, celdaAPintar)) { int distance = 0; Cell measuring; while (distance <= skill.getDistance() && (measuring = RoutePlanifier.next(entity.mover))) { entity.Position = measuring; distance++; } entity.Position = cell; RoutePlanifier.cancelRoute(entity.mover); if (distance > skill.getDistance()) { continue; } } else { continue; } } if ((int)Mathf.Abs(Mathf.Abs(i - xcentral) + Mathf.Abs(j - ycentral)) <= skill.getDistance()) { changedCells[contador] = celdaAPintar; oldTextures[contador] = celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].TextureMapping; celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].TextureMapping = color; celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].Texture = color.getTexture(); celdaAPintar.forceRefresh(); contador++; } } } } }