Ejemplo n.º 1
0
    public void InventoryClosed()
    {
        ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceCamera;
        InventoryOpen = false;

        MainCanvasScript.MainCanvas.GetComponent <Canvas>().renderMode        = RenderMode.ScreenSpaceOverlay;
        MainCanvasScript.MainCanvas.GetComponent <CanvasGroup>().interactable = true;

        ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <CanvasGroup>().interactable   = false;
        ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <CanvasGroup>().blocksRaycasts = false;
    }
Ejemplo n.º 2
0
    public void InventoryOpened()
    {
        ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
        InventoryOpen = true;
        // set up the Health and Mana bars and numbers in CharacterScript
        var characterScript = ActivePlayer.GetComponent <CharacterScript>();

        characterScript.SetInventoryBarsAndText();
        MainCanvasScript.MainCanvas.GetComponent <Canvas>().renderMode        = RenderMode.ScreenSpaceCamera;
        MainCanvasScript.MainCanvas.GetComponent <Canvas>().worldCamera       = InventoryActiveCameraScript.InventoryCamera;
        MainCanvasScript.MainCanvas.GetComponent <CanvasGroup>().interactable = false;

        ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <CanvasGroup>().interactable   = true;
        ActivePlayer.GetComponent <CharacterScript>().InventoryManager.GetComponent <CanvasGroup>().blocksRaycasts = true;
    }
 public override void PickedUp()
 {
     //make it easy to reference the active player
     ActivePlayer = CameraScript.GameController.ActivePlayer;
     // make it easy to reference the backpack
     ActiveBackpack = ActivePlayer.GetComponent <CharacterScript>().Backpack;
     //if we are close enough to pick it up
     if (Vector3.Distance(gameObject.transform.position, ActivePlayer.transform.position) <= 1.5f)
     {
         //get the backpacks next item slot
         for (int a = 0; a < ActiveBackpack.transform.childCount; a++)
         {
             //if the itemslotexists
             if (ActiveBackpack.transform.GetChild(a) != null)
             {
                 //make it easy to reference the item slot
                 CurrentItemSlot = ActiveBackpack.transform.GetChild(a).gameObject;
                 //if the itemslot is filled
                 if (CurrentItemSlot.transform.childCount != 0)
                 {
                     //if the itemslot has our consumable
                     if (CurrentItemSlot.transform.GetChild(0).CompareTag(ConsumableType.ToString()))
                     {
                         //add the consumable to the stack in the inventory
                         CurrentItemSlot.transform.GetChild(0).GetComponent <ConsumableScript>().PickedUpConsumable();
                         Destroy(gameObject);
                         return;
                     }
                 }
             }
         }
         //if we don't find any already Existing consumables we create a new one
         CurrentItem = Instantiate(Resources.Load("ConsumableSprites/" + ConsumableType + "Sprite") as GameObject);
         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;
                         CurrentItem.transform.localScale    = new Vector3(1.5f, 1.5f, 1.5f);
                         Destroy(gameObject);
                         break;
                     }
                 }
                 else
                 {
                     ActivePlayer.GetComponent <HealthScript>().ShowDamageTaken("Inventory Full", DamageType.Physical);
                     break;
                 }
             }
         }
     }
     else
     {
         ActivePlayer.GetComponent <HealthScript>().ShowDamageTaken("Too Far Away", DamageType.Physical);
     }
 }
    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);
        }
    }