Example #1
0
 public void init()
 {
     gm         = GameManager.gm;
     rm         = gm.getResearchManager();
     player     = gm.getPlayer();
     recipeList = RecipeDatabase.load();
 }
Example #2
0
    private void Show()
    {
        if (show)
        {
            if (reset)
            {
                // get random favorite

                RecipeDatabase rdb = player.GetComponentInChildren <RecipeDatabase>();
                Sprite         s;
                //if (Random.Range(0f, 1.0f) < 0.5f)
                //{
                // random ingredient
                int    len = flavors.favoriteIngredients.Length;
                string fav = flavors.favoriteIngredients[Random.Range(0, len - 1)];
                // get from ingredients
                IngredientData d = rdb.allIngredients[fav];
                // display
                s = d.image;
                //}

                /*else
                 * {
                 *  // favorite flavor
                 *  Debug.Log(flavors.favoriteFlavors);
                 *  string ff = rdb.flavorToString[flavors.favoriteFlavors];
                 *  Debug.Log(ff);
                 *  // get image from database
                 *  //s = rdb.allFlavors[ff];
                 *  s = rdb.allFlavors[ff];
                 * }*/

                Debug.Log(s.name);
                fruitRender.sprite = s;

                // set sprite
                StartCoroutine(EndAfterSeconds(2));

                if (audio != null)
                {
                    GameObject sfx = Instantiate(audioPlayer, transform.position, Quaternion.identity);
                    sfx.GetComponent <PlayAndDestroy>().Play(audio);
                    sfx.GetComponent <AudioSource>().volume /= 2;
                }
                reset = false;
            }

            fruitRender.enabled  = true;
            bubbleRender.enabled = true;
        }
        else
        {
            fruitRender.enabled  = false;
            bubbleRender.enabled = false;
            reset = true;
        }
    }
Example #3
0
 public void Start()
 {
     cb = CallbackLibrary.Instance;
     rd = RecipeDatabase.Instance;
     Debug.Log(rd.getRecipeFromId(recipe_id).ToString());
     this.recipe = rd.getRecipeFromId(recipe_id);
     this.recipe.required_items     = rd.getRecipeFromId(recipe_id).required_items;
     this.recipe.reward_func_string = rd.getRecipeFromId(recipe_id).reward_func_string;
 }
Example #4
0
    // try upgrade base
    public void upgradeBase(int upgradeType)
    {
        if (upgradeType == BASEUPGRADE.CRAFT)
        {
            Debug.Log(cm);
            if (cm.craft(BASEUPGRADE.CRAFT_UPGRADE[craftLevel], 1))
            {
                craftLevel++;
                gm.playSE("hammering");
                return;
            }

            // upgrade fail
            Recipe recipe = RecipeDatabase.findRecipe(BASEUPGRADE.CRAFT_UPGRADE[craftLevel]);
            string msg    = "";

            msg += "업그레이드를 위해 다음의 재료가 필요합니다. \n\n";

            List <RecipeElement> ingredients = recipe.getIngredients();
            foreach (RecipeElement e in ingredients)
            {
                msg += e.item.getName() + " x " + e.count.ToString() + "\n";
            }

            gm.showMessage(msg);
        }

        else if (upgradeType == BASEUPGRADE.CULTIVATE)
        {
            if (cm.craft(BASEUPGRADE.CULTIVATE_UPGRADE[cultivateLevel], 1))
            {
                cultivateLevel++;
                gm.playSE("hammering");
                return;
            }

            // upgrade fail
            Recipe recipe = RecipeDatabase.findRecipe(BASEUPGRADE.CULTIVATE_UPGRADE[cultivateLevel]);
            string msg    = "";

            msg += "업그레이드를 위해 다음의 재료가 필요합니다. \n\n";

            List <RecipeElement> ingredients = recipe.getIngredients();
            foreach (RecipeElement e in ingredients)
            {
                msg += e.item.getName() + " x " + e.count.ToString() + "\n";
            }

            gm.showMessage(msg);
        }
        else
        {
            return;
        }
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        gameController     = GameController.instance;
        player             = gameController.player;
        craftingController = CraftingController.instance;
        itemDatabase       = ItemDatabase.instance;
        recipeDatabase     = RecipeDatabase.instance;
        recipe             = recipeDatabase.GetRecipe(recipeId);

        craftingButton = GetComponent <Button>();
        craftingButton.onClick.AddListener(Craft);
    }
