Beispiel #1
0
    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");
        }
    }
Beispiel #2
0
        public void OnInspectorGUI()
        {
            GUIStyle style = new GUIStyle();

            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();

            parallelDecoration = EditorGUILayout.Toggle("Draw Parallel", parallelDecoration);
            EditorGUILayout.Space();

            autoanimate = EditorGUILayout.Toggle("Auto Animate", autoanimate);

            if (autoanimate)
            {
                FrameRate = float.Parse(EditorGUILayout.TextField("Frame Rate:", FrameRate.ToString()));

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Frame Secuence:", GUIStyle.none, titleStyle);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox("Let the frame secuence list empty if you want to use the default frame loop.", MessageType.None);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.BeginVertical();

                GUIContent btt = new GUIContent("Add Frame");
                Rect       btr = GUILayoutUtility.GetRect(btt, style);
                if (GUI.Button(btr, btt))
                {
                    if (FrameSecuence == null)
                    {
                        FrameSecuence = new int[0];
                    }
                    int[] tmpFrameSecuence = new int[FrameSecuence.Length + 1];
                    for (int i = 0; i < FrameSecuence.Length; i++)
                    {
                        tmpFrameSecuence[i] = FrameSecuence[i];
                    }
                    tmpFrameSecuence[tmpFrameSecuence.Length - 1] = 0;
                    FrameSecuence = tmpFrameSecuence;
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical();
                btt = new GUIContent("Remove Frame");
                btr = GUILayoutUtility.GetRect(btt, style);
                if (GUI.Button(btr, btt))
                {
                    if (FrameSecuence.Length > 0)
                    {
                        if (FrameSecuence == null)
                        {
                            FrameSecuence = new int[0];
                        }
                        int[] tmpFrameSecuence = new int[FrameSecuence.Length - 1];
                        for (int i = 0; i < FrameSecuence.Length - 1; i++)
                        {
                            tmpFrameSecuence[i] = FrameSecuence[i];
                        }
                        FrameSecuence = tmpFrameSecuence;
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();

                if (FrameSecuence != null)
                {
                    for (int i = 0; i < FrameSecuence.Length; i++)
                    {
                        FrameSecuence[i] = int.Parse(EditorGUILayout.TextField(i.ToString(), FrameSecuence[i].ToString()));
                    }
                }
            }
            EditorGUILayout.Space();

            EditorGUILayout.PrefixLabel("Decoration Objects", GUIStyle.none, titleStyle);

            GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f);

            EditorGUILayout.BeginVertical("Box");

            IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList();

            int   maxTextures  = 8;
            float anchoTextura = (Screen.width - 30) / maxTextures;

            if (isoDecorations.Length > maxTextures * LTSS)
            {
                scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura * LTSS));
            }

            Event e = Event.current;

            int currentTexture = 0;

            foreach (IsoDecoration it in isoDecorations)
            {
                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)
                    {
                        paintingIsoDecoration = it;
                        this.Repaint          = true;
                    }
                }

                if (it == paintingIsoDecoration)
                {
                    EditorGUI.DrawRect(border, Color.yellow);
                }

                Rect  textCoord   = it.getTextCoordsFor(currentTile);
                Rect  textureRect = new Rect(auxRect);
                float ratio       = (textCoord.height * it.getTexture().height) / (textCoord.width * it.getTexture().width);
                if (ratio < 1)
                {
                    float yCenter = auxRect.y + auxRect.height / 2.0f;
                    textureRect = new Rect(auxRect.x, yCenter - (auxRect.height / 2f) * ratio, auxRect.width, auxRect.height * ratio);
                }
                else
                {
                    float inverseRatio = 1 / ratio;
                    float xCenter      = auxRect.x + auxRect.width / 2.0f;
                    textureRect = new Rect(xCenter - (auxRect.width / 2f) * inverseRatio, auxRect.y, auxRect.width * inverseRatio, auxRect.height);
                }

                GUI.DrawTextureWithTexCoords(textureRect, it.getTexture(), textCoord);

                currentTexture++;
                if (currentTexture == maxTextures)
                {
                    EditorGUILayout.EndHorizontal(); currentTexture = 0;
                }
            }

            if (currentTexture != 0)
            {
                GUILayoutUtility.GetRect((maxTextures - currentTexture) * anchoTextura, anchoTextura);
                EditorGUILayout.EndHorizontal();
            }

            if (isoDecorations.Length > maxTextures * LTSS)
            {
                EditorGUILayout.EndScrollView();
            }


            EditorGUILayout.EndVertical();
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 public override void deleteTexture(IsoDecoration texture)
 {
     //AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(texture));
 }
Beispiel #7
0
 public override void update(IsoDecoration it)
 {
     regenerate(it.getTexture());
 }
Beispiel #8
0
 public abstract void update(IsoDecoration Decoration);
Beispiel #9
0
 public abstract void deleteTexture(IsoDecoration Decoration);