Exemple #1
0
    public void CreateSeed()
    {
        checkNeed = 0;

        for (int i = 0; i < Recipe.Count; i++)
        {
            if (Recipe[i].has)
            {
                checkNeed++;
            }
        }

        if (checkNeed == Recipe.Count)
        {
            for (int i = 0; i < Recipe.Count; i++)
            {
                if (scriptPlayer.ListSeeds[Recipe[i].IdPlant].quantity >= 0)
                {
                    scriptPlayer.ListSeeds[Recipe[i].IdPlant].quantity -= Recipe[i].quantityNeeded;
                }
                else
                {
                    scriptPlayer.ListSeeds[Recipe[i].IdPlant].quantity = 0;
                }

                Recipe[i].has = false;
            }

            Debug.Log("CREATE SEED ID " + seedRecipeId);
            scriptPlayer.AddSeed(seedRecipeId);

            updateRecipe();
        }
    }
Exemple #2
0
    private void OnMouseUp()
    {
        isDragging = false;

        if (onThisGO)
        {
            planterScript.DeletePlant();
            GameObject go = Instantiate(seedCreated.GetComponent <sc_Seed>().plantGO, onThisGO.transform.GetChild(0).transform.position, Quaternion.identity);
            planterScript.ChangeGameobject(go);
            Destroy(seedCreated);
        }
        else
        {
            scriptPlayer.AddSeed(IDPlant);
            Destroy(seedCreated);
        }


        /*if ((onThisGO != null) && (onThisGO.tag == "Planter"))
         * {
         * if (planterScript.GetComponent<sc_Planter>() && planterScript.GetComponent<sc_Planter>().plantInPot != null )
         *  {
         *      Debug.Log(" plante supprimé!");
         *      planterScript.DeletePlant();
         *      Destroy(seedCreate);
         *
         *  }
         *
         *  GameObject go = Instantiate(seedCreate.GetComponent<sc_Seed>().plantGO, onThisGO.transform.GetChild(0).transform.position, Quaternion.identity);
         *
         *  Debug.Log(go + " créé!");
         *
         *  if (planterScript != null)
         *  {
         *      Debug.Log(go + " Modifié!");
         *      planterScript.ChangeGameobject(go);
         *      Destroy(seedCreate);
         *  }
         * }
         * else
         * {
         *  scriptPlayer.AddSeed(IDPlant);
         *  Destroy(seedCreate);
         *
         * }*/
    }
Exemple #3
0
    private void OnMouseDown()
    {
        if (canBeGrab)
        {
            if (canFinishLevel)
            {
                scriptManager.WinLevel();
                Destroy(this.gameObject);
            }
            else
            {
                scriptPlayer.AddSeed(IDPlant);

                Debug.Log("Graines ramassées");
                LevelDown();
            }
        }
    }