Example #6
0
        public ActionResult Add(string name, string link)
        {
            RecipeDatabase db = new RecipeDatabase(ConnectionString);

            Recipe recipe = new Recipe {
                Name = name, Link = link
            };

            db.Insert(recipe);

            return(null);
        }
Example #7
0
    private void Awake()
    {
        //Insert some sort of app store check;
        ZPlayerPrefs.Initialize("password", SystemInfo.deviceUniqueIdentifier);
        Instance = this;

        equipped      = new int[8];
        equippedItems = new BaseItem[8];
        recipes       = new RecipeDatabase();
        db            = new ItemDatabase();
        inventory     = new int[db.items.Count];
        if (!ZPlayerPrefs.HasKey("SaveString"))
        {
            firstStart();
        }
        Application.targetFrameRate = ZPlayerPrefs.GetInt("framerate");
        initEquippedItemsArrayTypes();
        loadPlayerData();
        loadEquippedItemsArray();
        StartCoroutine(updateStats());
        model.spawnModel();
    }
    public override void setDescriptee(GameObject descriptee)
    {
        int  type       = descriptee.GetComponent <UpgradeButton>().upgradeType;
        Base baseObject = GameManager.gm.getBoardManager().getBase();

        if (type == BASEUPGRADE.CRAFT)
        {
            int craftLevel = baseObject.getCraftLevel();
            name.text = "LV " + craftLevel.ToString();

            Recipe recipe = RecipeDatabase.findRecipe(BASEUPGRADE.CRAFT_UPGRADE[craftLevel]);
            string msg    = "";

            List <RecipeElement> ingredients = recipe.getIngredients();
            foreach (RecipeElement e in ingredients)
            {
                msg += e.item.getName() + " x " + e.count.ToString() + "\n";
            }

            description.text = msg;
        }
        else if (type == BASEUPGRADE.CULTIVATE)
        {
            int cultivateLevel = baseObject.getCraftLevel();
            name.text = "LV " + cultivateLevel.ToString();

            Recipe recipe = RecipeDatabase.findRecipe(BASEUPGRADE.CULTIVATE_UPGRADE[cultivateLevel]);
            string msg    = "";

            List <RecipeElement> ingredients = recipe.getIngredients();
            foreach (RecipeElement e in ingredients)
            {
                msg += e.item.getName() + " x " + e.count.ToString() + "\n";
            }

            description.text = msg;
        }
    }
Example #9
0
    // Use this for initialization
    void Start()
    {
        playerHealthManager = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthManager>();
        database            = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemDatabase>();
        recipeDatabase      = GameObject.FindGameObjectWithTag("RecipeDatabase").GetComponent <RecipeDatabase>();
        craftingScrollList  = GameObject.FindGameObjectWithTag("CraftingScrollList").GetComponent <CraftingScrollList>();

        iconSize     = 40;
        SelectedItem = new Item();

        // Fill the slots list with empty items.
        for (int i = 0; i < slotsX * slotsY; i++)
        {
            slots.Add(new Item());
            inventory.Add(new Item());
        }

        for (int i = 0; i < hotbarX; i++)
        {
            hotBarSlots.Add(new Item());
            hotBar.Add(new Item());
        }
    }
Example #10
0
    public void onClick()
    {
        if (cm.craft(1000, 1))
        {
            gm.playSE("hammering");
            map.setBase();
        }
        else
        {
            Recipe recipe = RecipeDatabase.findRecipe(1000);
            string msg    = "";

            msg += "다음의 재료가 필요합니다. \n\n";

            List <RecipeElement> ingredients = recipe.getIngredients();
            foreach (RecipeElement e in ingredients)
            {
                msg += e.item.getName() + " x " + e.count.ToString() + "\n";
            }

            gm.showMessage(msg);
        }
    }
