Пример #1
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     //Debug.Log("collision stay" + collision.name);
     if (collision.tag == "PickItem")
     {
         if (!can_pick && !can_collect && craftFunc)
         {
             //Debug.Log("empty");
             picking_item = collision.GetComponent <CPickItem>();
             picking_item.GetComponent <COutLine>().SetOutLine(true);
             if (!b_handling)
             {
                 ChangeSlot(false, picking_item.id);
             }
             else
             {
                 craftB = items[picking_item.id];
                 CheckCrafting();
             }
             can_pick = true;
         }
     }
     else if (!can_collect && collision.tag == "PickCollection" && !can_pick && craftFunc)
     {
         can_collect  = true;
         pick_collect = collision.transform.GetComponent <CPickCollection>();
         pick_collect.GetComponent <COutLine>().SetOutLine(true);
     }
 }
Пример #2
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == "PickItem")
     {
         //if (pick_collect == null) return;
         if (picking_item != null && collision.gameObject == picking_item.gameObject)
         {
             //Debug.Log("the same");
             picking_item.GetComponent <COutLine>().SetOutLine(false);
             picking_item = null;
             ChangeSlot(true, 0);
             if (can_pick)
             {
                 can_pick = false;
             }
         }
         //if (can_pick) can_pick = false;
     }
     if (can_collect && collision.tag == "PickCollection")
     {
         //Debug.Log("LEAVE COLLECT");
         //if (pick_collect == null) return;
         if (pick_collect != null && collision.gameObject == pick_collect.gameObject)
         {
             pick_collect.GetComponent <COutLine>().SetOutLine(false);
             can_collect  = false;
             pick_collect = null;
         }
     }
 }
Пример #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //Debug.Log("enter");
     if (collision.tag == "PickItem")
     {
         if (!can_pick && !can_collect && craftFunc)
         {
             picking_item = collision.gameObject.GetComponent <CPickItem>();
             picking_item.GetComponent <COutLine>().SetOutLine(true);
             if (!b_handling)
             {
                 //Debug.Log("going to pick");
                 ChangeSlot(false, picking_item.id);
             }
             else
             {
                 //Debug.Log("going to craft");
                 craftB = items[picking_item.id];
                 CheckCrafting();
             }
             can_pick = true;
         }
     }
     else if (!can_collect && collision.tag == "PickCollection" && !can_pick)
     {
         if (!craftFunc)
         {
             return;
         }
         can_collect  = true;
         pick_collect = collision.transform.GetComponent <CPickCollection>();
         pick_collect.GetComponent <COutLine>().SetOutLine(true);
         //Debug.Log(pick_collect.gameObject.name);
     }
 }
Пример #4
0
 public void ThrowOut()
 {
     handling_item.GetComponent <CPickItem>().SetInFree();
     ChangeSlot(true, 0);
     picking_item   = null;
     handle.enabled = false;
     b_handling     = false;
     ArrowEnable(false);
 }
Пример #5
0
    //public void RecyleUsedList(GameObject pickItem) {
    //    pickItem.transform.parent = usedPickItemList;
    //}

    public void AddFreeList(CPickItem pickItem)
    {
        pickItem.transform.position = transform.GetChild(0).position;
        pickItem.transform.parent   = transform.GetChild(0);
        freePickItemList.Add(pickItem);
        usedPickItemList.Remove(pickItem);
        free_num++;
        used_num--;
    }
Пример #6
0
 void CheckPickItem()
 {
     if (picking_item != null)
     {
         if (!picking_item.gameObject.activeSelf)
         {
             can_pick     = false;
             picking_item = null;
             ChangeSlot(true, -1);
         }
     }
 }
Пример #7
0
    public void RecycleFree(Poison poison)
    {
        Vector3 posOffset = new Vector3(poison.transform.position.x, poison.transform.position.y - 0.8f, poison.transform.position.z);

        freePoisons.Add(poison);
        usedPoisons.Remove(poison);
        CPickItem tempPick = pickItemSystem.SpawnInUsed(posOffset, 3);

        tempPick.SetZBase(-110.0f);
        //if (IsOnHeight3(posOffset) && posOffset.z < -50.0f) {
        //    CPickItem tempPick= pickItemSystem.SpawnInUsed(posOffset, 3);
        //    tempPick.SetZBase(-100.0f);
        //}
        poison.gameObject.SetActive(false);
        freeNum++;
    }
Пример #8
0
    void IsNearWeapon()
    {
        if (ishold)
        {
            return;
        }
        int   temp = -1;
        float temp_dis, least_dis = 2.5f, current_dis;

        CItem tempWeapon;

        for (int i = 0; i < pickUsed.Count; i++)
        {
            tempPick   = pickUsed[i];
            tempWeapon = CItemDataBase.items[tempPick.id];
            if (tempWeapon.attack > 0)
            {
                temp_dis = Vector2.Distance(this.transform.position, tempPick.transform.position);
                if (temp_dis < 2.0f)
                {
                    current_dis = temp_dis;
                    //if (i == 0)least_dis = current_dis;
                    if (current_dis < least_dis)
                    {
                        least_dis = current_dis;
                        temp      = i;
                    }
                }
            }
        }
        if (temp < 0)
        {
            canPick    = false;
            pickWeapon = null;
        }
        else
        {
            if (pickUsed[temp] != lastPick && canPick)
            {
                lastPick.GetComponent <COutLine>().SetOutLine(false);
            }
            canPick  = true;
            lastPick = pickUsed[temp];
            lastPick.GetComponent <COutLine>().SetOutLine(true);
            //pickWeapon = lastPick;
        }
    }
