public void Show(ResourceGeneratorData resourceGeneratorData)
        {
            m_resourceGeneratorData = resourceGeneratorData;
            gameObject.SetActive(true);

            transform.Find("Icon").GetComponent <SpriteRenderer>().sprite = resourceGeneratorData.resourceType.sprite;
        }
Пример #2
0
        private void Start()
        {
            ResourceGeneratorData resourceGeneratorData = m_resourceGenerator.GetResourceGeneratorData();

            m_barTransform = transform.Find("Bar");

            transform.Find("Icon").GetComponent <SpriteRenderer>().sprite = resourceGeneratorData.resourceType.sprite;
            float amount = m_resourceGenerator.GetAmountGeneratedPerSecond();

//			Debug.Log($"{transform.parent.name} : amount: {amount}");
            transform.Find("Text_TMP").GetComponent <TextMeshPro>().SetText(amount.ToString("F1"));
        }
        public static int GetNearbyResourceAmount(ResourceGeneratorData resourceGeneratorData, Vector3 position)
        {
            Collider2D[] collider2DArray = Physics2D.OverlapCircleAll(position, resourceGeneratorData.resourceDetectionRadius);

            int nearbyResourceAmount = 0;

            foreach (Collider2D collider2D in collider2DArray)
            {
                ResourceNode resourceNode = collider2D.GetComponent <ResourceNode>();
                if (resourceNode != null)
                {
                    // It's a resource node!
                    if (resourceNode.resourceType == resourceGeneratorData.resourceType)
                    {
                        // Same type!
                        nearbyResourceAmount++;
                    }
                }
            }

            nearbyResourceAmount = Mathf.Clamp(nearbyResourceAmount, 0, resourceGeneratorData.maxResourceAmount);

            return(nearbyResourceAmount);
        }
 private void Awake()
 {
     m_resourceGeneratorData = GetComponent <BuildingTypeHolder>().buildingType.resourceGeneratorData;
     m_timerMax = m_resourceGeneratorData.timerMax;
 }