private void OnTriggerEnter2D(Collider2D collision) { ServantAI servant = AIParent.GetComponent <ServantAI>(); WerewolfAI werewolf = AIParent.GetComponent <WerewolfAI>(); if (collision.CompareTag("Servant") && werewolf != null) { werewolf.newState = WerewolfAI.EWerewolfStates.Chasing; werewolf.singleTarget = collision.gameObject.transform; } else if (collision.CompareTag("ManorLord") && werewolf != null) { werewolf.newState = WerewolfAI.EWerewolfStates.Chasing; werewolf.singleTarget = collision.gameObject.transform; } else if (collision.CompareTag("Enemy") && servant != null) { if (servant.hasWolfsbane) { servant.newState = ServantAI.EServantStates.PresentingWolfsbane; servant.singleTarget = collision.gameObject.transform; } else if (servant.CurrentState != ServantAI.EServantStates.CreatingWolfsbane || servant.CurrentState != ServantAI.EServantStates.FoundFoodbowl) { servant.newState = ServantAI.EServantStates.Running; } } else if (collision.CompareTag("Food Bowl") && servant != null) { servant.newState = ServantAI.EServantStates.FoundFoodbowl; servant.singleTarget = collision.gameObject.transform; } }
private void OnTriggerEnter2D(Collider2D collision) { ServantAI servant = collision.gameObject.GetComponent <ServantAI>(); WerewolfAI werewolf = collision.gameObject.GetComponent <WerewolfAI>(); if (collision.CompareTag("Enemy")) { werewolf.singleTarget = nextLevelTarget; werewolf.levelTarget = nextLevelTarget; } else if (collision.CompareTag("Servant")) { servant.singleTarget = nextLevelTarget; servant.levelTarget = nextLevelTarget; servant.AnalyzePatrolArray(nextWaypointTargets); } }
private void OnTriggerEnter2D(Collider2D collision) { ServantAI servant = collision.gameObject.GetComponent <ServantAI>(); WerewolfAI werewolf = collision.gameObject.GetComponent <WerewolfAI>(); if (collision.CompareTag("Servant")) { if (servant.CurrentState == ServantAI.EServantStates.Running) { servant.TakeDamage(servant.HP); } } else if (collision.CompareTag("Enemy")) { if (werewolf.CurrentState != WerewolfAI.EWerewolfStates.Chasing) { werewolf.TakeDamage(werewolf.HP); } } }
private void OnTriggerEnter2D(Collider2D collision) { ServantAI servant = collision.gameObject.GetComponent <ServantAI>(); WerewolfAI werewolf = collision.gameObject.GetComponent <WerewolfAI>(); if (collision.CompareTag("Enemy")) { werewolf.transform.position = teleportPoint.position; werewolf.singleTarget = nextLevelTarget; werewolf.levelTarget = nextLevelTarget; collision.gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(collision.gameObject.GetComponent <Rigidbody2D>().velocity.x * -1, collision.gameObject.GetComponent <Rigidbody2D>().velocity.y); collision.gameObject.transform.parent.GetComponent <Room>().NPCs.Remove(collision.gameObject);//sometimes object no exist error } else if (collision.CompareTag("Servant")) { servant.transform.position = teleportPoint.position; servant.singleTarget = nextLevelTarget; servant.levelTarget = nextLevelTarget; servant.AnalyzePatrolArray(nextWaypointTargets); collision.gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(collision.gameObject.GetComponent <Rigidbody2D>().velocity.x * -1, collision.gameObject.GetComponent <Rigidbody2D>().velocity.y); collision.gameObject.transform.parent.GetComponent <Room>().NPCs.Remove(collision.gameObject);//sometimes object no exist error } }