Inheritance: MonoBehaviour
示例#1
0
    void Start()
    {
        hpImage           = GameObject.Find("CurrentHp").GetComponent <Image>();
        expImage          = GameObject.Find("CurrentExp").GetComponent <Image>();
        po                = gameObject.GetComponent <PhysicsObject>();
        blueprintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");

        if (inputManagerDatabase == null)
        {
            inputManagerDatabase = (InputManager)Resources.Load("InputManager");
        }

        if (craftSystem != null)
        {
            cS = craftSystem.GetComponent <CraftSystem>();
        }

        if (GameObject.FindGameObjectWithTag("Tooltip") != null)
        {
            toolTip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent <Tooltip>();
        }
        if (inventory != null)
        {
            mainInventory = inventory.GetComponent <Inventory>();
        }
        if (characterSystem != null)
        {
            characterSystemInventory = characterSystem.GetComponent <Inventory>();
        }
        if (craftSystem != null)
        {
            craftSystemInventory = craftSystem.GetComponent <Inventory>();
        }
    }
示例#2
0
    //PlayerScript PlayerstatsScript;

    // Use this for initialization
    void Start()
    {
        blueprintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
        inv        = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().inventory;
        mainSlider = GameObject.FindGameObjectWithTag("Slider").transform.GetComponent <Slider>();
        input      = GameObject.FindGameObjectWithTag("CraftItemNumber").GetComponent <InputField>();
        //playerStatsScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
    }
    public static BlueprintDatabase asset;                                                  //The List of all Blueprints

#if UNITY_EDITOR
    public static BlueprintDatabase createBlueprintDatabase()                                    //creates a new BlueprintDatabase(new instance)
    {
        asset = ScriptableObject.CreateInstance<BlueprintDatabase>();                       //of the ScriptableObject Blueprint

        AssetDatabase.CreateAsset(asset, "Assets/InventoryMaster/Resources/BlueprintDatabase.asset");            //in the Folder Assets/Resources/BlueprintDatabase.asset
        AssetDatabase.SaveAssets();                                                         //and than saves it there
        asset.blueprints.Add(new Blueprint());
        return asset;
    }
示例#4
0
 // Use this for initialization
 void Start()
 {
     used               = false;
     affichage          = 0;
     recetteIndice      = 0;
     indiceImageAjoutee = 0;
     blueprint_database = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
     item_database      = (ItemDataBaseList)Resources.Load("ItemDatabase");
 }
    public static BlueprintDatabase asset;                                                  //The List of all Blueprints

#if UNITY_EDITOR
    public static BlueprintDatabase createBlueprintDatabase()                                         //creates a new BlueprintDatabase(new instance)
    {
        asset = ScriptableObject.CreateInstance <BlueprintDatabase>();                                //of the ScriptableObject Blueprint

        AssetDatabase.CreateAsset(asset, "Assets/InventoryMaster/Resources/BlueprintDatabase.asset"); //in the Folder Assets/Resources/BlueprintDatabase.asset
        AssetDatabase.SaveAssets();                                                                   //and than saves it there
        asset.blueprints.Add(new Blueprint());
        return(asset);
    }
    public static BlueprintDatabase createBlueprintDatabase()
    {
        asset = ScriptableObject.CreateInstance<BlueprintDatabase>();

        AssetDatabase.CreateAsset(asset, "Assets/InventoryMaster/Resources/BlueprintDatabase.asset");
        AssetDatabase.SaveAssets();
        asset.blueprints.Add(new Blueprint());
        return asset;
    }
 // Use this for initialization
 void Start()
 {
     craftSystem       = transform.parent.GetComponent <CraftSystem>();
     blueprintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
     _player           = GameObject.FindGameObjectWithTag("Player");
     itemGameObject    = (GameObject)Instantiate(Resources.Load("Prefabs/Item") as GameObject);
     itemGameObject.transform.SetParent(this.gameObject.transform);
     itemGameObject.GetComponent <RectTransform>().localPosition = Vector3.zero;
     itemGameObject.GetComponent <DragItem>().enabled            = false;
     itemGameObject.SetActive(false);
     itemGameObject.transform.GetChild(1).GetComponent <Text>().enabled = true;
     //  itemGameObject.transform.GetChild(1).GetComponent<RectTransform>().localPosition= new Vector2(GameObject.FindGameObjectWithTag("MainInventory").GetComponent<Inventory>().positionNumberX, GameObject.FindGameObjectWithTag("MainInventory").GetComponent<Inventory>().positionNumberY);
 }
