/*// Update is called once per frame * void Update() * { * * }*/ //new in a method declaration means "use me rather than my superclass's version" public override void takeDamage(int damageTaken) { //take the damage to the weakpoint this.currentHealth -= (int)Mathf.Floor(damageTaken * (1.0f - damageResistance)); //then deal the damage to the owner if (bypassDamageResistance) { //We divide by 100 - ownerHealth.damage resistance to cancel out the damage resistance //in the owner, with is * 100 - ownerHealth.damageResistance ownerHealth.takeDamage((int)Mathf.Floor( damageTaken * damageMultiplier / (1.0f - ownerHealth.damageResistance))); } else { ownerHealth.takeDamage((int)Mathf.Floor(damageTaken * damageMultiplier)); } //if the attack killed the thing if (this.currentHealth <= 0) { /*I'd like to use SendMessageOptions.RequireReciever to make it so * that the game vomits if we try to kill something that cannot die, * but I just don't know how*/ this.gameObject.SendMessage("DoActorDeath");//, null, RequireReciever); } }
private void OnTriggerEnter2D(Collider2D other) { Debug.Log(other); if (other.CompareTag("SceneChange")) { Debug.Log("Scene Changed to BossScene"); SceneManager.LoadScene(sceneToLoad); } if (other.CompareTag("Gluttony")) { //Debug.Log("Collided"); PlayerMovement playerMov = player.GetComponent <PlayerMovement>(); ActorHealth playerHealth = player.GetComponent <ActorHealth>(); TestBoss gluttonyMov = gluttony.GetComponent <TestBoss>(); playerMov.velocity += Vector2.Scale(gluttonyMov.movementDirection, 10.0f * new Vector2((Mathf.Log(1f / (Time.deltaTime * playerMov.Drag.x + 1)) / -Time.deltaTime), (Mathf.Log(1f / (Time.deltaTime * playerMov.Drag.y + 1)) / -Time.deltaTime))); if (gluttonyMov.state == TestBoss.State.Walk) { // reduces player health by 1 when gluttony is walking playerHealth.takeDamage(1); } else if (gluttonyMov.state == TestBoss.State.Crushed) { // reduces player health by 5 when gluttony is slamming/crushing playerHealth.takeDamage(3); } } if (other.CompareTag("Gluttony Projectile")) { ActorHealth playerHealth = player.GetComponent <ActorHealth>(); playerHealth.takeDamage(3); } if (other.CompareTag("Gluttony Bite")) { ActorHealth playerHealth = player.GetComponent <ActorHealth>(); playerHealth.takeDamage(1); } }