コード例 #1
0
ファイル: GetMine.cs プロジェクト: April-wind/NeteaseMiniGame
    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);
        }
    }
コード例 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Monster")
     {
         bloodChange = 40;
         BackpackManager.RemoveGrid();
         BackpackManager.instance.gridNum--;
         Debug.Log(collision.gameObject.name);
         Destroy(collision.gameObject, 0.5f);
     }
     if (collision.tag == "SnakeCost")
     {
         bloodChange = 20;
         BackpackManager.RemoveGrid();
         BackpackManager.instance.gridNum--;
         Debug.Log(collision.gameObject.name);
     }
     //猫头鹰扣血
     if (collision.tag == "Eagle")
     {
         bloodChange = 30;
         BackpackManager.RemoveGrid();
         BackpackManager.instance.gridNum--;
         Debug.Log(collision.gameObject.name);
     }
 }
コード例 #3
0
ファイル: GetMine.cs プロジェクト: April-wind/NeteaseMiniGame
 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);
             }
         }
     }
 }
コード例 #4
0
 //单例
 void Awake()
 {
     if (instance != null)
     {
         Destroy(this);
     }
     instance = this;
 }
コード例 #5
0
    public void SetWho(GameObject obj_who)
    {
        objWho          = obj_who;
        backpackManager = objWho.GetComponent <BackpackManager>();
        dressingManager = objWho.GetComponent <DressingManager>();

        RefreshBackpackItems(backpackManager.GetItems(enumItemKind.飾));
        DisplayWhoMoney();
    }
コード例 #6
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.clickCount == 2)
     {
         //Debug.Log("y=" + ((int)((transform.localPosition.x + 400) / 100)).ToString() + "x=" + ((int)((-transform.localPosition.y + 400) / 100)).ToString());
         //这坐标很神奇
         BackpackManager.UseItem((int)((-transform.localPosition.y + 400) / 100), (int)((transform.localPosition.x + 400) / 100));
     }
 }
コード例 #7
0
    // Start is called before the first frame update
    void Start()
    {
        sysDressing = GetComponent <DressingManager>();
        sysBackpack = GetComponent <BackpackManager>();
        Debug.Log(sysDressing);

        //if (!sysDressing.IsDressing())
        //sysDressing.RandomApparel();
        //else
        //sysDressing.SetModelByScriptableApparel();
    }
コード例 #8
0
ファイル: PickUp.cs プロジェクト: SilverMaRu/BING_Net
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals("Player"))
     {
         BackpackManager backpackManager = other.GetComponent <BackpackManager>();
         if (backpackManager != null && backpackManager.canPickUp)
         {
             Rest();
             GoBack();
         }
     }
 }
コード例 #9
0
    private void OnPickUp(BackpackManager sender, PickUpEventDate eventDate)
    {
        switch (eventDate.pickerFaction)
        {
        case PlayerFaction.People:
            scenePickUpList.Remove(eventDate.pickUpItem.gameObject);
            break;

        case PlayerFaction.Ghost:
            ClearItems();
            break;
        }
    }
コード例 #10
0
ファイル: Managers.cs プロジェクト: laiqiqi/Pharmacy_Maze
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        Data     = GetComponent <DataManager>();
        Player   = GetComponent <PlayerManager>();
        Backpack = GetComponent <BackpackManager>();

        _startSequence = new List <IGameManager>();
        _startSequence.Add(Player);
        _startSequence.Add(Backpack);
        _startSequence.Add(Data);

        StartCoroutine(StartupManagers());
    }
コード例 #11
0
    private void Awake()
    {
        //单例
        instance = this;
        //生成初始房间
        Instantiate(Room1, new Vector3(0.1f, 0, 0), Quaternion.identity);

        //加载数据
        Load();

        //注册事件
        GridUI.OnEnter         += onEnter;
        GridUI.OnExit          += onExit;
        GridUI.OnLeftBeginDrag += GridUI_OnLeftBeginDrag;
        GridUI.OnLeftEndDrag   += GridUI_OnLeftEndDrag;
    }
コード例 #12
0
    private void OnPickUp(BackpackManager sender, PickUpEventDate eventDate)
    {
        switch (eventDate.pickerFaction)
        {
        case PlayerFaction.People:
            if (attrManager.faction == PlayerFaction.People)
            {
                canPickUp = false;
            }
            break;

        case PlayerFaction.Ghost:
            canPickUp = true;
            break;
        }
    }
コード例 #13
0
    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();
    }
