Пример #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);
    }
Пример #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;
 }
Пример #4
0
 // 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>();
 }
Пример #5
0
    public void OnPointerClick()
    {
        InfoUpdater.EnterAction(null);
        storedItem.SetActive(true);
        storedItem.transform.position = PlayerInventoryManager.playerTransform.position;

        PlayerInventoryManager.onDropAction(this.item);
        Destroy(this.gameObject);
    }
Пример #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;
 }
Пример #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;
        }
Пример #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());
 }
Пример #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;
     }
 }
Пример #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);
     }
 }
Пример #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;
        }
Пример #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);
         }
     }
 }
Пример #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");
     }
 }
Пример #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);
            }
        }
Пример #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);
 }
Пример #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>();
 }
Пример #20
0
 private void Start()
 {
     inventoryManager = GameObject.FindGameObjectWithTag("Managers").GetComponent <PlayerInventoryManager>();
 }
Пример #21
0
 void Start()
 {
     InputHandler.instance.attackActions["Primary"].performed += ctx => OnAttack();
     playerInventoryManager = gameObject.GetComponent <PlayerInventoryManager>();
 }
Пример #22
0
 private void Awake()
 {
     healthSystem = GetComponent <HealthSystem>();
     groundedItemDropController = GetComponent <GroundedItemDropController>();
     playerInventoryManager     = GameUtility.Player.GetComponent <PlayerInventoryManager>();
 }
Пример #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;
 }
Пример #26
0
 private void Awake()
 {
     instance = this;
     animator = GetComponent <Animator>();
     playerInventoryManager = GetComponent <PlayerInventoryManager>();
 }
Пример #27
0
 private void Awake()
 {
     playerInventory = FindObjectOfType <PlayerInventoryManager>();
 }