Example #11
0
        static void Main(string[] args)
        {
            CommandLineArguments parsedArgs;
            var argsParser = new CommandLineParser(typeof(CommandLineArguments));

            try
            {
                parsedArgs = (CommandLineArguments)argsParser.Parse(args);
            }
            catch (CommandLineArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                argsParser.WriteUsageToConsole();
                return;
            }

            using (var db = RecipeDatabase.Open())
            {
                switch (parsedArgs.Operation)
                {
                case CommandLineOperation.Add:
                {
                    var recipes        = db.GetAllRecipes();
                    var matchingRecipe = recipes.FirstOrDefault(r => r.Name == parsedArgs.RecipeName);
                    if (matchingRecipe == null)
                    {
                        db.SaveRecipe(new Recipe {
                                Name = parsedArgs.RecipeName
                            });
                    }
                    else
                    {
                        Console.WriteLine("There is already a recipe named {0}", parsedArgs.RecipeName);
                    }
                }
                break;

                case CommandLineOperation.Rename:
                {
                    var recipes        = db.GetAllRecipes();
                    var matchingRecipe = recipes.FirstOrDefault(r => r.Name == parsedArgs.RecipeName);
                    if (matchingRecipe != null)
                    {
                        matchingRecipe.Name = parsedArgs.NewRecipeName;
                        db.SaveRecipe(matchingRecipe);
                    }
                    else
                    {
                        Console.WriteLine("Could not locate recipe named {0}", parsedArgs.RecipeName);
                    }
                }
                break;

                case CommandLineOperation.Delete:
                {
                    var recipes        = db.GetAllRecipes();
                    var matchingRecipe = recipes.FirstOrDefault(r => r.Name == parsedArgs.RecipeName);
                    if (matchingRecipe != null)
                    {
                        db.DeleteRecipe(matchingRecipe);
                    }
                    else
                    {
                        Console.WriteLine("Could not locate recipe named {0}", parsedArgs.RecipeName);
                    }
                }
                break;

                case CommandLineOperation.List:
                {
                    var recipes = db.GetAllRecipes();
                    foreach (var recipe in recipes)
                    {
                        Console.WriteLine(recipe.ToString());
                    }
                }
                break;
                }
            }
        }
    public RecipeInfo[] recipes;     // set these manually in the inspector
    #endregion

    #region Methods
    void Awake()
    {
        instance = this;
    }
Example #13
0
    void Start()
    {
        itemDB = new ItemDatabase();
        itemDB.BuildAllDatabases();

        recipeDB = new RecipeDatabase();
        recipeDB.InitializeRecipeDatabase();

        cookingPot.Add(itemDB.SearchDatabaseByUID("carrot_raw"));
        cookingPot.Add(itemDB.SearchDatabaseByUID("potato_raw"));
        UseCookingPot();

        for (int i = 0; i < playerInventory.Count; i++)
        {
            Debug.Log(playerInventory[i].name);
        }
    }
Example #14
0
 // Use this for initialization
 void Start()
 {
     itemDatabase   = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent <ItemDatabase>();
     recipeDatabase = GameObject.FindGameObjectWithTag("RecipeDatabase").GetComponent <RecipeDatabase>();
     RemoveButtons();
 }
Example #15
0
    private void initGame()
    {
        /*
         *  Initializing player
         *
         */
        player = new Player(100, 1000, 0, 100f);

        /*
         * Initializing Databases
         *
         */
        itemText   = Resources.Load("Data/Item") as TextAsset;
        recipeText = Resources.Load("Data/Recipe") as TextAsset;
        techText   = Resources.Load("Data/Technology") as TextAsset;

        ItemDatabase.init(itemText);
        RecipeDatabase.init(recipeText);
        TechnologyDatabase.init(techText);
        FieldDropDatabase.init();

        /*
         * Other Managers Initializing
         *
         * **CAUTION**
         * You must initialize managers after initializing databases, player
         * because initializing managers contain loading object, data from database, player
         * also, order of initializing managers also matters
         */

        researchManager = GetComponent <ResearchManager>();
        researchManager.init();

        // craftManager references researchManager
        craftManager = GetComponent <CraftManager>();
        craftManager.init();

        //
        boardManager = GetComponent <BoardManager>();
        boardManager.init();
        soundManager = GetComponentInChildren <SoundManager>();

        /*
         * Effect Processor Initializing
         * **CAUTION**
         * You must initialize this after all other initializing done
         */
        effectProcessor = new EffectProcessor();
        effectProcessor.init();

        ///*
        // * get Inventory
        // */

        //inventory = transform.Find("Canvas/InventoryPanel").gameObject;

        // default scene
        scene = SCENES.BASE;

        // game play variables initialize
        day            = 1;
        exploreChance  = true;
        moveChance     = true;
        researchChance = true;

        // start game
        SceneManager.LoadScene(scene);
    }
Example #16
0
 // Use this for initialization
 void Start()
 {
     itemDatabase   = ItemDatabase.instance;
     recipeDatabase = RecipeDatabase.instance;
     InitUnlockedRecipes();
 }
Example #17
0
 private void Awake()
 {
     sharedInstance = this;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RecipeDatabaseFactory"/> class.
 /// </summary>
 private RecipeDatabaseFactory()
 {
     this.recipeDatabase = new RecipeDatabase();
 }
Example #19
0
 public void Init()
 {
     // Instantiate the class to test
     this.toTest = new RecipeDatabase();
 }