コード例 #14
0
    private Vector2Int targetPosition  = new Vector2Int(0, 0); //目标坐标


    public void OnBeginDrag(PointerEventData eventData)
    {
        scaleUICamera        = GameObject.FindWithTag("ScaleUICamera").GetComponent <Camera>(); //寻找摄像机
        originalParentParent = transform.parent;                                                //被拖拽物品原来的父物体
        currentItem          = originalParentParent.GetComponent <Slot>().slotItem;             //当前物体赋值
        currentImage         = originalParentParent.GetComponent <Slot>().slotImage;            //当前图片赋值
        currentPosition      = originalParentParent.GetComponent <Slot>().position;             //当前位置赋值

        originalParentParent = transform.parent.parent;                                         //爷物体
        transform.SetParent(transform.parent.parent.parent);                                    //与父同级,这样就能渲染在最上层了

        addFactor          = scaleUICamera.WorldToScreenPoint(transform.position) - new Vector3(eventData.position.x, eventData.position.y, 0);
        transform.position = (eventData.position + addFactor) * (scaleUICamera.orthographicSize / 540); //物品和鼠标一起动

        BackpackManager.instance.backpack.ItemReduction(currentPosition.x, currentPosition.y);          //删除当前位置
        BackpackManager.RefreshItem();                                                                  //刷新碰撞体
    }
コード例 #15
0
ファイル: TreasureManager.cs プロジェクト: secminhr/Fantasy
        public override void Interact()//open the box
        {
            //make sure the box is opened
            isOpen         = true;
            gameObject.tag = "opened";
            gameObject.GetComponentInChildren <SpriteRenderer>().sprite = openSprite;

            //show item info to player
            TextMeshProUGUI itemsInfo = GameObject.Find("ItemsInfo").GetComponent <TextMeshProUGUI>();

            itemsInfo.text = "Get\n";

            //access backpack system
            BackpackManager backpack = GameObject.Find("Backpack").GetComponent <BackpackManager>();

            foreach (Item itemInBox in itemList)
            {
                bool nextItem = false;
                //show what you got
                itemsInfo.text += (itemInBox.body.name + "        x " + itemInBox.amount.ToString() + "\n");

                foreach (Item itemInPack in backpack.itemList)
                {
                    if (itemInBox.body == itemInPack.body)//already have the same item
                    {
                        Debug.Log("have same item");

                        Item t = new Item();//replace the old item
                        t.body   = itemInBox.body;
                        t.amount = (itemInPack.amount + itemInBox.amount);
                        backpack.itemList[backpack.itemList.IndexOf(itemInPack)] = t;

                        nextItem = true;
                        break;
                    }
                }
                if (nextItem)
                {
                    continue;
                }
                backpack.itemList.Add(itemInBox);
            }
            itemsInfo.GetComponentInParent <InfoManager>().ShowInfo();
        }
コード例 #16
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);
        }
    }
コード例 #17
0
ファイル: FocusController.cs プロジェクト: a91082900/Fantasy
        protected void Start()
        {
            Instance = this;
            backpack = GameObject.FindGameObjectWithTag("backpack").GetComponent <BackpackManager>();
            #region Another Approach

            /*Debug.Log("at least start");
             * FocusController[] focuses=GameObject.FindObjectsOfType<FocusController>();
             * foreach (FocusController f in focuses)
             * {
             *  if (f == this)
             *  {
             *      Debug.Log("me");
             *      continue;
             *  }
             *  else
             *  {
             *      Debug.Log("others");
             *      f.gameObject.SetActive(false);
             *  }
             * }
             * Debug.Log("i'm the only focus");*/
            #endregion
        }
コード例 #18
0
    public void HealthControl()
    {
        float subtractionFactor = Mathf.CeilToInt(Mathf.Sqrt(BackpackManager.instance.gridNum)) * 0.0003f;//目前因子:旅鼠数开方向上取整

        health = BackpackManager.instance.gridNum;
        LemmingSumControl._Instance.lemmingNumTrue = BackpackManager.instance.gridNum;
        counter += subtractionFactor;
        processTrans.GetComponent <Image>().fillAmount = Mathf.Sqrt(health - counter) / 10.0f;
        if (counter > 1)
        {
            for (int i = 0; (i < (int)counter) && (BackpackManager.instance.gridNum > 0); i++)
            {
                //Debug.Log(123);
                int id = BackpackManager.instance.backpack.GridReduction();
                if (id != 0)
                {
                    LemmingSumControl._Instance.CreateItem(BackpackManager.instance.myInventory.itemList[id]);
                }
                BackpackManager.instance.gridNum--;
            }
            BackpackManager.RefreshItem();
            counter = 0;
        }
    }
