public bool IsCurrentPlayerBodyPart(ICanGetDamage bodyPart) { bool isCurrentPlayerBodyPart = false; foreach (ICanGetDamage part in BodyParts) { if (part == bodyPart) { isCurrentPlayerBodyPart = true; Debug.Log("<color=orange><b> CURR </b></color>"); } } return(isCurrentPlayerBodyPart); }
protected void OnCollisionEnter2D(Collision2D collision) { if (IsThrowingNow) { if (collision.collider.gameObject.GetComponentInParent <PlayerController>() != null) { if (collision.collider.gameObject.GetComponentInParent <PlayerController>().IsFirstPlayer != IsFirstPlayer) { Debug.Log("<color=orange><b> ISTHROWINGNOW </b></color>"); if (collision.collider.tag == "Damagable") { Debug.Log("<color=orange><b> collision name : </b></color>" + collision.gameObject.name); ICanGetDamage damagedObject = collision.collider.gameObject.GetComponent <ICanGetDamage>(); Attack(damagedObject); Debug.Log("<color=orange><b> ISTHROWINGNOW COL</b></color>"); } } } } }
public abstract void Attack(ICanGetDamage damagedObject);
private void OnTriggerEnter2D(Collider2D collision) { if (!IsHandleNow) { if (collision.tag == "Player") { collision.GetComponent <PlayerWeaponController>().CatchWeapon(this); Debug.Log("<color=red><b> HANDLE </b></color>"); } } if (!IsAttackingNow || !IsColdownedNow()) { return; } if (collision.tag == "Damagable") { if (PlayerWeaponController != null) { Debug.Log("<color=green><b> PLAYERCONTROLLER = !null </b></color>"); ICanGetDamage damagedObject = collision.GetComponent <ICanGetDamage>(); //КОСТЫЛЬ ГОДА if (collision.gameObject.GetComponentInParent <PlayerController>() != null) { if (collision.gameObject.GetComponentInParent <PlayerController>().IsFirstPlayer != IsFirstPlayer) { if (damagedObject != null && !PlayerWeaponController.PlayerStateController.IsCurrentPlayerBodyPart(damagedObject)) { Attack(collision.GetComponent <ICanGetDamage>()); // Debug.Log(gameObject.name + "<color=orange><b> ТАЧ </b></color>" + collision.name); } else { Debug.Log("<color=red><b> ISCUR = null </b></color>" + PlayerWeaponController.PlayerStateController.IsCurrentPlayerBodyPart(damagedObject)); Debug.Log("<color=red><b> damagedObject = null </b></color>" + damagedObject); } } } //if (ISKOSTULTOCHECKERBODYPART) //{ // if (damagedObject != null && PlayerWeaponController.PlayerStateController.IsCurrentPlayerBodyPart(damagedObject)) // { // Attack(collision.GetComponent<ICanGetDamage>()); // // Debug.Log(gameObject.name + "<color=orange><b> ТАЧ </b></color>" + collision.name); // } //} //else //{ // if (damagedObject != null && !PlayerWeaponController.PlayerStateController.IsCurrentPlayerBodyPart(damagedObject)) // { // Attack(collision.GetComponent<ICanGetDamage>()); // // Debug.Log(gameObject.name + "<color=orange><b> ТАЧ </b></color>" + collision.name); // } //} } else { Debug.Log("<color=red><b> PLAYERCONTROLLER = null </b></color>"); } } }
public override void Attack(ICanGetDamage damagedObject) { damagedObject.GetDamage(IsThrowingNow?Damage:Damage * 0.8f, this); SetColdown(); }