// Start is called before the first frame update void Start() { princeAnimator = GetComponent <Animator>(); player = GameObject.FindWithTag("Player"); princeRigidBody = GetComponent <Rigidbody2D>(); princeHealth = GetComponentInChildren <Health_Script>(); princeTransform = GetComponent <Transform>(); currentCooldown = cooldown; }
// Start is called before the first frame update void Start() { healthScript = GetComponent <Health_Script>(); ratRigidBody = GetComponent <Rigidbody2D>(); bossAnimation = GetComponentInChildren <Animator>(); player = GameObject.FindWithTag("Player"); playerHealthScript = player.GetComponent <Health_Script>(); moveSelected = -1; hitBox = GetComponent <PolygonCollider2D>(); }
void AttackEnemy() { UnitLocation = gameObject.GetComponentInParent<Cells>(); for (int i = range; i > 0; i--) { //Debug.Log(gameObject.name + ": Attacking " + i + " tiles ahead"); if (transform.parent.GetComponent<Cells>().isEnd() == false | transform.parent.GetComponent<Owner_Script>().myOwner == UnitOwner.myOwner) { if (UnitLocation.BackExists(i) == true) { Cells TilesInRange = UnitLocation.GetBack(i).GetComponent<Cells>(); if (TilesInRange.isOccupied == true) { GameObject enemyObject = TilesInRange.transform.GetChild(0).gameObject; InRangeOwner = enemyObject.GetComponent<Owner_Script>(); if (InRangeOwner.myOwner != UnitOwner.myOwner) { //Debug.Log("hi ian: " + InRangeOwner.myOwner + ", " + UnitOwner.myOwner); //Debug.Log(gameObject + " - has delt damage to - " + enemyObject); EnemyHealth = enemyObject.GetComponent<Health_Script>(); EnemyHealth.ApplyDamage(UnitAttack.damage); } } } } else { InRangeOwner = transform.parent.GetComponent<Owner_Script>(); if (InRangeOwner && InRangeOwner.myOwner != UnitOwner.myOwner) { InRangeOwner = transform.parent.GetComponent<Owner_Script>(); if (InRangeOwner.myOwner != UnitOwner.myOwner) { //Debug.Log(gameObject.name + " has reached the end!"); EnemyHealth = InRangeOwner.myOwner.GetComponent<Health_Script>(); EnemyHealth.ApplyDamage(1); UnitHealth.ApplyDamage(9001); i = 0; } } } } }
private void OnTriggerEnter2D(Collider2D collision) { if (transform.parent.tag != collision.gameObject.tag) { Health_Script enemyHealth = collision.gameObject.GetComponent <Health_Script>(); PlayerController enemyDamageReduction = collision.gameObject.GetComponent <PlayerController>(); if (enemyHealth && enemyDamageReduction.invincibleBuffActive) { enemyHealth.ChangedHealth(-damage * 0); } else if (enemyHealth && enemyDamageReduction.defenseBuffActive) { enemyHealth.ChangedHealth(-damage * damageReduction.boostedDefenseMultiplier); } else if (enemyHealth) { enemyHealth.ChangedHealth(-damage); } Destroy(gameObject); } }
// Use this for initialization void Start() { UnitOwner = gameObject.GetComponent<Owner_Script>(); UnitAttack = gameObject.GetComponent<Attack_Script>(); UnitHealth = gameObject.GetComponent<Health_Script>(); UnitLocation = gameObject.GetComponentInParent<Cells>(); UnitOwner.myOwner.myTurnState.myCombatMessenger.Subscribe(new Subscription(gameObject, AttackDirection)); }
// Start is called before the first frame update void Start() { healthScript = GetComponent <Health_Script>(); originalHealth = healthScript.health; }