private void OnTriggerStay2D(Collider2D collision) { if (!isPlayer && collision.gameObject.layer == GameInfo.PLAYER_LAYER) { controller.SetCurrentState(EnemyState.melee_attacking); } }
/// <summary> /// Utilizar en algun momento que sea interesante, como al llegar /// a un waypoint para que descanse y luego continue. /// </summary> /// <returns>Devuelve si se quedo o no</returns> public bool StaysInPlace() { var rChance = Random.Range(0, 100); // genero un random que puede dejar al enemigo en el lugar por un rato, para // que no esten tan predecibles siempre bool res = rChance < chanceVal; if (res) { // quiero que deje de atacar si esta distraido? //this.GetComponent<FetchAndAttack>().enabled = false; //this.GetComponent<WaypointPatrol>().enabled = false; //Debug.Log("staying"); if (controller) { controller.SetCurrentState(EnemyState.idle); } else if (controllerD) { controllerD.SetCurrentState(DogState.idle); } //StartCoroutine(RestartBehaviours()); } return(res); }
private void OnTriggerStay2D(Collider2D collision) { if (Input.GetKeyDown(killKey) && collision.gameObject.layer == GameInfo.PLAYER_LAYER) { PointsManager.current.AddKillToTotal(500); controller.SetCurrentState(EnemyState.dead); //GameObject corpse = Instantiate(corpsePrefab, transform.position, Quaternion.identity); //Destroy(this.gameObject); } }
//EnemyControllerBB controller; // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { animator.TryGetComponent(out controller); animator.TryGetComponent(out health); if (health) { radioRemate = health.radioRemate; } if (controller) { controller.SetCurrentState(EnemyState.knocked); } }
public bool GetDamage(int damage) { bool died = false; CamerasManager.instance.ShakeCameraNormal(cameraShakeFactor, .1f); this.currentLife -= damage; //if (isPlayer) //{ // GetComponent<PlayerControllerBB>().SetCurrentState(PlayerState.damaged); //} if (canGetKnocked && currentLife > 0) { //print("iasdhajsdhasd"); EnemyControllerBB tryEnemyA; this.TryGetComponent <EnemyControllerBB>(out tryEnemyA); //DogControllerBB tryEnemyB; //this.TryGetComponent<DogControllerBB>(out tryEnemyB); if (tryEnemyA) { tryEnemyA.SetCurrentState(EnemyState.knocked); radioRemate.gameObject.SetActive(true); } //else if (tryEnemyB) // tryEnemyB.SetCurrentState(DogState.knocked); //GetComponent<EnemyControllerBB>().SetCurrentState(EnemyState.knocked); } else { died = true; canGetKnocked = false; if (isPlayer) { GetComponent <PlayerControllerBB>().SetCurrentState(PlayerState.dead); } else { if (tryEnemyA) { tryEnemyA.SetCurrentState(EnemyState.dead); } else if (tryEnemyB) { tryEnemyB.SetCurrentState(DogState.dead); } else if (bomber) { bomber.anim.Play("bomberExploding"); } else if (debuffer) { debuffer.anim.Play("pukerDie"); } else if (tryBoss) { GameManagerActions.current.winEvent.Invoke(); } } } return(died); }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) //{ // //controller.waypointComponent.SetFollowTarget(FindObjectOfType<PlayerController>().transform.position); // //controller.pursuitComponent.Follow(); //} // OnStateExit is called when a transition ends and the state machine finishes evaluating this state override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { controller.SetCurrentState(EnemyState.patroling); }