void Awake() { if (damage == 0) { damage = 1; } if (animator == null) { animator = GetComponent <Animator>(); if (animator == null) { animator = GetComponentInParent <Animator>(); } } if (AttackCollider == null) { AttackCollider = GetComponent <BoxCollider2D>(); } if (AttackCollider == null) { throw new ArgumentNullException(nameof(AttackCollider)); } if (damageablePlayer == null) { damageablePlayer = GetComponent <DamageablePlayer>(); if (damageablePlayer == null) { damageablePlayer = GetComponentInParent <DamageablePlayer>(); } } }
// Start is called before the first frame update void Start() { Damageable = GetComponent <DamageablePlayer>(); if (Damageable != null) { // Setting this because we cannot cast a property of an object, specifically we cannot cast the health object as player health to get and cast its innards. playerHealth = Damageable.playerHealth; // Subscribes to UpdateHp so UpdateHPPips will run when called. Damageable.UpdateHp += UpdateHPPips; } if (Hp_PipPool == null) { Hp_PipPool = GameObject.Find("HP_PipPool"); } if (PipPad == null) { PipPad = GameObject.Find("PipPad"); } PlayerCharacter = GetComponent <PlayerCharacter>(); pipPrefab = (GameObject)Resources.Load("Prefabs/Pip", typeof(GameObject)); // Initializing PipPoolCap in start because DamageablePlayer is initialized in awake and that needs to be set up first PipPoolCap = Damageable.StartingHealth; // Call function which sets the default/saved values for each of the pip models Initialized.Invoke(Head, Arms, Chest, Legs); curTempDecayScale = new Vector3(1, 1, 1); // Sets the PipLinkedList InitializePipPool(playerHealth); InitializePipPadDisplay(); if (Updated != null) { Updated.Invoke(Head, PipPadTextHolder, PipPadImageHolder); Updated.Invoke(Arms, PipPadTextHolder, PipPadImageHolder); Updated.Invoke(Chest, PipPadTextHolder, PipPadImageHolder); Updated.Invoke(Legs, PipPadTextHolder, PipPadImageHolder); } }