protected override void Awake() { base.Awake(); //get components pathUnit = GetComponent <Unit2D> (); //get the children biteDamager = transform.GetChild(0).gameObject; //internal stuff behaviour = Behaviour.NORMAL; durability.maxHealthPoints = 4; durability.healthPoints = 4; durability.invincibleWindow = 0.5f; //set callbacks Durability.callback onDmg = durability.onDamaged; durability.onDamaged = (int diff) => { if (onDmg != null) { onDmg(diff); } FlashColor(1, 0, 0, 0.1f); }; Durability.callback onHld = durability.onHealed; durability.onHealed = (int diff) => { if (onHld != null) { onHld(diff); } FlashColor(0, 1, 0, 0.1f); }; }
protected override void Awake() { base.Awake(); //get components liftable = GetComponent <Liftable> (); //internal stuff behaviour = Behaviour.NORMAL; durability.maxHealthPoints = 3; durability.healthPoints = 3; durability.invincibleWindow = 0.5f; //set callbacks Durability.callback onDmg = durability.onDamaged; durability.onDamaged = (int diff) => { if (onDmg != null) { onDmg(diff); } FlashColor(1, 0, 0, 0.1f); }; Durability.callback onHld = durability.onHealed; durability.onHealed = (int diff) => { if (onHld != null) { onHld(diff); } FlashColor(0, 1, 0, 0.1f); }; Durability.callback onDstr = durability.onDestruction; durability.onDestruction = (int i) => { if (onDstr != null) { onDstr(i); } Instantiate(Resources.Load("Meat_Raw", typeof(GameObject)), transform.position, Quaternion.identity); }; }
void Awake() { //get the components animator = GetComponent <Animator> (); boxCollider = GetComponent <BoxCollider2D> (); durability = GetComponent <Durability> (); lifter = GetComponent <Lifter> (); rigidBody = GetComponent <Rigidbody2D> (); spriteRenderer = GetComponent <SpriteRenderer> (); //get the sword swordDamager = transform.GetChild(0).gameObject; //set up the internals speed = 0.79f; durability.maxHealthPoints = 12; durability.healthPoints = 12; durability.invincibleWindow = 0.5f; //set callbacks Durability.callback onDmg = durability.onDamaged; durability.onDamaged = (int diff) => { if (onDmg != null) { onDmg(diff); } FlashColor(1, 0, 0, 0.1f); }; Durability.callback onHld = durability.onHealed; durability.onHealed = (int diff) => { if (onHld != null) { onHld(diff); } FlashColor(0, 1, 0, 0.1f); }; }
void Awake() { childImages = GetComponentsInChildren <Image> (); foreach (Image image in childImages) { image.enabled = false; } //BUGFIX: pop the Life_Bar's image List <Image> imageList = new List <Image> (childImages); imageList.RemoveAt(0); childImages = imageList.ToArray(); //check the durability fits the heart setup if (durability.maxHealthPoints % 4 != 0) { Debug.LogError("Durability.maxHealthPoints is not a multiple of 4"); } //set the callbacks Durability.callback onDmg = durability.onDamaged; durability.onDamaged = (diff) => { if (onDmg != null) { onDmg(diff); } UpdateGraphics(diff); }; Durability.callback onHld = durability.onHealed; durability.onHealed = (diff) => { if (onHld != null) { onHld(diff); } UpdateGraphics(diff); }; }