Exemple #1
0
        /* ********** *
        * CRUD Zone  *
        * ********** */

        public GameObject addCell(Vector3 position)
        {
            checkTransform();

            // Creating the gameObject
#if UNITY_EDITOR
            GameObject go = UnityEditor.PrefabUtility.InstantiatePrefab(IsoSettingsManager.getInstance().getIsoSettings().defaultCellPrefab) as GameObject;
#else
            GameObject go = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultCellPrefab);
#endif

            // Getting the localPosition
            position = m_transform.InverseTransformPoint(position);

            // Setting base properties
            Cell cell = go.GetComponent <Cell>();
            cell.Map = this;
            cell.transform.localPosition = new Vector3(position.x, 0, position.z);
            cell.Height = position.y;
            cell.Width  = cellSize;
            cell.forceRefresh();

            //Añado la celda al conjunto de celdas

            //La refresco
            updateCell(cell, true);

            return(go);
        }
    // 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();
    }
 private void cleanSkillCells()
 {
     SelectableCell[] selectableCells = FindObjectsOfType <SelectableCell>();
     foreach (SelectableCell selectableCell in selectableCells)
     {
         IsoUnity.Cell cell = selectableCell.cell;
         if (selectableCell.previousTexture != null)
         {
             cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = selectableCell.previousTexture;
             cell.Properties.faces[cell.Properties.faces.Length - 1].Texture        = selectableCell.previousTexture.getTexture();
         }
         else
         {
             cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = null;
             cell.Properties.faces[cell.Properties.faces.Length - 1].Texture        = null;
         }
         cell.forceRefresh();
     }
 }
Exemple #4
0
    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++;
                    }
                }
            }
        }
    }