void Start()
    {
        // Get IsoUnityOptions
        try
        {
            IsoUnityOptions isoUnityOptions = GameObject.Find("Game").GetComponent(typeof(IsoUnityOptions)) as IsoUnityOptions;
            colorMove   = isoUnityOptions.moveCell;
            colorAttack = isoUnityOptions.attackCell;
            colorSkill  = isoUnityOptions.skillCell;
            arrow       = isoUnityOptions.arrowDecoration;
        }
        catch (NullReferenceException e)
        {
            Debug.Log("IsoUnityConnector values are not properly defined");
        }

        // Get TRPGOptions
        try
        {
            health       = Database.Instance.battleOptions.healthAttribute;
            moveHeight   = Database.Instance.battleOptions.moveHeight;
            moveRange    = Database.Instance.battleOptions.moveRange;
            attackHeight = Database.Instance.battleOptions.attackHeight;
            attackRange  = Database.Instance.battleOptions.attackRange;
        }
        catch (NullReferenceException e)
        {
            Debug.Log("TRPGOptions in Battle Options values are not properly defined");
        }
    }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            isoTexture = target as IsoTexture;

            if (GUILayout.Button("Open texture assistant"))
            {
                TextureAssistant.OpenWindowEditor(isoTexture);
            }
        }
Exemple #3
0
        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;

        }
Exemple #4
0
 public override void deleteTexture(IsoTexture texture)
 {
     //AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(texture));
 }
Exemple #5
0
 public override void update(IsoTexture it)
 {
     regenerate(it.getTexture());
 }
Exemple #6
0
 public abstract void update(IsoTexture texture);
Exemple #7
0
 public abstract void deleteTexture(IsoTexture texture);
Exemple #8
0
        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());

                    Handles.BeginGUI();
                    Handles.color = Color.yellow;
                    Handles.DrawLine(xCorner, yCorner);
                    Handles.DrawLine(yCorner, xOtherCorner);
                    Handles.DrawLine(xOtherCorner, yOtherCorner);
                    Handles.DrawLine(yOtherCorner, xCorner);

                    Handles.EndGUI();
                }
                else
                    EditorGUILayout.LabelField("Please asign a texture!");
            }
            else
            {
                EditorGUILayout.LabelField("Please select a texture o create a new one!", style);
            }

            //GUI
        }
Exemple #9
0
 public void OnEnable()
 {
     isoTexture = target as IsoTexture;
 }
Exemple #10
0
        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();
        }