public void Dressing(Item item)
    {
        backpackManager.RemoveItem(item);

        Item model_item = null;

        if (item.itemName == enumItemName.染髮劑)
        {
            model_item = dressingManager.GetModelHairColor();
        }
        else if (item.itemName == enumItemName.衣服)
        {
            model_item = dressingManager.GetModelClothes();
        }
        else if (item.itemName == enumItemName.褲子)
        {
            model_item = dressingManager.GetModelPants();
        }
        else if (item.itemName == enumItemName.頭髮)
        {
            model_item = dressingManager.GetModelHair();
        }
        else if (item.itemName == enumItemName.鞋子)
        {
            model_item = dressingManager.GetModelShoes();
        }
        else if (item.itemName == enumItemName.變色瞳孔)
        {
            model_item = dressingManager.GetModelEyesColor();
        }

        backpackManager.AddItem(model_item);

        if (item.itemName == enumItemName.染髮劑)
        {
            dressingManager.SetModelHairColor(item);
        }
        else if (item.itemName == enumItemName.衣服)
        {
            dressingManager.SetModelClothes(item);
        }
        else if (item.itemName == enumItemName.褲子)
        {
            dressingManager.SetModelPants(item);
        }
        else if (item.itemName == enumItemName.頭髮)
        {
            dressingManager.SetModelHair(item);
        }
        else if (item.itemName == enumItemName.鞋子)
        {
            dressingManager.SetModelShoes(item);
        }
        else if (item.itemName == enumItemName.變色瞳孔)
        {
            dressingManager.SetModelEyesColor(item);
        }

        RefreshBackpackItems(backpackManager.GetItems(enumItemKind.飾));
    }
Esempio n. 2
0
    void MineProgress()
    {
        if (canMine)
        {
            sliderObj.SetActive(true);
            progress    += Time.deltaTime;
            slider.value = progress;
            if (slider.value >= slider.maxValue)
            {
                slider.value = slider.maxValue;
                Debug.Log(this.name + "开采成功");

                //该物体被开采成功
                BackpackManager.AddItem(ID);

                if (this.transform.parent.GetComponent <BoxCollider2D>())
                {
                    //Debug.Log(this.transform.parent.GetComponent<BoxCollider2D>().enabled = fa);
                    this.transform.parent.GetComponent <BoxCollider2D>().enabled = false;
                    Debug.Log(3);
                }

                Destroy(gameObject);
            }
            //Debug.Log(progress);
        }
    }
Esempio n. 3
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         if (Input.GetMouseButtonDown(0))
         {
             RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.back, 5f, layer);
             if (hit && hit.collider.tag == "Mine" && hit.collider.gameObject == this.gameObject)
             {
                 Debug.Log("Click");
                 canMine = true;
             }
             else if (hit && hit.collider.tag == "DropObj" && hit.collider.gameObject == this.gameObject)
             {
                 BackpackManager.AddItem(ID);
                 Debug.Log("uiqu");
                 Destroy(gameObject);
             }
             else if (hit && hit.collider.tag == "TreasureChest" && hit.collider.gameObject == this.gameObject)
             {
                 GetComponent <SpriteRenderer>().enabled = false;
                 GetComponent <BoxCollider2D>().enabled  = false;
                 this.gameObject.layer = LayerMask.NameToLayer("Default");
                 transform.Find("宝物").gameObject.SetActive(true);
                 transform.Find("奶酪").gameObject.SetActive(true);
             }
         }
     }
 }
    void OnCollisionEnter(Collision collision)
    {
        GameObject objItem = collision.gameObject;

        if (objItem.tag == "Item")
        {
            Item item = objItem.GetComponent <ColliderItem>().GetItem();
            if (item != null)
            {
                sysBackpack.AddItem(item);
            }

            Destroy(collision.gameObject);
        }
    }
    public void Buy()
    {
        BackpackManager backpack_manager = objWho.GetComponent <BackpackManager>();
        int             money            = backpack_manager.GetMoney();

        if (money >= PayMoney)
        {
            for (int i = 0; i < lstItemShoppingCart.Count; i++)
            {
                backpack_manager.AddItem(lstItemShoppingCart[i]);
            }

            backpack_manager.SetMoney(money - PayMoney);
        }

        InitialShoppingCart();
    }
Esempio n. 6
0
    void Test()
    {
        //背包格子增加
        if (Input.GetKeyDown(KeyCode.Z))
        {
            BackpackManager.instance.backpack.GridGeneration();
            BackpackManager.RefreshItem();
            BackpackManager.instance.gridNum++;
        }
        // //放入随机物品
        // if (Input.GetKeyDown(KeyCode.X))
        // {
        //     BackpackManager.AddItem(5);
        // }
        // //背包格子减少
        if (Input.GetKeyDown(KeyCode.C))
        {
            BackpackManager.RemoveGrid();
            BackpackManager.instance.gridNum--;
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            BackpackManager.AddItem(1);
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            BackpackManager.AddItem(2);
        }
        //显示/隐藏背包
        if (Input.GetKeyDown(KeyCode.I))
        {
            backpackObj.SetActive(!backpackObj.activeSelf);
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            BackpackManager.AddItem(6);
        }
    }