Esempio n. 1
0
    protected override void AfterOnStartLocalPlayer()
    {
        /* Get the toolbelt manager from the player */
        toolbeltManager = GetComponent <PlayerToolbeltManager>();
        if (toolbeltManager == null)
        {
            throw new System.Exception("Why does this VR player not have a toolbelt!");
        }

        /* Get the inventory manager for this player */
        playerInventory = GetComponent <PlayerInventoryManager>();
        if (playerInventory == null)
        {
            throw new System.Exception("Why is there no player inventory manager for this player?");
        }

        /* Get the bank manager for this player */
        playerBank = GetComponent <PlayerBankManager>();
        if (playerBank == null)
        {
            throw new System.Exception("Why is there no player bank manager for this player?");
        }

        /* Get the relic menu object */
        RelicUIManager relicUI = inventoryMenuObj.GetComponent <RelicUIManager>();

        Debug.Assert(relicUI != null);
        relicUI.SetPlayerInventory(playerInventory.GetInventory());

        /* Get the bank menu object */
        BankUIManager bankUI = bankMenuObj.GetComponent <BankUIManager>();

        Debug.Assert(bankUI != null);
        bankUI.SetPlayerBankManager(playerBank);
    }
Esempio n. 2
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            List <ItemInformation> ConsumedItems = new List <ItemInformation>();

            foreach (ItemInformation itemRequired in itemsRequired)
            {
                if (PlayerInventoryManager.IsThisItemInInventory(itemRequired))
                {
                    ConsumedItems.Add(itemRequired);
                    int index = itemsRequired.IndexOf(itemRequired);
                    requirementCanvas.greenBorders[index].gameObject.SetActive(true);
                }
            }
            foreach (ItemInformation itemConsumed in ConsumedItems)
            {
                itemsRequired.Remove(itemConsumed);
            }
            if (itemsRequired.Count == 0)
            {
                Destroy(blockade, 2f);
                Destroy(gameObject, 2f);
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     _animator      = GetComponentInChildren <Animator>();
     _healthBar     = GetComponentInChildren <HealthBar>();
     _currentHealth = gameObject.CompareTag("Player") ? PlayerInventoryManager.FindPlayerAttributeMaxValueByName("Health") : _currentHealth;
     _maxHealth     = _currentHealth;
     _isDead        = false;
 }
 // Use this for initialization
 void Start()
 {
     inventory.SetActive(false);
     player.GetComponent <PlayerController>().playerCanMove = true;
     itemBar.SetActive(true);
     itemBar.GetComponent <PlayerInventoryBar>().DisplayMenuBar();
     EventSystem.current.GetComponent <AltStandaloneInputModule>().mouseCanClick = false;
     inventoryScript = player.GetComponent <PlayerInventoryManager>();
 }
Esempio n. 5
0
    public void OnPointerClick()
    {
        InfoUpdater.EnterAction(null);
        storedItem.SetActive(true);
        storedItem.transform.position = PlayerInventoryManager.playerTransform.position;

        PlayerInventoryManager.onDropAction(this.item);
        Destroy(this.gameObject);
    }
Esempio n. 6
0
 public void Awake()
 {
     inventoryManager = this.GetComponent <PlayerInventoryManager>();
     miningManager    = this.GetComponent <MiningManager>();
     if (_instance != null)
     {
         Debug.LogError("Multiple PlayerManager instances found! Overriding existing instance.");
     }
     _instance = this;
 }
Esempio n. 7
0
        internal PartyMember(TSPlayer player)
        {
            Player        = player;
            Items         = new PlayerInventoryManager(player);
            Variables     = new Dictionary <string, object>();
            QuestStatuses = new QuestStatusCollection();

            SpawnTileX = Main.spawnTileX;
            SpawnTileY = Main.spawnTileY;
        }
Esempio n. 8
0
 private void Awake()
 {
     rb                         = GetComponent <Rigidbody>();
     hs                         = GetComponent <HealthSystem>();
     animator                   = GetComponent <Animator>();
     enemyState                 = GetComponent <EnemyState>();
     playerInventoryManager     = GameUtility.Player.GetComponent <PlayerInventoryManager>();
     groundedItemDropController = GetComponent <GroundedItemDropController>();
     grenade                    = new InventoryItem(new ItemsBase());
 }
Esempio n. 9
0
        public Player(Level level) : base(-1, level)
        {
            _chunksUsed = new Dictionary <Tuple <int, int>, ChunkColumn>();
            Inventory   = new PlayerInventoryManager(this);
            Level       = level;

            Width      = 0.6;
            Height     = 1.62;
            Length     = 0.6;
            IsOperator = false;
        }
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
Esempio n. 11
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Ground")
     {
         Invoke("PlayOnGroundAnimation", 0.5f);
     }
     else if (collision.gameObject.tag == "Player")
     {
         PlayerInventoryManager.AddItemToInventory(this);
         Destroy(gameObject);
     }
 }
Esempio n. 12
0
        public Player(Level level) : base(-1, level)
        {
            _chunksUsed = new List <Tuple <int, int> >();
            Inventory   = new PlayerInventoryManager(this);
            Level       = level;

            Width      = 0.6;
            Height     = 1.62;
            Length     = 0.6;
            IsOperator = false;
            Loaded     = false;
        }