Пример #9
0
 void OnPickWeapon()
 {
     if (canPick && holdWeapon.id == 0)
     {
         if (useControll)
         {
             if (Input.GetButtonDown(whichPlayer + "ButtonX"))
             {
                 if (!ButtonXFixed)
                 {
                     return;
                 }
                 if (!lastPick.gameObject.activeSelf)
                 {
                     return;
                 }
                 ButtonXFixed = false;
                 pickWeapon   = lastPick;
                 holdWeapon   = CItemDataBase.items[pickWeapon.id];
                 pickWeapon.transform.parent = this.transform;
                 pickWeapon.gameObject.SetActive(false);
                 ishold  = true;
                 canPick = false;
                 playerWeaponImg.sprite = weaponSprite[holdWeapon.id];
             }
         }
         else
         {
             if (Input.GetKeyDown(KeyCode.E))
             {
                 if (!lastPick.gameObject.activeSelf)
                 {
                     return;
                 }
                 pickWeapon = lastPick;
                 holdWeapon = CItemDataBase.items[pickWeapon.id];
                 pickWeapon.transform.parent = this.transform;
                 pickWeapon.gameObject.SetActive(false);
                 ishold  = true;
                 canPick = false;
                 playerWeaponImg.sprite = weaponSprite[holdWeapon.id];
             }
         }
     }
 }
Пример #10
0
 void OnPickWeapon()
 {
     if (canPick && Player.weapon.id == 0)
     {
         if (useControll)
         {
             if (Input.GetButtonDown(whichPlayer + "ButtonX"))
             {
                 if (!ButtonXFixed)
                 {
                     return;
                 }
                 ButtonXFixed  = false;
                 pickWeapon    = lastPick;
                 Player.weapon = CItemDataBase.items[pickWeapon.id];
                 pickWeapon.transform.parent = this.transform;
                 pickWeapon.gameObject.SetActive(false);
                 ishold  = true;
                 canPick = false;
                 playerWeaponImg.sprite = weaponSprite[Player.weapon.id];
                 if (test)
                 {
                     tutorialRequest.DonePickUp(false);
                 }
             }
         }
         else
         {
             if (Input.GetKeyDown(KeyCode.E))
             {
                 pickWeapon    = lastPick;
                 Player.weapon = CItemDataBase.items[pickWeapon.id];
                 pickWeapon.transform.parent = this.transform;
                 pickWeapon.gameObject.SetActive(false);
                 ishold  = true;
                 canPick = false;
                 playerWeaponImg.sprite = weaponSprite[Player.weapon.id];
                 if (test)
                 {
                     tutorialRequest.DonePickUp(false);
                 }
             }
         }
     }
 }
Пример #11
0
    void PickItem()
    {
        if (!can_pick || picking_item == null)
        {
            return;
        }
        if (useController)
        {
            if (Input.GetButtonDown(whichPlayer + "LB"))
            {
                if (!LBFixed)
                {
                    return;
                }
                LBFixed = false;
                if (CItemDataBase.items[picking_item.id].elementID < -20)
                {
                    TeamHp.ChangeHp(true, 0.15f);
                    healEffect.SetHealEffectAni();
                    picking_item.GetComponent <COutLine>().SetOutLine(false);
                    picking_item.SetInFree();
                    ChangeSlot(true, -1);
                    if (test)
                    {
                        tutorialRequest.DonePickUp(true);
                    }
                }
                else
                {
                    handle.enabled = true;
                    if (!b_handling)
                    {
                        b_handling    = true;
                        craftA        = items[picking_item.id];
                        handling_item = picking_item.gameObject;
                        handling_item.transform.parent   = transform.GetChild(0);
                        handling_item.transform.position = this.transform.position;
                        handling_item.GetComponent <COutLine>().SetOutLine(false);
                        handling_item.SetActive(false);
                        handle.sprite = CItemDataBase.spriteList[craftA.id];
                        handling_item.GetComponent <CPickItem>().SetLifeTime(0.0f);
                        ChangeSlot(true, 0);
                        ArrowEnable(true);
                        if (test)
                        {
                            tutorialRequest.DonePickUp(true);
                        }
                    }
                    else
                    {
                        OnCrafting();
                    }
                }
                can_pick     = false;
                picking_item = null;

                //if (picking_item == null) return;
                //crafterAnimator.SetBool("is_gather", true);
                ////Debug.Log("設動畫");
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                //if (picking_item == null) return;
                //crafterAnimator.SetBool("is_gather", true);

                if (CItemDataBase.items[picking_item.id].elementID < -20)
                {
                    TeamHp.ChangeHp(true, 0.15f);
                    healEffect.SetHealEffectAni();
                    picking_item.GetComponent <COutLine>().SetOutLine(false);
                    picking_item.SetInFree();
                    ChangeSlot(true, -1);
                    if (test)
                    {
                        tutorialRequest.DonePickUp(true);
                    }
                }
                else
                {
                    handle.enabled = true;
                    if (!b_handling)
                    {
                        b_handling    = true;
                        craftA        = items[picking_item.id];
                        handling_item = picking_item.gameObject;
                        handling_item.transform.parent   = transform.GetChild(0);
                        handling_item.transform.position = this.transform.position;
                        handling_item.GetComponent <COutLine>().SetOutLine(false);
                        handling_item.SetActive(false);
                        handle.sprite = CItemDataBase.spriteList[craftA.id];
                        handling_item.GetComponent <CPickItem>().SetLifeTime(0.0f);
                        ChangeSlot(true, 0);
                        ArrowEnable(true);
                        if (test)
                        {
                            tutorialRequest.DonePickUp(true);
                        }
                    }
                    else
                    {
                        OnCrafting();
                    }
                }
                can_pick     = false;
                picking_item = null;
            }
        }
    }