示例#8
0
    //PlayerScript PlayerstatsScript;

    // Use this for initialization
    void Start()
    {
        blueprintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
        //playerStatsScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
    }
 protected override void OnEnable()
 {
     base.OnEnable();
     BlueprintDatabase = (BlueprintDatabase)AssetDatabase.LoadAssetAtPath("Assets/Components/Inventory/Extensions/Crafting/Data/BlueprintDatabase.asset", typeof(BlueprintDatabase)) as BlueprintDatabase;
 }
示例#10
0
 /*void UpdateBlueprintDatabase()
 {
     for (uint i = 0; i < ItemDatabase.Blueprints.Count; i++)
     {
         ItemDatabase.Blueprints[i].Id = i;
     }
 }*/
 private void CreateBlueprintDatabase()
 {
     GUILayout.Space(10);
     GUILayout.BeginHorizontal();
     GUILayout.Label("The blueprint database could not be found");
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUI.color = Color.green;
     if (GUILayout.Button("Create", GUILayout.Width(200)))
     {
         BlueprintDatabase = ScriptableObject.CreateInstance<BlueprintDatabase>();
         AssetDatabase.CreateAsset(BlueprintDatabase, "Assets/Components/Inventory/Extensions/Crafting/Data/BlueprintDatabase.asset");
         AssetDatabase.SaveAssets();
     }
     GUI.color = Color.white;
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("The database will be installed in the following directory: Assets/Components/Inventory/Extensions/Crafting/Data/BlueprintDatabase.asset");
     GUILayout.EndHorizontal();
 }