コード例 #19
0
    public void OnEndDrag(PointerEventData eventData)
    {
        transform.SetParent(originalParentParent);//回归原爹

        /**
         * 共四种操作:
         * a.丢弃->应该有个丢弃信号
         * b.交换
         * c.合成
         * d.弹回->要检测,否则拖拽过程中若格子减少会出现bug
         **/
        //碰撞信息类
        RaycastHit hit;
        //射线起点
        Vector3 origin = new Vector3(transform.position.x + 50, transform.position.y - 50, transform.position.z - 100);

        //射线检测
        if (Physics.Raycast(origin, new Vector3(0, 0, 1), out hit, Mathf.Infinity, 1 << 9))//包内->b/c/d
        {
            targetItem     = hit.collider.gameObject.GetComponent <Slot>().slotItem;
            targetPosition = hit.collider.gameObject.GetComponent <Slot>().position;
            Debug.Log("射中" + targetPosition);
        }
        else//包外->a
        {
            //应该有个丢弃信号(关于currentItem的)
            BackpackManager.RefreshItem();
            LemmingSumControl._Instance.CreateItem(currentItem);
            return;
        }

        if (currentItem.width == 1 && currentItem.height == 1)                                                 //原物体1x1->b/c/d
        {
            if (targetItem == null)                                                                            //空格->b
            {
                BackpackManager.instance.backpack.PointPutIn(targetPosition.x, targetPosition.y, currentItem); //当前物体迁移过去
                BackpackManager.RefreshItem();
                Debug.Log("交换");
            }
            else if (targetItem.width == 1 && targetItem.height == 1)//目标1x1->b/c
            {
                //这里先进行合成判定->c
                if (!ItemSynthesis(currentItem.id, targetItem.id))                                                  //合成函数返回false->b
                {
                    BackpackManager.instance.backpack.ItemReduction(targetPosition.x, targetPosition.y);            //删除目标位置
                    BackpackManager.instance.backpack.PointPutIn(targetPosition.x, targetPosition.y, currentItem);  //当前物体迁移过去
                    BackpackManager.instance.backpack.PointPutIn(currentPosition.x, currentPosition.y, targetItem); //目标物体迁移过来
                    BackpackManager.RefreshItem();
                    Debug.Log("交换");
                }
                else
                {
                    BackpackManager.RefreshItem();
                    Debug.Log("合成");
                }
            }
            else//目标mxn->c/d
            {
                //这里先进行合成判定->c/d
                if (!ItemSynthesis(currentItem.id, targetItem.id))                                                       //合成函数返回false->d
                {
                    if (BackpackManager.instance.backpack.PointPutIn(currentPosition.x, currentPosition.y, currentItem)) //恢复原物体
                    {
                        BackpackManager.RefreshItem();
                        Debug.Log("弹回");
                    }
                    else
                    {
                        BackpackManager.RefreshItem();
                        LemmingSumControl._Instance.CreateItem(currentItem);
                        Debug.Log("弹回失败,丢弃");
                    }
                }
                else//->c
                {
                    BackpackManager.RefreshItem();
                    Debug.Log("合成");
                }
            }
            return;
        }
        else//原物体mxn->b/c/d
        {
            if (targetItem == null)//空格->b/d
            {
                //判断能否放下->b
                if (BackpackManager.instance.backpack.PointPutIn(targetPosition.x, targetPosition.y, currentItem))
                {
                    BackpackManager.RefreshItem();
                    Debug.Log("交换");
                }
                else//d
                {
                    if (BackpackManager.instance.backpack.PointPutIn(currentPosition.x, currentPosition.y, currentItem))//恢复原物体
                    {
                        BackpackManager.RefreshItem();
                        Debug.Log("弹回");
                    }
                    else
                    {
                        BackpackManager.RefreshItem();
                        LemmingSumControl._Instance.CreateItem(currentItem);
                        Debug.Log("弹回失败,丢弃");
                    }
                }
            }
            else//非空格->c/d
            {
                //这里先进行合成判定->c/d
                if (!ItemSynthesis(currentItem.id, targetItem.id))                                                       //合成函数返回false->d
                {
                    if (BackpackManager.instance.backpack.PointPutIn(currentPosition.x, currentPosition.y, currentItem)) //恢复原物体
                    {
                        BackpackManager.RefreshItem();
                        Debug.Log("弹回");
                    }
                    else
                    {
                        BackpackManager.RefreshItem();
                        LemmingSumControl._Instance.CreateItem(currentItem);
                        Debug.Log("弹回失败,丢弃");
                    }
                }
                else//->c
                {
                    BackpackManager.RefreshItem();
                    Debug.Log("合成");
                }
            }
            return;
        }
    }
コード例 #20
0
 // Start is called before the first frame update
 void Start()
 {
     Notebook.SetActive(false);
     player   = GameObject.Find("Player");
     backpack = GetComponent <BackpackManager>();
 }
コード例 #21
0
 private void Awake()
 {
     instance = this;
     Load();
     GridUI.OnEnter += this.onEnter;            //使委托指向方法
 }
コード例 #22
0
ファイル: PlayerMovement.cs プロジェクト: a91082900/Fantasy
 private void Start()
 {
     backpack = GameObject.FindGameObjectWithTag("backpack").GetComponent <BackpackManager>();
 }
コード例 #23
0
 void Start()
 {
     Instance = this;
 }