Пример #1
0
 public void Select()
 {
     if (_image == null)
     {
         _image = transform.Find("HighlightPanel").GetComponent <Image> ();
         _color = _image.color;
     }
     _color.a     = 1f;
     _image.color = _color;
     // get the parent
     if (_parent == null)
     {
         _parent = transform.GetComponentInParent <RecipeList> ();
     }
     _parent.Select(Index);
 }
Пример #2
0
        void Start()
        {
            _recipePanel = transform.Find("RecipePanel").GetComponent <RecipePanel> ();
            _recipes     = new List <CraftingRecipe> ();
            _inventory   = (Inventory)GameObject.Find("Player").GetComponent <Inventory>();
            _ui          = (UI_Game)GameObject.Find("PlayerUI").GetComponent <UI_Game> ();
            _recipeList  = transform.Find("CraftingList/Recipes").GetComponent <RecipeList> ();
            _image       = transform.GetComponent <Image> ();
            _color       = _image.color;
            _color.a     = 0f;
            _image.color = _color;

            // read from the text file
            TextAsset reader = Resources.Load("crafting-recipes") as TextAsset;

            _index = 0;
            foreach (string line in reader.text.Split("\n".ToCharArray()))
            {
                if (line.Length > 0)
                {
                    if (line [0] != '#')                       // commented lines start with #
                    // add to list
                    {
                        CraftingRecipe newRecipe = new CraftingRecipe(line);
                        // ensure it was a valid recipe
                        if (!newRecipe.CraftedItemName.Equals("invalid"))
                        {
                            _recipes.Add(newRecipe);
                            _recipeList.AddRecipe(newRecipe);
                        }
                    }
                }
            }
            _recipeList.Select(0);
            _recipePanel.ShowRecipe(_recipes[_index]);
            enabled = false;
        }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     _image = null;
     // the parent won't be set until after creation of this object
     _parent = null;
 }