示例#11
0
    void BluePrintDataBase()
    {
        EditorGUILayout.BeginVertical("Box");
        if (inventoryItemList == null)
            inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase");
        if (bluePrintDatabase == null)
            bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");

        GUILayout.BeginHorizontal();
        toolbarInt1 = GUILayout.Toolbar(toolbarInt1, toolbarStrings1, GUILayout.Width(position.width - 20));                                                    //creating a toolbar(tabs) to navigate what you wanna do
        GUILayout.EndHorizontal();
        scrollPosition1 = EditorGUILayout.BeginScrollView(scrollPosition1);
        GUILayout.Space(10);

        if (toolbarInt1 == 0)                                                                                                                              //if equal 0 than it is "Create Item"
        {
            GUI.color = Color.white;
            try
            {
                GUILayout.BeginVertical("Box");
                string[] items = new string[inventoryItemList.itemList.Count];                                                      //create a string array in length of the itemcount
                for (int i = 1; i < items.Length; i++)                                                                              //go through the item array
                {
                    items[i] = inventoryItemList.itemList[i].itemName;                                                              //and paste all names into the array
                }
                EditorGUILayout.BeginHorizontal();
                finalItemID = EditorGUILayout.Popup("Final Item", finalItemID, items, EditorStyles.popup);
                amountOfFinalItem = EditorGUILayout.IntField("Value", amountOfFinalItem);
                EditorGUILayout.EndHorizontal();
                //timeToCraft = EditorGUILayout.FloatField("Time to craft", timeToCraft);
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                amountofingredients = EditorGUILayout.IntSlider("Ingredients", amountofingredients, 1, 50, GUILayout.Width(position.width - 38));
                if (EditorGUI.EndChangeCheck())
                {
                    ingredients = new int[amountofingredients];
                    amount = new int[amountofingredients];
                }
                for (int i = 0; i < amountofingredients; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    ingredients[i] = EditorGUILayout.Popup("Ingredient " + i, ingredients[i], items, EditorStyles.popup, GUILayout.Width((position.width / 2) - 20));
                    amount[i] = EditorGUILayout.IntField("Value", amount[i], GUILayout.Width((position.width / 2) - 20));

                    EditorGUILayout.EndHorizontal();
                }
                GUI.color = Color.green;
                if (GUILayout.Button("Add Blueprint", GUILayout.Width(position.width - 35), GUILayout.Height(50)))
                    addBlueprint();

                GUILayout.EndVertical();

            }
            catch { }

        }

        if (toolbarInt1 == 1)
        {

            if (bluePrintDatabase == null)
            {
                bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
                if (bluePrintDatabase == null)
                {
                    bluePrintDatabase = CreateBlueprintDatabase.createBlueprintDatabase();
                    bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
                }
            }

            if (bluePrintDatabase.blueprints.Count == 1)
            {
                GUILayout.Label("There is no Blueprint in the Database!");
            }
            else
            {
                GUILayout.BeginVertical();
                for (int i = 1; i < bluePrintDatabase.blueprints.Count; i++)
                {
                    try
                    {
                        manageItem1.Add(false);
                        GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23));
                        manageItem1[i] = EditorGUILayout.Foldout(manageItem1[i], "" + bluePrintDatabase.blueprints[i].finalItem.itemName);                    //create for every item which you have in the itemdatabase a foldout
                        if (manageItem1[i])                                                                                                      //if you press on it you get this
                        {
                            EditorGUI.indentLevel++;
                            EditorUtility.SetDirty(bluePrintDatabase);                                                                          //message the scriptableobject that you change something now
                            GUI.color = Color.red;                                                                                              //all upcoming GUIelements get changed to red
                            if (GUILayout.Button("Delete Blueprint", GUILayout.Width(position.width - 38)))                                           //create button that deletes the item
                            {
                                bluePrintDatabase.blueprints.RemoveAt(i);                                                                         //remove the item out of the itemdatabase
                                EditorUtility.SetDirty(bluePrintDatabase);                                                                      //and message the database again that you changed something
                            }

                            GUI.color = Color.white;
                            EditorUtility.SetDirty(bluePrintDatabase);
                            bluePrintDatabase.blueprints[i].amountOfFinalItem = EditorGUILayout.IntField("Amount of final items", bluePrintDatabase.blueprints[i].amountOfFinalItem, GUILayout.Width(position.width - 35));
                            //bluePrintDatabase.blueprints[i].timeToCraft = EditorGUILayout.FloatField("Time to craft", bluePrintDatabase.blueprints[i].timeToCraft);
                            EditorUtility.SetDirty(bluePrintDatabase);
                            string[] items = new string[inventoryItemList.itemList.Count];                                                      //create a string array in length of the itemcount
                            for (int z = 1; z < items.Length; z++)                                                                              //go through the item array
                            {
                                items[z] = inventoryItemList.itemList[z].itemName;                                                              //and paste all names into the array
                            }
                            GUILayout.Label("Ingredients");
                            for (int k = 0; k < bluePrintDatabase.blueprints[i].ingredients.Count; k++)
                            {
                                GUILayout.BeginHorizontal();
                                GUI.color = Color.red;
                                if (GUILayout.Button("-"))
                                    bluePrintDatabase.blueprints[i].ingredients.RemoveAt(k);
                                GUI.color = Color.white;
                                bluePrintDatabase.blueprints[i].ingredients[k] = EditorGUILayout.Popup("Ingredient " + (k + 1), bluePrintDatabase.blueprints[i].ingredients[k], items, EditorStyles.popup);
                                bluePrintDatabase.blueprints[i].amount[k] = EditorGUILayout.IntField("Value", bluePrintDatabase.blueprints[i].amount[k]);

                                GUILayout.EndHorizontal();
                            }

                            GUI.color = Color.green;
                            if (GUILayout.Button("+"))
                            {
                                bluePrintDatabase.blueprints[i].ingredients.Add(0);
                                bluePrintDatabase.blueprints[i].amount.Add(0);
                            }
                            GUI.color = Color.white;
                            EditorGUI.indentLevel--;
                            EditorUtility.SetDirty(bluePrintDatabase);                                                                                              //message scriptable object that you have changed something
                        }
                        GUILayout.EndVertical();
                    }
                    catch { }
                }
                GUILayout.EndVertical();
            }

        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
