Exemplo n.º 1
0
 public static void HideCurrentItem()
 {
     if (CurrentItem != null)
     {
         CurrentItem.SetActive(false);
         CurrentItem.GetComponent <CurrentItem>().UseIt(false);
         CurrentItem = null;
     }
 }
    public override void PickedUp()
    {
        ActivePlayer = CameraScript.GameController.ActivePlayer;
        if (Vector3.Distance(gameObject.transform.position, ActivePlayer.transform.position) <= 1.5f)
        {
            ActiveBackpack = ActivePlayer.GetComponent <CharacterScript>().Backpack;
            if (WeaponVariation != null)
            {
                Debug.Log("WeaponSprites/" + WeaponCategory.ToString() + "/" + WeaponVariation + "Sprite");
                CurrentItem = Instantiate(Resources.Load("WeaponSprites/" + WeaponCategory.ToString() + "/" + WeaponVariation + "Sprite") as GameObject);
                Image img = CurrentItem.GetComponent <Image>();
                Debug.Log(img);
                switch (rarity)
                {
                case WeaponRarityEnum.common:
                    break;

                case WeaponRarityEnum.uncommon:
                    img.color = new Color32(0, 255, 0, 125);
                    break;

                case WeaponRarityEnum.rare:
                    img.color = new Color32(0, 0, 255, 125);
                    break;

                case WeaponRarityEnum.legendary:
                    img.color = new Color32(128, 0, 128, 125);
                    break;

                case WeaponRarityEnum.epic:
                    img.color = new Color32(255, 92, 0, 125);
                    break;

                case WeaponRarityEnum.relic:
                    img.color = new Color32(255, 255, 0, 125);
                    break;

                default:
                    img.color = Color.red;
                    break;
                }
            }
            if (ActivePlayer.GetComponent <CharacterScript>().WeaponSlot.transform.childCount == 0)
            {
                CurrentItem.transform.SetParent(ActivePlayer.GetComponent <CharacterScript>().WeaponSlot.transform, false);
                ActivePlayer.GetComponent <CharacterScript>().EquipNewWeapon();
                ActivePlayer.GetComponent <CharacterScript>().WeaponSlot.GetComponent <WeaponSlotScript>().EquipItem();
                ActivePlayer.GetComponent <CharacterScript>().MoveTo = new RaycastHit();
                Destroy(gameObject);
            }
            else
            {
                for (int i = 0; i < ActiveBackpack.transform.childCount; i++)
                {
                    if (ActiveBackpack.transform.GetChild(i) != null)
                    {
                        CurrentItemSlot = ActiveBackpack.transform.GetChild(i).gameObject;
                        if (CurrentItemSlot.transform.childCount == 0)
                        {
                            CurrentItem.transform.SetParent(CurrentItemSlot.transform);
                            CurrentItem.transform.localPosition = Vector3.zero;
                            Destroy(gameObject);
                            break;
                        }
                    }
                    else
                    {
                        ActivePlayer.GetComponent <HealthScript>().ShowDamageTaken("Inventory Full", DamageType.Physical);
                        break;
                    }
                }
            }
            CurrentItem.transform.localScale = Vector3.one;
            CurrentItem.GetComponent <WeaponScript>().AddSpecialRules(myRules.ToArray());
        }
        else
        {
            ActivePlayer.GetComponent <HealthScript>().ShowDamageTaken("Too Far Away", DamageType.Physical);
        }
    }