private void SetDestroyLocal(GameObject objToDestroy, TypeOfHashSet hsType) { if (objToDestroy) { if (hsType == TypeOfHashSet.bases) { DelBaseFromHashSet(objToDestroy); } else if (hsType == TypeOfHashSet.portables) { DelPortableFromHashSet(objToDestroy); } else if (hsType == TypeOfHashSet.other) { DelOtherObjFromHashSet(objToDestroy); } DelMoveableFromDict(objToDestroy); Rigidbody rbToDel = objToDestroy.GetComponent <Rigidbody>(); affectedBodies.Remove(rbToDel); GameStats.freeRunPts++; Destroy(objToDestroy); } }
/// <summary> /// уничтожает объект и контролирует его нахождение в хеш-сете /// </summary> /// <param name="objToDestroy"></param> /// <param name="timerToDestroy"></param> /// <param name="hsType"></param> public void SetDestroyObj(GameObject objToDestroy, TypeOfHashSet hsType, float timerToDestroy = 0) { if (timerToDestroy > 0) { StartCoroutine(SetDestroyCorut(objToDestroy, timerToDestroy, hsType)); } else { SetDestroyLocal(objToDestroy, hsType); } }
private IEnumerator SetDestroyCorut(GameObject objToDestroy, float timerToDestroy, TypeOfHashSet hsType) { yield return(new WaitForSeconds(timerToDestroy)); SetDestroyLocal(objToDestroy, hsType); }