//Check the collision between the melee collider and an object protected void SpecificCollision(LifeController lifeController, Collider2D col) { //When the Player attacks if (gameObject.GetComponentInParent <LifeController>().CompareTag("Player")) { Damage = GameObject.FindWithTag("Player").GetComponent <PlayerController>().GetDamageMelee(); //If Player attacks an Enemy with melee attack if (lifeController != null && lifeController.CompareTag("Enemy")) { ColorController EnemyColor = col.gameObject.GetComponent <ColorController>(); ColorController PlayerColor = GameObject.FindWithTag("Player").GetComponent <ColorController>(); //If the color is the same between Player & Enemy, melee attack works if (PlayerColor.SameColor(EnemyColor.GetColor())) { GameObject go = Instantiate(ImpactFX, col.transform.position, transform.rotation) as GameObject; lifeController.LoseLife(Damage); } else { GameObject go = Instantiate(NoImpactFX, col.transform.position, transform.rotation) as GameObject; } } } //When an Enemy attacks else { Damage = gameObject.GetComponentInParent <Enemy>().damageMelee; //If Enemy attacks the Player with melee attack if (lifeController != null && lifeController.CompareTag("Player")) { ColorController EnemyColor = gameObject.GetComponentInParent <ColorController>(); ColorController PlayerColor = GameObject.FindWithTag("Player").GetComponent <ColorController>(); //If the color is the same between Enemy & Player, melee attack works if (PlayerColor.SameColor(EnemyColor.GetColor())) { GameObject go = Instantiate(ImpactFX, col.transform.position, transform.rotation) as GameObject; lifeController.LoseLife(Damage); } else { GameObject go = Instantiate(NoImpactFX, col.transform.position, transform.rotation) as GameObject; } } } }
protected override void SpecificCollision(LifeController lifeController, Collision2D col) { if (lifeController != null && lifeController.CompareTag("Enemy")) { ColorController EnemyColor = col.collider.gameObject.GetComponent <ColorController>(); if (EnemyColor.SameColor(color)) { GameObject go = Instantiate(ImpactFX, transform.position, transform.rotation) as GameObject; lifeController.LoseLife(Damages); } else { GameObject go = Instantiate(NoImpactFX, col.transform.position, transform.rotation) as GameObject; SoundManager.instance.PlaySingle(projectileSoundNoImpact); } } }