protected override void OnTakeDamage(int amount) { int val = Mathf.Clamp(CurHealth - amount, 0, MaxHealth); bar.SetValue(val); if (shaker != null) { shaker.Shake(0.5f); } }
private void Start() { animator = GetComponentInChildren <Animator>(); shaker = GetComponentInChildren <Shaker>(); spriteRenderer = GetComponentInChildren <SpriteRenderer>(); bar = Instantiate(barPrefab, StageGUI.Instance.transform).GetComponent <Counterbar>(); bar.transform.SetAsFirstSibling(); bar.SetValue(MaxHealth); bar.GetComponent <FollowerGUI>().SetTarget(transform); AudioController.Instance.PlaySound("dummy_thump"); }
private void Start() { index = lastIndex++; usables = GetComponentsInChildren <Usable>(); bar = Instantiate(healthBar, StageGUI.Instance.transform).GetComponent <Counterbar>(); bar.SetValue(MaxHealth); bar.GetComponent <FollowerGUI>().SetTarget(transform); bar.transform.SetAsFirstSibling(); GetComponentInChildren <Animator>().runtimeAnimatorController = animControllers[index]; arrowSprite.color = Color; controls.Horizontal = "Horizontal_" + index; controls.Vertical = "Vertical_" + index; controls.Attack = "Attack_" + index; controls.Cycle = "Cycle_" + index; rigidbody = GetComponent <Rigidbody>(); EventManager.QueueEvent(new KidSpawnedEvent(this)); }