Exemplo n.º 1
0
 void ClearFields()
 {
     textureName = string.Empty;
     texture     = new Sprite();
     name        = string.Empty;
     pickupName  = string.Empty;
     itemType    = Constant.ItemType.Armor;
     if (tab == 3)
     {
         obstacle.hp = 0;
     }
     if (tab == 4)
     {
         door.InMap = new AbstractMap();
     }
     if (tab == 5)
     {
         house.Width  = 0;
         house.Heigth = 0;
     }
     Selected = null;
 }
Exemplo n.º 2
0
    void updateFields()
    {
        var obj = Selected.GetComponent <RPGElement>();

        name        = obj.Name;
        texture     = obj.Icon;
        textureName = obj.Icon.name;
        switch (tab)
        {
        case 1:
            var temp4 = obj as Wall;
            wall.Image = temp4.Image;
            break;

        case 2:
            var temp = obj as Pickup;
            if (temp.ItemArmor.ItemName != "")
            {
                pickupName = temp.ItemArmor.ItemName;
                itemType   = Constant.ItemType.Armor;
            }
            if (temp.ItemUsable.ItemName != "")
            {
                pickupName = temp.ItemUsable.ItemName;
                itemType   = Constant.ItemType.Usable;
            }
            if (temp.ItemWeapon.ItemName != "")
            {
                pickupName = temp.ItemWeapon.ItemName;
                itemType   = Constant.ItemType.Weapon;
            }
            pickup.ItemArmor  = temp.ItemArmor;
            pickup.ItemUsable = temp.ItemUsable;
            pickup.ItemWeapon = temp.ItemWeapon;
            pickup.Sound      = temp.Sound;
            break;

        case 3:
            var temp1 = obj as Obstacle;
            obstacle.hp    = temp1.hp;
            obstacle.Image = temp1.Image;
            obstacle.Sound = temp1.Sound;
            obstacle.Type  = temp1.Type;
            break;

        case 4:
            var temp2 = obj as Door;
            door.InMap = temp2.InMap;
            door.Image = temp2.Image;
            break;

        case 5:
            var temp3 = obj as House;
            house.Width  = temp3.Width;
            house.Heigth = temp3.Heigth;
            house.Image  = temp3.Image;
            break;

        default:
            var temp5 = obj as Tile;
            tile.Image = temp5.Image;
            tile.Type  = temp5.Type;
            break;
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Metodo que se llama cuando la ventana esta abierta.
    /// </summary>
    void OnGUI()
    {
        RenderLeftSide();
        GUILayout.BeginArea(new Rect((float)(this.position.width * 0.5), 0, 96, 96), string.Empty, EditorStyles.helpBox);
        GUILayout.EndArea();
        GUILayout.BeginArea(new Rect((float)(this.position.width * 0.5), 96, (float)(this.position.width * 0.5), this.position.height - 20), string.Empty, EditorStyles.helpBox);
        GUILayout.BeginHorizontal();
        GUILayout.Label("Name:", GUILayout.Width(labelWidth));
        name = GUILayout.TextField(name);
        GUILayout.EndHorizontal();
        GUILayout.Space(15);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Select Image", GUILayout.Width(labelWidth)))
        {
            EditorGUIUtility.ShowObjectPicker <Sprite>(null, false, type, 1);
        }
        GUI.enabled = false;
        GUILayout.TextField(textureName);
        GUI.enabled = true;
        GUILayout.EndHorizontal();
        AddObject();
        GUILayout.Space(15);
        if (tab == 0)
        {
            tile.Name     = name;
            tile.Icon     = texture;
            tile.Type     = (Constant.TileType)EditorGUILayout.EnumPopup("Type:", tile.Type);
            MapObjectType = Constant.MapObjectType.Tile;
        }
        else if (tab == 1)
        {
            wall.Name     = name;
            wall.Icon     = texture;
            MapObjectType = Constant.MapObjectType.Wall;
        }
        else if (tab == 2)
        {
            pickup.Name   = name;
            pickup.Icon   = texture;
            MapObjectType = Constant.MapObjectType.Pickup;

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select Sound", GUILayout.Width(labelWidth)))
            {
                EditorGUIUtility.ShowObjectPicker <AudioClip>(null, false, "Sound_", 2);
            }
            string soundName = pickup.Sound == null ? string.Empty : pickup.Sound.name;
            GUI.enabled = false;
            EditorGUILayout.TextField(soundName);
            GUI.enabled = true;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            itemType = (Constant.ItemType)EditorGUILayout.EnumPopup("Select Item Type", itemType);
            GUILayout.EndHorizontal();
            if (itemType == Constant.ItemType.Armor)
            {
                pickup.ItemArmor.Type = (AbstractArmor.ArmorType)EditorGUILayout.EnumPopup("Armor Type: ", pickup.ItemArmor.Type);
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select Item", GUILayout.Width(labelWidth)))
            {
                pickup.ItemArmor  = new AbstractArmor();
                pickup.ItemUsable = new AbstractUsable();
                pickup.ItemWeapon = new AbstractWeapon();
                switch (itemType)
                {
                case Constant.ItemType.Armor:
                    var window = EditorWindow.GetWindow <ArmorUI>();
                    window.Selected = true;
                    window.Initialize(ref pickup.ItemArmor, pickup.ItemArmor.Type);
                    window.Show();
                    break;

                case Constant.ItemType.Usable:
                    var window2 = EditorWindow.GetWindow <ItemUI>();
                    window2.Selected = true;
                    window2.Initialize(ref pickup.ItemUsable);
                    window2.Show();
                    break;

                case Constant.ItemType.Weapon:
                    var window3 = EditorWindow.GetWindow <WeaponUI>();
                    window3.Selected = true;
                    window3.Initialize(ref pickup.ItemWeapon);
                    window3.Show();
                    break;
                }
            }
            switch (itemType)
            {
            case Constant.ItemType.Armor:
                pickupName = pickup.ItemArmor.ItemName;
                break;

            case Constant.ItemType.Usable:
                pickupName = pickup.ItemUsable.ItemName;
                break;

            case Constant.ItemType.Weapon:
                pickupName = pickup.ItemWeapon.ItemName;
                break;
            }

            GUI.enabled = false;
            GUILayout.TextField(pickupName);
            GUI.enabled = true;
            GUILayout.EndHorizontal();
        }
        else if (tab == 3)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select Sound", GUILayout.Width(labelWidth)))
            {
                EditorGUIUtility.ShowObjectPicker <AudioClip>(null, false, "Sound_", 3);
            }
            string soundName = obstacle.Sound == null ? string.Empty : obstacle.Sound.name;
            GUI.enabled = false;
            EditorGUILayout.TextField(soundName);
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            obstacle.Type = (Constant.ObstacleType)EditorGUILayout.EnumPopup("Type:", obstacle.Type);

            if (obstacle.Type == Constant.ObstacleType.Destroyable)
            {
                obstacle.hp = EditorGUILayout.IntField("Obstacle HP:", obstacle.hp);
            }

            obstacle.Name = name;
            obstacle.Icon = texture;
            MapObjectType = Constant.MapObjectType.Obstacle;
        }
        else if (tab == 4)
        {
            door.Name     = name;
            door.Icon     = texture;
            MapObjectType = Constant.MapObjectType.Door;
        }
        else if (tab == 5)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("House Width:", GUILayout.Width(labelWidth));
            house.Width = EditorGUILayout.IntField(house.Width);
            GUILayout.EndHorizontal();
            GUILayout.Space(15);
            GUILayout.BeginHorizontal();
            GUILayout.Label("House Heigth:", GUILayout.Width(labelWidth));
            house.Heigth = EditorGUILayout.IntField(house.Heigth);
            GUILayout.EndHorizontal();
            house.Name    = name;
            house.Icon    = texture;
            MapObjectType = Constant.MapObjectType.House;
        }

        GUILayout.EndArea();

        if (GUI.Button(new Rect((float)(this.position.width * 0.5), this.position.height - 20, 100, 20), "Save"))
        {
            if (Selected != null)
            {
                SaveSelected();
            }
            else
            {
                CreateNew();
            }
        }
        if (Selected != null)
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
        }
        if (GUI.Button(new Rect((float)(this.position.width * 0.5) + 100, this.position.height - 20, 100, 20), "Delete"))
        {
            DeleteSelected();
            ClearFields();
        }
        GUI.enabled = true;

        if (texture != null)
        {
            GUI.DrawTextureWithTexCoords(new Rect((float)(this.position.width * 0.5), 0, 96, 96), texture.texture, Constant.GetTextureCoordinate(texture));
        }
    }