示例#12
0
    //PlayerScript PlayerstatsScript;

    // Use this for initialization
    void Start()
    {
        blueprintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
        //playerStatsScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
    }
示例#13
0
    void BluePrintDataBase()
    {
        EditorGUILayout.BeginVertical("Box");
        if (inventoryItemList == null)
        {
            inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase");
        }
        if (bluePrintDatabase == null)
        {
            bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
        }

        GUILayout.BeginHorizontal();
        toolbarInt1 = GUILayout.Toolbar(toolbarInt1, toolbarStrings1, GUILayout.Width(position.width - 20));                                                    //creating a toolbar(tabs) to navigate what you wanna do
        GUILayout.EndHorizontal();
        scrollPosition1 = EditorGUILayout.BeginScrollView(scrollPosition1);
        GUILayout.Space(10);

        if (toolbarInt1 == 0)                                                                                                                              //if equal 0 than it is "Create Item"
        {
            GUI.color = Color.white;
            try
            {
                GUILayout.BeginVertical("Box");
                string[] items = new string[inventoryItemList.itemList.Count];                                                      //create a string array in length of the itemcount
                for (int i = 1; i < items.Length; i++)                                                                              //go through the item array
                {
                    items[i] = inventoryItemList.itemList[i].itemName;                                                              //and paste all names into the array
                }
                EditorGUILayout.BeginHorizontal();
                finalItemID       = EditorGUILayout.Popup("Final Item", finalItemID, items, EditorStyles.popup);
                amountOfFinalItem = EditorGUILayout.IntField("Value", amountOfFinalItem);
                EditorGUILayout.EndHorizontal();
                //timeToCraft = EditorGUILayout.FloatField("Time to craft", timeToCraft);
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                amountofingredients = EditorGUILayout.IntSlider("Ingredients", amountofingredients, 1, 50, GUILayout.Width(position.width - 38));
                if (EditorGUI.EndChangeCheck())
                {
                    ingredients = new int[amountofingredients];
                    amount      = new int[amountofingredients];
                }
                for (int i = 0; i < amountofingredients; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    ingredients[i] = EditorGUILayout.Popup("Ingredient " + i, ingredients[i], items, EditorStyles.popup, GUILayout.Width((position.width / 2) - 20));
                    amount[i]      = EditorGUILayout.IntField("Value", amount[i], GUILayout.Width((position.width / 2) - 20));

                    EditorGUILayout.EndHorizontal();
                }
                GUI.color = Color.green;
                if (GUILayout.Button("Add Blueprint", GUILayout.Width(position.width - 35), GUILayout.Height(50)))
                {
                    addBlueprint();
                }

                GUILayout.EndVertical();
            }
            catch { }
        }

        if (toolbarInt1 == 1)
        {
            if (bluePrintDatabase == null)
            {
                bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
                if (bluePrintDatabase == null)
                {
                    bluePrintDatabase = CreateBlueprintDatabase.createBlueprintDatabase();
                    bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase");
                }
            }

            if (bluePrintDatabase.blueprints.Count == 1)
            {
                GUILayout.Label("There is no Blueprint in the Database!");
            }
            else
            {
                GUILayout.BeginVertical();
                for (int i = 1; i < bluePrintDatabase.blueprints.Count; i++)
                {
                    try
                    {
                        manageItem1.Add(false);
                        GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23));
                        manageItem1[i] = EditorGUILayout.Foldout(manageItem1[i], "" + bluePrintDatabase.blueprints[i].finalItem.itemName);       //create for every item which you have in the itemdatabase a foldout
                        if (manageItem1[i])                                                                                                      //if you press on it you get this
                        {
                            EditorGUI.indentLevel++;
                            EditorUtility.SetDirty(bluePrintDatabase);                                                                          //message the scriptableobject that you change something now
                            GUI.color = Color.red;                                                                                              //all upcoming GUIelements get changed to red
                            if (GUILayout.Button("Delete Blueprint", GUILayout.Width(position.width - 38)))                                     //create button that deletes the item
                            {
                                bluePrintDatabase.blueprints.RemoveAt(i);                                                                       //remove the item out of the itemdatabase
                                EditorUtility.SetDirty(bluePrintDatabase);                                                                      //and message the database again that you changed something
                            }

                            GUI.color = Color.white;
                            EditorUtility.SetDirty(bluePrintDatabase);
                            bluePrintDatabase.blueprints[i].amountOfFinalItem = EditorGUILayout.IntField("Amount of final items", bluePrintDatabase.blueprints[i].amountOfFinalItem, GUILayout.Width(position.width - 35));
                            //bluePrintDatabase.blueprints[i].timeToCraft = EditorGUILayout.FloatField("Time to craft", bluePrintDatabase.blueprints[i].timeToCraft);
                            EditorUtility.SetDirty(bluePrintDatabase);
                            string[] items = new string[inventoryItemList.itemList.Count];                                                      //create a string array in length of the itemcount
                            for (int z = 1; z < items.Length; z++)                                                                              //go through the item array
                            {
                                items[z] = inventoryItemList.itemList[z].itemName;                                                              //and paste all names into the array
                            }
                            GUILayout.Label("Ingredients");
                            for (int k = 0; k < bluePrintDatabase.blueprints[i].ingredients.Count; k++)
                            {
                                GUILayout.BeginHorizontal();
                                GUI.color = Color.red;
                                if (GUILayout.Button("-"))
                                {
                                    bluePrintDatabase.blueprints[i].ingredients.RemoveAt(k);
                                }
                                GUI.color = Color.white;
                                bluePrintDatabase.blueprints[i].ingredients[k] = EditorGUILayout.Popup("Ingredient " + (k + 1), bluePrintDatabase.blueprints[i].ingredients[k], items, EditorStyles.popup);
                                bluePrintDatabase.blueprints[i].amount[k]      = EditorGUILayout.IntField("Value", bluePrintDatabase.blueprints[i].amount[k]);

                                GUILayout.EndHorizontal();
                            }

                            GUI.color = Color.green;
                            if (GUILayout.Button("+"))
                            {
                                bluePrintDatabase.blueprints[i].ingredients.Add(0);
                                bluePrintDatabase.blueprints[i].amount.Add(0);
                            }
                            GUI.color = Color.white;
                            EditorGUI.indentLevel--;
                            EditorUtility.SetDirty(bluePrintDatabase);                                                                                              //message scriptable object that you have changed something
                        }
                        GUILayout.EndVertical();
                    }
                    catch { }
                }
                GUILayout.EndVertical();
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
示例#14
0
 protected Blueprint(string customPath)
 {
     ObjectId = BlueprintDatabase.GetUniqueId();
     InitializeBlueprint(customPath);
 }
示例#15
0
 public Blueprint()
 {
     ObjectId = BlueprintDatabase.GetUniqueId();
     InitializeBlueprint(Constants.Blueprint.BlueprintsPath);
 }
示例#16
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            DestroyImmediate(gameObject);
        }

        if (blueprintsMap == null)
        {
            Init();
            InitExtractors();
            InitBattleTowers();
        }
    }