コード例 #1
0
ファイル: ItemPickup.cs プロジェクト: alasaidi/file-cs
        public override void OnInteract(PlayerEventHandler player)
        {
            if (m_PickupMethod == PickupMethod.WalkOver || !ItemToAdd)
            {
                return;
            }

            // TODO: We shouldn't have access to GUI functions here.
            var  inventory = GUIController.Instance.GetContainer("Inventory");
            bool added     = inventory.TryAddItem(ItemToAdd);

            if (added)
            {
                if (m_OnDestroySound)
                {
                    GameController.Audio.Play2D(m_OnDestroySound, m_OnDestroyVolume);
                }

                MessageDisplayer.Instance.PushMessage(string.Format("Picked up <color=yellow>{0}</color> x {1}", ItemToAdd.Name, ItemToAdd.CurrentInStack));
            }

            Destroy(gameObject);
            if (!added)
            {
                i++;
                Debug.Log("i");
            }
        }
コード例 #2
0
 public override void OnInteract(PlayerEventHandler player)
 {
     if (enabled && InventoryController.Instance.OpenLootContainer.Try(this))
     {
         On_InventoryOpened();
         InventoryController.Instance.State.AddChangeListener(OnChanged_InventoryController_State);
     }
 }
コード例 #3
0
 public override void OnInteract(PlayerEventHandler player)
 {
     if (!player.Sleep.Active && TimeOfDay.Instance.State.Get() == ET.TimeOfDay.Night)
     {
         if (player.StartSleeping.Try(this))
         {
             player.Sleep.ForceStart();
         }
     }
 }
コード例 #4
0
ファイル: Lamp.cs プロジェクト: alasaidi/file-cs
 public override void OnInteract(PlayerEventHandler player)
 {
     if(m_Light != null)
     {
         m_Light.enabled = !m_Light.enabled;
         m_ToggleAudio.Play(ItemSelectionMethod.RandomlyButExcludeLast, m_AudioSource, 1f);
     }
     else
         Debug.LogError("No Light component assigned to this Lamp!", this);
 }
コード例 #5
0
 public override void OnInteract(PlayerEventHandler player)
 {
     if (m_Type == SmeltingStationType.Campfire)
     {
         InventoryController.Instance.OpenCampfire.Try(this);
     }
     else if (m_Type == SmeltingStationType.Furnace)
     {
         InventoryController.Instance.OpenFurnace.Try(this);
     }
 }
コード例 #6
0
        private void Awake()
        {
            if (!m_ItemDatabase)
            {
                Debug.LogError("No ItemDatabase specified, the inventory will be disabled!", this);
                enabled = false;
                return;
            }

            SetState.SetTryer(TryChange_State);

            // TODO: We shouldn't have access to GUI functions here.
            m_AllCollections = GUIController.Instance.Containers;

            // Create the inventory.
            // TODO: We shouldn't have access to GUI functions here.
            m_InventoryCollection = CreateListOfHolders(m_InventorySize);
            var inventoryCollection = GUIController.Instance.GetContainer("Inventory");

            inventoryCollection.Setup(m_InventoryCollection);

            // Create the hotbar.
            // TODO: We shouldn't have access to GUI functions here.
            m_HotbarCollection = CreateListOfHolders(m_HotbarSize);
            var hotbarCollection = GUIController.Instance.GetContainer("Hotbar");

            hotbarCollection.Setup(m_HotbarCollection);

            // Create the equipment.
            // TODO: We shouldn't have access to GUI functions here.
            m_EquipmentHolders = CreateListOfHolders(m_EquipmentList.Count);
            for (int i = 0; i < m_EquipmentList.Count; i++)
            {
                var equipmentGUI = GUIController.Instance.GetContainer(m_EquipmentList[i]);
                if (equipmentGUI)
                {
                    equipmentGUI.Setup(new List <ItemHolder>()
                    {
                        m_EquipmentHolders[i]
                    });
                }
                else
                {
                    Debug.LogErrorFormat(this, "No GUI collection with the name '{0}' was found!", m_EquipmentList[i]);
                }
            }

            m_Player = GameController.LocalPlayer;
            m_Player.ChangeHealth.AddListener(OnChanged_PlayerHealth);
            m_Player.Death.AddListener(On_PlayerDeath);
        }
コード例 #7
0
 /// <summary>
 ///
 /// </summary>
 public virtual void OnInteractHold(PlayerEventHandler player)
 {
 }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 public virtual void OnRaycastEnd(PlayerEventHandler player)
 {
 }
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 public virtual void OnRaycastUpdate(PlayerEventHandler player)
 {
 }
コード例 #10
0
 /// <summary>
 ///
 /// </summary>
 public virtual void OnRaycastStart(PlayerEventHandler player)
 {
 }
コード例 #11
0
 public override void OnInteract(PlayerEventHandler player)
 {
     InventoryController.Instance.OpenAnvil.Try(this);
 }