Esempio n. 13
0
 private void Awake()
 {
     playerInventoryManager = FindObjectOfType <PlayerInventoryManager>();
     slotIcons = new GameObject[slots.Length];
     for (int i = 0; i < slotIcons.Length; i++)
     {
         slotIcons[i] = slots[i].GetChild(0).GetChild(0).GetChild(0).gameObject;
         Image currentImage = slotIcons[i].GetComponentInChildren <Image>();
         if (currentImage.sprite == null)
         {
             slotIcons[i].SetActive(false);
         }
     }
 }
Esempio n. 14
0
    private void OnTriggerExit(Collider other)
    {
        PlayerInventoryManager playerInventory = other.GetComponent <PlayerInventoryManager>();

        if (playerInventory != null && playerInventory.Inventory.keys.Count > 0)
        {
            if (opened)
            {
                CloseDoor();
            }
            else
            {
                OnDoorClosed?.Invoke(false);
            }
        }
    }
 public void TakeDamage(int damage)
 {
     if (damage <= 0 || _isDead)
     {
         return;
     }
     _currentHealth = _currentHealth - damage <= 0 ? 0 : _currentHealth - damage;
     if (gameObject.CompareTag("Player"))
     {
         PlayerInventoryManager.SetPlayerAttributeByName("Health", _currentHealth, SetType.CurrentValue);
     }
     _healthBar.SubFillBar(damage / _maxHealth * 100);
     if (gameObject.CompareTag("Player"))
     {
         _animator.Play("TakeDamage");
     }
 }
Esempio n. 16
0
        /// <summary>
        /// Checks if this item can be crafted.
        /// </summary>
        public bool CanCraft(PlayerInventoryManager playerInventory)
        {
            if (recipe.OutputItem.ItemData.type == 0) //If output item is a weapon
            {
                if (playerInventory.HasWeapon(ItemConverter.ToInventoryWeapon(recipe.OutputItem)).contains)
                {
                    return(false);
                }

                foreach (RecipeItem item in recipe.RequiredItems)
                {
                    if (item.Item.ItemData.type == 0) // If weapon
                    {
                        var weaponData = playerInventory.HasWeapon(ItemConverter.ToInventoryWeapon(item.Item));
                        if (!weaponData.contains || weaponData.slotContained.ItemCount < item.RequiredItemCount)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        var itemData = playerInventory.HasItem(item.Item);
                        if (!itemData.contains || itemData.slotContained.ItemCount < item.RequiredItemCount)
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                foreach (RecipeItem item in recipe.RequiredItems)
                {
                    var itemData = playerInventory.HasItem(item.Item);
                    if (!itemData.contains || itemData.slotContained.ItemCount < item.RequiredItemCount)
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
Esempio n. 17
0
 /// <summary>
 /// Checks if this item can be crafted and returns crafted item if possible. Calling CanCraft for checking manually is not recommended since it will be relatively expensive.
 /// </summary>
 public InventoryItem Craft(PlayerInventoryManager playerInventory)
 {
     if (CanCraft(playerInventory))
     {
         foreach (RecipeItem item in recipe.RequiredItems)
         {
             if (item.Item.ItemData.type == 0) //If weapon
             {
                 playerInventory.RemoveWeapon(ItemConverter.ToInventoryWeapon(item.Item));
             }
             else
             {
                 playerInventory.RemoveItem(item.Item, item.RequiredItemCount);
             }
         }
         return(recipe.OutputItem);
     }
     return(null);
 }
Esempio n. 18
0
    private void OnCollisionEnter(Collision collision)
    {
        PlayerInventoryManager playerInventory = collision.gameObject.GetComponent <PlayerInventoryManager>();

        if (playerInventory != null && playerInventory.Inventory.keys.Count > 0)
        {
            if (!opened && playerInventory.Inventory.keys.Any(x => x.doorId == doorId))
            {
                OpenDoor();
            }
            else
            {
                OnDoorOpened?.Invoke(false);
            }
        }
        else
        {
            OnDoorOpened?.Invoke(false);
        }
    }
 private void Awake()
 {
     weaponsObtained        = new GameObject[4];
     playerInventoryManager = GetComponent <PlayerInventoryManager>();
 }
Esempio n. 20
0
 private void Start()
 {
     inventoryManager = GameObject.FindGameObjectWithTag("Managers").GetComponent <PlayerInventoryManager>();
 }
 void Start()
 {
     InputHandler.instance.attackActions["Primary"].performed += ctx => OnAttack();
     playerInventoryManager = gameObject.GetComponent <PlayerInventoryManager>();
 }
Esempio n. 22
0
 private void Awake()
 {
     healthSystem = GetComponent <HealthSystem>();
     groundedItemDropController = GetComponent <GroundedItemDropController>();
     playerInventoryManager     = GameUtility.Player.GetComponent <PlayerInventoryManager>();
 }
Esempio n. 23
0
 private void Awake()
 {
     ins = this;
 }
 public void SetParent(PlayerInventoryManager _parent)
 {
     parent = _parent;
     value  = new ModifiableInt(AttributeModified);
 }
 private void Awake()
 {
     inv          = GetComponent <PlayerInventoryManager>();
     canv.enabled = false;
 }
Esempio n. 26
0
 private void Awake()
 {
     instance = this;
     animator = GetComponent <Animator>();
     playerInventoryManager = GetComponent <PlayerInventoryManager>();
 }
Esempio n. 27
0
 private void Awake()
 {
     playerInventory = FindObjectOfType <PlayerInventoryManager>();
 }