// Start is called before the first frame update public override void OnInspectorGUI() { DrawDefaultInspector(); Dying script = (Dying)target; if (GUILayout.Button("Убить")) { script.Die(); } }
public void EnemyControllerUpdate(float deltaTime) { if (alive) { if (conditions.HasActiveConditions) { CheckHealth.Invoke(); conditions.ConditionsUpdateStart(CharacterModel, ref spec, deltaTime); } ///<summary> ///Проверка состояния деятельности врага /// </summary> if (inChase) { enemyView.enabled = false; Chasing.Chase(player, deltaTime); //Debug.Log("Chasing"); } else if (comingHome) { //Debug.Log("ComingHome"); timer += deltaTime; ComingHome.ComingHome(); if (timer > 3f && !enemyView.enabled) { enemyView.enabled = true; } } else if (onPatrol) { Patroling.Patrol(route); } else if (onIdle) { Idle.Idle(); } else if (inFight) { Fight.Fight(player, deltaTime); } else { var choseAct = Random.Range(-patrolChance, idleChance); if (choseAct < 0) { onPatrol = true; route = RouteGenerator.Compile(homePoint, spec.PatrolDistance); patrolChance--; idleChance = 5; } else { onIdle = true; idleChance--; patrolChance = 5; } } } else { Move.Stop(); headMesh.enabled = false; gun.enabled = false; knife.enabled = false; enemyBorder.enabled = false; //выключаем коллайдер rb.constraints = RigidbodyConstraints.FreezeAll; //замораживаем перемещения и повороты Dying.Die(mesh, deltaTime); //запускаем событие смерти } }