protected override void Awake() { base.Awake(); upgradeResource = GetComponentInChildren<UpgradeResource>(); upgrades = GetComponentInChildren<Upgrades>(); collectResources = GetComponent<CollectResources>(); sprite = GetComponent<SpriteRenderer>(); upgradeMenu = transform.Find("UpgradeMenu").gameObject; upgradeMenu.SetActive(false); InvokeRepeating("RecoverHealth", 0, healthRecoverRate); }
protected override void Awake() { base.Awake(); upgradeResource = GetComponentInChildren <UpgradeResource>(); upgrades = GetComponentInChildren <Upgrades>(); collectResources = GetComponent <CollectResources>(); sprite = GetComponent <SpriteRenderer>(); upgradeMenu = transform.Find("UpgradeMenu").gameObject; upgradeMenu.SetActive(false); InvokeRepeating("RecoverHealth", 0, healthRecoverRate); }
void OnCollisionEnter2D(Collision2D other) { CollectResources building = other.gameObject.GetComponent <CollectResources>(); if (building != null) { Health health = other.gameObject.GetComponent <Health>(); health.TakeDamage(damage); if (other.gameObject.GetComponent <LoseGame>()) { Destroy(this.gameObject); } } }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player").gameObject; PlayerResources = player.GetComponent <CollectResources>(); }