Example #1
0
 /// <summary>
 /// Affiche l'interface de craft
 /// </summary>
 private void Categoryze()
 {
     for (int i = 0; i < 5; i++)
     {
         Rect box = new Rect(0, (i + 2) * Screen.height / 9, Screen.height / 9, Screen.height / 9);
         if (GUI.Button(box, "", skin.GetStyle("slot")))
         {
             craftindex = 0;
             if (this.type == (Craft.Type)(i + 1))
             {
                 this.type = Craft.Type.None;
             }
             else
             {
                 this.type = (Craft.Type)(i + 1);
             }
             this.showcraft = false;
             this.pos = -1;
             this.craftindex = 0;
             sound.PlaySound(AudioClips.Button, 1f);
         }
         box = new Rect(10, (i + 2) * Screen.height / 9 + 10, Screen.height / 9 - 20, Screen.height / 9 - 20);
         GUI.DrawTexture(box, Resources.Load<Texture2D>("Sprites/CraftsIcon/Craft" + (i + 1)));
     }
     sub_Categoryze(this.type);
 }
Example #2
0
    /// <summary>
    /// affiche les elements necessaires
    /// </summary>
    /// <param name="craft"></param>
    private void Craft_used_HUD()
    {
        Rect box = new Rect();
        int i = 0;
        int cost = 1;
        if (!craftMastered[craftshow.ID])
        {
            cost++;
        }
        foreach (ItemStack item in craftshow.Consume)
        {
            box = new Rect((3 + i) * Screen.height / 18, 2 * Screen.height / 9 + pos * Screen.height / 18, Screen.height / 18, Screen.height / 18);

            if (GUI.Button(box, "", skin.GetStyle("Slot")))
            {
                Craft Craft = null;
                foreach (Craft craft in CraftDatabase.Crafts)
                {
                    if (craft.Product.Items.ID == item.Items.ID)
                    {
                        Craft = craft;
                        break;
                    }
                }
                if (Craft != null)
                {
                    int index = 0;
                    pos = 0;
                    this.type = Craft.What;
                    foreach (Craft recette in this.Craftslist[((int)type) - 1])
                    {
                        if (recette.ID == Craft.ID)
                        {
                            this.showcraft = true;
                            craftindex = index;
                            craftshow = recette;
                        }
                        index += 1;
                    }
                }
            }
            Rect littlebox = new Rect((3 + i) * Screen.height / 18 + Decal, 2 * Screen.height / 9 + pos * Screen.height / 18 + Decal, Screen.height / 18 - 2 * Decal, Screen.height / 18 - 2 * Decal);
            GUI.DrawTexture(littlebox, item.Items.Icon);
            littlebox = new Rect((3 + i) * Screen.height / 18 + Decal / 2, 2 * Screen.height / 9 + pos * Screen.height / 18 + Decal / 2, Screen.height / 18 - Decal, Screen.height / 18 - Decal);
            GUI.Box(littlebox, inventory.InventoryContains(item.Items, item.Quantity * cost) ? (item.Quantity * cost).ToString() : "<color=#ff0000>" + (item.Quantity * cost).ToString() + "</color>", skin.GetStyle("Quantity"));
            if (box.Contains(Event.current.mousePosition))
            {
                tooltip = true;
                tooltipItem = item.Items;
            }
            i += 1;
        }
        box = new Rect((3 + i) * Screen.height / 18, 2 * Screen.height / 9 + pos * Screen.height / 18, Screen.height / 18, Screen.height / 18);

        bool RecipeComplete = inventory.InventoryContains(craftshow, cost == 1);
        bool WorkTopNear = (!craftshow.Fire || nearwork[0]) && (!craftshow.Workbench || nearwork[1]) && (!craftshow.Forge || nearwork[2]) && (!craftshow.Brewer || nearwork[3]);

        if (WorkTopNear && RecipeComplete)
        {
            if (GUI.Button(box, "", this.skin.GetStyle("Slot")))
            {
                CmdMakeCraft(craftshow.ID);
                inventory.DeleteItems(craftshow.Consume, cost == 1);
                ItemStack its = new ItemStack(craftshow.Product.Items, craftshow.Product.Quantity);
                inventory.AddItemStack(its);
                if (its.Quantity != 0)
                    inventory.Drop(its);
                if (craftshow.Workbench)
                    sound.PlaySound(AudioClips.workbensh, 1f);
                else if (craftshow.Forge)
                    sound.PlaySound(AudioClips.forge, 1f);
                else if (craftshow.Brewer)
                    sound.PlaySound(AudioClips.cooking, 1f);
                else
                    sound.PlaySound(AudioClips.Button, 1f);
            }
            box.x += Decal;
            box.y += Decal;
            box.width -= 2 * Decal;
            box.height -= 2 * Decal;
            GUI.DrawTexture(box, Resources.Load<Texture2D>("Sprites/CraftsIcon/Valid"));
        }
        else
        {
            GUI.Box(box, "", this.skin.GetStyle("Slot"));
            box.x += Decal;
            box.y += Decal;
            box.width -= 2 * Decal;
            box.height -= 2 * Decal;
            GUI.DrawTexture(box, Resources.Load<Texture2D>("Sprites/CraftsIcon/Invalid"));
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        if (!isLocalPlayer)
            return;

        this.inventory = gameObject.GetComponent<Inventory>();
        this.sound = GetComponent<Sound>();
        this.type = Craft.Type.None;
        this.skin = Resources.Load<GUISkin>("Sprites/GUISkin/skin");
        this.Craftslist = new List<Craft>[5];
        this.CraftElementary = new List<Craft>();
        this.CraftWorkTop = new List<Craft>();
        this.CraftConsumable = new List<Craft>();
        this.CraftTools = new List<Craft>();
        this.CraftArmor = new List<Craft>();
        this.craftMastered = new Dictionary<int, bool>();
        this.character = GetComponentInChildren<CharacterCollision>().gameObject;
        this.Craftslist[0] = CraftElementary;
        this.Craftslist[1] = CraftWorkTop;
        this.Craftslist[2] = CraftConsumable;
        this.Craftslist[3] = CraftTools;
        this.Craftslist[4] = CraftArmor;
        foreach (Craft craft in CraftDatabase.Crafts)
        {
            if (!craft.Secret)
            {
                this.Craftslist[(int)(craft.What) - 1].Add(craft);
            }
            if (craft.ID != -1)
                this.craftMastered.Add(craft.ID, false);
        }

        this.craftindex = 0;
        this.showcraft = false;
        this.pos = -1;
        this.craftshow = new Craft(Craft.Type.None);
        this.nearwork = new bool[4];
        for (int j = 0; j < 4; j++)
            nearwork[j] = false;

        List<int> mastered = new List<int>();

        if (SceneManager.GetActiveScene().name != "main")
        {
            this.CraftConsumable.Add(CraftDatabase.InstableCore);
            mastered.Add(666);
        }

        foreach (int ids in mastered)
            this.craftMastered[ids] = true;
    }